Added separate tint colours for sleep times

This commit is contained in:
Mark van Renswoude 2024-11-25 16:59:59 +01:00
parent 91f0d0eb31
commit 5ea87e0d32
4 changed files with 22 additions and 14 deletions

View File

@ -1,7 +1,9 @@
{
"ArmHourTintHi": 9708837,
"ArmHourTintLo": 14429228,
"ArmHourTintSleep": 14429228,
"ArmMinuteTintHi": 9708837,
"ArmMinuteTintLo": 14429228,
"ArmMinuteTintSleep": 14429228,
"MinuteOrnamentOffset": 0
}

View File

@ -1,7 +1,9 @@
{
"ArmHourTintHi": 9708837,
"ArmHourTintLo": 3583350,
"ArmHourTintSleep": 1194278,
"ArmMinuteTintHi": 9708837,
"ArmMinuteTintLo": 6804128,
"ArmMinuteTintSleep": 2311732,
"MinuteOrnamentOffset": 130
}

View File

@ -28,7 +28,7 @@ class KittieCatsView extends WatchUi.WatchFace
private var sleepTime;
private var wakeTime;
private var sleeping = false;
private var highPowerMode = true;
function initialize()
@ -87,7 +87,9 @@ class KittieCatsView extends WatchUi.WatchFace
function onUpdate(dc as Dc) as Void
{
var highPowerMode = self.isHighPowerMode();
var isSleepMode = self.isSleepMode();
var highPowerMode = !isSleepMode && self.highPowerMode;
var clockTime = System.getClockTime();
var complications = ComplicationSubscriber.getSnapshot();
@ -110,10 +112,13 @@ class KittieCatsView extends WatchUi.WatchFace
// --- Arms ---
var hourTint = highPowerMode ? self.theme.ArmHourTintHi : isSleepMode ? self.theme.ArmHourTintSleep : self.theme.ArmHourTintLo;
var minuteTint = highPowerMode ? self.theme.ArmMinuteTintHi : isSleepMode ? self.theme.ArmMinuteTintSleep : self.theme.ArmMinuteTintLo;
// Base the hour arm on minutes as well, to prevent the arm from staying on the
// current hour tick mark right up until the 59th minute
self.drawArm(dc, self.armHour, 0, (clockTime.hour * 60) + clockTime.min, 720, highPowerMode ? self.theme.ArmHourTintHi : self.theme.ArmHourTintLo);
self.drawArm(dc, self.armMinute, 0, clockTime.min, 60, highPowerMode ? self.theme.ArmMinuteTintHi : self.theme.ArmMinuteTintLo);
self.drawArm(dc, self.armHour, 0, (clockTime.hour * 60) + clockTime.min, 720, hourTint);
self.drawArm(dc, self.armMinute, 0, clockTime.min, 60, minuteTint);
if (highPowerMode)
{
@ -148,23 +153,18 @@ class KittieCatsView extends WatchUi.WatchFace
function onExitSleep() as Void
{
self.sleeping = false;
self.highPowerMode = true;
}
function onEnterSleep() as Void
{
self.sleeping = true;
self.highPowerMode = false;
}
private function isHighPowerMode() as Boolean
private function isSleepMode() as Boolean
{
if (self.sleeping)
{
return false;
}
// Since isSleepMode is deprecated, base it on the wake and sleep times. Unfortunately this means
// the display will never be in high power mode between those times even if desired.
// Can't figure out how to check for the locked state either.
@ -174,10 +174,10 @@ class KittieCatsView extends WatchUi.WatchFace
if (now.greaterThan(today.add(self.sleepTime)) || now.lessThan(today.add(self.wakeTime)))
{
return false;
return true;
}
return true;
return false;
}

View File

@ -15,8 +15,10 @@ class Theme
public var ArmHourTintHi;
public var ArmHourTintLo;
public var ArmHourTintSleep;
public var ArmMinuteTintHi;
public var ArmMinuteTintLo;
public var ArmMinuteTintSleep;
function initialize(backgroundHi, backgroundLo, armHour, armMinute, armSecond, minuteOrnamentLo, variablesJsonResource)
@ -33,8 +35,10 @@ class Theme
var variables = Application.loadResource(variablesJsonResource) as Dictionary<String, Object>;
self.ArmHourTintHi = variables["ArmHourTintHi"];
self.ArmHourTintLo = variables["ArmHourTintLo"];
self.ArmHourTintSleep = variables["ArmHourTintSleep"];
self.ArmMinuteTintHi = variables["ArmMinuteTintHi"];
self.ArmMinuteTintLo = variables["ArmMinuteTintLo"];
self.ArmMinuteTintSleep = variables["ArmMinuteTintSleep"];
self.MinuteOrnamentOffset = variables["MinuteOrnamentOffset"];
}
}