|
@@ -13,15 +13,17 @@
|
|
|
#include <Fonts/TomThumb.h>
|
|
#include <Fonts/TomThumb.h>
|
|
|
#include <LightDependentResistor.h>
|
|
#include <LightDependentResistor.h>
|
|
|
|
|
|
|
|
|
|
+String version = "0.33j";
|
|
|
|
|
+
|
|
|
////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////
|
|
|
///////////////////////// Config begin /////////////////////////
|
|
///////////////////////// Config begin /////////////////////////
|
|
|
// Wifi Config
|
|
// Wifi Config
|
|
|
-const char *ssid = "xxxxx";
|
|
|
|
|
-const char *password = "xxxxx";
|
|
|
|
|
-char *awtrix_server = "192.168.178.39";
|
|
|
|
|
|
|
+const char *ssid = "SilberfishAtHome";
|
|
|
|
|
+const char *password = "6457328324132300AE";
|
|
|
|
|
+char *awtrix_server = "192.168.1.146";
|
|
|
|
|
|
|
|
/// LDR Config
|
|
/// LDR Config
|
|
|
-#define LDR_RESISTOR 10000 //ohms
|
|
|
|
|
|
|
+#define LDR_RESISTOR 1000 //ohms
|
|
|
#define LDR_PIN A0
|
|
#define LDR_PIN A0
|
|
|
#define LDR_PHOTOCELL LightDependentResistor::GL5516
|
|
#define LDR_PHOTOCELL LightDependentResistor::GL5516
|
|
|
|
|
|
|
@@ -38,7 +40,7 @@ char *awtrix_server = "192.168.178.39";
|
|
|
char *topics = "awtrixmatrix/";
|
|
char *topics = "awtrixmatrix/";
|
|
|
#define NUMMATRIX (32 * 8)
|
|
#define NUMMATRIX (32 * 8)
|
|
|
CRGB leds[NUMMATRIX];
|
|
CRGB leds[NUMMATRIX];
|
|
|
-String version = "0.32";
|
|
|
|
|
|
|
+
|
|
|
#ifdef MATRIX_MODEV2
|
|
#ifdef MATRIX_MODEV2
|
|
|
FastLED_NeoMatrix *matrix = new FastLED_NeoMatrix(leds, 32, 8, NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG);
|
|
FastLED_NeoMatrix *matrix = new FastLED_NeoMatrix(leds, 32, 8, NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG);
|
|
|
#endif
|
|
#endif
|
|
@@ -56,6 +58,54 @@ unsigned long startTime = 0;
|
|
|
unsigned long endTime = 0;
|
|
unsigned long endTime = 0;
|
|
|
unsigned long duration;
|
|
unsigned long duration;
|
|
|
|
|
|
|
|
|
|
+// from http://playground.arduino.cc/Main/Utf8ascii
|
|
|
|
|
+// ****** UTF8-Decoder: convert UTF8-string to extended ASCII *******
|
|
|
|
|
+static byte cl; // Last character buffer
|
|
|
|
|
+
|
|
|
|
|
+// Convert a single Character from UTF8 to Extended ASCII
|
|
|
|
|
+// Return "0" if a byte has to be ignored
|
|
|
|
|
+byte utf8ascii(byte ascii) {
|
|
|
|
|
+ if ( ascii < 128 ) // Standard ASCII-set 0..0x7F handling
|
|
|
|
|
+ { cl = 0;
|
|
|
|
|
+ return ( ascii );
|
|
|
|
|
+ }
|
|
|
|
|
+ // get previous input
|
|
|
|
|
+ byte last = cl; // get last char
|
|
|
|
|
+ cl = ascii; // remember actual character
|
|
|
|
|
+ switch (last) // conversion depending on first UTF8-character
|
|
|
|
|
+ { case 0xC2: return (ascii) - 34; break;
|
|
|
|
|
+ case 0xC3: return (ascii | 0xC0) - 34; break;// TomThumb extended characters off by 34
|
|
|
|
|
+ case 0x82: if (ascii == 0xAC) return (0xEA); // special case Euro-symbol
|
|
|
|
|
+ }
|
|
|
|
|
+ return (0); // otherwise: return zero, if character has to be ignored
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// convert String object from UTF8 String to Extended ASCII
|
|
|
|
|
+String utf8ascii(String s) {
|
|
|
|
|
+ String r = "";
|
|
|
|
|
+ char c;
|
|
|
|
|
+ for (int i = 0; i < s.length(); i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ c = utf8ascii(s.charAt(i));
|
|
|
|
|
+ if (c != 0) r += c;
|
|
|
|
|
+ }
|
|
|
|
|
+ return r;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// In Place conversion UTF8-string to Extended ASCII (ASCII is shorter!)
|
|
|
|
|
+void utf8ascii(char* s) {
|
|
|
|
|
+ int k = 0;
|
|
|
|
|
+ char c;
|
|
|
|
|
+ for (int i = 0; i < strlen(s); i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ c = utf8ascii(s[i]);
|
|
|
|
|
+ if (c != 0)
|
|
|
|
|
+ s[k++] = c;
|
|
|
|
|
+ }
|
|
|
|
|
+ s[k] = 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
String GetChipID()
|
|
String GetChipID()
|
|
|
{
|
|
{
|
|
|
return String(ESP.getChipId());
|
|
return String(ESP.getChipId());
|
|
@@ -90,6 +140,7 @@ void callback(char *topic, byte *payload, unsigned int length)
|
|
|
{
|
|
{
|
|
|
String s_payload = String((char *)payload);
|
|
String s_payload = String((char *)payload);
|
|
|
|
|
|
|
|
|
|
+
|
|
|
String s_topic = String(topic);
|
|
String s_topic = String(topic);
|
|
|
int last = s_topic.lastIndexOf("/") + 1;
|
|
int last = s_topic.lastIndexOf("/") + 1;
|
|
|
String channel = s_topic.substring(last);
|
|
String channel = s_topic.substring(last);
|
|
@@ -107,7 +158,7 @@ void callback(char *topic, byte *payload, unsigned int length)
|
|
|
}
|
|
}
|
|
|
else if (channel.equals("drawText"))
|
|
else if (channel.equals("drawText"))
|
|
|
{
|
|
{
|
|
|
- if (json["font"].as<String>().equals("big"))
|
|
|
|
|
|
|
+ if (json["font"].as<String>().equals("big"))
|
|
|
{
|
|
{
|
|
|
matrix->setFont();
|
|
matrix->setFont();
|
|
|
matrix->setCursor(json["x"].as<int16_t>(), json["y"].as<int16_t>() - 1);
|
|
matrix->setCursor(json["x"].as<int16_t>(), json["y"].as<int16_t>() - 1);
|
|
@@ -119,7 +170,8 @@ void callback(char *topic, byte *payload, unsigned int length)
|
|
|
}
|
|
}
|
|
|
matrix->setTextColor(matrix->Color(json["color"][0].as<int16_t>(), json["color"][1].as<int16_t>(), json["color"][2].as<int16_t>()));
|
|
matrix->setTextColor(matrix->Color(json["color"][0].as<int16_t>(), json["color"][1].as<int16_t>(), json["color"][2].as<int16_t>()));
|
|
|
String text = json["text"];
|
|
String text = json["text"];
|
|
|
- matrix->print(text);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ matrix->print(utf8ascii(text));
|
|
|
}
|
|
}
|
|
|
else if (channel.equals("drawBMP"))
|
|
else if (channel.equals("drawBMP"))
|
|
|
{
|
|
{
|
|
@@ -194,13 +246,12 @@ void reconnect()
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
// Attempt to connect
|
|
// Attempt to connect
|
|
|
- if (client.connect(("AWTRIXController_" + GetChipID()).c_str(),"matrixstate",0,false,"diconnected"))
|
|
|
|
|
|
|
+ if (client.connect(("AWTRIXController_" + GetChipID()).c_str()))
|
|
|
{
|
|
{
|
|
|
// ... and resubscribe
|
|
// ... and resubscribe
|
|
|
client.subscribe((String(topics) + "#").c_str());
|
|
client.subscribe((String(topics) + "#").c_str());
|
|
|
// ... and publish
|
|
// ... and publish
|
|
|
client.publish("chipid", GetChipID().c_str(), true);
|
|
client.publish("chipid", GetChipID().c_str(), true);
|
|
|
- client.publish("ip", WiFi.localIP().toString().c_str(), true);
|
|
|
|
|
client.publish("matrixstate", "connected");
|
|
client.publish("matrixstate", "connected");
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
@@ -213,15 +264,16 @@ void reconnect()
|
|
|
|
|
|
|
|
void setup()
|
|
void setup()
|
|
|
{
|
|
{
|
|
|
|
|
+ FastLED.addLeds<NEOPIXEL, MATRIX_PIN>(leds, NUMMATRIX).setCorrection(TypicalLEDStrip);
|
|
|
|
|
+ WiFi.mode(WIFI_STA);
|
|
|
|
|
+ WiFi.begin(ssid, password);
|
|
|
matrix->begin();
|
|
matrix->begin();
|
|
|
matrix->setTextWrap(false);
|
|
matrix->setTextWrap(false);
|
|
|
- matrix->setBrightness(127);
|
|
|
|
|
|
|
+ matrix->setBrightness(80);
|
|
|
matrix->setFont(&TomThumb);
|
|
matrix->setFont(&TomThumb);
|
|
|
matrix->setCursor(0, 7);
|
|
matrix->setCursor(0, 7);
|
|
|
- matrix->print("WIFI...");
|
|
|
|
|
|
|
+ matrix->print("WiFi...");
|
|
|
matrix->show();
|
|
matrix->show();
|
|
|
- WiFi.mode(WIFI_STA);
|
|
|
|
|
- WiFi.begin(ssid, password);
|
|
|
|
|
while (WiFi.status() != WL_CONNECTED)
|
|
while (WiFi.status() != WL_CONNECTED)
|
|
|
{
|
|
{
|
|
|
delay(500);
|
|
delay(500);
|
|
@@ -230,10 +282,10 @@ void setup()
|
|
|
MDNS.begin("AWTRIXController");
|
|
MDNS.begin("AWTRIXController");
|
|
|
|
|
|
|
|
photocell.setPhotocellPositionOnGround(false);
|
|
photocell.setPhotocellPositionOnGround(false);
|
|
|
- FastLED.addLeds<NEOPIXEL, MATRIX_PIN>(leds, NUMMATRIX).setCorrection(TypicalLEDStrip);
|
|
|
|
|
|
|
+
|
|
|
matrix->clear();
|
|
matrix->clear();
|
|
|
matrix->setCursor(0, 7);
|
|
matrix->setCursor(0, 7);
|
|
|
- matrix->print("READY!");
|
|
|
|
|
|
|
+ matrix->print("Ready!");
|
|
|
matrix->show();
|
|
matrix->show();
|
|
|
|
|
|
|
|
httpUpdater.setup(&server);
|
|
httpUpdater.setup(&server);
|