@@ -84,11 +84,12 @@ class BlinkerApi
84
84
_fresh = false ;
85
85
86
86
for (uint8_t bNum = 0 ; bNum < _bCount; bNum++) {
87
- button (_Button[bNum]->getName ());
87
+ buttonParse (_Button[bNum]->getName ());
88
88
}
89
89
for (uint8_t sNum = 0 ; sNum < _sCount; sNum ++) {
90
90
slider (_Slider[sNum ]->getName ());
91
91
}
92
+
92
93
joystick (J_Xaxis);
93
94
ahrs (Yaw);
94
95
@@ -145,7 +146,10 @@ class BlinkerApi
145
146
return false ;
146
147
}
147
148
148
- return _Button[num]->getState ();;
149
+ bool _state = _Button[num]->getState ();
150
+ _Button[num]->freshState (false );
151
+
152
+ return _state;
149
153
}
150
154
}
151
155
@@ -294,6 +298,57 @@ class BlinkerApi
294
298
uint8_t joyValue[2 ];
295
299
int16_t ahrsValue[3 ];
296
300
bool _fresh = false ;
301
+
302
+ bool buttonParse (const String & _bName)
303
+ {
304
+ int8_t num = checkNum (_bName, _Button, _bCount);
305
+ String state = STRING_find_string_value (static_cast <Proto*>(this )->dataParse (), _bName);
306
+
307
+ if (state == BLINKER_CMD_BUTTON_PRESSED) {
308
+ if ( num == BLINKER_OBJECT_NOT_AVAIL ) {
309
+ if ( _bCount < BLINKER_MAX_WIDGET_SIZE ) {
310
+ _Button[_bCount] = new BlinkerButton ();
311
+ _Button[_bCount]->name (_bName);
312
+ _Button[_bCount]->freshState (true );
313
+ _bCount++;
314
+ }
315
+ }
316
+ else {
317
+ _Button[num]->freshState (true );
318
+ }
319
+
320
+ _fresh = true ;
321
+ return true ;
322
+ }
323
+ else if (state == BLINKER_CMD_BUTTON_RELEASED) {
324
+ if ( num == BLINKER_OBJECT_NOT_AVAIL ) {
325
+ if ( _bCount < BLINKER_MAX_WIDGET_SIZE ) {
326
+ _Button[_bCount] = new BlinkerButton ();
327
+ _Button[_bCount]->name (_bName);
328
+ _Button[_bCount]->freshState (false );
329
+ _bCount++;
330
+ }
331
+ }
332
+ else {
333
+ _Button[num]->freshState (false );
334
+ }
335
+
336
+ _fresh = true ;
337
+ return false ;
338
+ }
339
+ else {
340
+ if ( num == BLINKER_OBJECT_NOT_AVAIL ) {
341
+ if ( _bCount < BLINKER_MAX_WIDGET_SIZE ) {
342
+ _Button[_bCount] = new BlinkerButton ();
343
+ _Button[_bCount]->name (_bName);
344
+ _bCount++;
345
+ }
346
+ return false ;
347
+ }
348
+
349
+ return _Button[num]->getState ();;
350
+ }
351
+ }
297
352
};
298
353
299
354
#endif
0 commit comments