3
3
#include " structRgb.h"
4
4
#include < avr/pgmspace.h>
5
5
6
- char *queryString1 = " #Champions " ;
6
+ char *queryString1 = " #news " ;
7
7
char *queryString2 = " #arduino" ;
8
8
9
9
char ssid[] = " OFFICINE ARDUINO" ; // your network SSID (name)
10
- char pass[] = " T3mporary! " ; // your network password (use for WPA, or use as key for WEP)
10
+ char pass[] = " password " ; // your network password (use for WPA, or use as key for WEP)
11
11
int keyIndex = 0 ; // your network key Index number (needed only for WEP)
12
12
int status = WL_IDLE_STATUS; // status of the wifi connection
13
13
66
66
unidecode (byte),
67
67
timedRead(void );
68
68
void
69
- pippo (rgb, rgb);
69
+ fadeTo (rgb, rgb);
70
70
71
71
// ---------------------------------------------------------------------------
72
72
@@ -146,6 +146,7 @@ void loop() {
146
146
lampShades[i].green = i*15 ;
147
147
lampShades[i].blue = 0 ;
148
148
149
+ // Loaded colors
149
150
Serial.print (i);
150
151
Serial.print (" : " );
151
152
Serial.print (lampShades[i].red );
@@ -168,6 +169,7 @@ void loop() {
168
169
lampShades[i].green = i*15 ;
169
170
lampShades[i].blue = 255 ;
170
171
172
+ // Loaded colors
171
173
Serial.print (i);
172
174
Serial.print (" : " );
173
175
Serial.print (lampShades[i].red );
@@ -322,7 +324,7 @@ boolean jsonParse(int depth, byte endChar) {
322
324
323
325
uint8_t cc = (colorCount+1 )%8 ;
324
326
325
- pippo (lampShades[colorCount], lampShades[cc]);
327
+ fadeTo (lampShades[colorCount], lampShades[cc]);
326
328
327
329
colorCount = cc;
328
330
@@ -445,10 +447,13 @@ void printWifiStatus() {
445
447
Serial.println (F (" dBm" ));
446
448
}
447
449
448
- void pippo (rgb in, rgb out) {
450
+ void fadeTo (rgb in, rgb out) {
449
451
boolean stop_r, stop_g, stop_b;
450
452
stop_r = stop_g = stop_b = false ;
451
453
454
+ // use for debugging purposes, this is
455
+ // very noisy otherwise ... too much info
456
+ /*
452
457
Serial.print(in.red);
453
458
Serial.print(" ");
454
459
Serial.print(in.green);
@@ -462,52 +467,57 @@ void pippo(rgb in, rgb out) {
462
467
Serial.print(out.green);
463
468
Serial.print(" ");
464
469
Serial.println(out.blue);
470
+ */
465
471
466
472
while (!(stop_r & stop_g & stop_b)) {
467
- // operate each color: RED
468
-
469
- if (in.red > 0 && in.red < out.red && out.red <= 255 ) {
470
- stop_r = false ;
473
+
474
+ if (in.red < out.red ) {
471
475
in.red ++;
476
+ stop_r = false ;
477
+ if (in.red > 255 ) { in.red = 255 ; stop_r = true ; }
472
478
}
473
- if (in.red <= 255 && in. red >out. red && out.red > 0 ) {
479
+ if (in.red > out.red ) {
474
480
in.red --;
475
- stop_r = true ;
481
+ stop_r = false ;
482
+ if (in.red < 0 ) { in.red = 0 ; stop_r = true ; }
476
483
}
477
-
478
- if (in. green < out. green ){
479
- stop_g = false ;
484
+ if (in. red == out. red ) stop_r = true ;
485
+
486
+ if (in. green < out. green ) {
480
487
in.green ++;
488
+ stop_g = false ;
489
+ if (in.green > 255 ) { in.green = 255 ; stop_r = true ; }
481
490
}
482
- if (in.green >= out.green ) {
483
- in.green =out.green ;
484
- stop_g = true ;
491
+ if (in.green > out.green ) {
492
+ in.green --;
493
+ stop_g = false ;
494
+ if (in.green < 0 ) { in.green = 0 ; stop_r = true ; }
485
495
}
486
-
487
- if (in. blue < out. blue ){
488
- stop_b = false ;
496
+ if (in. green == out. green ) stop_g = true ;
497
+
498
+ if (in. blue < out. blue ) {
489
499
in.blue ++;
500
+ stop_b = false ;
501
+ if (in.blue > 255 ) { in.blue = 255 ; stop_r = true ; }
490
502
}
491
- if (in.blue >= out.blue ) {
492
- in.blue =out.blue ;
493
- stop_b = true ;
503
+ if (in.blue > out.blue ) {
504
+ in.blue --;
505
+ stop_b = false ;
506
+ if (in.blue < 0 ) { in.blue = 0 ; stop_r = true ; }
494
507
}
495
-
508
+ if (in. blue == out. blue ) stop_b = true ;
496
509
497
- Serial.print (stop_r);
498
- Serial.print (stop_g);
499
- Serial.println (stop_b);
500
- Serial.println ((stop_r | stop_g | stop_b));
510
+
501
511
// use for debugging purposes, this is
502
512
// very noisy otherwise ... too much info
503
-
513
+ /*
504
514
Serial.print("R: ");
505
515
Serial.print(in.red);
506
516
Serial.print(" - G: ");
507
517
Serial.print(in.green);
508
518
Serial.print(" - B: ");
509
519
Serial.println(in.blue);
510
-
520
+ */
511
521
512
522
// push out the colors
513
523
analogWrite (pin_r, in.red );
@@ -518,9 +528,3 @@ void pippo(rgb in, rgb out) {
518
528
}
519
529
520
530
}
521
-
522
- int freeRam () {
523
- extern int __heap_start, *__brkval;
524
- int v;
525
- return (int ) &v - (__brkval == 0 ? (int ) &__heap_start : (int ) __brkval);
526
- }
0 commit comments