~/Projects/AWTRIX2.0-Controller
git clone https://code.lsong.org/AWTRIX2.0-Controller
Commit
- Commit
- 8c488389f58840acd9b8de7c8afbd100f46eaf7a
- Author
- Blueforcer <[email protected]>
- Date
- 2019-07-06 14:37:36 +0200 +0200
- Diffstat
src/AWTRIXController.cpp | 72 ++++++++++++++++++++++-------------------
Update AWTRIXController.cpp add matrixstyle
diff --git a/src/AWTRIXController.cpp b/src/AWTRIXController.cpp index 75236cc36893ee55b8fd110ac17ddc56631a9056..1782142c472a75a5c977ab0d08c98616cd0e6c1c 100644 --- a/src/AWTRIXController.cpp +++ b/src/AWTRIXController.cpp @@ -36,6 +36,7 @@ int gestureState = false; // 0 = false ; 1 = true int ldrState = false; // 0 = None int USBConnection = false; // true = usb... int pairingState = 0; //0 = not paired ; 1 = paired +int MatrixStyle = 1; String version = "0.9b"; char awtrix_server[16]; @@ -101,14 +102,9 @@ SoftwareSerial mySoftwareSerial(D7, D5); // RX, TX // Matrix Settings CRGB leds[256]; -#include <ESP8266WebServer.h> #include <ArduinoOTA.h> -#include <ESP8266WebServer.h> #include <ESP8266WiFi.h> #include <ESP8266WebServer.h> -#include <ESP8266WebServer.h> -FastLED_NeoMatrix *matrix = new FastLED_NeoMatrix(leds, 32, 8, NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG); -#endif static byte c1; // Last character buffer byte utf8ascii(byte ascii) @@ -146,7 +143,7 @@ json["usbWifi"] = USBConnection; json["ldr"] = ldrState; json["gesture"] = gestureState; json["audio"] = audioState; - + json["MatrixStyle"] = MatrixStyle; json["paired"] = pairingState; File configFile = SPIFFS.open("/config.json", "w"); @@ -620,10 +617,9 @@ USBConnection = (int)payload[1]; tempState = (int)payload[2]; audioState = (int)payload[3]; gestureState = (int)payload[4]; -// by Blueforcer & Mazze2000 #include <ArduinoOTA.h> -// AWTRIX Controller +bool updating = false; - + MatrixStyle = (int)payload[7]; matrix->clear(); matrix->setCursor(6, 6); matrix->setTextColor(matrix->Color(0, 255, 50)); @@ -779,29 +775,6 @@ void setup() { delay(2000); -char awtrix_server[16]; - matrix->begin(); - matrix->setTextWrap(false); - matrix->setBrightness(80); - matrix->setFont(&TomThumb); - - if (drd.detect()) - { - Serial.println("** Double reset boot **"); - matrix->clear(); - matrix->setTextColor(matrix->Color(255, 0, 0)); - matrix->setCursor(6, 6); - matrix->print("RESET!"); - matrix->show(); - delay(3000); - wifiManager.resetSettings(); - if (SPIFFS.begin()) - { - SPIFFS.remove("/config.json"); - SPIFFS.end(); - } - } - wifiManager.setAPStaticIPConfig(IPAddress(172, 217, 28, 1), IPAddress(172, 217, 28, 1), IPAddress(255, 255, 255, 0)); Serial.setRxBufferSize(1024); @@ -840,6 +813,7 @@ gestureState = json["gesture"].as(); ldrState = json["ldr"].as<int>(); tempState = json["temp"].as<int>(); pairingState = json["paired"].as<int>(); + MatrixStyle = json["MatrixStyle"].as<int>(); } configFile.close(); } @@ -849,6 +823,38 @@ { Serial.println("mounting not possible"); } + if (MatrixStyle) + { + matrix = new FastLED_NeoMatrix(leds, 32, 8, NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG); + } + else + { + matrix = new FastLED_NeoMatrix(leds, 32, 8, NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG); + } + + FastLED.addLeds<NEOPIXEL, D2>(leds, 256).setCorrection(TypicalLEDStrip); + matrix->begin(); + matrix->setTextWrap(false); + matrix->setBrightness(80); + matrix->setFont(&TomThumb); + + if (drd.detect()) + { + Serial.println("** Double reset boot **"); + matrix->clear(); + matrix->setTextColor(matrix->Color(255, 0, 0)); + matrix->setCursor(6, 6); + matrix->print("RESET!"); + matrix->show(); + delay(3000); + wifiManager.resetSettings(); + if (SPIFFS.begin()) + { + SPIFFS.remove("/config.json"); + SPIFFS.end(); + } + } + Serial.println("Loading from SPIFFS:"); Serial.println(awtrix_server); if (USBConnection) @@ -1160,10 +1166,11 @@ ldrState = int(incomingPacket[4] << 8) + int(incomingPacket[5]); IPAddress ip = IPAddress(incomingPacket[6], incomingPacket[7], incomingPacket[8], incomingPacket[9]); ip.toString().toCharArray(awtrix_server, 16); + MatrixStyle = (int)incomingPacket[10]; #include <ArduinoOTA.h> -// by Blueforcer & Mazze2000 #include <ESP8266WebServer.h> +#include <ESP8266WiFi.h> { matrix->clear(); matrix->setCursor(6, 6);