summaryrefslogtreecommitdiff
path: root/esp-hyperion.ino
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2016-06-12 18:00:53 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2016-06-12 18:00:53 +0200
commit8fde1af539ae88a06343b7cfe08d4ed5dc1011d8 (patch)
tree002074f2c82a917f81286bb01bcc53cb939170a0 /esp-hyperion.ino
parent6ab457d9d05944bfb8208a57dd43618b5532c6ea (diff)
downloadesp-ledstrip-8fde1af539ae88a06343b7cfe08d4ed5dc1011d8.tar.gz
esp-ledstrip-8fde1af539ae88a06343b7cfe08d4ed5dc1011d8.zip
rename project
Diffstat (limited to 'esp-hyperion.ino')
-rw-r--r--esp-hyperion.ino110
1 files changed, 0 insertions, 110 deletions
diff --git a/esp-hyperion.ino b/esp-hyperion.ino
deleted file mode 100644
index 1286b7d..0000000
--- a/esp-hyperion.ino
+++ /dev/null
@@ -1,110 +0,0 @@
-#include <ESP8266WiFi.h>
-#include <ESP8266mDNS.h>
-#include <WiFiClient.h>
-#include <ESP8266WebServer.h>
-#include <ESP8266mDNS.h>
-#include <WiFiUdp.h>
-#include <ArduinoOTA.h>
-
-const char* ssid = "";
-const char* password = "";
-// R G B
-const int leds[] = {2, 0, 3};
-unsigned int state[] = {0, 0, 0};
-unsigned char cstate[] = {0, 0, 0};
-const int udpPort = 2391;
-
-#define LRED 0
-#define LGREEN 1
-#define LBLUE 2
-#define OFF 0
-#define ON 1
-ESP8266WebServer server(80);
-WiFiUDP RAWudp;
-
-#ifndef BSSID
- #define BSSID NULL
-#endif
-
-void updateLeds() {
- for(int i=0; i<3; i++)
- analogWrite(leds[i], state[i]);
-}
-
-void handleRoot() {
- char temp[400];
-
- if(server.hasArg("red"))
- state[0] = server.arg("red").toInt();
- if(server.hasArg("green"))
- state[1] = server.arg("green").toInt();
- if(server.hasArg("blue"))
- state[2] = server.arg("blue").toInt();
-
- updateLeds();
-
- snprintf(temp, 400,
- " {'red': %d,\
- 'green': %d,\
- 'blue': %d}\
- ",
- state[LRED],
- state[LGREEN],
- state[LBLUE]
- );
- server.send(200, "text/html", temp);
-}
-
-void setup() {
- WiFi.begin(ssid, password);
-
- for(int i=0; i<3; i++) {
- pinMode(leds[i], OUTPUT);
- }
-
- while(WiFi.status() != WL_CONNECTED) {
- updateLeds();
- delay(500);
- for(int i=0; i<3; i++) {
- if(state[i] < 512) {
- state[i] = 1023;
- } else {
- state[i] = 0;
- }
- }
- }
-
- MDNS.begin("esplamp1", WiFi.localIP());
- WiFi.hostname("esplamp1");
-
- server.on("/", handleRoot);
- server.begin();
- MDNS.addService("http", "tcp", 80);
-
- ArduinoOTA.setHostname("esplamp1");
- ArduinoOTA.begin();
-}
-
-void handleUdp() {
- if (!RAWudp) {
- RAWudp.begin(udpPort);
- }
- if (!RAWudp) {
- return;
- }
-
- int cb = RAWudp.parsePacket();
- if (cb) {
- RAWudp.read(cstate, 3);
- for(int i=0; i<3; i++) {
- state[i] = cstate[i] << 2;
- }
- updateLeds();
- }
-}
-
-void loop() {
- server.handleClient();
- handleUdp();
- ArduinoOTA.handle();
-}