Mercurial > public > ostc4
comparison Discovery/Src/tMenuEditSystem.c @ 805:dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
This can be used to time safety stops, or to prebreathe a CCR (or to boil your breakfast eggs if you are so inclined). The duration of the timer is configurable from 1 second to 9:59 minutes in the System menu.
The timer is started by switching to the custom view, and remaining on it until a 10 second delay has elapsed. Once the timer has started the custom view can be changed and the timer will continue running in the background.
After the timer has run out 'Finished' will be shown for 10 seconds in the timer custom view, and then automatic switching of custom views (if configured) resumes.
In surface mode the dive computer will not go to sleep while the timer is running, and a mini timer will be shown when the timer custom view is not showing. (mikeller)
author | heinrichsweikamp |
---|---|
date | Mon, 21 Aug 2023 17:20:07 +0200 |
parents | 9c65d226f4f6 |
children | e04d7dd199fb |
comparison
equal
deleted
inserted
replaced
804:391b3d420a39 | 805:dd7ce655db26 |
---|---|
99 uint8_t OnAction_TestCLog (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 99 uint8_t OnAction_TestCLog (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
100 */ | 100 */ |
101 | 101 |
102 /* Exported functions --------------------------------------------------------*/ | 102 /* Exported functions --------------------------------------------------------*/ |
103 | 103 |
104 static uint8_t OnAction_Timer(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
105 { | |
106 SSettings *settings = settingsGetPointer(); | |
107 uint8_t digitContentNew; | |
108 switch (action) { | |
109 case ACTION_BUTTON_ENTER: | |
110 | |
111 return digitContent; | |
112 case ACTION_BUTTON_ENTER_FINAL: | |
113 { | |
114 uint32_t timerM; | |
115 uint32_t timerS; | |
116 evaluateNewString(editId, &timerM, &timerS, 0, 0); | |
117 if (timerM > 9) { | |
118 timerM = 9; | |
119 } | |
120 if (timerS > 59) { | |
121 timerS = 59; | |
122 } | |
123 | |
124 uint16_t timerDurationS = 60 * timerM + timerS; | |
125 | |
126 if (timerDurationS < 1) { | |
127 timerDurationS = 1; | |
128 } | |
129 | |
130 if (timerDurationS != settings->timerDurationS) { | |
131 settings->timerDurationS = timerDurationS; | |
132 | |
133 disableTimer(); | |
134 | |
135 tMenuEdit_newInput(editId, settings->timerDurationS / 60, settings->timerDurationS % 60, 0, 0); | |
136 } | |
137 | |
138 return EXIT_TO_MENU; | |
139 } | |
140 case ACTION_BUTTON_NEXT: | |
141 digitContentNew = digitContent + 1; | |
142 if ((blockNumber == 1 && digitNumber == 0 && digitContentNew > '5') || digitContentNew > '9') { | |
143 digitContentNew = '0'; | |
144 } | |
145 | |
146 return digitContentNew; | |
147 case ACTION_BUTTON_BACK: | |
148 digitContentNew = digitContent - 1; | |
149 if (digitContentNew < '0') { | |
150 if (blockNumber == 1 && digitNumber == 0) { | |
151 digitContentNew = '5'; | |
152 } else { | |
153 digitContentNew = '9'; | |
154 } | |
155 } | |
156 | |
157 return digitContentNew; | |
158 } | |
159 | |
160 return EXIT_TO_MENU; | |
161 } | |
162 | |
163 | |
164 static void openEdit_Timer(void) | |
165 { | |
166 SSettings *settings = settingsGetPointer(); | |
167 | |
168 char text[32]; | |
169 snprintf(text, 32, "\001%c%c", TXT_2BYTE, TXT2BYTE_Timer); | |
170 write_topline(text); | |
171 | |
172 uint16_t yPos = ME_Y_LINE_BASE + get_globalState_Menu_Line() * ME_Y_LINE_STEP; | |
173 snprintf(text, 32, "%c%c", TXT_2BYTE, TXT2BYTE_Timer); | |
174 write_label_var(30, 299, yPos, &FontT48, text); | |
175 write_field_udigit(StMSYS_Timer, 300, 392, yPos, &FontT48, "#:##", settings->timerDurationS / 60, settings->timerDurationS % 60, 0, 0); | |
176 write_label_var(393, 800, yPos, &FontT48, "\016\016 [m:ss]\017"); | |
177 | |
178 write_buttonTextline(TXT2BYTE_ButtonMinus, TXT2BYTE_ButtonEnter, TXT2BYTE_ButtonPlus); | |
179 | |
180 setEvent(StMSYS_Timer, (uint32_t)OnAction_Timer); | |
181 startEdit(); | |
182 } | |
183 | |
184 | |
104 void openEdit_System(uint8_t line) | 185 void openEdit_System(uint8_t line) |
105 { | 186 { |
106 set_globalState_Menu_Line(line); | 187 set_globalState_Menu_Line(line); |
107 resetMenuEdit(CLUT_MenuPageSystem); | 188 resetMenuEdit(CLUT_MenuPageSystem); |
108 | 189 |
113 case 1: | 194 case 1: |
114 default: | 195 default: |
115 openEdit_DateTime(); | 196 openEdit_DateTime(); |
116 break; | 197 break; |
117 case 2: | 198 case 2: |
199 openEdit_Timer(); | |
200 break; | |
201 case 3: | |
118 openEdit_Language(); | 202 openEdit_Language(); |
119 break; | 203 break; |
120 case 3: | 204 case 4: |
121 openEdit_Design(); | 205 openEdit_Design(); |
122 break; | 206 break; |
123 case 4: | 207 case 5: |
124 openEdit_Information(); | 208 openEdit_Information(); |
125 break; | 209 break; |
126 case 5: | 210 case 6: |
127 openEdit_Reset(); | 211 openEdit_Reset(); |
128 break; | 212 break; |
129 /* | 213 /* |
130 case 3: | 214 case 3: |
131 openEdit_DecoFutureTTS(); | 215 openEdit_DecoFutureTTS(); |