Commit graph

30 commits

Author SHA1 Message Date
c0f8cac065 Proper debouncing and dechattering
Move debouncing and dechattering to the beginning of the interrupt
service routines to handle them properly.
2021-09-23 23:42:20 +02:00
3aa458c4bc Furbish code and comments
Add `TODO` comment to optimize waiting times, fix capitalization in
comments, add blank line and break up long lines. To improve code
semantics `lcd_home()` and `lcd_setup()` were renamed to `draw_home()`
and `draw_setup()` respectively. Improve ordering of function calls in
`main()`.
2021-09-23 22:52:54 +02:00
2579ae3686 Print actual status and data on TWI error
The contents of `TWSR` (TWI Status Register) and `TWDR` (TWI Data
Register) are printed when an error occured.
2021-09-23 22:47:17 +02:00
664aa4bad5 Add underscore and extend symbol lookup table
To be able to print the underscore symbol `_` the symbol is added and
the symbol lookup table is extended.
2021-09-23 22:45:46 +02:00
99175efc8c Add basic TWI support
To support basic TWI support some defines are created to keep track of
port, pins and address. Fundamental procedures such as:
- `twi_error()`
- `twi_start()`
- `twi_transmit()`
- `twi_receive()`
- `twi_stop()`
are created. Those procedures are used in `twi_read_register()` and
`twi_write_register()` which read and write data from and to registers
respectively. Lastly the TWI bit rate is set to 200kHz.
2021-09-23 21:26:59 +02:00
52e161f43b Create an invalid character
This character is used for invalid characters.
2021-09-21 19:43:22 +02:00
bd217ce6e7 Disable CKDIV8 and adapt to clock div. factor
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.
2021-09-21 19:10:46 +02:00
c48e4a31ab Use NULL instead of strlen for printing strings
This makes more sense and also removes the dependency for `string.h`.
2021-09-21 18:55:53 +02:00
47bd5e45f7 Create a function to move the cursor
Create a function (`lcs_move_cursor()`) to move the cursor in order to
reduce code repetition.
2021-09-14 23:54:19 +02:00
c53ccba034 Use symbol table for symbol parsing
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.
2021-09-14 00:25:43 +02:00
f9f131a6da Add static and const declarations and spaces
Add `static` keyword for consistency and `const` where it makes
sense. Also add spaces when declaring enums.
2021-09-12 15:37:01 +02:00
a5d88e879c Furbish code and comment
Remove unneeded brackets and improve comment.
2021-09-12 01:05:33 +02:00
14dd301657 Fix kerning in setup screen for backlight
This fixes the inverting of the first two pixel on the setup screen
when the backlight setting is selected.
2021-09-12 01:04:10 +02:00
d75d230541 Implement contrast and backlight handling
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.
2021-09-12 00:59:22 +02:00
05c9888a75 Store setup settings in eeprom
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.
2021-09-11 15:44:11 +02:00
acf4bc5754 Editable setup settings
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.
2021-09-11 15:36:02 +02:00
0acd0bd98b Iterable setup settings with encoder
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.
2021-09-11 11:13:15 +02:00
e2d30d7050 Fix indents and switch syntax
Fix indentions in `spi_byte()` and add missing space after `switch`
keywords.
2021-09-11 00:21:01 +02:00
6eb515e2d4 Display digits and integers
Display digits and integers, for the later displaying leading zeroes
is supported via parameter. Demo integers are displayed in the setup
screen.
2021-09-11 00:19:59 +02:00
19c0f141a4 Add setup screen
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.
2021-09-09 20:50:52 +02:00
9c496e765d Refactor state handling
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.
2021-09-09 20:40:50 +02:00
6746d34b2f Handle switch input
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.
2021-09-09 20:19:40 +02:00
e099b0f94a Move clock speed setting into makefile
Move clock speed setting into makefile.
2021-09-09 20:01:23 +02:00
727f89eeb0 Basic state handling
Prepare for handling of different screens and their states and add a
minimal menu.
2021-09-08 14:53:29 +02:00
cd2c6cf196 Improve splash screen
The splash screen blob is now splitted in to parts in order to reduce
zero valued memory space.
2021-09-08 14:04:07 +02:00
86ec90b202 Minimal encoder input handling
It is now possible to act on the encoders input. No effort regarding
debouncing and dechattering has been done yet.
2021-09-08 13:58:24 +02:00
3b2bf1d967 Remove unnecessary memory for spash screen
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.
2021-03-01 16:45:03 +01:00
d14f1c33e0 Draw splash screen
Hail sacred chao, kallisti!
2021-02-27 15:17:01 +01:00
7f7d7b628a Interact with the display
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.
2021-02-27 02:26:57 +01:00
0065fb630f Generate a PWM signal for the display
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%.
2021-02-19 15:46:36 +01:00