Skip to content
Snippets Groups Projects
Commit 7480904c authored by egorguslyan's avatar egorguslyan
Browse files

millis() reset, no animations

parent 8368008c
No related branches found
No related tags found
No related merge requests found
......@@ -82,14 +82,21 @@ struct
uint8_t currentState;
uint8_t animation : 4;
uint8_t prepare : 2;
uint64_t timer;
uint32_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;
mData leds[0 /*NUMLEDS*/]; // Sorry, but this buffer drains a lot of memory
// mData leds[NUMLEDS];
void leds; // Sorry, but this buffer drains a lot of memory
// Measured data
uint16_t ppm : 13; // CO2 ppm (surely cant be more than 8192)
uint8_t hours : 5;
uint8_t minutes : 6;
uint8_t seconds : 6;
} globalVars;
microLED<NUMLEDS, LEDsPin, MLED_NO_CLOCK, LED_WS2812, ORDER_GRB, CLI_AVER, SAVE_MILLIS> matrix(WIDTH, HEIGHT, ZIGZAG, RIGHT_TOP, DIR_LEFT);
......@@ -98,6 +105,8 @@ textbox tb;
#include "configScreens.h"
MHZ19_uart co2;
extern volatile unsigned long timer0_millis;
void setup()
{
// Hardware init
......@@ -108,7 +117,7 @@ void setup()
co2.setAutoCalibration(false);
Serial.begin(9600);
// For safe debugging
while (!Serial.available()) {}
//while (!Serial.available()) {}
Serial.println("Hello");
// Reading settings from nonvolatile memory
......@@ -130,7 +139,7 @@ void setup()
void loop()
{
// Terminate if buttuns are holded
static uint64_t timer_debug0 = 0;
static uint32_t timer_debug0 = 0;
static bool button = 0;
static bool last_button = 0;
last_button = button;
......@@ -156,4 +165,15 @@ void loop()
}
matrix.show();
// Monthly preventative safe reset of the millis() timer
TIMER(0, 3456000000)
{
noInterrupts();
timer0_millis = 0;
interrupts();
globalVars.timer = 0;
tb.resetTimers();
timer_debug0 = 0;
}
}
\ No newline at end of file
......@@ -26,11 +26,11 @@ void changeScreen(uint8_t current, uint8_t next)
void animate(uint16_t reciprocal_speed)
{
static uint8_t counter = 0;
TIMER(globalVars.timer, reciprocal_speed)
//if(globalVars.animation == NO_ANIMATION)
if(true)
{
globalVars.timer = millis();
globalVars.prepare = 0;
return;
}
}
......@@ -74,12 +74,14 @@ void welcome(Arg *arg)
globalVars.currentState++;
globalVars.timer = millis();
break;
// Setup textbox
case 2:
char S[20];
strcpy_P(S, pgm_read_word(strings[0]));
tb.setup(S, LANGMASK(0), COLOR2, TB_REPEAT, 1, 1, 14, 100);
globalVars.currentState++;
break;
// Render until it disappears
case 3:
if(tb.render()) globalVars.timer = millis();
if(globalVars.swipeLeft)
......
......@@ -33,7 +33,7 @@ private:
uint64_t langMask;
bool native;
void getLetter(uint8_t i, bool skipBitmap = 0);
uint64_t timer0;
uint32_t timer0;
public:
textbox(void);
......@@ -45,6 +45,7 @@ public:
uint8_t render(void);
void disable(void);
void changeCords(uint8_t newx, uint8_t newy);
void resetTimers(void);
};
textbox::textbox(void)
......@@ -115,6 +116,7 @@ void textbox::setup(char _text[], uint64_t _langMask,
uint8_t textbox::render(void)
{
uint8_t r = 1; // Return 1 if rendered, 2 if rendered with new cycle
if (mode != TB_DISABLED)
{
// If static or kickstart
......@@ -134,6 +136,7 @@ uint8_t textbox::render(void)
{
if ((!direction && offset == -textwidth + w) || (direction && offset == 0))
{
r = direction + 1;
direction = !direction;
state = 0;
}
......@@ -147,6 +150,7 @@ uint8_t textbox::render(void)
{
offset = 0 + (mode == TB_REPEAT) * w;
state = 0;
r = 2;
}
}
}
......@@ -206,7 +210,7 @@ uint8_t textbox::render(void)
index = 0;
}
}
return 1;
return r;
}
void textbox::disable(void)
......@@ -244,4 +248,9 @@ void textbox::changeCords(uint8_t newx, uint8_t newy)
{
cord_x = newx;
cord_y = newy;
}
void textbox::resetTimers(void)
{
timer0 = 0;
}
\ No newline at end of file
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