einsatzprotokoll/source/ErrorView.mc
EiSiMo 257ca71d87 Return to menu on simulator after event, exit on device
Split _dismiss() into (:debug) popView and (:release) System.exit
so simulator testing stays fluid while device behavior is unchanged.
2026-04-17 01:33:35 +02:00

66 lines
2 KiB
MonkeyC
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Toybox.Attention;
import Toybox.Graphics;
import Toybox.Lang;
import Toybox.Timer;
import Toybox.WatchUi;
// Red warning flash when GPS acquisition fails. 3× vibration + German
// error message for Config.ERROR_DISPLAY_MS, then closes the app.
class ErrorView extends WatchUi.View {
private var _timer as Timer.Timer;
function initialize() {
View.initialize();
_timer = new Timer.Timer();
}
function onShow() as Void {
if (Attention has :vibrate) {
var profile = [
new Attention.VibeProfile(75, 250),
new Attention.VibeProfile(0, 150),
new Attention.VibeProfile(75, 250),
new Attention.VibeProfile(0, 150),
new Attention.VibeProfile(75, 250)
] as Array<Attention.VibeProfile>;
Attention.vibrate(profile);
}
_timer.start(method(:_dismiss), Config.ERROR_DISPLAY_MS, false);
}
function onHide() as Void {
_timer.stop();
}
(:debug)
function _dismiss() as Void {
WatchUi.popView(WatchUi.SLIDE_RIGHT);
}
(:release)
function _dismiss() as Void {
System.exit();
}
function onUpdate(dc as Dc) as Void {
dc.setColor(Config.COLOR_FG, Config.COLOR_BG);
dc.clear();
var cx = LayoutMetrics.centerX(dc);
var cy = LayoutMetrics.centerY(dc);
var min = LayoutMetrics.minDim(dc);
var iconRadius = (min * 0.1).toNumber();
var iconCy = (min * 0.25).toNumber();
dc.setColor(Config.COLOR_ERROR, Config.COLOR_BG);
dc.fillCircle(cx, iconCy, iconRadius);
dc.setColor(Config.COLOR_BG, Config.COLOR_ERROR);
dc.drawText(cx, iconCy, Graphics.FONT_MEDIUM, "!",
Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER);
dc.setColor(Config.COLOR_FG, Config.COLOR_BG);
var textCy = cy + (min * 0.08).toNumber();
TextUtils.drawResourceCentered(dc, Rez.Strings.error_gps, cx, textCy, Graphics.FONT_TINY);
}
}