Increased event queue size. Sleep no longer stops TIM1 clock - bugfix
This commit is contained in:
parent
a7e19b5b8e
commit
73104c90c8
27
code/main.c
27
code/main.c
@ -26,7 +26,7 @@
|
||||
// Rotary Encoder Parameters
|
||||
#define ROT_PULSE_COUNT 12
|
||||
#define ROT_DETENTS 24
|
||||
#define ROT_WHEEL_RAD 13.125
|
||||
#define ROT_WHEEL_RAD 13
|
||||
//#define ROT_CW_UP
|
||||
|
||||
// Input masks
|
||||
@ -41,7 +41,7 @@
|
||||
#define INPUT_MASK (BUTTON_M | ENCODER_M)
|
||||
|
||||
// Event queue macros
|
||||
#define MAX_EVENT_COUNT 16
|
||||
#define MAX_EVENT_COUNT 64
|
||||
#define PTR_INC(x) ((x) = events + ((((x) - events) + 1) % MAX_EVENT_COUNT))
|
||||
|
||||
enum event_e
|
||||
@ -311,19 +311,8 @@ int main()
|
||||
|
||||
if (rot_value / (ROT_PULSE_COUNT * 4 / ROT_DETENTS) != 0)
|
||||
{
|
||||
int8_t rot_abs;
|
||||
int8_t adjust;
|
||||
|
||||
rot_abs = rot_value;
|
||||
adjust = 1;
|
||||
if (rot_value < 0)
|
||||
{
|
||||
rot_abs = -rot_abs;
|
||||
adjust = -1;
|
||||
}
|
||||
|
||||
rot_value -= (rot_abs * adjust);
|
||||
count_value_fine += (rot_coeff * adjust * rot_abs);
|
||||
count_value_fine += rot_coeff * rot_value;
|
||||
rot_value = 0;
|
||||
|
||||
if (count_value_fine < 0)
|
||||
{
|
||||
@ -950,8 +939,8 @@ void write_eeprom_val(uint16_t idx, uint32_t value, uint8_t dir)
|
||||
|
||||
void do_sleep()
|
||||
{
|
||||
// Disable clock to Timer1, USI, ADC
|
||||
PRR |= (1 << PRTIM1) | (1 << PRUSI) | (1 << PRADC);
|
||||
// Disable clock to USI, ADC
|
||||
PRR |= (1 << PRUSI) | (1 << PRADC);
|
||||
|
||||
// Enable sleep
|
||||
MCUCR |= (1 << SE);
|
||||
@ -967,8 +956,8 @@ void do_sleep()
|
||||
// Disable sleep
|
||||
MCUCR &= ~(1 << SE);
|
||||
|
||||
// Enable clock to Timer1, USI, ADC
|
||||
PRR &= ~((1 << PRTIM1) | (1 << PRUSI) | (1 << PRADC));
|
||||
// Enable clock to USI, ADC
|
||||
PRR &= ~((1 << PRUSI) | (1 << PRADC));
|
||||
}
|
||||
|
||||
void update_display(uint32_t value, uint32_t highlight, uint8_t dir, uint8_t dir_highlight)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user