aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'wear_ui.cpp')
-rw-r--r--wear_ui.cpp56
1 files changed, 4 insertions, 52 deletions
diff --git a/wear_ui.cpp b/wear_ui.cpp
index e6937755..3ea1060e 100644
--- a/wear_ui.cpp
+++ b/wear_ui.cpp
@@ -184,55 +184,10 @@ void WearRecoveryUI::draw_screen_locked()
184 } 184 }
185} 185}
186 186
187// Keeps the progress bar updated, even when the process is otherwise busy. 187// TODO merge drawing routines with screen_ui
188void* WearRecoveryUI::progress_thread(void *cookie) { 188void WearRecoveryUI::update_progress_locked() {
189 self->progress_loop(); 189 draw_screen_locked();
190 return NULL; 190 gr_flip();
191}
192
193void WearRecoveryUI::progress_loop() {
194 double interval = 1.0 / animation_fps;
195 for (;;) {
196 double start = now();
197 pthread_mutex_lock(&updateMutex);
198 bool redraw = false;
199
200 if ((currentIcon == INSTALLING_UPDATE || currentIcon == ERASING)
201 && !show_text) {
202 if (!intro_done) {
203 if (current_frame >= intro_frames - 1) {
204 intro_done = true;
205 current_frame = 0;
206 } else {
207 current_frame++;
208 }
209 } else {
210 current_frame = (current_frame + 1) % loop_frames;
211 }
212 redraw = true;
213 }
214
215 // move the progress bar forward on timed intervals, if configured
216 int duration = progressScopeDuration;
217 if (progressBarType == DETERMINATE && duration > 0) {
218 double elapsed = now() - progressScopeTime;
219 float p = 1.0 * elapsed / duration;
220 if (p > 1.0) p = 1.0;
221 if (p > progress) {
222 progress = p;
223 redraw = true;
224 }
225 }
226
227 if (redraw) update_screen_locked();
228
229 pthread_mutex_unlock(&updateMutex);
230 double end = now();
231 // minimum of 20ms delay between frames
232 double delay = interval - (end-start);
233 if (delay < 0.02) delay = 0.02;
234 usleep(static_cast<useconds_t>(delay * 1000000));
235 }
236} 191}
237 192
238void WearRecoveryUI::InitTextParams() { 193void WearRecoveryUI::InitTextParams() {
@@ -253,9 +208,6 @@ void WearRecoveryUI::Init() {
253 backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE]; 208 backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE];
254 LoadBitmap("icon_error", &backgroundIcon[ERROR]); 209 LoadBitmap("icon_error", &backgroundIcon[ERROR]);
255 backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR]; 210 backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR];
256
257 pthread_create(&progress_t, NULL, progress_thread, NULL);
258
259} 211}
260 212
261void WearRecoveryUI::SetStage(int current, int max) 213void WearRecoveryUI::SetStage(int current, int max)