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

Go to the source code of this file.

Data Structures

struct  displayMetrics_T
 Parameters for each of the possible Displays. More...
 
struct  displayValues_t
 Holds all values used for Display Purposes. More...
 

Macros

#define ADCVoltsPerLSB   (2.56/1024)
 Voltage step for one LSB of the AD converter. More...
 
#define dividerP3   (4.7/(4.7+8.2))
 Resistor divider for P3. Gives 7.03V FSR or 6.86mV/LSB. More...
 
#define dividerP5   (4.7/(4.7+8.2))
 Resistor divider for P5. Gives 7.03V FSR or 6.86mV/LSB. More...
 
#define dividerSWUnreg   (4.7/(4.7+68))
 Resistor divider for SWUnreg. Gives 39.6V FSR or 38.7mV/LSB. More...
 
#define dividerUnreg   (4.7/(4.7+68))
 Resistor divider for Unreg. Gives 39.6V FSR or 38.7mV/LSB. More...
 
#define SCREENABSPAGE_VERSION   128
 Display Version Screen at startup. More...
 
#define SIGNAL_1_MASK   0b00000100
 
#define SIGNAL_2_MASK   0b00001000
 
#define SIGNAL_PORT   PORTA
 
#define WITH_UPDATE
 Compile with Sensor Update Function. More...
 

Typedefs

typedef uint8_t delay_t
 
typedef double LITERS_T
 Remember that liters may go negative. More...
 

Enumerations

enum  displayType_t { DISPLAY_2x16, DISPLAY_4x20, DISPLAY_ANALOG }
 Constants for Display Type. More...
 
enum  RTCAdj_t { RTC_NORMAL, RTC_FASTER, RTC_SLOWER }
 Current speed of the RTC (Real Time Clock) More...
 
enum  showScreen_t { SCREENSTEPAUTO, SCREENSTEPMANU, SCREENREFRESH, SCREENABSPAGE }
 Command for ShowScreen() More...
 

Functions

static void BluetoothPowerOff (void)
 Switches the Bluetooth Power off. More...
 
static void BluetoothPowerOn (void)
 Switches the Bluetooth Power on. More...
 
void delay10ms (delay_t delay10ms)
 Delay for a multiple of 10ms. More...
 
static bool GetSig1 (void)
 Gets State of Optocoupler 1 True means Optocoupler is ON. More...
 
static bool GetSig2 (void)
 Gets State of Optocoupler 2 True means Optocoupler is ON. More...
 
static void SensorPowerOff (void)
 Switches the Sensor Power off. More...
 
static void SensorPowerOn (void)
 Switches the Sensor Power on. More...
 
void SetAnalogPerCent (double perCent)
 Sets the analog Instrument display. More...
 
static void Sig1OFF (void)
 Switches Signal Output Optocoupler 1 to OFF. More...
 
static void Sig1ON (void)
 Switches Signal Output Optocoupler 1 to ON. More...
 
static void Sig2OFF (void)
 Switches Signal Output Optocoupler 2 to OFF. More...
 
static void Sig2ON (void)
 Switches Signal Output Optocoupler 2 to ON. More...
 

Variables

volatile uint8_t blFlags
 Boot Loader Communication Flags. More...
 
uint16_t bootLdAdr
 The address of the page. More...
 
static const uint8_t BOOTLDDATA =2
 Boot Loader Data received ("=") More...
 
static const uint8_t BOOTLDERROR =8
 Boot Loader Error received ("-") More...
 
static const uint8_t BOOTLDHELLO =1
 Boot Loader Hello received ("*") More...
 
static const uint8_t BOOTLDOK =4
 Boot Loader Data received ("+") More...
 
uint8_t bootLdPage []
 Holds the data for boot loader write/read. More...
 
static const uint8_t BOOTLDPROTECTED =16
 Boot Loader Protected Area received ("P") More...
 
static const uint8_t CFLAG_BYTERECEIVED =32
 Received a Byte from the host. More...
 
static const uint8_t CFLAG_CHECKSUMERROR =8
 Checksum Error in received Telegram. More...
 
static const uint8_t CFLAG_CMDRECEIVED =16
 Received the terminating CR of a Command. More...
 
static const uint8_t CFLAG_PARITYERROR =4
 Parity Error in received Byte. More...
 
static const uint8_t CFLAG_TEMPRECEIVED =2
 Received the current Sensor Temperature. More...
 
static const uint8_t CFLAG_TIMERECEIVED =1
 Received a Travel Time from the Sensor. More...
 
volatile uint8_t cFlags
 Flags set by Serial Communication with the Sensor. More...
 
volatile char cmdline [81]
 Ready to hold 80 chars plus terminating 0. More...
 
uint8_t deadTime
 Received dead time value from the sensor. More...
 
static const uint8_t DFLAG_DCF77 =1
 Gives information about DCF77 and RTC. More...
 
static const uint8_t DFLAG_SENSOR =2
 Gives information about Sensor Communication. More...
 
volatile uint8_t dFlags
 Flags Controlling Debug Output. More...
 
const displayMetrics_T displayMetrics []
 Metrics for each of the possible displays. More...
 
displayType_t displayType
 
volatile uint8_t hrCnt
 Hours of the RTC. More...
 
volatile uint8_t minCnt
 Minutes of the RTC. More...
 
uint16_t pulseTimeInt
 Traveling time of the last pulse in timer1-clocks of the sensor CPU. More...
 
uint8_t pulseTimeMult
 1 or 8 clocks from sensor timer1 prescaler More...
 
volatile RTCAdj_t RTCAdj
 Soft Adjustment of the RTC (+-1%) More...
 
const char * RTCAdjTxt []
 Human readable interpretation of RTCAdj. More...
 
volatile uint8_t secCnt
 Seconds of the RTC. More...
 
uint8_t tempRaw
 Raw value from the ADC. More...
 
signed char tempSemi
 Temperature in 0.5°C. More...
 
static const uint8_t TFLAG_DAY =8
 Is set every Day at Midnight. More...
 
static const uint8_t TFLAG_HOUR =4
 Is set once per Hour at Minute 0. More...
 
static const uint8_t TFLAG_MIN =2
 Is set once per Minute at Second 0. More...
 
static const uint8_t TFLAG_SEC =1
 Is set once per Second. More...
 
volatile uint8_t tFlags
 Flags set by Timer Interrupt to signal Main Loop. More...
 
volatile uint8_t tickCnt
 counter for timer0 interrupts More...
 

Macro Definition Documentation

#define ADCVoltsPerLSB   (2.56/1024)

Voltage step for one LSB of the AD converter.

#define dividerP3   (4.7/(4.7+8.2))

Resistor divider for P3. Gives 7.03V FSR or 6.86mV/LSB.

#define dividerP5   (4.7/(4.7+8.2))

Resistor divider for P5. Gives 7.03V FSR or 6.86mV/LSB.

#define dividerSWUnreg   (4.7/(4.7+68))

Resistor divider for SWUnreg. Gives 39.6V FSR or 38.7mV/LSB.

#define dividerUnreg   (4.7/(4.7+68))

Resistor divider for Unreg. Gives 39.6V FSR or 38.7mV/LSB.

#define SCREENABSPAGE_VERSION   128

Display Version Screen at startup.

#define SIGNAL_1_MASK   0b00000100
#define SIGNAL_2_MASK   0b00001000
#define SIGNAL_PORT   PORTA
#define WITH_UPDATE

Compile with Sensor Update Function.

Typedef Documentation

typedef uint8_t delay_t
typedef double LITERS_T

Remember that liters may go negative.

Enumeration Type Documentation

Constants for Display Type.

Enumerator
DISPLAY_2x16 

Display is a Winstar WH1602B3 or equivalent.

DISPLAY_4x20 

Display is a Winstar WH2004A or equivalent.

DISPLAY_ANALOG 

We have no LCD at all, only analog output.

enum RTCAdj_t

Current speed of the RTC (Real Time Clock)

Enumerator
RTC_NORMAL 

RTC is running at normal speed (realtime)

RTC_FASTER 

RTC is running faster by 1%.

RTC_SLOWER 

RTC is running slower by 1%.

Command for ShowScreen()

Enumerator
SCREENSTEPAUTO 

Advance to the next page of the frequently used.

SCREENSTEPMANU 

Advance to the next of all available pages.

SCREENREFRESH 

Do not change the page, just refresh the current one.

SCREENABSPAGE 

Show a special page. Currently only used for the init-screen.

Function Documentation

static void BluetoothPowerOff ( void  )
inlinestatic

Switches the Bluetooth Power off.

static void BluetoothPowerOn ( void  )
inlinestatic

Switches the Bluetooth Power on.

void delay10ms ( delay_t  delay10ms)

Delay for a multiple of 10ms.

This function allows delays up to the range of delay_t controlled by the timer interrupt.
delay_t should be an unsigned integer type.
delaycnt must be decremented in the 100Hz-Interrupt.
This function of course takes care of the Watchdog and puts the CPU into sleep mode until the time expires.

Parameters
delay10msDelay in multiple of 10ms
Note
This function is not reentrant since there is only one delaycnt! The timer interrupt has to be enabled when calling this function else it will result in an infinite loop. Not even the watchdog would take you out!
static bool GetSig1 ( void  )
inlinestatic

Gets State of Optocoupler 1 True means Optocoupler is ON.

static bool GetSig2 ( void  )
inlinestatic

Gets State of Optocoupler 2 True means Optocoupler is ON.

static void SensorPowerOff ( void  )
inlinestatic

Switches the Sensor Power off.

static void SensorPowerOn ( void  )
inlinestatic

Switches the Sensor Power on.

void SetAnalogPerCent ( double  perCent)

Sets the analog Instrument display.

Parameters
perCentThe value in a range from 0.0 to 100.0. Exceeding values will be trimmed correctly.
static void Sig1OFF ( void  )
inlinestatic

Switches Signal Output Optocoupler 1 to OFF.

static void Sig1ON ( void  )
inlinestatic

Switches Signal Output Optocoupler 1 to ON.

static void Sig2OFF ( void  )
inlinestatic

Switches Signal Output Optocoupler 2 to OFF.

static void Sig2ON ( void  )
inlinestatic

Switches Signal Output Optocoupler 2 to ON.

Variable Documentation

volatile uint8_t blFlags

Boot Loader Communication Flags.

uint16_t bootLdAdr

The address of the page.

const uint8_t BOOTLDDATA =2
static

Boot Loader Data received ("=")

const uint8_t BOOTLDERROR =8
static

Boot Loader Error received ("-")

const uint8_t BOOTLDHELLO =1
static

Boot Loader Hello received ("*")

const uint8_t BOOTLDOK =4
static

Boot Loader Data received ("+")

uint8_t bootLdPage[]

Holds the data for boot loader write/read.

const uint8_t BOOTLDPROTECTED =16
static

Boot Loader Protected Area received ("P")

const uint8_t CFLAG_BYTERECEIVED =32
static

Received a Byte from the host.

const uint8_t CFLAG_CHECKSUMERROR =8
static

Checksum Error in received Telegram.

const uint8_t CFLAG_CMDRECEIVED =16
static

Received the terminating CR of a Command.

const uint8_t CFLAG_PARITYERROR =4
static

Parity Error in received Byte.

const uint8_t CFLAG_TEMPRECEIVED =2
static

Received the current Sensor Temperature.

const uint8_t CFLAG_TIMERECEIVED =1
static

Received a Travel Time from the Sensor.

volatile uint8_t cFlags

Flags set by Serial Communication with the Sensor.

The flags are set by serial interrupt and must be cleared by the main loop

volatile char cmdline[81]

Ready to hold 80 chars plus terminating 0.

uint8_t deadTime

Received dead time value from the sensor.

const uint8_t DFLAG_DCF77 =1
static

Gives information about DCF77 and RTC.

const uint8_t DFLAG_SENSOR =2
static

Gives information about Sensor Communication.

volatile uint8_t dFlags

Flags Controlling Debug Output.

const displayMetrics_T displayMetrics[]

Metrics for each of the possible displays.

displayType_t displayType
volatile uint8_t hrCnt

Hours of the RTC.

volatile uint8_t minCnt

Minutes of the RTC.

uint16_t pulseTimeInt

Traveling time of the last pulse in timer1-clocks of the sensor CPU.

uint8_t pulseTimeMult

1 or 8 clocks from sensor timer1 prescaler

volatile RTCAdj_t RTCAdj

Soft Adjustment of the RTC (+-1%)

const char* RTCAdjTxt[]

Human readable interpretation of RTCAdj.

volatile uint8_t secCnt

Seconds of the RTC.

uint8_t tempRaw

Raw value from the ADC.

signed char tempSemi

Temperature in 0.5°C.

const uint8_t TFLAG_DAY =8
static

Is set every Day at Midnight.

const uint8_t TFLAG_HOUR =4
static

Is set once per Hour at Minute 0.

const uint8_t TFLAG_MIN =2
static

Is set once per Minute at Second 0.

const uint8_t TFLAG_SEC =1
static

Is set once per Second.

volatile uint8_t tFlags

Flags set by Timer Interrupt to signal Main Loop.

The flags are set each second, minute, hour or day respectively by timer interrupt. The flags must be cleared by the main loop.

volatile uint8_t tickCnt

counter for timer0 interrupts