File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -312,6 +312,39 @@ unsigned long AdafruitIO_Data::toUnsignedLong()
312
312
#endif
313
313
}
314
314
315
+ int AdafruitIO_Data::toRed ()
316
+ {
317
+ if (! _value)
318
+ return 0 ;
319
+
320
+ char r[] = " 0x" ;
321
+ strncat (r, toChar () + 1 , 2 );
322
+
323
+ return (int )strtol (r, NULL , 0 );
324
+ }
325
+
326
+ int AdafruitIO_Data::toGreen ()
327
+ {
328
+ if (! _value)
329
+ return 0 ;
330
+
331
+ char g[] = " 0x" ;
332
+ strncat (g, toChar () + 3 , 2 );
333
+
334
+ return (int )strtol (g, NULL , 0 );
335
+ }
336
+
337
+ int AdafruitIO_Data::toBlue ()
338
+ {
339
+ if (! _value)
340
+ return 0 ;
341
+
342
+ char b[] = " 0x" ;
343
+ strncat (b, toChar () + 5 , 2 );
344
+
345
+ return (int )strtol (b, NULL , 0 );
346
+ }
347
+
315
348
long AdafruitIO_Data::toNeoPixel ()
316
349
{
317
350
if (! _value)
Original file line number Diff line number Diff line change @@ -62,6 +62,9 @@ class AdafruitIO_Data {
62
62
long toLong ();
63
63
unsigned long toUnsignedLong ();
64
64
65
+ int toRed ();
66
+ int toGreen ();
67
+ int toBlue ();
65
68
long toNeoPixel ();
66
69
67
70
char * toCSV ();
You can’t perform that action at this time.
0 commit comments