From 66c11af437a7ffb8b6b5fa983ab8adf9ba149036 Mon Sep 17 00:00:00 2001
From: egorguslyan <egorguslyan@gmail.com>
Date: Sat, 25 Dec 2021 20:11:02 +0300
Subject: [PATCH] Strings

---
 Dashboard/Dashboard.ino |  4 +--
 Dashboard/config.h      |  2 ++
 Dashboard/screens.h     | 54 ++++++++++++++++++++++++++++++++++++++---
 Dashboard/strings.h     | 17 ++++++++++---
 4 files changed, 67 insertions(+), 10 deletions(-)

diff --git a/Dashboard/Dashboard.ino b/Dashboard/Dashboard.ino
index d7e135e..84b156f 100644
--- a/Dashboard/Dashboard.ino
+++ b/Dashboard/Dashboard.ino
@@ -70,10 +70,8 @@ struct
   uint64_t timer;
 } globalVars;
 
-#include "screens.h"
-#include "config.h"
-
 microLED<numLeds, LEDsPin, MLED_NO_CLOCK, LED_WS2812, ORDER_GRB, CLI_AVER/*, SAVE_MILLIS*/> matrix(WIDTH, HEIGHT, ZIGZAG, RIGHT_TOP, DIR_LEFT);
+#include "config.h"
 #include "textbox.h"
 textbox tb;
 MHZ19_uart co2;
diff --git a/Dashboard/config.h b/Dashboard/config.h
index af8a6c4..76c5373 100644
--- a/Dashboard/config.h
+++ b/Dashboard/config.h
@@ -13,6 +13,8 @@
 
 #define startWith SCREEN_WELCOME
 
+#include "screens.h"
+
 // Links
 enum SCREENS
 {
diff --git a/Dashboard/screens.h b/Dashboard/screens.h
index 346268f..e14f561 100644
--- a/Dashboard/screens.h
+++ b/Dashboard/screens.h
@@ -1,16 +1,62 @@
+#include "strings.h"
+
 void welcome(Arg *arg);
 void dashboard(Arg *arg);
 
 void welcome(Arg *arg)
 {
-    const uint8_t delayMap[] = {50};
+    const uint16_t delayMap[] = {50};
+
+    // Local vars
+    static uint8_t counter = 0;
+
     if(millis() - globalVars.timer > delayMap[globalVars.currentState])
-        digitalWrite(13, 1);
+    {
+        globalVars.timer = millis();
+        switch(globalVars.currentState)
+        {
+            // Init
+            case 0:
+                counter = 0;
+                globalVars.currentState++;
+            break;
+            // Fill borders
+            case 1:
+                uint8_t x = counter < WIDTH ? (counter) 
+                                            : (counter < WIDTH + HEIGHT - 1 ? (WIDTH - 1) 
+                                            : (counter < 2 * WIDTH + HEIGHT - 2 ? (2 * WIDTH - counter + HEIGHT - 2) 
+                                            : (0)));
+                uint8_t y = counter < WIDTH ? (0) 
+                                            : (counter < WIDTH + HEIGHT - 1 ? (counter - WIDTH + 1) 
+                                            : (counter < 2 * WIDTH + HEIGHT - 2 ? (HEIGHT - 1) 
+                                            : (2 * HEIGHT - counter + 2 * WIDTH - 3)));
+                matrix.set(x, y, COLOR1);
+                matrix.show();
+                counter += 1;
+                if(counter == 2 * (WIDTH + HEIGHT) - 4)
+                    globalVars.currentState++;
+            break;
+            case 2:
+                // EEPROM read here
+                tb.setup(, COLOR2, TB_REPEAT, 1, 1, 14, 100);
+                globalVars.currentState++;
+            break;
+        }
+    }
 }
 
 void dashboard(Arg *arg)
 {
-    const uint8_t delayMap[] = {50};
+    const uint16_t delayMap[] = {50};
+    
     if(millis() - globalVars.timer > delayMap[globalVars.currentState])
-        digitalWrite(13, 1);
+    {
+        globalVars.timer = millis();
+        switch(globalVars.currentState)
+        {
+            case 0:
+                //
+            break;
+        }
+    }
 }
\ No newline at end of file
diff --git a/Dashboard/strings.h b/Dashboard/strings.h
index 6a6c4f0..7606fe6 100644
--- a/Dashboard/strings.h
+++ b/Dashboard/strings.h
@@ -1,5 +1,16 @@
 #if LANG_RU_RU
-char* strings[] = {};
+#define LANGMASK(n) langmask[n]
+const char hello[] PROGMEM = "Привет";
+const char start_prompt[] PROGMEM = "<- Свайпни влево";
+const char pomodoro[] PROGMEM = "Помидор";
+const char set_time[] PROGMEM = "Установи время";
+const uint64_t langmask[] PROGMEM = {0xFF, 0x1FFF, 0xFF, 0xFFFF}; 
 #else
-char* strings[] = {"Hello", "<- Swipe left"};
-#endif
\ No newline at end of file
+#define LANGMASK(n) 0
+const char hello[] PROGMEM = "Hello";
+const char start_prompt[] PROGMEM = "<- Swipe left";
+const char pomodoro[] PROGMEM = "Pomodoro";
+const char set_time[] PROGMEM = "Set time";
+#endif
+
+const char* const strings[] = {hello, start_prompt, pomodoro, set_time};
\ No newline at end of file
-- 
GitLab