Skip to content
Snippets Groups Projects
Commit 5ad8cc9a authored by egorguslyan's avatar egorguslyan
Browse files

Screens pt.2

parent 66c11af4
No related branches found
No related tags found
No related merge requests found
...@@ -47,9 +47,9 @@ typedef struct ...@@ -47,9 +47,9 @@ typedef struct
{ {
void (*func)(const Arg *); void (*func)(const Arg *);
const Arg arg; const Arg arg;
const uint8_t nextFunc0; const uint8_t nextScreen0;
const uint8_t nextFunc1; const uint8_t nextScreen1;
const uint8_t nextFunc2; const uint8_t nextScreen2;
} Screen; } Screen;
// It will be stored in EEPROM with a special key // It will be stored in EEPROM with a special key
...@@ -68,12 +68,19 @@ struct ...@@ -68,12 +68,19 @@ struct
uint8_t currentScreen; uint8_t currentScreen;
uint8_t currentState; uint8_t currentState;
uint64_t timer; uint64_t timer;
uint8_t tapLeft : 1;
uint8_t tapRight : 1;
uint8_t swipeLeft : 1;
uint8_t swipeRight : 1;
uint8_t holdLeft : 1;
uint8_t holdRight : 1;
} globalVars; } globalVars;
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 "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 "textbox.h" #include "textbox.h"
textbox tb; textbox tb;
#include "configScreens.h"
MHZ19_uart co2; MHZ19_uart co2;
void setup() void setup()
...@@ -96,6 +103,9 @@ void setup() ...@@ -96,6 +103,9 @@ void setup()
globalVars.panelOrientation = eepromData & 0b00000011; globalVars.panelOrientation = eepromData & 0b00000011;
else globalVars.panelOrientation = PANEL_UNKNOWN; else globalVars.panelOrientation = PANEL_UNKNOWN;
// Set start screen
globalVars.currentScreen = startWith;
delay(500); delay(500);
} }
......
...@@ -9,23 +9,4 @@ ...@@ -9,23 +9,4 @@
#define HEIGHT 9 #define HEIGHT 9
#define COLOR1 mHEX(0x9aa100) #define COLOR1 mHEX(0x9aa100)
#define COLOR2 mHEX(0x000aa0) #define COLOR2 mHEX(0x000aa0)
\ No newline at end of file
#define startWith SCREEN_WELCOME
#include "screens.h"
// Links
enum SCREENS
{
NONE = 255,
SCREEN_WELCOME = 0,
SCREEN_DASHBOARD,
SCREEN_GRAPH,
SCREEN_POMODORO,
};
const Screen screens[] = {
{ welcome, {.ui8 = globalVars.panelOrientation}, SCREEN_DASHBOARD, NONE, NONE },
{ dashboard, {.ui8 = globalVars.panelOrientation}, SCREEN_DASHBOARD, NONE, NONE },
};
\ No newline at end of file
#define startWith SCREEN_WELCOME
// Screens
// Welcome screen with greetings
void welcome(Arg *arg);
// Main screen with clock and CO2 bar
void dashboard(Arg *arg);
// Links
enum SCREENS
{
NONE = 255,
SCREEN_WELCOME = 0,
SCREEN_DASHBOARD,
SCREEN_GRAPH,
SCREEN_POMODORO,
};
const Screen screens[] = {
{ welcome, {.ui8 = globalVars.panelOrientation}, SCREEN_DASHBOARD, NONE, NONE },
{ dashboard, {.ui8 = globalVars.panelOrientation}, SCREEN_DASHBOARD, NONE, NONE },
};
#include "screens.h"
\ No newline at end of file
#include "strings.h" #include "strings.h"
void welcome(Arg *arg); // Clear touch panel bools
void dashboard(Arg *arg); void unhandle();
void unhandle()
{
globalVars.tapLeft = globalVars.tapRight =
globalVars.holdLeft = globalVars.holdRight =
globalVars.swipeLeft = globalVars.swipeRight = 0;
}
void welcome(Arg *arg) void welcome(Arg *arg)
{ {
const uint16_t delayMap[] = {50}; const uint16_t delayMap[] = {0, 50, 0, 99};
// Local vars // Local vars
static uint8_t counter = 0; static uint8_t counter = 0;
if(millis() - globalVars.timer > delayMap[globalVars.currentState]) if(millis() - globalVars.timer > delayMap[globalVars.currentState])
{ {
globalVars.timer = millis();
switch(globalVars.currentState) switch(globalVars.currentState)
{ {
// Init // Init
case 0: case 0:
if(globalVars.panelOrientation != PANEL_UNKNOWN)
{
globalVars.currentScreen = screens[SCREEN_WELCOME].nextScreen0;
break;
}
counter = 0; counter = 0;
globalVars.currentState++; globalVars.currentState++;
globalVars.timer = millis();
break; break;
// Fill borders // Fill borders
case 1: case 1:
...@@ -35,13 +47,20 @@ void welcome(Arg *arg) ...@@ -35,13 +47,20 @@ void welcome(Arg *arg)
counter += 1; counter += 1;
if(counter == 2 * (WIDTH + HEIGHT) - 4) if(counter == 2 * (WIDTH + HEIGHT) - 4)
globalVars.currentState++; globalVars.currentState++;
globalVars.timer = millis();
break; break;
case 2: case 2:
// EEPROM read here char S[20];
tb.setup(, COLOR2, TB_REPEAT, 1, 1, 14, 100); strcpy_P(S, pgm_read_word(strings[0]));
tb.setup(S, LANGMASK(0), COLOR2, TB_REPEAT, 1, 1, 14, 100);
globalVars.currentState++; globalVars.currentState++;
break; break;
case 3:
if(tb.render()) globalVars.timer = millis();
if(globalVars.swipeLeft) globalVars.currentScreen = screens[SCREEN_WELCOME].nextScreen0;
break;
} }
unhandle();
} }
} }
......
#if LANG_RU_RU #ifdef LANG_RU_RU
#define LANGMASK(n) langmask[n] #define LANGMASK(n) langmask[n]
const char hello[] PROGMEM = "Привет"; const char hello[] PROGMEM = "Привет";
const char start_prompt[] PROGMEM = "<- Свайпни влево"; const char start_prompt[] PROGMEM = "<- Свайпни влево";
const char pomodoro[] PROGMEM = "Помидор"; const char pomodoro[] PROGMEM = "Помидор";
const char set_time[] PROGMEM = "Установи время"; const char set_time[] PROGMEM = "Установи время";
const uint64_t langmask[] PROGMEM = {0xFF, 0x1FFF, 0xFF, 0xFFFF}; // Need to make it PROGMEM
const uint64_t langmask[] = {0xFF, 0x1FFF, 0xFF, 0xFFFF};
#else #else
#define LANGMASK(n) 0 #define LANGMASK(n) 0
const char hello[] PROGMEM = "Hello"; const char hello[] PROGMEM = "Hello";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment