The Seven Segment Display and its TM1637 controller
Line: 65 to 65
Scan the keyboard in intervals of 100 ms and print the key that is pressed. This will result in printing the key as long as it is pressed.
Exercise 2:
Changed:
< <
Wait until the key is released and only the print the key. This will result of a single key value for each button press.
> >
Wait until the key is released and only then print the key. This will result in a single key value for each button press.
Exercise3:
Changed:
< <
Read the keypad in an interrupt driven routine. Keep the pressed keys in a circular buffer. Add the following methods:
available: returns true if at least 1 character is in the buffer
read: read a character and remove it from the circular buffer
status: return an overrun error if the circular buffer is full and a pressed key has been missed
flush: clear the circular buffer
Comments
> >
Write a CircularBuffer class in which you can keep key presses. This will allow to read the keypad completely asynchronously (see exercise 4).
The CircularBuffer class should implement a buffer of 32 elements with the following methods:
write: add an element to the end of the buffer. Check if the buffer is full before writing and set the overrun flag if this is the case
available: check if new data have arrived in the buffer
read: read data from the buffer if it is not empty
is_full: tells if the buffer is full
overrun: tells if an overrun error has occurred in the past
clr_overrun: clear the overrun flag
flush: clears the buffer
Write a test script exercising the CircularBuffer class.
Exercise 4:
Read the keypad in an interrupt driven routine. Keep the pressed keys in the circular buffer written in exercise 3.
Write a test program that starts the interrupt driven keypad driver and reads data from the circular buffer in rather large intervals (e.g. every 5s or 10s)