Skip to content

Commit 2f24e4d

Browse files
author
Wegmann Peter
committed
works for gcm disp
1 parent 9018390 commit 2f24e4d

File tree

5 files changed

+80
-41
lines changed

5 files changed

+80
-41
lines changed

DispAdapter.c

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,16 @@
2121
#include "disp/gcm_old_lcd_driver.h"
2222
#endif
2323

24+
#ifdef ili9341
2425
#include "disp/display_lib.h"
2526
#include "disp/ili9341_driver.h"
27+
#include "StringPixelCoordTable_ili9341.h"
28+
#endif
2629

2730

28-
#include "StringPixelCoordTable_ili9341.h"
31+
32+
#ifdef ili9341
33+
2934

3035
InitScreenType InitScreen_ili = {
3136
.ForeColor = ERR,
@@ -37,7 +42,7 @@ InitScreenType InitScreen_ili = {
3742
.XScale = 1,
3843
.YScale = 1
3944
};
40-
45+
#endif
4146

4247

4348
void lcd_init(void){
@@ -77,8 +82,8 @@ void lcd_Cls(unsigned int color){
7782
#endif
7883

7984
#ifdef GCM_old_disp
80-
LCD_Clear();
81-
#endif
85+
LCD_Clear();
86+
#endif
8287
}
8388

8489

@@ -154,40 +159,50 @@ void paint_info_line(char * line, _Bool update){
154159

155160

156161

162+
157163
void paint_string_row(char *text,ROW_NAME row,uint8_t update,char* unit,uint16_t color){
158-
if (update)
159-
{
160-
lcd_Print(" ",X_LEFT_EDGE + DESCRUPTOR_LEN * FONT2_W,Y_VALUES_START + FONT2_H * row,2,1,1,color,BGC);
161-
}
162-
163-
strcat(text," ");
164-
165-
lcd_Print(text,X_LEFT_EDGE + DESCRUPTOR_LEN * FONT2_W,Y_VALUES_START + FONT2_H * row,2,1,1,color,BGC);
164+
#ifdef ili9341
165+
if (update)
166+
{
167+
lcd_Print(" ",X_LEFT_EDGE + DESCRUPTOR_LEN * FONT2_W,Y_VALUES_START + FONT2_H * row,2,1,1,color,BGC);
168+
}
169+
170+
lcd_Print(text,X_LEFT_EDGE + DESCRUPTOR_LEN * FONT2_W,Y_VALUES_START + FONT2_H * row,2,1,1,color,BGC);
171+
172+
lcd_Print(" ",X_LEFT_EDGE + DESCRUPTOR_LEN * FONT2_W + strlen(text) * FONT2_W,Y_VALUES_START + FONT2_H * row,2,1,1,color,BGC);
166173

167-
lcd_Print(unit,HALF_SPACE_WIDTH_FONT_2 + X_LEFT_EDGE + (DESCRUPTOR_LEN+strlen(text)-1) * FONT2_W, Y_VALUES_START + FONT2_H * row,2,1,1,color,BGC);
174+
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);
175+
#endif
168176
}
169177

170178
void paint_Main(void){
179+
#ifdef ili9341
171180
lcd_Print("Inf:",X_LEFT_EDGE ,Y_VALUES_START + FONT2_H * INFO ,2,1,1,FGC,BGC);
172181
lcd_Print("Val:",X_LEFT_EDGE ,Y_VALUES_START + FONT2_H * VALUE ,2,1,1,FGC,BGC);
173182
lcd_Print("Vol:",X_LEFT_EDGE ,Y_VALUES_START + FONT2_H * VOLUME ,2,1,1,FGC,BGC);
174183
lcd_Print("Cor:",X_LEFT_EDGE ,Y_VALUES_START + FONT2_H * CORRVOL,2,1,1,FGC,BGC);
175184
lcd_Print("Tmp:",X_LEFT_EDGE ,Y_VALUES_START + FONT2_H * TEMP ,2,1,1,FGC,BGC);
176185
lcd_Print("Prs:",X_LEFT_EDGE ,Y_VALUES_START + FONT2_H * PRESS ,2,1,1,FGC,BGC);
177186
lcd_Print("Con:",X_LEFT_EDGE ,Y_VALUES_START + FONT2_H * CONN ,2,1,1,FGC,BGC);
178-
}
187+
188+
#endif
189+
}
179190

180191

181192

182193
void paint_Value(uint64_t val,ROW_NAME row,uint8_t precision, uint8_t min_width,char* unit){
194+
#ifdef ili9341
183195
char numberbuffer[30];
184196
dtostrf(((double)val)/pow(10,precision),min_width,precision,numberbuffer);
185197

186198
paint_string_row(numberbuffer,row,0,unit,white);
199+
#endif
187200
}
188201

189202
void paint_Error(char* text, ROW_NAME row){
203+
#ifdef ili9341
190204
paint_string_row(text,row,1,"",red);
205+
#endif
191206
}
192207

193208
//=========================================================================
@@ -198,6 +213,8 @@ void paint_Error(char* text, ROW_NAME row){
198213
// if FirstLine is 1 clear page and start with first line
199214
void InitScreen_AddLine_ili(const char* Text, const char FirstLine)
200215
{
216+
#ifdef ili9341
217+
201218
if (FirstLine == 1)
202219
{
203220
InitScreen_ili.NextLine = 1;
@@ -219,21 +236,28 @@ void InitScreen_AddLine_ili(const char* Text, const char FirstLine)
219236
_delay_ms(1000); // wait until next page is displayed
220237
}
221238
_delay_ms(500);
239+
#endif // ili9341
222240

223241
}
224242

225243
void setInitScreen_ili(uint16_t fore, uint16_t back, uint8_t nextLine, uint8_t FontNr, uint8_t XScale, uint8_t YScale){
244+
#ifdef ili9341
245+
226246
InitScreen_ili.ForeColor = fore;
227247
InitScreen_ili.BackColor = back;
228248
InitScreen_ili.NextLine = nextLine;
229249
InitScreen_ili.FontNr = FontNr;
230250
InitScreen_ili.XScale = XScale;
231251
InitScreen_ili.YScale = YScale;
252+
#endif
232253
}
233254

234255

235256
void paint_info_line_ili(char *line, _Bool update)
236257
{
258+
#ifdef ili9341
259+
237260
if (!update) LCD_Print(" ", X_PIL_2, Y_PIL_90, 1, 1, 1, FGC, BGC); // clears line (not necessary if in update mode)
238261
LCD_Print(line, X_PIL_2, Y_PIL_90, 1, 1, 1, ERR, BGC);
239-
}
262+
#endif
263+
}

Gascounter_main.c

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include "module_globals.h"
5252
#include "adwandler.h"
5353
#include "assert.h"
54+
#include "timerUtil.h"
5455

5556

5657

@@ -102,7 +103,7 @@ deltaType delta = {.Volume_since_last_send = 0,.Pressure_since_last_send = 0,.t_
102103
*
103104
* Timestamps and Pressurevalues for last send/display-reset/ping - Event
104105
*/
105-
lastType last= {.Pressure_on_send = 0,.time_send = 0,.time_display_reset = 0,.time_ping = 0, .time_Pressure_Temp_meas = 0, .time_I2C_check = 0,.time_valid_time_reading = 0};
106+
lastType last= {.Pressure_on_send = 0,.time_send = 0,.time_display_reset = 0, .time_Pressure_Temp_meas = 0,.time_valid_time_reading = 0};
106107

107108

108109

@@ -794,7 +795,7 @@ void displayTemPreVol(void){
794795

795796
paint_string_row(print_temp,INFO,0,"", FGC);
796797

797-
798+
798799

799800
if (ex_mode == online)
800801
{
@@ -803,11 +804,11 @@ void displayTemPreVol(void){
803804
}
804805
else
805806
{
806-
if(NetStatIndex == 1){
807+
if(xbee.netstat == NO_SERVER){
807808
paint_string_row(xbee_get_coordID(),CONN,0,"", orange);
808809

809810
}
810-
if(NetStatIndex == 2){
811+
if(xbee.netstat == NO_NETWORK){
811812
paint_string_row(xbee_get_coordID(),CONN,0,"", red);
812813
}
813814
}
@@ -977,7 +978,7 @@ void displayTemPreVol(void){
977978
}
978979
else
979980
{
980-
paint_info_line(NetStat[NetStatIndex],0);
981+
paint_info_line(NetStat[xbee.netstat],0);
981982
}
982983

983984

@@ -1229,7 +1230,7 @@ void reset_display(uint8_t clear)
12291230

12301231
if (clear)
12311232
{
1232-
lcd_Cls(white);
1233+
lcd_Cls(BGC);
12331234
}
12341235

12351236
paint_Main();
@@ -1336,7 +1337,7 @@ uint8_t xbee_send_login_msg(uint8_t db_cmd_type, uint8_t *buffer)
13361337
paint_Value(frameBuffer[reply_Id].data_len,VOLUME,1,3,"");
13371338
#endif
13381339
#ifdef GCM_old_disp
1339-
Print_add_Line("len false",0,0);
1340+
Print_add_Line("len false",0);
13401341
LCD_Value(frameBuffer[reply_Id].data_len,0,0,1,"num ");
13411342
#endif
13421343

@@ -1609,6 +1610,7 @@ uint8_t ping_server(void)
16091610
_delay_ms(500);
16101611
SET_ERROR(NETWORK_ERROR);
16111612
ex_mode = offline;
1613+
t_start(RECONNECT,options.Ping_Intervall*60);
16121614
return 0;
16131615
}
16141616
else
@@ -1638,11 +1640,10 @@ uint8_t ping_server(void)
16381640
/**
16391641
* @brief Checks current Connection Status. Possible states are "No Network" if no connection to a coordinator could be established. "No Server", if the Device is connected to a coordinator but, pings sent by #ping_server() are not answered. And "Online" if pings are answered by the server. The State is saved in #NetStatIndex
16401642
*
1641-
* @param dest_high high 32-bit of coordinator address
1642-
* @param dest_low low 32-bit of coordinator address
16431643
*
16441644
* @return uint8_t 1 if online and 0 if there are any problems with the connection to the server
16451645
*/
1646+
/*
16461647
uint8_t analyze_Connection(void)
16471648
{
16481649
FUNCTION_TRACE
@@ -1658,6 +1659,9 @@ uint8_t analyze_Connection(void)
16581659
CLEAR_ERROR(NETWORK_ERROR);
16591660
16601661
CLEAR_ERROR(NO_REPLY_ERROR);
1662+
1663+
xbee_coordIdentifier();
1664+
16611665
if(!ping_server()){
16621666
paint_info_line("NoServ",0);
16631667
NetStatIndex = 2;
@@ -1687,7 +1691,7 @@ uint8_t analyze_Connection(void)
16871691
16881692
#endif
16891693
}
1690-
1694+
*/
16911695

16921696
/**
16931697
* @brief Receives new options in #buffer and validates them. The validity of the options is reported back to the Server via a #OPTIONS_SET_ACK Message containing the status#byte_93.
@@ -2021,7 +2025,7 @@ int main(void)
20212025

20222026
_Bool CoordActive = false;
20232027

2024-
// set default sc mask
2028+
// set default sc mask
20252029
xbee_Set_Scan_Channels(xbee.ScanChannels);
20262030
// main part
20272031
while(1)
@@ -2204,7 +2208,8 @@ int main(void)
22042208
_delay_ms(500);
22052209
SET_ERROR(NETWORK_ERROR);
22062210
ex_mode = offline;
2207-
analyze_Connection();
2211+
t_start(RECONNECT,options.Ping_Intervall*60);
2212+
22082213

22092214

22102215
}
@@ -2374,7 +2379,8 @@ int main(void)
23742379
_delay_ms(500);
23752380
SET_ERROR(NETWORK_ERROR);
23762381
ex_mode = offline;
2377-
analyze_Connection();
2382+
t_start(RECONNECT,options.Ping_Intervall*60);
2383+
23782384
}
23792385
}
23802386

@@ -2395,9 +2401,9 @@ int main(void)
23952401
// Checks on all I2C DEVICES are done every 5min
23962402
//=========================================================================================
23972403

2398-
if ((count_t_elapsed - last.time_I2C_check) > 10 )
2404+
if (t_check(I2C_CHECK))
23992405
{
2400-
last.time_I2C_check = count_t_elapsed;
2406+
t_start(I2C_CHECK,10);
24012407

24022408
if(!connected.TWI || !connected.DS3231M || (!connected.BMP && connected.BMP_on_Startup) || CHECK_ERROR(I2C_BUS_ERROR))
24032409
{
@@ -2520,15 +2526,15 @@ int main(void)
25202526
// PING
25212527
//==========================================================
25222528
// since pressure/temp is measured every 5s and ping is done every 60+2 seconds to ensure they dont get triggerd at the same Second
2523-
if (((count_t_elapsed % (options.Ping_Intervall*60)) == 2) && ((count_t_elapsed - last.time_ping) > 5 ))
2529+
if (t_check(PING))
25242530
{
2525-
last.time_ping = count_t_elapsed;
2531+
t_start(PING,options.Ping_Intervall * 60);
25262532

25272533

25282534
if(!ping_server()){
2529-
if(!analyze_Connection()){
2530-
break; // Ping unsuccessful --> offline Mode
2531-
}
2535+
2536+
break; // Ping unsuccessful --> offline Mode
2537+
25322538
}
25332539

25342540

@@ -2570,7 +2576,11 @@ int main(void)
25702576
//========================================================
25712577
// try to Reconnect after every 60s (Reconnect_after_time)
25722578
//========================================================
2573-
if (count_t_elapsed % (options.Ping_Intervall*60) == 2){
2579+
if (t_check(RECONNECT)){
2580+
2581+
t_start(RECONNECT,options.Ping_Intervall*60);
2582+
2583+
paint_string_row("RECON",CONN +1 ,1,"",red);
25742584
#ifdef USE_XBEE
25752585

25762586
if (!xbee_reconnect(0))
@@ -2638,6 +2648,7 @@ int main(void)
26382648
_delay_ms(500);
26392649
SET_ERROR(NETWORK_ERROR);
26402650
ex_mode = offline;
2651+
t_start(RECONNECT,options.Ping_Intervall*60);
26412652
reset_display(1);
26422653
break;
26432654

Gascounter_main.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,8 @@ typedef struct {
151151
uint32_t Pressure_on_send; /**< @brief Pressure the last time Data was sent/stored to the Server/memory (in 0.1 mbar)*/
152152
uint32_t time_send; /**< @brief Absolute time of last sending of Data*/
153153
uint32_t time_display_reset; /**< @brief Absolute time of last Display Reset*/
154-
uint32_t time_ping; /**< @brief Absolute time of last Ping*/
155154
uint32_t time_Pressure_Temp_meas; /**< @brief Absolute time of last Temp and Pressure Measurement */
156155
uint32_t time_TWI_action; /**< @brief Absolute time of last TWI read/write/stop */
157-
uint32_t time_I2C_check; /**< @brief Absolute time of last I2C Peripheral checkup */
158156
uint32_t time_valid_time_reading; /**< @brief Absolute time of last Valid Time reading */
159157
}lastType;
160158

@@ -376,6 +374,6 @@ uint8_t xbee_send_login_msg(uint8_t db_cmd_type, uint8_t *buffer);
376374
void execute_server_CMDS(uint8_t reply_id);
377375
uint8_t ping_server(void);
378376
void Set_Options(uint8_t *optBuffer,uint8_t answer_code);
379-
uint8_t analyze_Connection(void);
377+
//uint8_t analyze_Connection(void);
380378

381379
#endif // Gascounter_main.h

avr-util-library

Submodule avr-util-library updated from 8144003 to 3dcb138

gascounter-module.cproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
<Value>F_CPU=6144000</Value>
137137
<Value>GASCOUNTER_MODULE</Value>
138138
<Value>USE_XBEE</Value>
139-
<Value>ili9341</Value>
139+
<Value>GCM_old_disp</Value>
140140
</ListValues>
141141
</avrgcc.compiler.symbols.DefSymbols>
142142
<avrgcc.compiler.directories.IncludePaths>
@@ -333,6 +333,12 @@
333333
<Compile Include="StringPixelCoordTable_ili9341.h">
334334
<SubType>compile</SubType>
335335
</Compile>
336+
<Compile Include="timerUtil.c">
337+
<SubType>compile</SubType>
338+
</Compile>
339+
<Compile Include="timerUtil.h">
340+
<SubType>compile</SubType>
341+
</Compile>
336342
</ItemGroup>
337343
<ItemGroup>
338344
<Folder Include="avr-util-library\" />

0 commit comments

Comments
 (0)