led state applier
This commit is contained in:
+55
-9
@@ -1,18 +1,64 @@
|
||||
#include <Arduino.h>
|
||||
#include <hardware_led.hpp>
|
||||
#include "hardware.pb.h"
|
||||
|
||||
// put function declarations here:
|
||||
int myFunction(int, int);
|
||||
// Demo for HardwareLed
|
||||
HardwareLed led(2); // Assuming NeoPixel on pin 4 (D2 on ESP8266)
|
||||
|
||||
hardware_LedConfig configs[4];
|
||||
unsigned long lastChange = 0;
|
||||
int currentConfig = 0;
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
int result = myFunction(2, 3);
|
||||
Serial.begin(9600);
|
||||
led.begin();
|
||||
|
||||
// Static config
|
||||
configs[0] = {0};
|
||||
configs[0].brightness = 128;
|
||||
configs[0].duration_ms = 0;
|
||||
configs[0].which_animation_params = 3;
|
||||
configs[0].animation_params.static_params.color = 0x00FF00; // Green
|
||||
|
||||
// Pulse config
|
||||
configs[1] = {0};
|
||||
configs[1].brightness = 128;
|
||||
configs[1].duration_ms = 0;
|
||||
configs[1].which_animation_params = 4;
|
||||
configs[1].animation_params.pulse_params.color = 0xFF0000; // Red
|
||||
configs[1].animation_params.pulse_params.speed_ms = 500;
|
||||
|
||||
// Fade config
|
||||
configs[2] = {0};
|
||||
configs[2].brightness = 128;
|
||||
configs[2].duration_ms = 0;
|
||||
configs[2].which_animation_params = 5;
|
||||
configs[2].animation_params.fade_params.colors_count = 3;
|
||||
configs[2].animation_params.fade_params.colors[0] = 0xFF0000; // Red
|
||||
configs[2].animation_params.fade_params.colors[1] = 0x00FF00; // Green
|
||||
configs[2].animation_params.fade_params.colors[2] = 0x0000FF; // Blue
|
||||
configs[2].animation_params.fade_params.speed_ms = 1000;
|
||||
|
||||
// Flicker config
|
||||
configs[3] = {0};
|
||||
configs[3].brightness = 128;
|
||||
configs[3].duration_ms = 0;
|
||||
configs[3].which_animation_params = 6;
|
||||
configs[3].animation_params.flicker_params.color = 0xFFFFFF; // White
|
||||
configs[3].animation_params.flicker_params.intensity = 50;
|
||||
|
||||
led.set(configs[0]);
|
||||
Serial.println("Starting with static green");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
}
|
||||
led.update();
|
||||
|
||||
// put function definitions here:
|
||||
int myFunction(int x, int y) {
|
||||
return x + y;
|
||||
if (millis() - lastChange >= 10000) {
|
||||
lastChange = millis();
|
||||
currentConfig = (currentConfig + 1) % 4;
|
||||
led.set(configs[currentConfig]);
|
||||
Serial.print("Switched to config ");
|
||||
Serial.println(currentConfig);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user