MCPcopy Create free account
hub / github.com/SmingHub/Sming / updateLED

Function updateLED

samples/Basic_APA102/app/application.cpp:68–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68void updateLED()
69{
70 static unsigned state;
71 static unsigned cnt;
72
73 switch(state++) {
74 case 0:
75 LED.setBrightness(10); // Default brightness [0..31]
76 LED.clear();
77
78 Serial.println(_F("Start: set all pixels to red"));
79 LED.setAllPixel(255, 0, 0);
80 LED.show();
81 break;
82
83 case 1:
84 Serial.println(_F("Set all pixels to green"));
85 LED.setAllPixel(0, 255, 0);
86 LED.show();
87 break;
88
89 case 2:
90 Serial.println(_F("Set pixel #10 to red"));
91 LED.setPixel(10, 255, 0, 0);
92 LED.show();
93 break;
94
95 case 3:
96 Serial.println(_F("Start cycling through rainbow patterns"));
97 for(unsigned i = 0; i < NUM_LED; i++) { // some rainbow ..
98 auto pixel = colorWheel(i, NUM_LED);
99 LED.setPixel(i, pixel);
100 }
101 LED.show();
102 procTimer.setIntervalMs<100>();
103 break;
104
105 default:
106 if(cnt < NUM_LED) {
107 cnt++;
108 } else {
109 cnt = 0;
110 }
111
112 Serial << "ping " << cnt << endl;
113 LED.show(cnt); // show shifted LED buffer
114 break;
115 }
116}
117
118} // namespace
119

Callers

nothing calls this directly

Calls 7

colorWheelFunction · 0.85
printlnMethod · 0.80
setBrightnessMethod · 0.45
clearMethod · 0.45
setAllPixelMethod · 0.45
showMethod · 0.45
setPixelMethod · 0.45

Tested by

no test coverage detected