Fixed updating the screen when sleeping
This commit is contained in:
parent
353982c309
commit
a7e19b5b8e
35
code/main.c
35
code/main.c
@ -25,7 +25,9 @@
|
|||||||
|
|
||||||
// Rotary Encoder Parameters
|
// Rotary Encoder Parameters
|
||||||
#define ROT_PULSE_COUNT 12
|
#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
|
// Input masks
|
||||||
#define BUTTON_V 0x01
|
#define BUTTON_V 0x01
|
||||||
@ -66,6 +68,7 @@ uint8_t *event_write = events;
|
|||||||
|
|
||||||
uint32_t ms = 0;
|
uint32_t ms = 0;
|
||||||
|
|
||||||
|
#ifdef ROT_CW_UP
|
||||||
const uint8_t PROGMEM rot_table[16] =
|
const uint8_t PROGMEM rot_table[16] =
|
||||||
{
|
{
|
||||||
EVENT_NONE, EVENT_ROT_CCW, EVENT_ROT_CW, EVENT_NONE,
|
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_ROT_CCW, EVENT_NONE, EVENT_NONE, EVENT_ROT_CW,
|
||||||
EVENT_NONE, EVENT_ROT_CW, EVENT_ROT_CCW, EVENT_NONE
|
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] =
|
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 rot_abs;
|
||||||
int8_t adjust;
|
int8_t adjust;
|
||||||
@ -340,7 +352,7 @@ int main()
|
|||||||
}
|
}
|
||||||
count_value = (uint32_t) count_value_fine;
|
count_value = (uint32_t) count_value_fine;
|
||||||
|
|
||||||
if (0 != sleep_when_ms)
|
if ((0 != sleep_when_ms) && (sleep_when_ms > ms))
|
||||||
{
|
{
|
||||||
needs_update = 1;
|
needs_update = 1;
|
||||||
}
|
}
|
||||||
@ -360,6 +372,7 @@ int main()
|
|||||||
{
|
{
|
||||||
display_enable(0);
|
display_enable(0);
|
||||||
do_sleep();
|
do_sleep();
|
||||||
|
sleep_when_ms = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// STATE_COUNTING
|
// STATE_COUNTING
|
||||||
@ -604,7 +617,19 @@ void display_init()
|
|||||||
|
|
||||||
void display_enable(uint8_t en)
|
void display_enable(uint8_t en)
|
||||||
{
|
{
|
||||||
display_send_cmd(0xAE | (en & 0x01));
|
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)
|
void get_symbol16(uint8_t index, uint8_t *out)
|
||||||
@ -936,7 +961,7 @@ void do_sleep()
|
|||||||
|
|
||||||
// Reset ms counter
|
// Reset ms counter
|
||||||
cli();
|
cli();
|
||||||
ms = 0;
|
ms = 2;
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
// Disable sleep
|
// Disable sleep
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user