8
8
enum b_widgettype_t {
9
9
W_BUTTON,
10
10
W_SLIDER,
11
- W_TOGGLE
11
+ W_TOGGLE,
12
+ W_RGB
12
13
};
13
14
14
15
enum b_joystickaxis_t {
@@ -36,6 +37,7 @@ enum b_rgb_t {
36
37
static class BlinkerButton * _Button[BLINKER_MAX_WIDGET_SIZE];
37
38
static class BlinkerSlider * _Slider[BLINKER_MAX_WIDGET_SIZE];
38
39
static class BlinkerToggle * _Toggle[BLINKER_MAX_WIDGET_SIZE];
40
+ static class BlinkerRGB * _RGB[BLINKER_MAX_WIDGET_SIZE];
39
41
40
42
class BlinkerButton
41
43
{
@@ -91,6 +93,24 @@ class BlinkerToggle
91
93
bool toggleState;
92
94
};
93
95
96
+ class BlinkerRGB
97
+ {
98
+ public :
99
+ BlinkerRGB ()
100
+ : rgbName(NULL )
101
+ {}
102
+
103
+ void name (String name) { rgbName = name; }
104
+ String getName () { return rgbName; }
105
+ void freshValue (b_rgb_t color,uint8_t value) { rgbValue[color] = value; }
106
+ uint8_t getValue (b_rgb_t color) { return rgbValue[color]; }
107
+ bool checkName (String name) { return ((rgbName == name) ? true : false ); }
108
+
109
+ private :
110
+ String rgbName;
111
+ uint8_t rgbValue[3 ];
112
+ };
113
+
94
114
template <class T >
95
115
int8_t checkNum (String name, T * c, uint8_t count)
96
116
{
@@ -114,9 +134,9 @@ class BlinkerApi
114
134
ahrsValue[Pitch] = 0 ;
115
135
gpsValue[LONG] = " 0.000000" ;
116
136
gpsValue[LAT] = " 0.000000" ;
117
- rgbValue[R] = 0 ;
118
- rgbValue[G] = 0 ;
119
- rgbValue[B] = 0 ;
137
+ // rgbValue[R] = 0;
138
+ // rgbValue[G] = 0;
139
+ // rgbValue[B] = 0;
120
140
}
121
141
122
142
void wInit (const String & _name, b_widgettype_t _type) {
@@ -148,6 +168,15 @@ class BlinkerApi
148
168
}
149
169
}
150
170
break ;
171
+ case W_RGB :
172
+ if (checkNum (_name, _RGB, _rgbCount) == BLINKER_OBJECT_NOT_AVAIL) {
173
+ if ( _rgbCount < BLINKER_MAX_WIDGET_SIZE ) {
174
+ _RGB[_rgbCount] = new BlinkerRGB ();
175
+ _RGB[_rgbCount]->name (_name);
176
+ _rgbCount++;
177
+ }
178
+ }
179
+ break ;
151
180
default :
152
181
break ;
153
182
}
@@ -167,11 +196,13 @@ class BlinkerApi
167
196
for (uint8_t kNum = 0 ; kNum < _tCount; kNum ++) {
168
197
toggle (_Toggle[kNum ]->getName ());
169
198
}
199
+ for (uint8_t rgbNum = 0 ; rgbNum < _rgbCount; rgbNum++) {
200
+ rgb (_RGB[rgbNum]->getName (), R);
201
+ }
170
202
171
203
joystick (J_Xaxis);
172
204
ahrs (Yaw);
173
205
gps (LONG, true );
174
- rgb (R);
175
206
176
207
if (_fresh) {
177
208
static_cast <Proto*>(this )->isParsed ();
@@ -434,19 +465,45 @@ class BlinkerApi
434
465
}
435
466
}
436
467
437
- uint8_t rgb (b_rgb_t color) {
438
- int16_t colorValue = STRING_find_array_numberic_value (static_cast <Proto*>(this )->dataParse (), BLINKER_CMD_RGB, color);
468
+ uint8_t rgb (const String & _rgbName, b_rgb_t color) {
469
+ int8_t num = checkNum (_rgbName, _RGB, _rgbCount);
470
+ int16_t value = STRING_find_array_numberic_value (static_cast <Proto*>(this )->dataParse (), _rgbName, color);
439
471
440
- if (colorValue != FIND_KEY_VALUE_FAILED) {
441
- rgbValue[R] = STRING_find_array_numberic_value (static_cast <Proto*>(this )->dataParse (), BLINKER_CMD_RGB, R);
442
- rgbValue[G] = STRING_find_array_numberic_value (static_cast <Proto*>(this )->dataParse (), BLINKER_CMD_RGB, G);
443
- rgbValue[B] = STRING_find_array_numberic_value (static_cast <Proto*>(this )->dataParse (), BLINKER_CMD_RGB, B);
472
+ if (value != FIND_KEY_VALUE_FAILED) {
473
+ uint8_t _rValue = STRING_find_array_numberic_value (static_cast <Proto*>(this )->dataParse (), _rgbName, R);
474
+ uint8_t _gValue = STRING_find_array_numberic_value (static_cast <Proto*>(this )->dataParse (), _rgbName, G);
475
+ uint8_t _bValue = STRING_find_array_numberic_value (static_cast <Proto*>(this )->dataParse (), _rgbName, B);
476
+
477
+ if ( num == BLINKER_OBJECT_NOT_AVAIL ) {
478
+ if ( _rgbCount < BLINKER_MAX_WIDGET_SIZE ) {
479
+ _RGB[_rgbCount] = new BlinkerRGB ();
480
+ _RGB[_rgbCount]->name (_rgbName);
481
+ _RGB[_rgbCount]->freshValue (R, _rValue);
482
+ _RGB[_rgbCount]->freshValue (G, _gValue);
483
+ _RGB[_rgbCount]->freshValue (B, _bValue);
484
+ _rgbCount++;
485
+ }
486
+ }
487
+ else {
488
+ _RGB[num]->freshValue (R, _rValue);
489
+ _RGB[num]->freshValue (G, _gValue);
490
+ _RGB[num]->freshValue (B, _bValue);
491
+ }
444
492
445
493
_fresh = true ;
446
- return colorValue ;
494
+ return value ;
447
495
}
448
496
else {
449
- return rgbValue[color];
497
+ if ( num == BLINKER_OBJECT_NOT_AVAIL ) {
498
+ if ( _rgbCount < BLINKER_MAX_WIDGET_SIZE ) {
499
+ _RGB[_rgbCount] = new BlinkerRGB ();
500
+ _RGB[_rgbCount]->name (_rgbName);
501
+ _rgbCount++;
502
+ }
503
+ return 0 ;
504
+ }
505
+
506
+ return _RGB[num]->getValue (color);
450
507
}
451
508
}
452
509
@@ -483,10 +540,11 @@ class BlinkerApi
483
540
uint8_t _bCount = 0 ;
484
541
uint8_t _sCount = 0 ;
485
542
uint8_t _tCount = 0 ;
543
+ uint8_t _rgbCount = 0 ;
486
544
uint8_t joyValue[2 ];
487
545
int16_t ahrsValue[3 ];
488
546
String gpsValue[2 ];
489
- uint8_t rgbValue[3 ];
547
+ // uint8_t rgbValue[3];
490
548
bool _fresh = false ;
491
549
492
550
bool buttonParse (const String & _bName)
0 commit comments