mirror of
https://github.com/balkian/shinesp.git
synced 2024-12-22 05:28:12 +00:00
More power
This commit is contained in:
parent
5de91bf984
commit
b9b782a828
39
shinesp.ino
39
shinesp.ino
@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
#define FASTLED_ESP8266_RAW_PIN_ORDER
|
#define FASTLED_ESP8266_RAW_PIN_ORDER
|
||||||
#include "FastLED.h"
|
#include "FastLED.h"
|
||||||
|
|
||||||
#define NUM_LEDS 150
|
#define NUM_LEDS 300
|
||||||
#define DATA_PIN 0
|
#define DATA_PIN 0
|
||||||
#define led 13
|
#define led 13
|
||||||
|
|
||||||
@ -15,8 +16,11 @@ CRGB leds[NUM_LEDS];
|
|||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
|
|
||||||
const char* customssid = "led";
|
const char* customssid = "led";
|
||||||
|
const int binterval = 10;
|
||||||
ESP8266WebServer httpServer(80);
|
ESP8266WebServer httpServer(80);
|
||||||
|
|
||||||
|
int brightness = 255;
|
||||||
|
|
||||||
struct credential {
|
struct credential {
|
||||||
String ssid;
|
String ssid;
|
||||||
String pass;
|
String pass;
|
||||||
@ -157,12 +161,35 @@ void handleOff() {
|
|||||||
FastLED.show();
|
FastLED.show();
|
||||||
httpServer.send(200, "text/plain", "Off!");
|
httpServer.send(200, "text/plain", "Off!");
|
||||||
}
|
}
|
||||||
|
void handleBrightnessUp() {
|
||||||
|
// min/max don't work
|
||||||
|
if (brightness > 255 - binterval) {
|
||||||
|
brightness = 255;
|
||||||
|
} else {
|
||||||
|
brightness = brightness + binterval;
|
||||||
|
}
|
||||||
|
FastLED.setBrightness(brightness);
|
||||||
|
httpServer.send(200, "text/plain", "Brightness set to " + String(brightness));
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleBrightnessDown() {
|
||||||
|
if (brightness < binterval) {
|
||||||
|
brightness = 0;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
brightness = brightness - binterval;
|
||||||
|
}
|
||||||
|
FastLED.setBrightness(brightness);
|
||||||
|
httpServer.send(200, "text/plain", "Brightness set to " + String(brightness));
|
||||||
|
}
|
||||||
|
|
||||||
void handleBrightness() {
|
void handleBrightness() {
|
||||||
int value = httpServer.arg("value").toInt();
|
int value = httpServer.arg("value").toInt();
|
||||||
if (value > 0) {
|
if (value > 0) {
|
||||||
FastLED.setBrightness(value);
|
brightness = value;
|
||||||
httpServer.send(200, "text/plain", "Brightness set to " + String(value));
|
|
||||||
|
FastLED.setBrightness(brightness);
|
||||||
|
httpServer.send(200, "text/plain", "Brightness set to " + String(brightness));
|
||||||
FastLED.show();
|
FastLED.show();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -302,12 +329,16 @@ void setup() {
|
|||||||
httpServer.on ( "/color", handleColor );
|
httpServer.on ( "/color", handleColor );
|
||||||
httpServer.on ( "/off", handleOff );
|
httpServer.on ( "/off", handleOff );
|
||||||
httpServer.on ( "/brightness", handleBrightness );
|
httpServer.on ( "/brightness", handleBrightness );
|
||||||
|
httpServer.on ( "/brightness/up", handleBrightnessUp );
|
||||||
|
httpServer.on ( "/brightness/down", handleBrightnessDown );
|
||||||
httpServer.begin();
|
httpServer.begin();
|
||||||
|
|
||||||
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
|
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
|
||||||
// FastLED.setDither(0);
|
// FastLED.setDither(0);
|
||||||
FastLED.setBrightness(100);
|
FastLED.setBrightness(255);
|
||||||
FastLED.setMaxPowerInVoltsAndMilliamps(5, 20000);
|
FastLED.setMaxPowerInVoltsAndMilliamps(5, 20000);
|
||||||
|
fill_solid(leds, NUM_LEDS, CRGB(255, 255, 255));
|
||||||
|
FastLED.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
Loading…
Reference in New Issue
Block a user