comparison Discovery/Src/t7.c @ 527:962d7b2c18c6

Do not show gases in "Off" state in custom gas list: May be added / removed from code using "ENABLE_UNUSED_GAS_HIDING"
author Ideenmodellierer
date Sun, 13 Sep 2020 20:58:37 +0200
parents 85e0945552ce
children c880907fd1d7
comparison
equal deleted inserted replaced
526:88c626d01ee5 527:962d7b2c18c6
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. 26 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
27 ////////////////////////////////////////////////////////////////////////////// 27 //////////////////////////////////////////////////////////////////////////////
28 28
29 /* Includes ------------------------------------------------------------------*/ 29 /* Includes ------------------------------------------------------------------*/
30 #include "t7.h" 30 #include "t7.h"
31 31 #include "settings.h"
32 #include "data_exchange_main.h" 32 #include "data_exchange_main.h"
33 #include "decom.h" 33 #include "decom.h"
34 #include "gfx_fonts.h" 34 #include "gfx_fonts.h"
35 #include "logbook_miniLive.h" 35 #include "logbook_miniLive.h"
36 #include "math.h" 36 #include "math.h"
37 #include "tHome.h" 37 #include "tHome.h"
38 #include "simulation.h" 38 #include "simulation.h"
39 #include "timer.h" 39 #include "timer.h"
40 #include "unit.h" 40 #include "unit.h"
41 #include "motion.h" 41 #include "motion.h"
42 #include "configuration.h"
42 43
43 /* Private function prototypes -----------------------------------------------*/ 44 /* Private function prototypes -----------------------------------------------*/
44 45
45 void t7_refresh_surface(void); 46 void t7_refresh_surface(void);
46 void t7_refresh_surface_debugmode(void); 47 void t7_refresh_surface_debugmode(void);
672 673
673 void t7_refresh_surface(void) 674 void t7_refresh_surface(void)
674 { 675 {
675 static float debounceAmbientPressure = 0; 676 static float debounceAmbientPressure = 0;
676 char text[256]; 677 char text[256];
678 uint8_t loop, textIdx;
677 uint8_t date[3], year,month,day; 679 uint8_t date[3], year,month,day;
678 uint32_t color; 680 uint32_t color;
679 uint8_t customview_warnings = 0; 681 uint8_t customview_warnings = 0;
680 682
681 RTC_DateTypeDef Sdate; 683 RTC_DateTypeDef Sdate;
742 dateNotSet = 0; 744 dateNotSet = 0;
743 /* 745 /*
744 if(Stime.Seconds % 2) 746 if(Stime.Seconds % 2)
745 snprintf(text,255,"\001%02d:%02d",Stime.Hours,Stime.Minutes); 747 snprintf(text,255,"\001%02d:%02d",Stime.Hours,Stime.Minutes);
746 else 748 else
747 snprintf(text,255,"\001%02d\021:\020%02d",Stime.Hours,Stime.Minutes); 749 snprintf(text,255,"\001%02d\031:\020%02d",Stime.Hours,Stime.Minutes);
748 GFX_write_string(&FontT54,&t7surfaceR,text,3); 750 GFX_write_string(&FontT54,&t7surfaceR,text,3);
749 */ 751 */
750 // debug version: 752 // debug version:
751 if(Stime.Seconds % 2) 753 if(Stime.Seconds % 2)
752 snprintf(text,255,"\001%02d:%02d:%02d",Stime.Hours,Stime.Minutes,Stime.Seconds); 754 snprintf(text,255,"\001%02d:%02d:%02d",Stime.Hours,Stime.Minutes,Stime.Seconds);
753 else if(dateNotSet) 755 else if(dateNotSet)
754 snprintf(text,255,"\001\021%02d:%02d:%02d\020",Stime.Hours,Stime.Minutes,Stime.Seconds); 756 snprintf(text,255,"\001\031%02d:%02d:%02d\020",Stime.Hours,Stime.Minutes,Stime.Seconds);
755 else 757 else
756 snprintf(text,255,"\001%02d\021:\020%02d:%02d",Stime.Hours,Stime.Minutes,Stime.Seconds); 758 snprintf(text,255,"\001%02d\031:\020%02d:%02d",Stime.Hours,Stime.Minutes,Stime.Seconds);
757 GFX_write_string(&FontT54,&t7surfaceR,text,3); 759 GFX_write_string(&FontT54,&t7surfaceR,text,3);
758 760
759 if(settingsGetPointer()->date_format == DDMMYY) 761 if(settingsGetPointer()->date_format == DDMMYY)
760 { 762 {
761 day = 0; 763 day = 0;
780 date[year] = Sdate.Year; 782 date[year] = Sdate.Year;
781 783
782 if((Stime.Seconds % 2) || (dateNotSet == 0)) 784 if((Stime.Seconds % 2) || (dateNotSet == 0))
783 snprintf(text,255,"\001%02d.%02d.%02d",date[0],date[1],date[2]); 785 snprintf(text,255,"\001%02d.%02d.%02d",date[0],date[1],date[2]);
784 else 786 else
785 snprintf(text,255,"\001\021%02d.%02d.%02d",date[0],date[1],date[2]); 787 snprintf(text,255,"\001\031%02d.%02d.%02d",date[0],date[1],date[2]);
786 788
787 GFX_write_string(&FontT54,&t7surfaceR,text,5); 789 GFX_write_string(&FontT54,&t7surfaceR,text,5);
788 790
789 if(!DataEX_was_power_on() && !errorsInSettings) 791 if(!DataEX_was_power_on() && !errorsInSettings)
790 { 792 {
797 text[6] = 0; 799 text[6] = 0;
798 if(Sdate.WeekDay != RTC_WEEKDAY_SUNDAY) 800 if(Sdate.WeekDay != RTC_WEEKDAY_SUNDAY)
799 text[5] += Sdate.WeekDay; 801 text[5] += Sdate.WeekDay;
800 802
801 if(!(Stime.Seconds % 2) && (dateNotSet == 1)) 803 if(!(Stime.Seconds % 2) && (dateNotSet == 1))
802 text[1] = '\021'; 804 text[1] = '\031';
803 805
804 GFX_write_string(&FontT48,&t7surfaceR,text,4); 806 GFX_write_string(&FontT48,&t7surfaceR,text,4);
805 } 807 }
806 808
807 /* DEBUG uTick Pressure and Compass */ 809 /* DEBUG uTick Pressure and Compass */
965 text[1] = 0; 967 text[1] = 0;
966 GFX_write_string(&FontT48,&t7surfaceL,text,6); 968 GFX_write_string(&FontT48,&t7surfaceL,text,6);
967 } 969 }
968 else 970 else
969 { 971 {
970 text[0] = '\021'; 972 textIdx = 0;
971 text[1] = '1';
972 text[2] = '\177';
973 text[3] = '\177';
974 text[4] = 10;
975 text[5] = '\021';
976 text[6] = '2';
977 text[7] = '\177';
978 text[8] = '\177';
979 text[9] = 10;
980 text[10] = '\021';
981 text[11] = '3';
982 text[12] = '\177';
983 text[13] = '\177';
984 text[14] = 10;
985 text[15] = '\021';
986 text[16] = '4';
987 text[17] = '\177';
988 text[18] = '\177';
989 text[19] = 10;
990 text[20] = '\021';
991 text[21] = '5';
992 text[22] = 0;
993
994 if(stateUsed->diveSettings.diveMode == DIVEMODE_CCR) 973 if(stateUsed->diveSettings.diveMode == DIVEMODE_CCR)
995 gasOffset = NUM_OFFSET_DILUENT; 974 gasOffset = NUM_OFFSET_DILUENT;
996 else 975 else
997 gasOffset = 0; 976 gasOffset = 0;
998 for(int i=1;i<=5;i++) 977
999 { 978 /* Display gas setup */
1000 if(stateUsed->diveSettings.gas[i+gasOffset].note.ub.active) 979 for(loop = 1; loop <= NUM_GASES; loop++)
1001 text[(i-1)*5] -= 1; 980 {
1002 } 981 #ifdef ENABLE_UNUSED_GAS_HIDING
982 if(stateUsed->diveSettings.gas[loop+gasOffset].note.ub.off)
983 {
984 text[textIdx++] = '\021';
985 }
986 else
987 #endif
988 if(stateUsed->diveSettings.gas[loop+gasOffset].note.ub.active)
989 {
990 text[textIdx++]= '\020';
991 }
992 else
993 {
994 text[textIdx++]= '\031';
995 }
996
997 text[textIdx++] = '0' + loop;
998 text[textIdx++] = '\177';
999 text[textIdx++] = '\177';
1000 text[textIdx++] = 10;
1001 }
1002 text[textIdx++] = 0;
1003 GFX_write_string(&FontT48,&t7surfaceL,text,6); 1003 GFX_write_string(&FontT48,&t7surfaceL,text,6);
1004 1004
1005 1005
1006 oxygen_percentage = 100; 1006 oxygen_percentage = 100;
1007 oxygen_percentage -= stateUsed->lifeData.actualGas.nitrogen_percentage; 1007 oxygen_percentage -= stateUsed->lifeData.actualGas.nitrogen_percentage;
1792 fPpO2limitHigh = (float)(settingsGetPointer()->ppO2_max_std) / 100; 1792 fPpO2limitHigh = (float)(settingsGetPointer()->ppO2_max_std) / 100;
1793 fPpO2limitLow = (float)(settingsGetPointer()->ppO2_min) / 100; 1793 fPpO2limitLow = (float)(settingsGetPointer()->ppO2_min) / 100;
1794 for(int gasId=1;gasId<=NUM_GASES;gasId++) 1794 for(int gasId=1;gasId<=NUM_GASES;gasId++)
1795 { 1795 {
1796 textpointer = 0; 1796 textpointer = 0;
1797 #ifdef ENABLE_UNUSED_GAS_HIDING
1798 if(!pGasLine[gasId].note.ub.off)
1799 {
1800 #endif
1797 fPpO2ofGasAtThisDepth = (stateUsed->lifeData.pressure_ambient_bar - WATER_VAPOUR_PRESSURE) * pGasLine[gasId].oxygen_percentage / 100; 1801 fPpO2ofGasAtThisDepth = (stateUsed->lifeData.pressure_ambient_bar - WATER_VAPOUR_PRESSURE) * pGasLine[gasId].oxygen_percentage / 100;
1798 if(pGasLine[gasId].note.ub.active == 0) 1802 if(pGasLine[gasId].note.ub.active == 0)
1799 strcpy(&text[textpointer++],"\021"); 1803 strcpy(&text[textpointer++],"\031");
1800 else if(stateUsed->lifeData.actualGas.GasIdInSettings == gasId) /* actual selected gas */ 1804 else if(stateUsed->lifeData.actualGas.GasIdInSettings == gasId) /* actual selected gas */
1801 { 1805 {
1802 strcpy(&text[textpointer++],"\030"); 1806 strcpy(&text[textpointer++],"\030");
1803 } 1807 }
1804 else if((fPpO2ofGasAtThisDepth > fPpO2limitHigh) || (fPpO2ofGasAtThisDepth < fPpO2limitLow)) 1808 else if((fPpO2ofGasAtThisDepth > fPpO2limitHigh) || (fPpO2ofGasAtThisDepth < fPpO2limitLow))
1818 if(pGasLine[gasId].depth_meter) 1822 if(pGasLine[gasId].depth_meter)
1819 { 1823 {
1820 textpointer += snprintf(&text[textpointer],7,"\t%u %c%c",unit_depth_integer(pGasLine[gasId].depth_meter), unit_depth_char1(), unit_depth_char2()); 1824 textpointer += snprintf(&text[textpointer],7,"\t%u %c%c",unit_depth_integer(pGasLine[gasId].depth_meter), unit_depth_char1(), unit_depth_char2());
1821 } 1825 }
1822 GFX_write_string(&FontT42, &t7cY0free, text, gasId); 1826 GFX_write_string(&FontT42, &t7cY0free, text, gasId);
1827 #ifdef ENABLE_UNUSED_GAS_HIDING
1828 }
1829 #endif
1823 } 1830 }
1824 break; 1831 break;
1825 1832
1826 case CVIEW_EADTime: 1833 case CVIEW_EADTime:
1827 snprintf(text,100,"\032\f\001%c%c",TXT_2BYTE,TXT2BYTE_Info ); 1834 snprintf(text,100,"\032\f\001%c%c",TXT_2BYTE,TXT2BYTE_Info );
2246 , unit_depth_char1_T105() 2253 , unit_depth_char1_T105()
2247 , unit_depth_char2_T105() 2254 , unit_depth_char2_T105()
2248 , (nextstopLengthSeconds+59)/60); 2255 , (nextstopLengthSeconds+59)/60);
2249 t7_colorscheme_mod(TextR2); 2256 t7_colorscheme_mod(TextR2);
2250 if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS) 2257 if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS)
2251 TextR2[0] = '\021'; 2258 TextR2[0] = '\031';
2252 if(textlength <= 9) 2259 if(textlength <= 9)
2253 GFX_write_string(&FontT105,&t7r2,TextR2,1); 2260 GFX_write_string(&FontT105,&t7r2,TextR2,1);
2254 else 2261 else
2255 GFX_write_string(&FontT54,&t7r2,TextR2,1); 2262 GFX_write_string(&FontT54,&t7r2,TextR2,1);
2256 } 2263 }
2274 snprintf(TextR3,TEXTSIZE,"\020\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60); 2281 snprintf(TextR3,TEXTSIZE,"\020\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60);
2275 else 2282 else
2276 snprintf(TextR3,TEXTSIZE,"\020\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600); 2283 snprintf(TextR3,TEXTSIZE,"\020\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600);
2277 t7_colorscheme_mod(TextR3); 2284 t7_colorscheme_mod(TextR3);
2278 if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS) 2285 if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS)
2279 TextR2[0] = '\021'; 2286 TextR2[0] = '\031';
2280 GFX_write_string(&FontT105,&t7r3,TextR3,1); 2287 GFX_write_string(&FontT105,&t7r3,TextR3,1);
2281 } 2288 }
2282 else if(pDecoinfo->output_ndl_seconds) 2289 else if(pDecoinfo->output_ndl_seconds)
2283 { 2290 {
2284 snprintf(TextR3,TEXTSIZE,"\032\f\002%c",TXT_Nullzeit); 2291 snprintf(TextR3,TEXTSIZE,"\032\f\002%c",TXT_Nullzeit);
2287 snprintf(TextR3,TEXTSIZE,"\020\002%i'",pDecoinfo->output_ndl_seconds/60); 2294 snprintf(TextR3,TEXTSIZE,"\020\002%i'",pDecoinfo->output_ndl_seconds/60);
2288 else 2295 else
2289 snprintf(TextR3,TEXTSIZE,"\020\002%ih",pDecoinfo->output_ndl_seconds/3600); 2296 snprintf(TextR3,TEXTSIZE,"\020\002%ih",pDecoinfo->output_ndl_seconds/3600);
2290 t7_colorscheme_mod(TextR3); 2297 t7_colorscheme_mod(TextR3);
2291 if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS) 2298 if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS)
2292 TextR2[0] = '\021'; 2299 TextR2[0] = '\031';
2293 GFX_write_string(&FontT105,&t7r3,TextR3,1); 2300 GFX_write_string(&FontT105,&t7r3,TextR3,1);
2294 } 2301 }
2295 2302
2296 /* Menu Selection (and gas mix) */ 2303 /* Menu Selection (and gas mix) */
2297 if(get_globalState() == StDMGAS) 2304 if(get_globalState() == StDMGAS)