Grove sensor component example for Seeed Wio 3G

Dependencies:   Grove_LCD_RGB_Backlight Grove_temperature PixelArray Servo WS2812

Fork of mbed-os-example-blinky by mbed-os-examples

Grove connectorGrove component
D38LED Socket kit
A6Rotary Angle Sensor
A4Temperature Sensor
D20Button
I2CGrove LCD RGB Backlight

Files at this revision

API Documentation at this revision

Comitter:
MACRUM
Date:
Fri Aug 10 09:07:14 2018 +0000
Parent:
74:847e5dc7b4d5
Commit message:
Code clean-up

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Aug 08 09:41:37 2018 +0000
+++ b/main.cpp	Fri Aug 10 09:07:14 2018 +0000
@@ -72,20 +72,22 @@
     pc.printf("hello, Mbed world\n");
 
     int cnt = 0;
-    int color = 0;
+    int idx = 0;
 
     while (true) {
         pc.printf("count = %4d, button = %d, analog = %2.2f, temp = %2.2f\n", cnt++, button, ain.read(), temp.getTemperature());
         sprintf(buf, "L=%2.2f, T=%2.2f", ain.read(), temp.getTemperature());
+        
         lcd.setRGB(0xff, (255*ain.read()), 0x00);
         lcd.locate(0, 1);
         lcd.print(buf);
+        
         led1 = !led1;
 
-        ws.write_offsets(px.getBuf(), color, color, color);
-        color++;
-        if (color >= WS2812_BUF) {
-            color = 0;
+        ws.write_offsets(px.getBuf(), idx, idx, idx);
+        idx++;
+        if (idx >= WS2812_BUF) {
+            idx = 0;
         }
 
         wait(0.5);