Configure fuses for the `fuses` target in Makefile to disable
`CKDIV8`. Adapt PWM generation in `lcd_update_backlight()` to new
clock division factor, as well as interrupt handling, debouncing and
dechattering.
This also enables partially lower PWM frequencies (between off and
former lowest PWM setting) for a dimmer lcd backlight.
Store read-only graphics and symbols in flash and use a symbol lookup
table which somehow fits to the ASCII character set. A macro is used
to make the creation of the symbol lookup table shorter. A function to
print strings enables the use of strings.
The default values for the contrast and backlight are set when writing
to eeprom. Use the values stored in eeprom for contrast and
backlight. Update the contrast and backlight when changing their
values.
To have the values of `value_contrast` and `value_backlight` persist
over turn offs they are loaded and stored from and in the eeprom.
For preventing the flash target from earasing the eeprom the `EESAVE`
high fuse byte is set to 0 (programmed).
The values are now loaded when booted and stored when a new value is
set in the setup menu.
In order to be able to change the setup settings two new setup states
are introduced `change_contrast` and `change_backlight`. All
procedures that handle the setup states are adapted to handle those
new states correct. To keep track of their values the global variables
`value_contrast` and `value_backlight` are introduced.
To make setup settings configurable make it possible to select them
first. Therefore the `setup_state` enum is created to keep track of
the currently selected setting state.
In order to draw the setup screen, several character symbols are
added. The `lcd_setup` function, which draws the setup screen, as well
as the `update_setup` function, that updates the setup screens state,
are added.
In order to improve the handling of states the `state` enum is also
used for saving the `home_state`, which was previously called
`current_home_state`. All dependent functions were adapted to the
change.
The `volatile` keyword was added to some variables.
The `input` enum is extended with `click` and `hold` values and all
dependencies are adapted to that. In order to handle the `click` input
an interrupt is used. Further, for handling held button input with the
switch the Timer/Counter1 compare match interrupt with OCR1A is used.
When `lcd_fill(0x00)` is called before drawing the splash screen and
only a part of the image is stored as done now, some memory in the
`.bss` segment can be used for something else.
Enable the SPI bus to configure the display and program its ram. For
that the fastest available SPI clock is used. To configure the display
a minimal config is used which is not identical but similar to the
displays datasheet. The display can only be filled columnwise so far.
Generate a variable duty cycle PWM signal for the dimmable display
backlight at a frequency of 1.25kHz.
For demo und testing purposes PD5 is currently fading between 0 and
100%.