Mercurial > public > ostc4
comparison Discovery/Src/t7.c @ 696:cc542448fb28
Merge
author | heinrichsweikamp |
---|---|
date | Fri, 19 Aug 2022 11:30:24 +0200 |
parents | 79ce499e26aa |
children | 8c48553a0176 |
comparison
equal
deleted
inserted
replaced
661:87bee7cc77b3 | 696:cc542448fb28 |
---|---|
33 #include "data_exchange_main.h" | 33 #include "data_exchange_main.h" |
34 #include "decom.h" | 34 #include "decom.h" |
35 #include "gfx_fonts.h" | 35 #include "gfx_fonts.h" |
36 #include "logbook_miniLive.h" | 36 #include "logbook_miniLive.h" |
37 #include "math.h" | 37 #include "math.h" |
38 #include "tComm.h" | |
38 #include "tHome.h" | 39 #include "tHome.h" |
39 #include "simulation.h" | 40 #include "simulation.h" |
40 #include "timer.h" | 41 #include "timer.h" |
41 #include "unit.h" | 42 #include "unit.h" |
42 #include "motion.h" | 43 #include "motion.h" |
59 void t7_SummaryOfLeftCorner(void); | 60 void t7_SummaryOfLeftCorner(void); |
60 void t7_debug(void); | 61 void t7_debug(void); |
61 | 62 |
62 void t7_miniLiveLogProfile(void); | 63 void t7_miniLiveLogProfile(void); |
63 void t7_logo_OSTC(void); | 64 void t7_logo_OSTC(void); |
65 void t7_ChargerView(void); | |
64 static void t7_colorscheme_mod(char *text); | 66 static void t7_colorscheme_mod(char *text); |
65 | 67 |
66 uint8_t t7_test_customview_warnings(void); | 68 uint8_t t7_test_customview_warnings(void); |
67 void t7_show_customview_warnings(void); | 69 void t7_show_customview_warnings(void); |
68 | 70 |
134 CVIEW_Hello, | 136 CVIEW_Hello, |
135 CVIEW_sensors, | 137 CVIEW_sensors, |
136 CVIEW_Compass, | 138 CVIEW_Compass, |
137 CVIEW_Tissues, | 139 CVIEW_Tissues, |
138 CVIEW_sensors_mV, | 140 CVIEW_sensors_mV, |
139 CVIEW_END, | 141 CVIEW_Charger, |
140 CVIEW_END | 142 CVIEW_END |
141 }; | 143 }; |
142 | 144 |
143 | 145 |
144 static uint8_t selection_custom_field = LLC_Temperature; | 146 static uint8_t selection_custom_field = LLC_Temperature; |
683 } | 685 } |
684 | 686 |
685 void t7_refresh_surface(void) | 687 void t7_refresh_surface(void) |
686 { | 688 { |
687 static float debounceAmbientPressure = 0; | 689 static float debounceAmbientPressure = 0; |
690 static uint8_t lastChargeStatus = 0; | |
688 char text[256]; | 691 char text[256]; |
689 char timeSuffix; | 692 char timeSuffix; |
690 uint8_t hours; | 693 uint8_t hours; |
691 uint8_t loop, textIdx; | 694 uint8_t loop, textIdx; |
692 uint8_t date[3], year,month,day; | 695 uint8_t date[3], year,month,day; |
741 sprintf(text,"Settings: %u",errorsInSettings); | 744 sprintf(text,"Settings: %u",errorsInSettings); |
742 GFX_write_string_color(&FontT42,&t7surfaceR,text,4,CLUT_WarningRed); | 745 GFX_write_string_color(&FontT42,&t7surfaceR,text,4,CLUT_WarningRed); |
743 } | 746 } |
744 else | 747 else |
745 */ | 748 */ |
746 if(DataEX_was_power_on()) | 749 if(DataEX_was_power_on()) { |
747 GFX_write_string_color(&FontT42,&t7surfaceR,"cold start",4,CLUT_WarningRed); | 750 GFX_write_string_color(&FontT42,&t7surfaceR,"cold start",4,CLUT_WarningRed); |
751 } | |
748 | 752 |
749 /* time and date */ | 753 /* time and date */ |
750 translateDate(stateUsed->lifeData.dateBinaryFormat, &Sdate); | 754 translateDate(stateUsed->lifeData.dateBinaryFormat, &Sdate); |
751 translateTime(stateUsed->lifeData.timeBinaryFormat, &Stime); | 755 translateTime(stateUsed->lifeData.timeBinaryFormat, &Stime); |
752 | 756 |
1013 GFX_write_string(&FontT48,&t7surfaceL,text,6); | 1017 GFX_write_string(&FontT48,&t7surfaceL,text,6); |
1014 } | 1018 } |
1015 else | 1019 else |
1016 { | 1020 { |
1017 textIdx = 0; | 1021 textIdx = 0; |
1018 if(stateUsed->diveSettings.diveMode == DIVEMODE_CCR) | 1022 if(isLoopMode(stateUsed->diveSettings.diveMode)) |
1019 gasOffset = NUM_OFFSET_DILUENT; | 1023 gasOffset = NUM_OFFSET_DILUENT; |
1020 else | 1024 else |
1021 gasOffset = 0; | 1025 gasOffset = 0; |
1022 | 1026 |
1023 /* Display gas setup */ | 1027 /* Display gas setup */ |
1087 | 1091 |
1088 /* dive mode */ | 1092 /* dive mode */ |
1089 switch (stateUsed->diveSettings.diveMode) { | 1093 switch (stateUsed->diveSettings.diveMode) { |
1090 case DIVEMODE_CCR: | 1094 case DIVEMODE_CCR: |
1091 GFX_write_string(&FontT24, &t7c1, "\f\002" "CCR", 0); | 1095 GFX_write_string(&FontT24, &t7c1, "\f\002" "CCR", 0); |
1096 break; | |
1097 case DIVEMODE_PSCR: | |
1098 GFX_write_string(&FontT24, &t7c1, "\f\002" "PSCR", 0); | |
1092 break; | 1099 break; |
1093 case DIVEMODE_OC: | 1100 case DIVEMODE_OC: |
1094 GFX_write_string(&FontT24, &t7c1, "\f\002" "OC", 0); | 1101 GFX_write_string(&FontT24, &t7c1, "\f\002" "OC", 0); |
1095 break; | 1102 break; |
1096 case DIVEMODE_Gauge: | 1103 case DIVEMODE_Gauge: |
1178 } | 1185 } |
1179 } | 1186 } |
1180 } | 1187 } |
1181 else | 1188 else |
1182 { | 1189 { |
1190 if(lastChargeStatus == CHARGER_off) | |
1191 { | |
1192 t7_select_customview(CVIEW_Charger); | |
1193 } | |
1194 | |
1183 GFX_write_string_color(&Batt24,&t7batt,text,0,CLUT_BatteryCharging); | 1195 GFX_write_string_color(&Batt24,&t7batt,text,0,CLUT_BatteryCharging); |
1184 | 1196 |
1185 switch(stateUsed->chargeStatus) | 1197 switch(stateUsed->chargeStatus) |
1186 { | 1198 { |
1187 case CHARGER_running: | 1199 case CHARGER_running: |
1198 text[0] = '4'; | 1210 text[0] = '4'; |
1199 text[1] = 0; | 1211 text[1] = 0; |
1200 GFX_write_string_color(&Batt24,&t7charge,text,0,color); | 1212 GFX_write_string_color(&Batt24,&t7charge,text,0,color); |
1201 } | 1213 } |
1202 | 1214 |
1215 lastChargeStatus = stateUsed->chargeStatus; | |
1203 | 1216 |
1204 | 1217 |
1205 customview_warnings = t7_test_customview_warnings_surface_mode(); | 1218 customview_warnings = t7_test_customview_warnings_surface_mode(); |
1206 if(customview_warnings && warning_count_high_time) | 1219 if(customview_warnings && warning_count_high_time) |
1207 t7_show_customview_warnings_surface_mode(); | 1220 t7_show_customview_warnings_surface_mode(); |
1602 if (((view == CVIEW_sensors) || (view == CVIEW_sensors_mV)) && | 1615 if (((view == CVIEW_sensors) || (view == CVIEW_sensors_mV)) && |
1603 ((stateUsed->diveSettings.ppo2sensors_deactivated == 0x07) || (stateUsed->diveSettings.ccrOption == 0) || (stateUsed->warnings.fallback))) | 1616 ((stateUsed->diveSettings.ppo2sensors_deactivated == 0x07) || (stateUsed->diveSettings.ccrOption == 0) || (stateUsed->warnings.fallback))) |
1604 { | 1617 { |
1605 cv_disabled = 1; | 1618 cv_disabled = 1; |
1606 } | 1619 } |
1620 | |
1621 if ((view == CVIEW_Charger) && (stateUsed->chargeStatus != CHARGER_running) && (stateUsed->chargeStatus != CHARGER_lostConnection)) | |
1622 { | |
1623 cv_disabled = 1; | |
1624 } | |
1625 | |
1626 | |
1607 return cv_disabled; | 1627 return cv_disabled; |
1608 } | 1628 } |
1609 | 1629 |
1610 uint8_t t7_change_customview(uint8_t action) | 1630 uint8_t t7_change_customview(uint8_t action) |
1611 { | 1631 { |
1612 uint8_t *pViews; | 1632 uint8_t *pViews; |
1613 uint8_t *pStartView,*pCurView, *pLastView; | 1633 uint8_t *pStartView,*pLastView; |
1634 uint8_t *pCurView = NULL; | |
1614 _Bool cv_disabled = 0; | 1635 _Bool cv_disabled = 0; |
1615 | 1636 |
1616 if(stateUsed->mode == MODE_DIVE) | 1637 if(stateUsed->mode == MODE_DIVE) |
1617 pViews = (uint8_t*)customviewsDive; | 1638 pViews = (uint8_t*)customviewsDive; |
1618 else | 1639 else |
1692 static uint8_t last_customview = CVIEW_END; | 1713 static uint8_t last_customview = CVIEW_END; |
1693 | 1714 |
1694 char text[256]; | 1715 char text[256]; |
1695 char timeSuffix; | 1716 char timeSuffix; |
1696 uint8_t hoursToDisplay; | 1717 uint8_t hoursToDisplay; |
1718 #ifdef ENABLE_PSCR_MODE | |
1719 uint8_t showSimPPO2 = 1; | |
1720 #endif | |
1697 uint16_t textpointer = 0; | 1721 uint16_t textpointer = 0; |
1698 uint16_t heading = 0; | 1722 uint16_t heading = 0; |
1699 int16_t start; | 1723 int16_t start; |
1700 uint8_t lineCountCustomtext = 0; | 1724 uint8_t lineCountCustomtext = 0; |
1701 int16_t shiftWindowY0; | 1725 int16_t shiftWindowY0; |
1726 strcpy(text,"\032\f\001Debug"); | 1750 strcpy(text,"\032\f\001Debug"); |
1727 GFX_write_string(&FontT42,&t7cH,text,0); | 1751 GFX_write_string(&FontT42,&t7cH,text,0); |
1728 // content | 1752 // content |
1729 t7_debug(); | 1753 t7_debug(); |
1730 } | 1754 } |
1755 break; | |
1756 | |
1757 case CVIEW_Charger: | |
1758 snprintf(text,100,"\032\f\001%c",TXT_Charging); | |
1759 GFX_write_string(&FontT42,&t7cH,text,0); | |
1760 t7_ChargerView(); | |
1761 | |
1731 break; | 1762 break; |
1732 | 1763 |
1733 case CVIEW_SummaryOfLeftCorner: | 1764 case CVIEW_SummaryOfLeftCorner: |
1734 snprintf(text,100,"\032\f\001%c%c",TXT_2BYTE,TXT2BYTE_Summary); | 1765 snprintf(text,100,"\032\f\001%c%c",TXT_2BYTE,TXT2BYTE_Summary); |
1735 GFX_write_string(&FontT42,&t7cH,text,0); | 1766 GFX_write_string(&FontT42,&t7cH,text,0); |
1788 GFX_write_string_color(&FontT42,&t7cC,text,1, CLUT_WarningRed); | 1819 GFX_write_string_color(&FontT42,&t7cC,text,1, CLUT_WarningRed); |
1789 t7cC.WindowY0 += shiftWindowY0; | 1820 t7cC.WindowY0 += shiftWindowY0; |
1790 } | 1821 } |
1791 t7cC.WindowNumberOfTextLines = 3; | 1822 t7cC.WindowNumberOfTextLines = 3; |
1792 } | 1823 } |
1824 else if(isSettingsWarning()) | |
1825 { | |
1826 if(warning_count_high_time) | |
1827 { | |
1828 shiftWindowY0 += 20; | |
1829 t7cC.WindowY0 -= shiftWindowY0; | |
1830 textpointer = 0; | |
1831 text[textpointer++] = '\001'; | |
1832 text[textpointer++] = TXT_2BYTE; | |
1833 text[textpointer++] = TXT2BYTE_CheckSettings; | |
1834 text[textpointer++] = '\n'; | |
1835 text[textpointer++] = '\r'; | |
1836 text[textpointer++] = 0; | |
1837 GFX_write_string_color(&FontT42,&t7cC,text,1, CLUT_WarningRed); | |
1838 t7cC.WindowY0 += shiftWindowY0; | |
1839 } | |
1840 t7cC.WindowNumberOfTextLines = 1; | |
1841 } | |
1793 else // customtext | 1842 else // customtext |
1794 { | 1843 { |
1795 lineCountCustomtext = t7_customtextPrepare(text); | 1844 lineCountCustomtext = t7_customtextPrepare(text); |
1796 if(lineCountCustomtext <= 2) | 1845 if(lineCountCustomtext <= 2) |
1797 shiftWindowY0 += 20+26; // nach unten | 1846 shiftWindowY0 += 20+26; // nach unten |
1991 text[textpointer++] = '\030'; // main color | 2040 text[textpointer++] = '\030'; // main color |
1992 for(int i=0;i<3;i++) | 2041 for(int i=0;i<3;i++) |
1993 { | 2042 { |
1994 if((stateUsed->diveSettings.ppo2sensors_deactivated & (1<<i)) || (stateUsed->lifeData.ppO2Sensor_bar[i] == 0.0)) | 2043 if((stateUsed->diveSettings.ppo2sensors_deactivated & (1<<i)) || (stateUsed->lifeData.ppO2Sensor_bar[i] == 0.0)) |
1995 { | 2044 { |
1996 text[textpointer++] = '\031'; // labelcolor | 2045 #ifdef ENABLE_PSCR_MODE |
1997 text[textpointer++] = '\001'; | 2046 if((stateUsed->diveSettings.diveMode == DIVEMODE_PSCR) && (showSimPPO2) && (stateUsed->mode == MODE_DIVE)) /* display ppo2 sim in blue letters in case a slot is not used in the ppo2 custom view */ |
1998 text[textpointer++] = '-'; | 2047 { |
1999 text[textpointer++] = '\n'; | 2048 text[textpointer++] = '\023'; |
2000 text[textpointer++] = '\r'; | 2049 textpointer += snprintf(&text[textpointer],100,"\001%01.2f\n\r\030",stateUsed->lifeData.ppo2Simulated_bar); |
2001 text[textpointer++] = '\030'; // main color | 2050 showSimPPO2 = 0; |
2002 text[textpointer] = 0; | 2051 } |
2052 else | |
2053 #endif | |
2054 { | |
2055 text[textpointer++] = '\031'; // labelcolor | |
2056 text[textpointer++] = '\001'; | |
2057 text[textpointer++] = '-'; | |
2058 text[textpointer++] = '\n'; | |
2059 text[textpointer++] = '\r'; | |
2060 text[textpointer++] = '\030'; // main color | |
2061 text[textpointer] = 0; | |
2062 } | |
2003 } | 2063 } |
2004 else | 2064 else |
2005 { | 2065 { |
2006 if(stateUsed->warnings.sensorOutOfBounds[i]) | 2066 if(stateUsed->warnings.sensorOutOfBounds[i]) |
2007 text[textpointer++] = '\025'; // Warning Red | 2067 text[textpointer++] = '\025'; // Warning Red |
2410 { | 2470 { |
2411 textPointer = 0; | 2471 textPointer = 0; |
2412 TextR1[textPointer++] = '\a'; | 2472 TextR1[textPointer++] = '\a'; |
2413 TextR1[textPointer++] = '\001'; | 2473 TextR1[textPointer++] = '\001'; |
2414 TextR1[textPointer++] = ' '; | 2474 TextR1[textPointer++] = ' '; |
2415 textPointer += snprintf(&TextR1[textPointer],TEXTSIZE,"%f01.2",((float)(stateUsed->diveSettings.setpoint[actualBetterSetpointId()].setpoint_cbar))/100); | 2475 textPointer += snprintf(&TextR1[textPointer],TEXTSIZE,"%01.2f",(float)(stateUsed->diveSettings.setpoint[actualBetterSetpointId()].setpoint_cbar) / 100.0); |
2416 TextR1[textPointer++] = '?'; | 2476 TextR1[textPointer++] = '?'; |
2417 TextR1[textPointer++] = ' '; | 2477 TextR1[textPointer++] = ' '; |
2418 TextR1[textPointer++] = 0; | 2478 TextR1[textPointer++] = 0; |
2419 GFX_write_string_color(&FontT48,&t7c2,TextR1,0,CLUT_WarningYellow); | 2479 GFX_write_string_color(&FontT48,&t7c2,TextR1,0,CLUT_WarningYellow); |
2420 } | 2480 } |
2513 GFX_write_string(&FontT48,&t7c2,TextC2,0); // T54 has only numbers | 2573 GFX_write_string(&FontT48,&t7c2,TextC2,0); // T54 has only numbers |
2514 } | 2574 } |
2515 | 2575 |
2516 if(stateUsed->diveSettings.ccrOption) | 2576 if(stateUsed->diveSettings.ccrOption) |
2517 { | 2577 { |
2518 if(stateUsed->diveSettings.diveMode == DIVEMODE_CCR) | 2578 if(isLoopMode(stateUsed->diveSettings.diveMode)) |
2519 { | 2579 { |
2520 snprintf(TextC2,TEXTSIZE,"\020%01.2f",stateUsed->lifeData.ppO2); | 2580 snprintf(TextC2,TEXTSIZE,"\020%01.2f",stateUsed->lifeData.ppO2); |
2581 | |
2521 if(stateUsed->warnings.betterSetpoint && warning_count_high_time && (stateUsed->diveSettings.diveMode == DIVEMODE_CCR)) | 2582 if(stateUsed->warnings.betterSetpoint && warning_count_high_time && (stateUsed->diveSettings.diveMode == DIVEMODE_CCR)) |
2522 { | 2583 { |
2523 TextC2[0] = '\a'; // inverse instead of color \020 | 2584 TextC2[0] = '\a'; // inverse instead of color \020 |
2524 GFX_write_string_color(&FontT48,&t7c2,TextC2,0,CLUT_WarningYellow); | 2585 GFX_write_string_color(&FontT48,&t7c2,TextC2,0,CLUT_WarningYellow); |
2525 } | 2586 } |
2545 { | 2606 { |
2546 TextC2[0] = '\f'; | 2607 TextC2[0] = '\f'; |
2547 TextC2[1] = TXT_2BYTE; | 2608 TextC2[1] = TXT_2BYTE; |
2548 TextC2[2] = TXT2BYTE_WarnCnsHigh; | 2609 TextC2[2] = TXT2BYTE_WarnCnsHigh; |
2549 TextC2[3] = 0; | 2610 TextC2[3] = 0; |
2550 GFX_write_string_color(&FontT48,&t7c1,TextC2,0,CLUT_WarningRed); | 2611 GFX_write_string_color(&FontT42,&t7c1,TextC2,0,CLUT_WarningRed); |
2551 } | 2612 } |
2552 else | 2613 else |
2553 { | 2614 { |
2554 if(stateUsed->warnings.aGf) | 2615 if(stateUsed->warnings.aGf) |
2555 { | 2616 { |
2565 } | 2626 } |
2566 | 2627 |
2567 if(stateUsed->diveSettings.diveMode == DIVEMODE_CCR) | 2628 if(stateUsed->diveSettings.diveMode == DIVEMODE_CCR) |
2568 GFX_write_string(&FontT24,&t7c1,"\027\f\002" "CCR",0); | 2629 GFX_write_string(&FontT24,&t7c1,"\027\f\002" "CCR",0); |
2569 // GFX_write_string(&FontT24,&t7c1,"\f\177\177\x80" "CCR",0); | 2630 // GFX_write_string(&FontT24,&t7c1,"\f\177\177\x80" "CCR",0); |
2631 else | |
2632 if(stateUsed->diveSettings.diveMode == DIVEMODE_PSCR) | |
2633 GFX_write_string(&FontT24,&t7c1,"\027\f\002" "PSCR",0); | |
2570 else | 2634 else |
2571 if(stateUsed->diveSettings.ccrOption) | 2635 if(stateUsed->diveSettings.ccrOption) |
2572 GFX_write_string(&FontT24,&t7c1,"\f\002\024" "Bailout",0); | 2636 GFX_write_string(&FontT24,&t7c1,"\f\002\024" "Bailout",0); |
2573 // GFX_write_string(&FontT24,&t7c1,"\f\177\177\x80\024" "Bailout",0); | 2637 // GFX_write_string(&FontT24,&t7c1,"\f\177\177\x80\024" "Bailout",0); |
2574 } | 2638 } |
2659 | 2723 |
2660 if((stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE) && (selection_custom_field == LLC_GF)) /* no GF if in VPM mode */ | 2724 if((stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE) && (selection_custom_field == LLC_GF)) /* no GF if in VPM mode */ |
2661 { | 2725 { |
2662 selection_custom_field++; | 2726 selection_custom_field++; |
2663 } | 2727 } |
2664 if((selection_custom_field == LLC_ScrubberTime) && ((settingsGetPointer()->scrubTimerMode == SCRUB_TIMER_OFF) || (settingsGetPointer()->dive_mode != DIVEMODE_CCR))) | 2728 if((selection_custom_field == LLC_ScrubberTime) && ((settingsGetPointer()->scrubTimerMode == SCRUB_TIMER_OFF) || (!isLoopMode(settingsGetPointer()->dive_mode)))) |
2665 { | 2729 { |
2666 selection_custom_field++; | 2730 selection_custom_field++; |
2667 } | 2731 } |
2668 | 2732 #ifdef ENABLE_PSCR_MODE |
2733 if((selection_custom_field == LCC_SimPpo2) && (settingsGetPointer()->dive_mode != DIVEMODE_PSCR)) | |
2734 { | |
2735 selection_custom_field++; | |
2736 } | |
2737 #endif | |
2669 if(selection_custom_field >= LLC_END) | 2738 if(selection_custom_field >= LLC_END) |
2670 { | 2739 { |
2671 selection_custom_field = LLC_Empty; | 2740 selection_custom_field = LLC_Empty; |
2672 } | 2741 } |
2673 } | 2742 } |
2801 else | 2870 else |
2802 { | 2871 { |
2803 snprintf(text,TEXTSIZE,"\020%u\016\016%%\017", (settingsGetPointer()->scrubTimerCur * 100 / settingsGetPointer()->scrubTimerMax)); | 2872 snprintf(text,TEXTSIZE,"\020%u\016\016%%\017", (settingsGetPointer()->scrubTimerCur * 100 / settingsGetPointer()->scrubTimerMax)); |
2804 } | 2873 } |
2805 break; | 2874 break; |
2875 #ifdef ENABLE_PSCR_MODE | |
2876 case LCC_SimPpo2: | |
2877 headerText[2] = TXT_SimPpo2; | |
2878 snprintf(text,TEXTSIZE,"\020%.2f\016\016Bar\017",stateUsed->lifeData.ppo2Simulated_bar); | |
2879 break; | |
2880 #endif | |
2806 | 2881 |
2807 #ifdef ENABLE_BOTTLE_SENSOR | 2882 #ifdef ENABLE_BOTTLE_SENSOR |
2808 case LCC_BottleBar: | 2883 case LCC_BottleBar: |
2809 headerText[2] = TXT_AtemGasVorrat; | 2884 headerText[2] = TXT_AtemGasVorrat; |
2810 tinyHeaderFont = 1; | 2885 tinyHeaderFont = 1; |
3378 text[textpointer++] = '\n'; | 3453 text[textpointer++] = '\n'; |
3379 text[textpointer++] = '\r'; | 3454 text[textpointer++] = '\r'; |
3380 text[textpointer++] = TXT_FutureTTS; | 3455 text[textpointer++] = TXT_FutureTTS; |
3381 text[textpointer++] = '\n'; | 3456 text[textpointer++] = '\n'; |
3382 text[textpointer++] = '\r'; | 3457 text[textpointer++] = '\r'; |
3383 if((pSettings->scrubTimerMode != SCRUB_TIMER_OFF) && (pSettings->dive_mode == DIVEMODE_CCR)) | 3458 if((pSettings->scrubTimerMode != SCRUB_TIMER_OFF) && (isLoopMode(pSettings->dive_mode))) |
3384 { | 3459 { |
3385 text[textpointer++] = TXT_ScrubTime; | 3460 text[textpointer++] = TXT_ScrubTime; |
3386 | 3461 |
3387 } | 3462 } |
3388 text[textpointer++] = '\017'; | 3463 text[textpointer++] = '\017'; |
3427 if (pDecoinfoFuture->output_time_to_surface_seconds < 1000 * 60) | 3502 if (pDecoinfoFuture->output_time_to_surface_seconds < 1000 * 60) |
3428 textpointer += snprintf(&text[textpointer],10,"\020%i'", (pDecoinfoFuture->output_time_to_surface_seconds + 59) / 60); | 3503 textpointer += snprintf(&text[textpointer],10,"\020%i'", (pDecoinfoFuture->output_time_to_surface_seconds + 59) / 60); |
3429 else | 3504 else |
3430 textpointer += snprintf(&text[textpointer],10,"\020%ih", (pDecoinfoFuture->output_time_to_surface_seconds + 59) / 3600); | 3505 textpointer += snprintf(&text[textpointer],10,"\020%ih", (pDecoinfoFuture->output_time_to_surface_seconds + 59) / 3600); |
3431 | 3506 |
3432 if((pSettings->scrubTimerMode != SCRUB_TIMER_OFF) && (pSettings->dive_mode == DIVEMODE_CCR)) | 3507 if((pSettings->scrubTimerMode != SCRUB_TIMER_OFF) && (isLoopMode(pSettings->dive_mode))) |
3433 { | 3508 { |
3434 text[textpointer++] = '\n'; | 3509 text[textpointer++] = '\n'; |
3435 text[textpointer++] = '\r'; | 3510 text[textpointer++] = '\r'; |
3436 text[textpointer++] = '\t'; | 3511 text[textpointer++] = '\t'; |
3437 if(settingsGetPointer()->scrubTimerMode == SCRUB_TIMER_MINUTES) | 3512 if(settingsGetPointer()->scrubTimerMode == SCRUB_TIMER_MINUTES) |
3777 } | 3852 } |
3778 | 3853 |
3779 windowGimp.top = 40 + 32; | 3854 windowGimp.top = 40 + 32; |
3780 GFX_draw_image_monochrome(&t7screen, windowGimp, &ImgOSTC, 0); | 3855 GFX_draw_image_monochrome(&t7screen, windowGimp, &ImgOSTC, 0); |
3781 } | 3856 } |
3857 | |
3858 static uint16_t ChargerLog[60] = {10,10,10,10,10,10,10,10,10,10, | |
3859 10,10,10,10,10,10,10,10,10,10, | |
3860 10,10,10,10,10,10,10,10,10,10, | |
3861 10,10,10,10,10,10,10,10,10,10, | |
3862 10,10,10,10,10,10,10,10,10,10, | |
3863 10,10,10,10,10,10,10,10,10,10}; | |
3864 | |
3865 uint16_t LogDeltaCharge(float charge) | |
3866 { | |
3867 static uint8_t curIndex = 0; | |
3868 static float averageSpeed = 0.0; | |
3869 uint16_t level = 0; | |
3870 uint16_t completeSec = 0; | |
3871 | |
3872 if(charge > 0.003) | |
3873 { | |
3874 level = 2; | |
3875 } | |
3876 else if(charge > 0.0025) | |
3877 { | |
3878 level = 3; | |
3879 } | |
3880 else if(charge > 0.002) | |
3881 { | |
3882 level = 4; | |
3883 } | |
3884 else if(charge > 0.0015) | |
3885 { | |
3886 level = 5; | |
3887 } | |
3888 else if(charge > 0.001) | |
3889 { | |
3890 level = 6; | |
3891 } | |
3892 else if(charge > 0.0005) | |
3893 { | |
3894 level = 7; | |
3895 } | |
3896 else if(charge > 0.00) | |
3897 { | |
3898 level = 8; | |
3899 } | |
3900 else | |
3901 { | |
3902 level = 10; | |
3903 } | |
3904 if(curIndex < 59) | |
3905 { | |
3906 ChargerLog[curIndex++] = level; | |
3907 } | |
3908 else | |
3909 { | |
3910 memcpy (&ChargerLog[0],&ChargerLog[1],sizeof(ChargerLog) - 1); | |
3911 ChargerLog[curIndex] = level; | |
3912 } | |
3913 if(curIndex > 1) | |
3914 { | |
3915 averageSpeed = ((averageSpeed * (curIndex-1)) + charge) / curIndex; | |
3916 completeSec = (100.0 - stateUsed->lifeData.battery_charge) / averageSpeed; | |
3917 } | |
3918 else | |
3919 { | |
3920 completeSec = 0xffff; | |
3921 } | |
3922 return completeSec; | |
3923 } | |
3924 | |
3925 uint16_t* getChargeLog() | |
3926 { | |
3927 return ChargerLog; | |
3928 } | |
3929 | |
3930 void t7_ChargerView(void) | |
3931 { | |
3932 static float lastCharge = 0.0; | |
3933 float localCharge = 0.0; | |
3934 static uint32_t lastTick = 0; | |
3935 uint32_t curTick = 0; | |
3936 static float speed = 0.0; | |
3937 float deltatime = 0.0; | |
3938 | |
3939 char text[256+50]; | |
3940 uint8_t textpointer = 0; | |
3941 static uint16_t remainingSec = 0; | |
3942 uint16_t hoursto100 = 0; | |
3943 char indicator = '~'; | |
3944 | |
3945 point_t start, stop; | |
3946 | |
3947 SWindowGimpStyle wintemp; | |
3948 SSettings* pSettings; | |
3949 pSettings = settingsGetPointer(); | |
3950 | |
3951 t7cY0free.WindowLineSpacing = 28 + 48 + 14; | |
3952 t7cY0free.WindowY0 = t7cH.WindowY0 - 5 - 2 * t7cY0free.WindowLineSpacing; | |
3953 t7cY0free.WindowNumberOfTextLines = 3; | |
3954 | |
3955 | |
3956 if(pSettings->FlipDisplay) | |
3957 { | |
3958 t7cY0free.WindowY0 = t7cH.WindowY0 + 15; | |
3959 t7cY0free.WindowY1 = t7cY0free.WindowY0 + 250; | |
3960 } | |
3961 | |
3962 localCharge = stateUsed->lifeData.battery_charge; | |
3963 if(localCharge < 0.0) | |
3964 { | |
3965 localCharge *= -1.0; | |
3966 } | |
3967 | |
3968 if(stateUsed->chargeStatus != CHARGER_off) | |
3969 { | |
3970 if(lastCharge != localCharge) | |
3971 { | |
3972 curTick = HAL_GetTick(); | |
3973 deltatime = (curTick - lastTick); | |
3974 lastTick = curTick; | |
3975 if(lastCharge < localCharge) | |
3976 { | |
3977 speed = (localCharge - lastCharge) * 1000.0 / deltatime; | |
3978 } | |
3979 | |
3980 if(localCharge > 100.0) | |
3981 { | |
3982 localCharge = 100.0; | |
3983 } | |
3984 | |
3985 lastCharge = localCharge; | |
3986 } | |
3987 | |
3988 | |
3989 if(deltatime > 1000) | |
3990 { | |
3991 deltatime = 0; | |
3992 remainingSec = LogDeltaCharge(speed); | |
3993 speed = 0; | |
3994 } | |
3995 } | |
3996 textpointer += snprintf(&text[textpointer],50,"\n\r"); | |
3997 textpointer += snprintf(&text[textpointer],50,"\001%c\n\r",TXT_ChargeHour); | |
3998 | |
3999 GFX_write_string(&FontT24, &t7cY0free, text, 1); | |
4000 | |
4001 hoursto100 = remainingSec / 3600; /* reduce to hours */ | |
4002 if(hoursto100 < 1) | |
4003 { | |
4004 indicator = '<'; | |
4005 hoursto100 = 1; | |
4006 } | |
4007 | |
4008 if(!pSettings->FlipDisplay) | |
4009 { | |
4010 t7cY0free.WindowY0 -= 52; | |
4011 } | |
4012 else | |
4013 { | |
4014 t7cY0free.WindowY1 += 52; | |
4015 } | |
4016 | |
4017 if((stateUsed->lifeData.battery_charge > 0) && (stateUsed->chargeStatus != CHARGER_off)) | |
4018 { | |
4019 snprintf(text,60, | |
4020 "\001%0.2f\016\016%%\017\n\r" | |
4021 "\001%c%d\n\r" | |
4022 ,stateUsed->lifeData.battery_charge | |
4023 ,indicator | |
4024 ,hoursto100); | |
4025 } | |
4026 else | |
4027 { | |
4028 snprintf(text,60, | |
4029 "\001---\n\r" | |
4030 "\001---\n\r"); | |
4031 } | |
4032 GFX_write_string(&FontT42, &t7cY0free, text, 1); | |
4033 | |
4034 wintemp.left = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET + 50; | |
4035 wintemp.right = wintemp.left + CUSTOMBOX_SPACE_INSIDE - 100; | |
4036 | |
4037 | |
4038 if(!pSettings->FlipDisplay) | |
4039 { | |
4040 wintemp.top = 480 - t7l1.WindowY0 + 115; | |
4041 wintemp.bottom = wintemp.top + 100; | |
4042 } | |
4043 else | |
4044 { | |
4045 wintemp.top = t7l1.WindowY1 + 102; | |
4046 wintemp.bottom = wintemp.top + 100; | |
4047 } | |
4048 | |
4049 start.x = wintemp.left-5; | |
4050 start.y = 90; | |
4051 | |
4052 stop.x = wintemp.right + 5 - start.x; | |
4053 stop.y = 100; | |
4054 GFX_draw_box(&t7screen, start, stop,1, CLUT_Font020); | |
4055 | |
4056 if(stateUsed->chargeStatus != CHARGER_off) | |
4057 { | |
4058 GFX_graph_print(&t7screen, &wintemp, 1,1,0, 10, getChargeLog(), 60, CLUT_Font030, NULL); | |
4059 } | |
4060 else | |
4061 { | |
4062 GFX_graph_print(&t7screen, &wintemp, 1,1,0, 10, getChargeLog(), 60, CLUT_Font031, NULL); | |
4063 } | |
4064 | |
4065 } |