LevelMeter-Display  2.0
An ultrasonic Level Meter for Stormwater Cisterns
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Display.h
Go to the documentation of this file.
1 // Display.h
2 
3 #ifndef DISPLAY_H_
4 #define DISPLAY_H_
5 
6 #include <stdbool.h>
7 #include <avr/io.h>
8 #include "lcd.h"
9 
10 #define WITH_UPDATE
11 
12 #define SIGNAL_PORT PORTA
13 #define SIGNAL_1_MASK 0b00000100
14 #define SIGNAL_2_MASK 0b00001000
15 
16 typedef double LITERS_T;
17 
30 typedef struct
31 {
37  double litersPerCent;
38  uint8_t temp;
39  int32_t liters_temp;
40  uint8_t nliters_temp;
45 // char dcf77Char; ///< Character to appear on position "DCF77 in sync"
47 
48 extern uint16_t pulseTimeInt;
49 extern uint8_t pulseTimeMult;
50 extern uint8_t deadTime;
51 extern signed char tempSemi;
52 extern uint8_t tempRaw;
53 extern volatile char cmdline[81];
54 
55 extern volatile uint8_t tickCnt,secCnt,minCnt,hrCnt;
56 
58 typedef enum
59 {
63 } RTCAdj_t;
64 extern const char *RTCAdjTxt[];
65 extern volatile RTCAdj_t RTCAdj;
66 
68 typedef enum
69 {
74 } showScreen_t;
75 
76 #define SCREENABSPAGE_VERSION 128
77 
78 #define ADCVoltsPerLSB (2.56/1024)
79 #define dividerP3 (4.7/(4.7+8.2))
80 #define dividerP5 (4.7/(4.7+8.2))
81 #define dividerUnreg (4.7/(4.7+68))
82 #define dividerSWUnreg (4.7/(4.7+68))
83 
84 extern uint8_t bootLdPage[];
85 extern uint16_t bootLdAdr;
86 extern volatile uint8_t tFlags;
87 static const uint8_t TFLAG_SEC=1;
88 static const uint8_t TFLAG_MIN=2;
89 static const uint8_t TFLAG_HOUR=4;
90 static const uint8_t TFLAG_DAY=8;
91 
92 
93 extern volatile uint8_t cFlags;
94 static const uint8_t CFLAG_TIMERECEIVED=1;
95 static const uint8_t CFLAG_TEMPRECEIVED=2;
96 static const uint8_t CFLAG_PARITYERROR=4;
97 static const uint8_t CFLAG_CHECKSUMERROR=8;
98 static const uint8_t CFLAG_CMDRECEIVED=16;
99 static const uint8_t CFLAG_BYTERECEIVED=32;
100 
101 extern volatile uint8_t blFlags;
102 static const uint8_t BOOTLDHELLO=1;
103 static const uint8_t BOOTLDDATA=2;
104 static const uint8_t BOOTLDOK=4;
105 static const uint8_t BOOTLDERROR=8;
106 static const uint8_t BOOTLDPROTECTED=16;
107 
108 extern volatile uint8_t dFlags;
109 static const uint8_t DFLAG_DCF77=1;
110 static const uint8_t DFLAG_SENSOR=2;
111 
113 typedef enum
114 {
118 } displayType_t;
122 typedef struct {
123  uint8_t width;
124  uint8_t nLines;
125  uint8_t startLine[LCD_MAX_LINES];
127 extern const displayMetrics_T displayMetrics[];
128 
131 inline static void SensorPowerOn(void)
132 {
133  PORTA |= 0x01;
134 }
135 
138 inline static void SensorPowerOff(void)
139 {
140  PORTA &= ~0x01;
141 }
142 
145 inline static void BluetoothPowerOn(void)
146 {
147  PORTD |= 0xC0;
148 }
149 
152 inline static void BluetoothPowerOff(void)
153 {
154  PORTD &= ~0x80;
155 }
156 
159 inline static void Sig1ON (void)
160 {
162 }
163 
166 inline static void Sig1OFF (void)
167 {
169 }
170 
173 inline static void Sig2ON (void)
174 {
176 }
177 
180 inline static void Sig2OFF (void)
181 {
183 }
184 
188 inline static bool GetSig1(void)
189 {
190  return !(SIGNAL_PORT&SIGNAL_1_MASK);
191 }
192 
196 inline static bool GetSig2(void)
197 {
198  return !(SIGNAL_PORT&SIGNAL_2_MASK);
199 }
200 
201 typedef uint8_t delay_t;
202 
203 extern void delay10ms(delay_t delay10ms);
204 
205 extern void SetAnalogPerCent(double perCent);
206 
207 #endif