123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565 |
- #include <FastLED.h>
- #include <ArduinoJson.h>
- #include <ESP8266HTTPClient.h>
- #include <ESP8266WiFi.h>
- #include <ESP8266WiFiMulti.h>
- #include <WiFiClient.h>
- #define LED_PIN 0
- #define COLOR_ORDER GRB
- #define CHIPSET WS2811
- #define BRIGHTNESS 10
- #ifndef STASSID
- #define STASSID "FNT-Gast"
- #define STAPSK "Laserjet09"
- #endif
- #define APIKEY "e471293b25fdb6697c0a862f2695df5f"
- const char* ssid = STASSID;
- const char* password = STAPSK;
- // networking and json
- String apiUrl;
- int status = WL_IDLE_STATUS;
- ESP8266WiFiMulti WiFiMulti;
- WiFiClient client;
- HTTPClient http;
- boolean tempView = false;
- int respCode = 0;
- unsigned long startMillis1;
- unsigned long currentMillis1;
- unsigned long startMillis2;
- unsigned long currentMillis2;
- boolean firstIteration = true;
- void connectWiFi() {
- // We start by connecting to a WiFi network
- WiFi.mode(WIFI_STA);
- WiFiMulti.addAP(ssid, password);
- Serial.println();
- Serial.println();
- Serial.print("Wait for WiFi... ");
- while (WiFiMulti.run() != WL_CONNECTED) {
- Serial.print(".");
- delay(500);
- }
- Serial.println("");
- Serial.println("WiFi connected");
- Serial.println("IP address: ");
- Serial.println(WiFi.localIP());
- delay(500);
- }
- String buildAPIUrl (double lat, double lon, const String& apiKey) {
- const String latStr(lat, 4);
- const String lonStr(lon, 4);
- return String("http://api.openweathermap.org/data/2.5/weather?lat=" +
- latStr + "&lon=" + lonStr + "&appid=" + apiKey + "&units=metric");
- }
- // Params for width and height
- const uint8_t kMatrixWidth = 16;
- const uint8_t kMatrixHeight = 16;
- uint16_t XY( uint8_t x, uint8_t y)
- {
- uint16_t i;
- if ( x & 0x01) {
- i = kMatrixHeight * (kMatrixWidth - (x + 1)) + y;
- } else {
- i = kMatrixHeight * (kMatrixWidth - x) - (y + 1);
- }
- return i;
- }
- #define NUM_LEDS (kMatrixWidth * kMatrixHeight)
- CRGB leds_plus_safety_pixel[ NUM_LEDS + 1];
- CRGB* const leds( leds_plus_safety_pixel + 1);
- uint16_t XYsafe( uint8_t x, uint8_t y)
- {
- if ( x >= kMatrixWidth) return -1;
- if ( y >= kMatrixHeight) return -1;
- return XY(x, y);
- }
- uint8_t sun_yx[16][16] = {
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
- {0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0},
- {0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0},
- {1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1},
- {0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0},
- {0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0},
- {0, 0, 0, 0, 1, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
- };
- uint8_t empty[11][8] = {
- {0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0}
- };
- uint8_t zero[11][8] = {
- {0, 0, 1, 1, 1, 1, 0, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 0, 1, 1, 1, 1, 0, 0}
- };
- uint8_t one[11][8] = {
- {0, 0, 0, 1, 0, 0, 0, 0},
- {0, 0, 1, 1, 0, 0, 0, 0},
- {0, 1, 0, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 0, 0, 0, 0},
- {0, 0, 1, 1, 1, 0, 0, 0}
- };
- uint8_t two[11][8] = {
- {0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 1, 1, 1, 1, 0, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 0, 0, 0, 0, 0, 1, 0},
- {0, 0, 0, 0, 0, 0, 1, 0},
- {0, 0, 0, 0, 0, 1, 0, 0},
- {0, 0, 0, 1, 1, 0, 0, 0},
- {0, 0, 1, 0, 0, 0, 0, 0},
- {0, 1, 0, 0, 0, 0, 0, 0},
- {0, 1, 1, 1, 1, 1, 1, 0}
- };
- uint8_t three[11][8] = {
- {0, 0, 1, 1, 1, 0, 0, 0},
- {0, 1, 0, 0, 0, 1, 0, 0},
- {0, 0, 0, 0, 0, 0, 1, 0},
- {0, 0, 0, 0, 0, 0, 1, 0},
- {0, 0, 0, 0, 0, 1, 0, 0},
- {0, 0, 0, 1, 1, 0, 0, 0},
- {0, 0, 0, 0, 0, 1, 0, 0},
- {0, 0, 0, 0, 0, 0, 1, 0},
- {0, 0, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 1, 0, 0},
- {0, 0, 1, 1, 1, 0, 0, 0}
- };
- uint8_t four[11][8] = {
- {0, 1, 0, 0, 0, 0, 0, 0},
- {0, 1, 0, 0, 0, 0, 0, 0},
- {0, 1, 0, 0, 0, 0, 0, 0},
- {0, 1, 0, 0, 1, 0, 0, 0},
- {0, 1, 0, 0, 1, 0, 0, 0},
- {0, 1, 0, 0, 1, 0, 0, 0},
- {0, 1, 1, 1, 1, 1, 1, 0},
- {0, 0, 0, 0, 1, 0, 0, 0},
- {0, 0, 0, 0, 1, 0, 0, 0},
- {0, 0, 0, 0, 1, 0, 0, 0},
- {0, 0, 0, 0, 1, 0, 0, 0}
- };
- uint8_t five[11][8] = {
- {0, 1, 1, 1, 1, 1, 1, 0},
- {0, 1, 0, 0, 0, 0, 0, 0},
- {0, 1, 0, 0, 0, 0, 0, 0},
- {0, 1, 0, 0, 0, 0, 0, 0},
- {0, 1, 0, 0, 0, 0, 0, 0},
- {0, 0, 1, 1, 1, 1, 0, 0},
- {0, 0, 0, 0, 0, 0, 1, 0},
- {0, 0, 0, 0, 0, 0, 1, 0},
- {0, 0, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 0, 1, 1, 1, 1, 0, 0}
- };
- uint8_t six[11][8] = {
- {0, 0, 1, 1, 1, 1, 0, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 0, 0},
- {0, 1, 0, 0, 0, 0, 0, 0},
- {0, 1, 0, 0, 0, 0, 0, 0},
- {0, 1, 1, 1, 1, 1, 0, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 0, 1, 1, 1, 1, 0, 0}
- };
- uint8_t seven[11][8] = {
- {0, 1, 1, 1, 1, 1, 1, 0},
- {0, 0, 0, 0, 0, 0, 1, 0},
- {0, 0, 0, 0, 0, 1, 0, 0},
- {0, 0, 0, 0, 0, 1, 0, 0},
- {0, 0, 0, 0, 1, 0, 0, 0},
- {0, 0, 0, 0, 1, 0, 0, 0},
- {0, 0, 0, 1, 0, 0, 0, 0},
- {0, 0, 0, 1, 0, 0, 0, 0},
- {0, 0, 1, 0, 0, 0, 0, 0},
- {0, 0, 1, 0, 0, 0, 0, 0},
- {0, 1, 0, 0, 0, 0, 0, 0}
- };
- uint8_t eight[11][8] = {
- {0, 0, 1, 1, 1, 1, 0, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 0, 1, 1, 1, 1, 0, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 0, 1, 1, 1, 1, 0, 0}
- };
- uint8_t nine[11][8] = {
- {0, 0, 1, 1, 1, 1, 0, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 0, 1, 1, 1, 1, 1, 0},
- {0, 0, 0, 0, 0, 0, 1, 0},
- {0, 0, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 1, 0, 0, 0, 0, 1, 0},
- {0, 0, 1, 1, 1, 1, 0, 0}
- };
- uint8_t (*digitOne)[8];
- uint8_t (*digitTwo)[8];
- void drawFrame(uint8_t arr[][16], String identifier)
- {
- FastLED.clear();
- FastLED.show();
- for (int i = 0; i < 16; i++) {
- for (int j = 0; j < 16; j++) {
- uint8_t elem = arr[i][j];
- if (elem == 1) {
- if (identifier == "Rain") {
- if (i >= 12) {
- leds[ XYsafe(i, j)] = CRGB::Blue;
- } else {
- leds[ XYsafe(i, j)] = CRGB::WhiteSmoke;
- }
- } else if (identifier == "Clouds") {
- leds[ XYsafe(i, j)] = CRGB::WhiteSmoke;
- } else if (identifier == "Sun") {
- leds[ XYsafe(i, j)] = CRGB::Yellow;
- } else if (identifier == "CloudSun") {
- if ((((i >= 0) && (i <= 8))
- && ((j >= 0) && (j <= 2)))
- ||
- (((i >= 0) && (i <= 4))
- && ((j >= 0) && (j <= 15)))) {
- leds[ XYsafe(i, j)] = CRGB::Yellow;
- Serial.println("Yellow!");
- } else {
- leds[ XYsafe(i, j)] = CRGB::WhiteSmoke;
- Serial.println("White!");
- }
- }
- }
- }
- }
- FastLED.show();
- }
- void drawTemp()
- {
- FastLED.clear();
- FastLED.show();
- for (int i = 0; i < 5; i++) {
- for (int j = 0; j < 16; j++) {
- // Celsius Symbol
- uint8_t elemCelsius = celsius[i][j];
- if (elemCelsius == 1) {
- leds[ XYsafe(i, j)] = CRGB::WhiteSmoke;
- }
- }
- }
- }
- void drawFirstDigit(int num) {
- for (int i = 0; i < 11; i++) {
- for (int j = 0; j < 8; j++) {
- uint8_t elem;
- switch (num) {
- case 1:
- elem = one[i][j];
- break;
- case 2:
- elem = two[i][j];
- break;
- case 3:
- elem = three[i][j];
- break;
- case 4:
- elem = four[i][j];
- break;
- case 5:
- elem = five[i][j];
- break;
- case 6:
- elem = six[i][j];
- break;
- case 7:
- elem = seven[i][j];
- break;
- case 8:
- elem = eight[i][j];
- break;
- case 9:
- elem = nine[i][j];
- break;
- default:
- elem = 0;
- break;
- }
- if (elem == 1) {
- leds[ XYsafe(i + 5, j)] = CRGB::WhiteSmoke;
- }
- }
- }
- }
- void drawSecondDigit(int num) {
- for (int i = 0; i < 11; i++) {
- for (int j = 0; j < 8; j++) {
- uint8_t elem;
- switch (num) {
- case 1:
- elem = one[i][j];
- break;
- case 2:
- elem = two[i][j];
- break;
- case 3:
- elem = three[i][j];
- break;
- case 4:
- elem = four[i][j];
- break;
- case 5:
- elem = five[i][j];
- break;
- case 6:
- elem = six[i][j];
- break;
- case 7:
- elem = seven[i][j];
- break;
- case 8:
- elem = eight[i][j];
- break;
- case 9:
- elem = nine[i][j];
- break;
- default:
- elem = zero[i][j];
- break;
- }
- if (elem == 1) {
- leds[ XYsafe(i + 5, j + 8)] = CRGB::WhiteSmoke;
- }
- }
- }
- FastLED.show();
- }
- int extractDigit(int num, int i)
- {
- return num / i % 10 ;
- }
- void loop()
- {
- currentMillis1 = millis();
- currentMillis2 = millis();
- if (firstIteration || (currentMillis1 - startMillis1 >= 180000)) {
- respCode = http.GET();
- firstIteration = false;
- startMillis1 = currentMillis1;
- }
- if (respCode > 0) {
- JsonDocument payload;
- const String response = http.getString();
- deserializeJson(payload, response);
- if (currentMillis2 - startMillis2 >= 3000) {
- if (tempView) {
- Serial.print("Response: ");
- Serial.println(response);
- int temp = (int) payload["main"]["temp"];
- Serial.print("Temp: ");
- Serial.println(temp);
- int firstDigit = extractDigit(temp, 10);
- int secondDigit = extractDigit(temp, 1);
- Serial.print("First digit: ");
- Serial.println(firstDigit);
- Serial.print("Second digit: ");
- Serial.println(secondDigit);
- drawTemp();
- drawFirstDigit(firstDigit);
- drawSecondDigit(secondDigit);
- } else {
- if (String("Clouds") == String(payload["weather"][0]["main"])) {
- if (payload["weather"][0]["id"] >= 803) {
- drawFrame(cloud_yx, "Clouds");
- } else {
- drawFrame(cloudSun_yx, "CloudSun");
- }
- } else if (String("Rain") == String(payload["weather"][0]["main"]) || String("Drizzle") == String(payload["weather"][0]["main"])) {
- drawFrame(rain_yx, "Rain");
- } else if (String("Clear") == String(payload["weather"][0]["main"])) {
- drawFrame(sun_yx, "Sun");
- } else {
- drawFrame(cloudSun_yx, "CloudSun");
- }
- }
- tempView = !tempView;
- startMillis2 = currentMillis2;
- }
- } else {
- Serial.print("error ");
- Serial.println(respCode);
- }
- }
- void setup() {
- startMillis1 = millis();
- startMillis2 = millis();
- Serial.begin(115200);
- // weather api
- const float lat = 48.9517;
- const float lon = 10.1703;
- apiUrl = buildAPIUrl(lat, lon, APIKEY);
- connectWiFi();
- if (WiFi.status() != WL_CONNECTED) {
- Serial.println(WiFi.status());
- }
- http.begin(client, apiUrl);
- FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalSMD5050);
- FastLED.setBrightness( BRIGHTNESS );
- }
|