Fixed updating the screen when sleeping

This commit is contained in:
DWW 2021-10-16 00:54:57 +03:00
parent 353982c309
commit a7e19b5b8e

View File

@ -25,7 +25,9 @@
// Rotary Encoder Parameters
#define ROT_PULSE_COUNT 12
#define ROT_WHEEL_RAD 12
#define ROT_DETENTS 24
#define ROT_WHEEL_RAD 13.125
//#define ROT_CW_UP
// Input masks
#define BUTTON_V 0x01
@ -66,6 +68,7 @@ uint8_t *event_write = events;
uint32_t ms = 0;
#ifdef ROT_CW_UP
const uint8_t PROGMEM rot_table[16] =
{
EVENT_NONE, EVENT_ROT_CCW, EVENT_ROT_CW, EVENT_NONE,
@ -73,6 +76,15 @@ const uint8_t PROGMEM rot_table[16] =
EVENT_ROT_CCW, EVENT_NONE, EVENT_NONE, EVENT_ROT_CW,
EVENT_NONE, EVENT_ROT_CW, EVENT_ROT_CCW, EVENT_NONE
};
#else
const uint8_t PROGMEM rot_table[16] =
{
EVENT_NONE, EVENT_ROT_CW, EVENT_ROT_CCW, EVENT_NONE,
EVENT_ROT_CCW, EVENT_NONE, EVENT_NONE, EVENT_ROT_CW,
EVENT_ROT_CW, EVENT_NONE, EVENT_NONE, EVENT_ROT_CCW,
EVENT_NONE, EVENT_ROT_CCW, EVENT_ROT_CW, EVENT_NONE
};
#endif
const uint8_t PROGMEM unfold_table[16] =
{
@ -297,7 +309,7 @@ int main()
}
}
if (rot_value / 2 != 0)
if (rot_value / (ROT_PULSE_COUNT * 4 / ROT_DETENTS) != 0)
{
int8_t rot_abs;
int8_t adjust;
@ -340,7 +352,7 @@ int main()
}
count_value = (uint32_t) count_value_fine;
if (0 != sleep_when_ms)
if ((0 != sleep_when_ms) && (sleep_when_ms > ms))
{
needs_update = 1;
}
@ -360,6 +372,7 @@ int main()
{
display_enable(0);
do_sleep();
sleep_when_ms = 1;
}
// STATE_COUNTING
@ -603,10 +616,22 @@ void display_init()
}
void display_enable(uint8_t en)
{
static uint8_t old_state = 1;
if (en != 0)
{
en = 1;
}
if (en != old_state)
{
display_send_cmd(0xAE | (en & 0x01));
}
old_state = en;
}
void get_symbol16(uint8_t index, uint8_t *out)
{
uint8_t i;
@ -936,7 +961,7 @@ void do_sleep()
// Reset ms counter
cli();
ms = 0;
ms = 2;
sei();
// Disable sleep