5 dechour mode (am/pm)

This commit is contained in:
Gyuri Horák 2025-11-04 18:10:32 +01:00
parent 7803d440ea
commit 23c0bb95bc
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG Key ID: 4993F07B3EAE8D38
4 changed files with 72 additions and 18 deletions

3
resources/properties.xml Normal file
View File

@ -0,0 +1,3 @@
<properties>
<property id="UseFiveHourMode" type="boolean">false</property>
</properties>

View File

@ -0,0 +1,5 @@
<settings>
<setting propertyKey="@Properties.UseFiveHourMode" title="@Strings.FiveHourModeTitle">
<settingConfig type="boolean" />
</setting>
</settings>

View File

@ -1,3 +1,4 @@
<strings>
<string id="AppName">Decimal Day</string>
<string id="FiveHourModeTitle">5-Hour Mode</string>
</strings>

View File

@ -4,6 +4,7 @@ using Toybox.System;
using Toybox.Lang;
using Toybox.Time;
using Toybox.Time.Gregorian;
using Toybox.Application;
class DecimalWatchFaceView extends WatchUi.WatchFace {
@ -30,15 +31,31 @@ class DecimalWatchFaceView extends WatchUi.WatchFace {
var clockTime = System.getClockTime();
var decimalTime = computeDecimalTime(clockTime);
// Check if 5-hour mode is enabled
var useFiveHourMode = Application.Properties.getValue("UseFiveHourMode");
var displayTime = decimalTime;
var isMorning = true;
if (useFiveHourMode) {
// Convert 0-10 to 0-5 twice per day
if (decimalTime >= 5.0) {
displayTime = decimalTime - 5.0;
isMorning = false; // Afternoon
} else {
displayTime = decimalTime;
isMorning = true; // Morning
}
}
// Clear the screen
dc.setColor(Graphics.COLOR_BLACK, Graphics.COLOR_BLACK);
dc.clear();
// Draw the watchface
drawWatchFace(dc);
drawWatchFace(dc, useFiveHourMode, isMorning);
// Draw the hand
drawHand(dc, decimalTime);
// Draw the hands
drawHand(dc, displayTime, useFiveHourMode);
// Draw digital time display
drawDigitalTime(dc, decimalTime);
@ -74,7 +91,7 @@ class DecimalWatchFaceView extends WatchUi.WatchFace {
}
// Draw the watchface circle, tick marks, and numbers
function drawWatchFace(dc) {
function drawWatchFace(dc, useFiveHourMode, isMorning) {
var width = dc.getWidth();
var height = dc.getHeight();
var centerX = width / 2;
@ -83,10 +100,14 @@ class DecimalWatchFaceView extends WatchUi.WatchFace {
dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);
// Determine scale based on mode (5 or 10 hour)
var maxValue = useFiveHourMode ? 5.0 : 10.0;
var tickCount = useFiveHourMode ? 50 : 100; // 0.1 intervals
// Draw tick marks at 0.1 intervals (major at whole numbers, minor at 0.1)
for (var i = 0; i < 100; i++) {
for (var i = 0; i < tickCount; i++) {
var decimalValue = i * 0.1;
var angle = (decimalValue / 10.0) * 360.0 - 90.0; // -90 to start at top
var angle = (decimalValue / maxValue) * 360.0 - 90.0; // -90 to start at top
var angleRad = Math.toRadians(angle);
// Determine if this is a major tick (whole number) or minor tick
@ -108,9 +129,29 @@ class DecimalWatchFaceView extends WatchUi.WatchFace {
if (isMajor) {
var numberX = centerX + (radius - 38) * Math.cos(angleRad);
var numberY = centerY + (radius - 38) * Math.sin(angleRad);
var numberValue = (i / 10).toNumber(); // Convert to 0-9
var numberValue = (i / 10).toNumber(); // Position 0-4 or 0-9
if (useFiveHourMode) {
// 5-hour mode: show different numbers based on morning/afternoon
if (isMorning) {
// Morning: show 5,1,2,3,4 (5 at top, then 1,2,3,4)
if (numberValue == 0) {
numberValue = 10; // Display 10 instead of 0
numberValue = 5;
}
// else numberValue stays as 1,2,3,4
} else {
// Afternoon: show 10,6,7,8,9 (10 at top, then 6,7,8,9)
if (numberValue == 0) {
numberValue = 10;
} else {
numberValue = numberValue + 5; // 1->6, 2->7, 3->8, 4->9
}
}
} else {
// 10-hour mode: show 10 at top instead of 0
if (numberValue == 0) {
numberValue = 10;
}
}
dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);
@ -129,33 +170,37 @@ class DecimalWatchFaceView extends WatchUi.WatchFace {
}
// Draw hour, minute, and second hands for current decimal time
function drawHand(dc, decimalTime) {
function drawHand(dc, decimalTime, useFiveHourMode) {
var width = dc.getWidth();
var height = dc.getHeight();
var centerX = width / 2;
var centerY = height / 2;
var radius = (width < height ? width : height) / 2 - 10;
// Calculate hour hand (shows which decimal unit 0-9, one rotation per day)
var hourAngle = (decimalTime / 10.0) * 360.0 - 90.0;
var hourAngleRad = Math.toRadians(hourAngle);
// Adjust scale based on mode
var maxValue = useFiveHourMode ? 5.0 : 10.0;
// Calculate hour hand (shows which decimal unit)
// In 10-hour mode: one rotation per day
// In 5-hour mode: two rotations per day
var hourAngle = (decimalTime / maxValue) * 360.0 - 90.0;
var hourHandLength = radius - 70; // Shorter hand
// Calculate minute hand (shows fractional part, 10 rotations per day)
// Calculate minute hand (shows fractional part)
var fractionalPart = decimalTime - decimalTime.toNumber(); // Get decimal part
var minuteAngle = fractionalPart * 360.0 - 90.0;
var minuteAngleRad = Math.toRadians(minuteAngle);
var minuteHandLength = radius - 45; // Longer hand
// Calculate second hand (shows finer detail, 100 rotations per day)
// Calculate second hand (shows finer detail)
// Only visible in high power mode
var secondFractionalPart = (decimalTime * 10.0) - (decimalTime * 10.0).toNumber();
var multiplier = useFiveHourMode ? 5.0 : 10.0;
var secondFractionalPart = (decimalTime * multiplier) - (decimalTime * multiplier).toNumber();
var secondAngle = secondFractionalPart * 360.0 - 90.0;
var secondHandLength = radius - 35; // Longest hand
// Draw second hand first (if in high power mode), so it appears behind other hands
if (isHighPowerMode) {
drawSingleHand(dc, centerX, centerY, secondAngle, secondHandLength, 2, Graphics.COLOR_DK_GRAY);
drawSingleHand(dc, centerX, centerY, secondAngle, secondHandLength, 2, Graphics.COLOR_YELLOW);
}
// Draw minute hand (longer, thinner)