8
8
enum b_widgettype_t {
9
9
W_BUTTON,
10
10
W_SLIDER,
11
- W_TOGGLE,
12
- W_RGB
11
+ W_TOGGLE
13
12
};
14
13
15
14
enum b_joystickaxis_t {
@@ -37,7 +36,6 @@ enum b_rgb_t {
37
36
static class BlinkerButton * _Button[BLINKER_MAX_WIDGET_SIZE];
38
37
static class BlinkerSlider * _Slider[BLINKER_MAX_WIDGET_SIZE];
39
38
static class BlinkerToggle * _Toggle[BLINKER_MAX_WIDGET_SIZE];
40
- static class BlinkerRGB * _RGB[BLINKER_MAX_WIDGET_SIZE];
41
39
42
40
class BlinkerButton
43
41
{
@@ -93,24 +91,6 @@ class BlinkerToggle
93
91
bool toggleState;
94
92
};
95
93
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
-
114
94
template <class T >
115
95
int8_t checkNum (String name, T * c, uint8_t count)
116
96
{
@@ -134,9 +114,9 @@ class BlinkerApi
134
114
ahrsValue[Pitch] = 0 ;
135
115
gpsValue[LONG] = " 0.000000" ;
136
116
gpsValue[LAT] = " 0.000000" ;
137
- // rgbValue[R] = 0;
138
- // rgbValue[G] = 0;
139
- // rgbValue[B] = 0;
117
+ rgbValue[R] = 0 ;
118
+ rgbValue[G] = 0 ;
119
+ rgbValue[B] = 0 ;
140
120
}
141
121
142
122
void wInit (const String & _name, b_widgettype_t _type) {
@@ -168,15 +148,6 @@ class BlinkerApi
168
148
}
169
149
}
170
150
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 ;
180
151
default :
181
152
break ;
182
153
}
@@ -196,13 +167,11 @@ class BlinkerApi
196
167
for (uint8_t kNum = 0 ; kNum < _tCount; kNum ++) {
197
168
toggle (_Toggle[kNum ]->getName ());
198
169
}
199
- for (uint8_t rgbNum = 0 ; rgbNum < _rgbCount; rgbNum++) {
200
- rgb (_RGB[rgbNum]->getName (), R);
201
- }
202
170
203
171
joystick (J_Xaxis);
204
172
ahrs (Yaw);
205
173
gps (LONG, true );
174
+ rgb (R);
206
175
207
176
if (_fresh) {
208
177
static_cast <Proto*>(this )->isParsed ();
@@ -465,45 +434,19 @@ class BlinkerApi
465
434
}
466
435
}
467
436
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);
471
-
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);
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);
476
439
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
- }
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);
492
444
493
445
_fresh = true ;
494
- return value ;
446
+ return colorValue ;
495
447
}
496
448
else {
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);
449
+ return rgbValue[color];
507
450
}
508
451
}
509
452
@@ -527,6 +470,8 @@ class BlinkerApi
527
470
uint32_t start = micros ();
528
471
while (ms > 0 ) {
529
472
static_cast <Proto*>(this )->run ();
473
+
474
+ yield ();
530
475
531
476
if ((micros () - start)/1000 >= ms) {
532
477
ms = 0 ;
@@ -538,11 +483,10 @@ class BlinkerApi
538
483
uint8_t _bCount = 0 ;
539
484
uint8_t _sCount = 0 ;
540
485
uint8_t _tCount = 0 ;
541
- uint8_t _rgbCount = 0 ;
542
486
uint8_t joyValue[2 ];
543
487
int16_t ahrsValue[3 ];
544
488
String gpsValue[2 ];
545
- // uint8_t rgbValue[3];
489
+ uint8_t rgbValue[3 ];
546
490
bool _fresh = false ;
547
491
548
492
bool buttonParse (const String & _bName)
0 commit comments