LevelMeter-Display  2.0
An ultrasonic Level Meter for Stormwater Cisterns
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Functions | Variables
Key.h File Reference

Go to the source code of this file.

Functions

static bool GetKeyState (void)
 
static void KeyInt (void)
 Must be called from the 100Hz-Timer Interrupt. More...
 

Variables

static const uint8_t KFLAG_KEYPRESSED =1
 The key has been pressed. More...
 
static const uint8_t KFLAG_KEYPRESSEDLONG =8
 The key has been pressed for more than 2 seconds. More...
 
static const uint8_t KFLAG_KEYPRESSEDSHORT =4
 The key has been pressed and released within 2 seconds. More...
 
static const uint8_t KFLAG_KEYRELEASED =2
 The key has been released. More...
 
volatile uint8_t kflags
 Flags set by KeyInt() for evaluation by the main loop. More...
 

Function Documentation

static bool GetKeyState ( void  )
inlinestatic
static void KeyInt ( void  )
inlinestatic

Must be called from the 100Hz-Timer Interrupt.

kflags are set in the following order:
KEY_PRESSED as soon as a key press is detected
KEY_PRESSEDSHORT the key has been released but has not been pressed for at least 2.5 seconds
KEY_PRESSEDLONG the Key is pressed for 2.5 seconds or more (but not necessarily released yet).
Only the KEY_PRESSED event is immediate. The others are set after the key has been released or after 2.5 seconds.
The times have a granularity of 100ms (i.e. KEY_PRESSED may be detected 99ms after the key has really been pressed and the 2.5 seconds may have been 2.50 or 2.599 seconds) but that's absolutely o.k. for a UI.

Variable Documentation

const uint8_t KFLAG_KEYPRESSED =1
static

The key has been pressed.

const uint8_t KFLAG_KEYPRESSEDLONG =8
static

The key has been pressed for more than 2 seconds.

const uint8_t KFLAG_KEYPRESSEDSHORT =4
static

The key has been pressed and released within 2 seconds.

const uint8_t KFLAG_KEYRELEASED =2
static

The key has been released.

volatile uint8_t kflags

Flags set by KeyInt() for evaluation by the main loop.