Adjustable timeout
This commit is contained in:
parent
812eafd09c
commit
91e94aa0e8
@ -15,7 +15,7 @@ bool backlightSupport = 0; //only if it's true will any of the settings be visib
|
|||||||
int16_t backlightLevel_HIGH = 0;
|
int16_t backlightLevel_HIGH = 0;
|
||||||
int16_t backlightLevel_LOW = 0;
|
int16_t backlightLevel_LOW = 0;
|
||||||
uint8_t backlightMode = BACKLIGHT_MODE_BRIGHT;
|
uint8_t backlightMode = BACKLIGHT_MODE_BRIGHT;
|
||||||
unsigned long backlightTimer_period = 10000ul;
|
int16_t backlightTimer_period = 10;
|
||||||
LongTimer backlightTimer;
|
LongTimer backlightTimer;
|
||||||
|
|
||||||
void backlight_save() //saves all backlight data to eeprom.
|
void backlight_save() //saves all backlight data to eeprom.
|
||||||
@ -23,6 +23,7 @@ void backlight_save() //saves all backlight data to eeprom.
|
|||||||
eeprom_update_byte((uint8_t *)EEPROM_BACKLIGHT_LEVEL_HIGH, (uint8_t)backlightLevel_HIGH);
|
eeprom_update_byte((uint8_t *)EEPROM_BACKLIGHT_LEVEL_HIGH, (uint8_t)backlightLevel_HIGH);
|
||||||
eeprom_update_byte((uint8_t *)EEPROM_BACKLIGHT_LEVEL_LOW, (uint8_t)backlightLevel_LOW);
|
eeprom_update_byte((uint8_t *)EEPROM_BACKLIGHT_LEVEL_LOW, (uint8_t)backlightLevel_LOW);
|
||||||
eeprom_update_byte((uint8_t *)EEPROM_BACKLIGHT_MODE, backlightMode);
|
eeprom_update_byte((uint8_t *)EEPROM_BACKLIGHT_MODE, backlightMode);
|
||||||
|
eeprom_update_word((uint16_t *)EEPROM_BACKLIGHT_TIMEOUT, backlightTimer_period);
|
||||||
}
|
}
|
||||||
|
|
||||||
void backlightTimer_reset() //used for resetting the timer and waking the display. Triggered on events such as knob click, rotate and on full screen notifications.
|
void backlightTimer_reset() //used for resetting the timer and waking the display. Triggered on events such as knob click, rotate and on full screen notifications.
|
||||||
@ -37,7 +38,7 @@ void backlight_update()
|
|||||||
|
|
||||||
if (backlightMode == BACKLIGHT_MODE_AUTO)
|
if (backlightMode == BACKLIGHT_MODE_AUTO)
|
||||||
{
|
{
|
||||||
if (backlightTimer.expired(backlightTimer_period)) analogWrite(LCD_BL_PIN, backlightLevel_LOW);
|
if (backlightTimer.expired((uint32_t)backlightTimer_period * 1000ul)) analogWrite(LCD_BL_PIN, backlightLevel_LOW);
|
||||||
else if (backlightTimer.running()) analogWrite(LCD_BL_PIN, backlightLevel_HIGH);
|
else if (backlightTimer.running()) analogWrite(LCD_BL_PIN, backlightLevel_HIGH);
|
||||||
else {/*do nothing*/;} //display is dimmed.
|
else {/*do nothing*/;} //display is dimmed.
|
||||||
}
|
}
|
||||||
@ -61,10 +62,12 @@ void backlight_init()
|
|||||||
backlightMode = BACKLIGHT_MODE_AUTO;
|
backlightMode = BACKLIGHT_MODE_AUTO;
|
||||||
backlightLevel_HIGH = 130;
|
backlightLevel_HIGH = 130;
|
||||||
backlightLevel_LOW = 50;
|
backlightLevel_LOW = 50;
|
||||||
|
backlightTimer_period = 10; //in seconds
|
||||||
backlight_save();
|
backlight_save();
|
||||||
}
|
}
|
||||||
backlightLevel_HIGH = eeprom_read_byte((uint8_t *)EEPROM_BACKLIGHT_LEVEL_HIGH);
|
backlightLevel_HIGH = eeprom_read_byte((uint8_t *)EEPROM_BACKLIGHT_LEVEL_HIGH);
|
||||||
backlightLevel_LOW = eeprom_read_byte((uint8_t *)EEPROM_BACKLIGHT_LEVEL_LOW);
|
backlightLevel_LOW = eeprom_read_byte((uint8_t *)EEPROM_BACKLIGHT_LEVEL_LOW);
|
||||||
|
backlightTimer_period = eeprom_read_word((uint16_t *)EEPROM_BACKLIGHT_TIMEOUT);
|
||||||
|
|
||||||
SET_OUTPUT(LCD_BL_PIN);
|
SET_OUTPUT(LCD_BL_PIN);
|
||||||
backlightTimer_reset();
|
backlightTimer_reset();
|
||||||
|
@ -15,6 +15,7 @@ extern int16_t backlightLevel_HIGH;
|
|||||||
extern int16_t backlightLevel_LOW;
|
extern int16_t backlightLevel_LOW;
|
||||||
extern uint8_t backlightMode;
|
extern uint8_t backlightMode;
|
||||||
extern bool backlightSupport;
|
extern bool backlightSupport;
|
||||||
|
extern int16_t backlightTimer_period;
|
||||||
|
|
||||||
extern void backlight_update();
|
extern void backlight_update();
|
||||||
extern void backlight_init();
|
extern void backlight_init();
|
||||||
|
@ -204,9 +204,10 @@ static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_SHEETS_BASE);
|
|||||||
#define EEPROM_BACKLIGHT_LEVEL_HIGH (EEPROM_SHEETS_BASE-1) // uint8
|
#define EEPROM_BACKLIGHT_LEVEL_HIGH (EEPROM_SHEETS_BASE-1) // uint8
|
||||||
#define EEPROM_BACKLIGHT_LEVEL_LOW (EEPROM_BACKLIGHT_LEVEL_HIGH-1) // uint8
|
#define EEPROM_BACKLIGHT_LEVEL_LOW (EEPROM_BACKLIGHT_LEVEL_HIGH-1) // uint8
|
||||||
#define EEPROM_BACKLIGHT_MODE (EEPROM_BACKLIGHT_LEVEL_LOW-1) // uint8
|
#define EEPROM_BACKLIGHT_MODE (EEPROM_BACKLIGHT_LEVEL_LOW-1) // uint8
|
||||||
|
#define EEPROM_BACKLIGHT_TIMEOUT (EEPROM_BACKLIGHT_MODE-2) // uint16
|
||||||
|
|
||||||
//This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items.
|
//This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items.
|
||||||
#define EEPROM_LAST_ITEM EEPROM_BACKLIGHT_MODE
|
#define EEPROM_LAST_ITEM EEPROM_BACKLIGHT_TIMEOUT
|
||||||
// !!!!!
|
// !!!!!
|
||||||
// !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!!
|
// !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!!
|
||||||
// !!!!!
|
// !!!!!
|
||||||
|
@ -7187,14 +7187,15 @@ static void lcd_backlight_menu()
|
|||||||
);
|
);
|
||||||
|
|
||||||
MENU_ITEM_BACK_P(_T(MSG_BACK));
|
MENU_ITEM_BACK_P(_T(MSG_BACK));
|
||||||
MENU_ITEM_EDIT_int3_P(_i("Level Bright"), &backlightLevel_HIGH, 0, 255);
|
MENU_ITEM_EDIT_int3_P(_i("Level Bright"), &backlightLevel_HIGH, backlightLevel_LOW, 255);
|
||||||
MENU_ITEM_EDIT_int3_P(_i("Level Dimmed"), &backlightLevel_LOW, 0, 255);
|
MENU_ITEM_EDIT_int3_P(_i("Level Dimmed"), &backlightLevel_LOW, 0, backlightLevel_HIGH);
|
||||||
switch (backlightMode)
|
switch (backlightMode)
|
||||||
{
|
{
|
||||||
case BACKLIGHT_MODE_BRIGHT: MENU_ITEM_FUNCTION_P(_i("Mode [Always on]"), backlight_mode_toggle); break;
|
case BACKLIGHT_MODE_BRIGHT: MENU_ITEM_FUNCTION_P(_i("Mode [Bright]"), backlight_mode_toggle); break;
|
||||||
case BACKLIGHT_MODE_DIM: MENU_ITEM_FUNCTION_P(_i("Mode [Always off]"), backlight_mode_toggle); break;
|
case BACKLIGHT_MODE_DIM: MENU_ITEM_FUNCTION_P(_i("Mode [Dim]"), backlight_mode_toggle); break;
|
||||||
default: MENU_ITEM_FUNCTION_P(_i("Mode [Auto]"), backlight_mode_toggle); break;
|
default: MENU_ITEM_FUNCTION_P(_i("Mode [Auto]"), backlight_mode_toggle); break;
|
||||||
}
|
}
|
||||||
|
MENU_ITEM_EDIT_int3_P(_i("Timeout"), &backlightTimer_period, 1, 999);
|
||||||
|
|
||||||
MENU_END();
|
MENU_END();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user