Skip to content

Commit 492e3e2

Browse files
author
Wegmann Peter
committed
fixes and rssi indicator
1 parent 176d043 commit 492e3e2

File tree

5 files changed

+145
-89
lines changed

5 files changed

+145
-89
lines changed

DispAdapter.c

Lines changed: 127 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "Gascounter_main.h"
1818

1919
#include "xbee.h"
20+
#include "xbee_AT_comm.h"
2021
#include "I2C_utilities.h"
2122
#include "DS3231M.h"
2223
#include "status.h"
@@ -58,6 +59,8 @@ uint8_t activity_indicator = 0; /**< @brief Activity Inticator on the bottom Pa
5859

5960

6061

62+
uint8_t sensor_err = 0;
63+
6164
char strBuff[30];
6265

6366

@@ -344,49 +347,59 @@ void displayTemPreVol(void){
344347

345348

346349

347-
348-
if ( CHECK_ERROR(TEMPPRESS_ERROR))
350+
if (!connected.BMP && connected.BMP_on_Startup)
349351
{
350-
paint_Error("TEMP ERR",TEMP);
352+
paint_Error("BMP Sensor",TEMP);
353+
paint_Error("Error",PRESS);
354+
355+
sensor_err = 1;
356+
357+
351358
}
352-
if (CHECK_ERROR(TEMPPRESS_ERROR))
359+
else
353360
{
354-
paint_Error("PRESS ERR",PRESS);
355-
if (options.T_Compensation_enable){
361+
362+
if ( CHECK_ERROR(TEMPPRESS_ERROR))
363+
{
356364
paint_Error("TEMP ERR",TEMP);
357365
}
366+
if (CHECK_ERROR(TEMPPRESS_ERROR))
367+
{
368+
paint_Error("PRESS ERR",PRESS);
369+
if (options.T_Compensation_enable){
370+
paint_Error("TEMP ERR",TEMP);
371+
}
358372

359-
}
360-
361-
// TEMPERATURE
362-
if (!(options.T_Compensation_enable && (CHECK_ERROR(TEMPPRESS_ERROR))))
363-
{
364-
365-
paint_Value( options.Temperature_value - 2732,TEMP, 1, 4, "°C");
366-
}
367-
else{
368-
369-
paint_Error("TEMP ERR",TEMP);
370-
}
371-
372-
373-
//PRESSURE
374-
if(!(options.p_Compensation_enable && (CHECK_ERROR(TEMPPRESS_ERROR))))
375-
{
376-
paint_Value(options.Pressure_value,PRESS, 1, 6, "mbar");
377-
}
378-
else{
379-
380-
paint_Error("PRESS ERR",PRESS);
381-
}
382-
373+
}
374+
375+
// TEMPERATURE
376+
if (!(options.T_Compensation_enable && (CHECK_ERROR(TEMPPRESS_ERROR))))
377+
{
378+
if (sensor_err)
379+
{
380+
paint_string_row("",TEMP,1,"",white);
381+
sensor_err = 0;
382+
}
383+
384+
paint_Value( options.Temperature_value - 2732,TEMP, 1, 4, "°C");
385+
}
386+
else{
383387

384-
if (!connected.BMP && connected.BMP_on_Startup)
385-
{
386-
paint_Error("BMP Sensor",TEMP);
387-
paint_Error("Error",PRESS);
388+
paint_Error("TEMP ERR",TEMP);
389+
}
390+
388391

392+
//PRESSURE
393+
if(!(options.p_Compensation_enable && (CHECK_ERROR(TEMPPRESS_ERROR))))
394+
{
395+
paint_Value(options.Pressure_value,PRESS, 1, 6, "mbar");
396+
}
397+
else{
398+
399+
paint_Error("PRESS ERR",PRESS);
400+
}
389401

402+
390403
}
391404

392405

@@ -445,19 +458,24 @@ void displayTemPreVol(void){
445458
strcat(strBuff,versionStr);
446459

447460

448-
paint_string_row(strBuff,INFO,0,"", FGC);
461+
paint_string_row_col(strBuff,INFO,4, FGC);
449462

463+
xbee_get_DB();
450464

465+
uint16_t x = X_LEFT_EDGE + (DESCRUPTOR_LEN+ 12) * FONT2_W+FONT2_W/2;
466+
uint16_t y = Y_VALUES_START + FONT2_H * INFO;
451467

452468
if (ex_mode == online)
453469
{
454470
paint_string_row(xbee_get_coordID(),CONN,0,"", green);
471+
LCD_conn_Stregth(0,xbee.RSSI,x, y, green);
455472

456473
}
457474
else
458475
{
459476
if(xbee.netstat == NO_SERVER){
460477
paint_string_row(xbee_get_coordID(),CONN,0,"", orange);
478+
LCD_conn_Stregth(0,xbee.RSSI,x, y, orange);
461479

462480
}
463481
if(xbee.netstat == NO_NETWORK){
@@ -466,6 +484,10 @@ void displayTemPreVol(void){
466484
}
467485

468486

487+
488+
489+
490+
469491

470492

471493
activity_indicator++;
@@ -584,7 +606,7 @@ void displayTemPreVol(void){
584606

585607
if (connected.TWI && connected.DS3231M)
586608
{
587-
sprintf(strBuff,"%02i:%02i", Time.tm_hour, Time.tm_min);
609+
sprintf(strBuff,"%02i:%02i", Time.tm_hour, Time.tm_min);
588610
}
589611
else
590612
{
@@ -646,6 +668,75 @@ void displayTemPreVol(void){
646668

647669
}
648670

671+
void I2C_Clear_view(uint8_t i2cState,uint8_t DS3231State, uint8_t BMPSate){
672+
lcd_Cls(BGC);
673+
char twiStr[11] ="";
674+
675+
676+
677+
678+
#ifdef ili9341
679+
sprintf(twiStr,"clearBUS:%d",i2cState);
680+
paint_string_row_col("I2C Bus Recovery",INFO,0,white);
681+
paint_string_row(twiStr,VALUE,1,"",FGC);
682+
683+
if (!DS3231State)
684+
{
685+
paint_string_row("DS3231M OK",CORRVOL,1,"",FGC);
686+
}
687+
else
688+
{
689+
paint_string_row("DS3231M NO",CORRVOL,1,"",FGC);
690+
}
691+
692+
if (!BMPSate)
693+
{
694+
paint_string_row("TEM/PRES OK",VOLUME,1,"",FGC);
695+
}
696+
else
697+
{
698+
paint_string_row("TEM/PRES NO",VOLUME,1,"",FGC);
699+
}
700+
701+
702+
#endif
703+
704+
705+
706+
707+
#ifdef GCM_old_disp
708+
sprintf(twiStr,"clearBUS:%d",i2cState);
709+
LCD_String(twiStr,0,0);
710+
711+
if (!DS3231State)
712+
{
713+
LCD_String("DS3231M OK",0,3);
714+
}
715+
else
716+
{
717+
LCD_String("DS3231M NO",0,3);
718+
}
719+
720+
if (!BMPSate)
721+
{
722+
paint_string_row("TEM/PRES OK",VOLUME,1,"",FGC);
723+
}
724+
else
725+
{
726+
LCD_String("TEM/PRES NO",0,2);
727+
}
728+
729+
#endif
730+
731+
_delay_ms(2000);
732+
reset_display(1);
733+
734+
735+
736+
}
737+
738+
739+
649740

650741
/**
651742
* @brief Used to periodically reset contents of the display to the normal Layout.

DispAdapter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,6 @@ void paint_store_meas(uint8_t meas_in_Buffer, uint8_t max_Number );
9292
void paint_send_stored_meas(uint8_t meas_in_Buffer, uint8_t max_Number, uint8_t update);
9393
void displayTemPreVol(void);
9494
void reset_display(uint8_t clear);
95+
void I2C_Clear_view(uint8_t i2cState,uint8_t DS3231State, uint8_t BMPSate);
96+
9597
#endif /* DISPADAPTER_H_ */

Gascounter_main.c

Lines changed: 14 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ const uint16_t reset_display_Interval = 60 * 60;
184184
*
185185
* Time between Pressure-Temperature-Measurements (in s)
186186
*/
187-
const uint8_t Measure_Interval = 5;
187+
const uint8_t Measure_Interval = 2;
188188

189189

190190
/************************************************************************/
@@ -500,7 +500,8 @@ void init(void)
500500
Print_add_Line("HZB Gascount",1);
501501
#endif
502502

503-
503+
504+
504505

505506
sprintf(print_temp,"v%i.%i",version.Branch_id,version.Fw_version);
506507
Print_add_Line(print_temp,0);
@@ -2027,21 +2028,8 @@ int main(void)
20272028
{
20282029

20292030
uint8_t i2cState = I2C_ClearBus();
2030-
2031-
2032-
lcd_Cls(BGC);
2033-
char twiStr[11] ="";
2034-
sprintf(twiStr,"clearBUS:%d",i2cState);
2035-
2036-
#ifdef ili9341
2037-
paint_string_row("I2C Bus Recovery",INFO,1,"",white);
2038-
paint_string_row(twiStr,VALUE,1,"",FGC);
2039-
#endif
2040-
#ifdef GCM_old_disp
2041-
LCD_String(twiStr,0,0);
2042-
#endif
2043-
2044-
2031+
uint8_t DS3231Mstate = 0;
2032+
uint8_t BMPState = 0;
20452033

20462034
connected.TWI = 1;
20472035
connected.DS3231M = 1;
@@ -2052,50 +2040,26 @@ int main(void)
20522040
{
20532041

20542042
DS3231M_read_time();
2055-
if(!CHECK_ERROR(TIMER_ERROR))
2043+
2044+
DS3231Mstate = CHECK_ERROR(TIMER_ERROR);
2045+
2046+
if(!DS3231Mstate)
20562047
{
20572048
CLEAR_ERROR(I2C_BUS_ERROR);
2058-
#ifdef ili9341
2059-
paint_string_row("DS3231M OK",CORRVOL,1,"",FGC);
2060-
#endif
2061-
#ifdef GCM_old_disp
2062-
LCD_String("DS3231M OK",0,3);
2063-
#endif
2064-
2065-
}else{
2066-
#ifdef ili9341
2067-
paint_string_row("DS3231M NO",CORRVOL,1,"",FGC);
2068-
#endif
2069-
#ifdef GCM_old_disp
2070-
LCD_String("DS3231M NO",0,3);
2071-
#endif
2049+
20722050
}
2051+
20732052

2074-
2053+
BMPState = BMP_Temp_and_Pressure();
20752054

2076-
if (!BMP_Temp_and_Pressure())
2055+
if (!BMPState)
20772056
{
2078-
#ifdef ili9341
2079-
paint_string_row("TEM/PRES OK",VOLUME,1,"",FGC);
2080-
#endif
2081-
#ifdef GCM_old_disp
2082-
LCD_String("TEM/PRES OK",0,2);
2083-
#endif
2084-
2085-
2086-
20872057
CLEAR_ERROR(TEMPPRESS_ERROR);;
20882058
CLEAR_ERROR(I2C_BUS_ERROR);;
20892059
connected.BMP =1 ;
20902060
}
20912061
else
20922062
{
2093-
#ifdef ili9341
2094-
paint_string_row("TEM/PRES NO",VOLUME,1,"",FGC);
2095-
#endif
2096-
#ifdef GCM_old_disp
2097-
LCD_String("TEM/PRES NO",0,2);
2098-
#endif
20992063
connected.BMP = 0;
21002064
}
21012065

@@ -2107,8 +2071,7 @@ int main(void)
21072071
connected.TWI = 1;
21082072
}
21092073

2110-
_delay_ms(2000);
2111-
reset_display(1);
2074+
I2C_Clear_view(i2cState,DS3231Mstate,BMPState);
21122075

21132076
}
21142077

StringPixelCoordTable_ili9341.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// String and Pixel Coord Table for ILI9341
1+
// String and Pixel Coord Table for ILI9341
22

33

44
// there is 5px padding around the outer edge of the Display for placing elements,

avr-util-library

Submodule avr-util-library updated from 39de183 to ee1ebbb

0 commit comments

Comments
 (0)