|
9 | 9 | #include <stdint.h> |
10 | 10 | #include <stdio.h> |
11 | 11 | #include <string.h> |
| 12 | +#include <stdlib.h> |
| 13 | +#include <math.h> |
12 | 14 |
|
13 | 15 | #include "DispAdapter.h" |
14 | 16 | #include "config.h" |
|
21 | 23 |
|
22 | 24 |
|
23 | 25 |
|
24 | | -MainscreenType MainScreen = { |
25 | | - .Value.x = X_LEFT_EDGE, |
26 | | - .Value.y = Y_VALUES_START, |
27 | | - .Volume.x = X_LEFT_EDGE, |
28 | | - .Volume.y = Y_VALUES_START + FONT2_H * 1, |
29 | | - .Corr.x = X_LEFT_EDGE, |
30 | | - .Corr.y = Y_VALUES_START + FONT2_H * 2, |
31 | | - .Temp.x = X_LEFT_EDGE, |
32 | | - .Temp.y = Y_VALUES_START + FONT2_H * 3, |
33 | | - .Press.x = X_LEFT_EDGE, |
34 | | - .Press.y = Y_VALUES_START + FONT2_H * 4, |
35 | | -}; |
| 26 | + |
36 | 27 |
|
37 | 28 |
|
38 | 29 | void lcd_init(void){ |
@@ -141,61 +132,38 @@ void paint_info_line(char * line, _Bool update){ |
141 | 132 | } |
142 | 133 |
|
143 | 134 |
|
144 | | -void paint_value(char* text,uint8_t update,char* unit){ |
145 | | - if (update) |
146 | | - { |
147 | | - lcd_Print(" ",MainScreen.Value.x + DESCRUPTOR_LEN * FONT2_W,MainScreen.Value.y,2,1,1,FGC,BGC); |
148 | | - } |
149 | | - lcd_Print(text,MainScreen.Value.x + DESCRUPTOR_LEN * FONT2_W,MainScreen.Value.y,2,1,1,FGC,BGC); |
150 | | - |
151 | | - lcd_Print(unit,HALF_SPACE_WIDTH_FONT_2 + MainScreen.Value.x + (DESCRUPTOR_LEN+strlen(text)) * FONT2_W, MainScreen.Value.y,2,1,1,FGC,BGC); |
152 | | -} |
153 | | -void paint_volume(char* text,uint8_t update,char* unit){ |
154 | | - if (update) |
155 | | - { |
156 | | - lcd_Print(" ",MainScreen.Volume.x + DESCRUPTOR_LEN * FONT2_W,MainScreen.Volume.y,2,1,1,FGC,BGC); |
157 | | - } |
158 | | - lcd_Print(text,MainScreen.Volume.x + DESCRUPTOR_LEN * FONT2_W,MainScreen.Volume.y,2,1,1,FGC,BGC); |
159 | | - |
160 | | - lcd_Print(unit,HALF_SPACE_WIDTH_FONT_2 + MainScreen.Volume.x + (DESCRUPTOR_LEN+strlen(text)) * FONT2_W, MainScreen.Volume.y,2,1,1,FGC,BGC); |
161 | | - |
162 | | -} |
163 | 135 |
|
164 | | -void paint_corr(char* text,uint8_t update,char* unit){ |
165 | | - if (update) |
166 | | - { |
167 | | - lcd_Print(" ",MainScreen.Corr.x + DESCRUPTOR_LEN * FONT2_W,MainScreen.Corr.y,2,1,1,FGC,BGC); |
168 | | - } |
169 | | - lcd_Print(text,MainScreen.Corr.x + DESCRUPTOR_LEN * FONT2_W,MainScreen.Corr.y,2,1,1,FGC,BGC); |
170 | | - |
171 | | - lcd_Print(unit,HALF_SPACE_WIDTH_FONT_2 + MainScreen.Corr.x + (DESCRUPTOR_LEN+strlen(text)) * FONT2_W, MainScreen.Corr.y,2,1,1,FGC,BGC); |
172 | | -} |
173 | | -void paint_temp(char* text,uint8_t update,char* unit){ |
174 | | - if (update) |
175 | | - { |
176 | | - lcd_Print(" ",MainScreen.Temp.x + DESCRUPTOR_LEN * FONT2_W,MainScreen.Temp.y,2,1,1,FGC,BGC); |
177 | | - } |
178 | | - lcd_Print(text,MainScreen.Temp.x + DESCRUPTOR_LEN * FONT2_W,MainScreen.Temp.y,2,1,1,FGC,BGC); |
179 | | - |
180 | | - lcd_Print(unit,HALF_SPACE_WIDTH_FONT_2 + MainScreen.Temp.x + (DESCRUPTOR_LEN+strlen(text)) * FONT2_W, MainScreen.Temp.y,2,1,1,FGC,BGC); |
181 | | -} |
182 | 136 |
|
183 | | -void paint_press(char* text,uint8_t update,char* unit){ |
184 | | - if (update) |
185 | | - { |
186 | | - lcd_Print(" ",MainScreen.Press.x + DESCRUPTOR_LEN * FONT2_W,MainScreen.Press.y,2,1,1,FGC,BGC); |
187 | | - } |
188 | | - lcd_Print(text,MainScreen.Press.x + DESCRUPTOR_LEN * FONT2_W,MainScreen.Press.y,2,1,1,FGC,BGC); |
189 | 137 |
|
190 | | - lcd_Print(unit,HALF_SPACE_WIDTH_FONT_2 + MainScreen.Press.x + (DESCRUPTOR_LEN+strlen(text)) * FONT2_W, MainScreen.Press.y,2,1,1,FGC,BGC); |
| 138 | + |
| 139 | +void paint_string_row(char *text,ROW_NAME row,uint8_t update,char* unit,uint16_t color){ |
| 140 | + if (update) |
| 141 | + { |
| 142 | + lcd_Print(" ",X_LEFT_EDGE + DESCRUPTOR_LEN * FONT2_W,Y_VALUES_START + FONT2_H * row,2,1,1,color,BGC); |
| 143 | + } |
| 144 | + lcd_Print(text,X_LEFT_EDGE + DESCRUPTOR_LEN * FONT2_W,Y_VALUES_START + FONT2_H * row,2,1,1,color,BGC); |
| 145 | + |
| 146 | + lcd_Print(unit,HALF_SPACE_WIDTH_FONT_2 + X_LEFT_EDGE + (DESCRUPTOR_LEN+strlen(text)) * FONT2_W, Y_VALUES_START + FONT2_H * row,2,1,1,color,BGC); |
191 | 147 | } |
192 | 148 |
|
193 | 149 | void paint_Main(void){ |
194 | | - lcd_Print("Val:",MainScreen.Value.x ,MainScreen.Value.y,2,1,1,FGC,BGC); |
195 | | - lcd_Print("Vol:",MainScreen.Volume.x ,MainScreen.Volume.y,2,1,1,FGC,BGC); |
196 | | - lcd_Print("Cor:",MainScreen.Corr.x ,MainScreen.Corr.y,2,1,1,FGC,BGC); |
197 | | - lcd_Print("Tmp:",MainScreen.Temp.x ,MainScreen.Temp.y,2,1,1,FGC,BGC); |
198 | | - lcd_Print("Prs:",MainScreen.Press.x ,MainScreen.Press.y,2,1,1,FGC,BGC); |
| 150 | + lcd_Print("Val:",X_LEFT_EDGE ,Y_VALUES_START + FONT2_H * VALUE ,2,1,1,FGC,BGC); |
| 151 | + lcd_Print("Vol:",X_LEFT_EDGE ,Y_VALUES_START + FONT2_H * VOLUME ,2,1,1,FGC,BGC); |
| 152 | + lcd_Print("Cor:",X_LEFT_EDGE ,Y_VALUES_START + FONT2_H * CORRVOL,2,1,1,FGC,BGC); |
| 153 | + lcd_Print("Tmp:",X_LEFT_EDGE ,Y_VALUES_START + FONT2_H * TEMP ,2,1,1,FGC,BGC); |
| 154 | + lcd_Print("Prs:",X_LEFT_EDGE ,Y_VALUES_START + FONT2_H * PRESS ,2,1,1,FGC,BGC); |
199 | 155 | } |
200 | 156 |
|
201 | 157 |
|
| 158 | + |
| 159 | +void paint_Value(uint64_t val,ROW_NAME row,uint8_t precision,char* unit){ |
| 160 | + char numberbuffer[30]; |
| 161 | + dtostrf(((double)val)/pow(10,precision),3,precision,numberbuffer); |
| 162 | + |
| 163 | + paint_string_row(numberbuffer,row,1,unit,FGC); |
| 164 | +} |
| 165 | + |
| 166 | +void paint_Error(char* text, ROW_NAME row){ |
| 167 | + paint_string_row(text,row,1,"",red); |
| 168 | +} |
| 169 | + |
0 commit comments