88enum b_widgettype_t {
99 W_BUTTON,
1010 W_SLIDER,
11- W_TOGGLE
11+ W_TOGGLE,
12+ W_RGB
1213};
1314
1415enum b_joystickaxis_t {
@@ -36,6 +37,7 @@ enum b_rgb_t {
3637static class BlinkerButton * _Button[BLINKER_MAX_WIDGET_SIZE];
3738static class BlinkerSlider * _Slider[BLINKER_MAX_WIDGET_SIZE];
3839static class BlinkerToggle * _Toggle[BLINKER_MAX_WIDGET_SIZE];
40+ static class BlinkerRGB * _RGB[BLINKER_MAX_WIDGET_SIZE];
3941
4042class BlinkerButton
4143{
@@ -91,6 +93,24 @@ class BlinkerToggle
9193 bool toggleState;
9294};
9395
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+
94114template <class T >
95115int8_t checkNum (String name, T * c, uint8_t count)
96116{
@@ -114,9 +134,9 @@ class BlinkerApi
114134 ahrsValue[Pitch] = 0 ;
115135 gpsValue[LONG] = " 0.000000" ;
116136 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;
120140 }
121141
122142 void wInit (const String & _name, b_widgettype_t _type) {
@@ -148,6 +168,15 @@ class BlinkerApi
148168 }
149169 }
150170 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 ;
151180 default :
152181 break ;
153182 }
@@ -167,11 +196,13 @@ class BlinkerApi
167196 for (uint8_t kNum = 0 ; kNum < _tCount; kNum ++) {
168197 toggle (_Toggle[kNum ]->getName ());
169198 }
199+ for (uint8_t rgbNum = 0 ; rgbNum < _rgbCount; rgbNum++) {
200+ rgb (_RGB[rgbNum]->getName (), R);
201+ }
170202
171203 joystick (J_Xaxis);
172204 ahrs (Yaw);
173205 gps (LONG, true );
174- rgb (R);
175206
176207 if (_fresh) {
177208 static_cast <Proto*>(this )->isParsed ();
@@ -434,19 +465,45 @@ class BlinkerApi
434465 }
435466 }
436467
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);
439471
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+ }
444492
445493 _fresh = true ;
446- return colorValue ;
494+ return value ;
447495 }
448496 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);
450507 }
451508 }
452509
@@ -483,10 +540,11 @@ class BlinkerApi
483540 uint8_t _bCount = 0 ;
484541 uint8_t _sCount = 0 ;
485542 uint8_t _tCount = 0 ;
543+ uint8_t _rgbCount = 0 ;
486544 uint8_t joyValue[2 ];
487545 int16_t ahrsValue[3 ];
488546 String gpsValue[2 ];
489- uint8_t rgbValue[3 ];
547+ // uint8_t rgbValue[3];
490548 bool _fresh = false ;
491549
492550 bool buttonParse (const String & _bName)
0 commit comments