Hi!
I am trying to create a simple watch face. A simple picture plus showing the time. I would prefer analog, but having a digital format as well will be ideal for diversity.
The bitmap seems to be an issue when I try to run the app.
This is the notification it provides:
Error: Unexpected Type Error
Details: Failed invoking <symbol>
Stack:
- onUpdate() at /Users/ramirezla/eclipse-workspace/RUTA/source/RUTAView.mc:51 0x10000191
Can someone help shed some light on this?
The View.mc file:
using Toybox.WatchUi;
using Toybox.Graphics;
using Toybox.System;
using Toybox.Lang;
using Toybox.Application;
class TestView extends WatchUi.WatchFace {
var bitmap;
function initialize() {
WatchFace.initialize();
}
// Load your resources here
function onLayout(dc) {
bitmap = WatchUi.loadResource(Rez.Drawables.TestView);
}
// Called when this View is brought to the foreground. Restore
// the state of this View and prepare it to be shown. This includes
// loading resources into memory.
function onShow() {
}
// Update the view
function onUpdate(dc) {
// Get the current time and format it correctly
dc.setColor(Graphics.COLOR_BLACK, Graphics.COLOR_BLACK);
dc.clear();
dc.drawBitmap(50, 50, bitmap);
var timeFormat = "$1$:$2$";
var clockTime = System.getClockTime();
var hours = clockTime.hour;
if (!System.getDeviceSettings().is24Hour) {
if (hours > 12) {
hours = hours - 12;
}
} else {
if (Application.getApp().getProperty("UseMilitaryFormat")) {
timeFormat = "$1$$2$";
hours = hours.format("%02d");
}
}
var timeString = Lang.format(timeFormat, [hours, clockTime.min.format("%02d")]);
// Update the view
var view = View.findDrawableById("TimeLavel");
view.setColor(Application.getApp().getProperty("ForegroundColor"));
view.setText(timeString);
// Call the parent onUpdate function to redraw the layout
View.onUpdate(dc);
}
// Called when this View is removed from the screen. Save the
// state of this View here. This includes freeing resources from
// memory.
function onHide() {
}
// The user has just looked at their watch. Timers and animations may be started here.
function onExitSleep() {
}
// Terminate any active timers and prepare for slow updates.
function onEnterSleep() {
}
}