Skip to content

Commit 38432a6

Browse files
committed
Fix: more than 5 channels can be used
1 parent 23f732b commit 38432a6

File tree

6 files changed

+18
-17
lines changed

6 files changed

+18
-17
lines changed

src/experiment.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "phyphoxBleExperiment.h"
22

3+
int PhyphoxBleExperiment::numberOfChannels = 5;
34
void PhyphoxBleExperiment::addView(View& v)
45
{
56
for(int i=0; i<phyphoxBleNViews; i++)

src/exportSet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void PhyphoxBleExperiment::ExportSet::getBytes(char *buffArray)
3333
strcat(buffArray,">\n");
3434

3535
//loop over elements
36-
for(int i=0; i<phyphoxBleNElements; i++){
36+
for(int i=0; i<phyphoxBleNExportSets; i++){
3737
if(ELEMENTS[i]!=nullptr){
3838
ELEMENTS[i]->getBytes(buffArray);
3939
}

src/graph.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ void PhyphoxBleExperiment::Graph::setYPrecision(int py){
5252

5353
void PhyphoxBleExperiment::Graph::setChannel(int x, int y)
5454
{
55-
ERROR = (strcmp(ERROR.MESSAGE, "")==0) ? err_checkUpper(x, 5, "setChannel") : ERROR;
56-
ERROR = (strcmp(ERROR.MESSAGE, "")==0) ? err_checkUpper(y, 5, "setChannel") : ERROR;
55+
ERROR = (strcmp(ERROR.MESSAGE, "")==0) ? err_checkUpper(x, numberOfChannels, "setChannel") : ERROR;
56+
ERROR = (strcmp(ERROR.MESSAGE, "")==0) ? err_checkUpper(y, numberOfChannels, "setChannel") : ERROR;
5757
sprintf(INPUTX, "CH%i", x);
5858
sprintf(INPUTY, "CH%i", y);
5959
}

src/phyphoxBLE_ESP32.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "Arduino.h"
44
#include <stdio.h>
55
#include "esp_system.h"
6-
6+
//#define DEBUG
77
//init statics
88
uint8_t PhyphoxBLE::data_package[20] = {0};
99
void (*PhyphoxBLE::configHandler)() = nullptr;
@@ -356,8 +356,8 @@ void PhyphoxBLE::addExperiment(PhyphoxBleExperiment& exp)
356356
#ifdef DEBUG
357357
if(printer != nullptr){
358358
for(int i =0; i<length;i++){
359-
char test = EXPARRAY[i];
360-
359+
char CHAR = EXPARRAY[i];
360+
printer->print(CHAR);
361361
}
362362
}
363363
#endif

src/phyphoxBleExperiment.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define PHYPHOX_BLE_EXPERIMENT
33

44
#define phyphoxBleNViews 5
5-
#define phyphoxBleNElements 5
5+
#define phyphoxBleNElements 20
66
#define phyphoxBleNExportSets 5
77

88
#include <Arduino.h>
@@ -73,7 +73,7 @@ class PhyphoxBleExperiment {
7373

7474
char STYLE[17] = "";
7575

76-
char XMLAttribute[100] = "";
76+
char XMLAttribute[25] = "";
7777

7878
void setUnitX(const char *);
7979
void setUnitY(const char *);
@@ -106,7 +106,7 @@ class PhyphoxBleExperiment {
106106
void setXMLAttribute(const char *);
107107

108108
char LABEL[50] = " label=\"label\"";
109-
char XMLAttribute[100] = "";
109+
char XMLAttribute[25] = "";
110110

111111
Element *ELEMENTS[phyphoxBleNElements] = {nullptr};
112112

@@ -122,7 +122,7 @@ class PhyphoxBleExperiment {
122122
~ExportData() = default;
123123

124124
char BUFFER[5] = "CH1";
125-
char XMLAttribute[100] = "";
125+
char XMLAttribute[1] = "";
126126
void setDatachannel(int);
127127
void setXMLAttribute(const char *);
128128
void setLabel(const char *);
@@ -145,7 +145,7 @@ class PhyphoxBleExperiment {
145145
void setXMLAttribute(const char *);
146146

147147
char LABEL[50] = "";
148-
char XMLAttribute[100] = "";
148+
char XMLAttribute[25] = "";
149149
Element *ELEMENTS[phyphoxBleNExportSets] = {nullptr};
150150

151151
private:
@@ -166,7 +166,7 @@ class PhyphoxBleExperiment {
166166

167167
char INFO[200] = "";
168168
char COLOR[17] = "";
169-
char XMLAttribute[100] = "";
169+
char XMLAttribute[25] = "";
170170

171171
private:
172172
};
@@ -186,7 +186,7 @@ class PhyphoxBleExperiment {
186186

187187
char COLOR[17] = "";
188188
char HEIGHT[20] = " height=\"0.1\"";
189-
char XMLAttribute[100] = "";
189+
char XMLAttribute[25] = "";
190190

191191
private:
192192
};
@@ -210,7 +210,7 @@ class PhyphoxBleExperiment {
210210
char UNIT[20] = "";
211211
char COLOR[17] = "";
212212
char INPUTVALUE[5] = "CH3";
213-
char XMLAttribute[100] = "";
213+
char XMLAttribute[25] = "";
214214

215215
private:
216216
};
@@ -233,7 +233,7 @@ class PhyphoxBleExperiment {
233233
char UNIT[20] = "";
234234
char SIGNED[17] = "";
235235
char DECIMAL[17] = "";
236-
char XMLAttribute[100] = "";
236+
char XMLAttribute[25] = "";
237237
char BUFFER[5] = "CH5";
238238

239239
private:
@@ -259,7 +259,7 @@ class PhyphoxBleExperiment {
259259
View *VIEWS[phyphoxBleNViews] = {nullptr};
260260
ExportSet *EXPORTSETS[phyphoxBleNExportSets] = {nullptr};
261261

262-
int numberOfChannels = 5;
262+
static int numberOfChannels;
263263
int repeating = 0;
264264

265265

src/value.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void PhyphoxBleExperiment::Value::setUnit(const char* u)
2626

2727
void PhyphoxBleExperiment::Value::setChannel(int c)
2828
{
29-
ERROR = (strcmp(ERROR.MESSAGE, "")==0) ? err_checkUpper(c, 5, "setChannel") : ERROR;
29+
ERROR = (strcmp(ERROR.MESSAGE, "")==0) ? err_checkUpper(c, numberOfChannels, "setChannel") : ERROR;
3030
sprintf(INPUTVALUE, "CH%i", c);
3131
}
3232

0 commit comments

Comments
 (0)