digital displays
This commit is contained in:
parent
710c4a0cd0
commit
147db823b7
@ -10,8 +10,28 @@ class DecimalWatchFaceView extends WatchUi.WatchFace {
|
|||||||
|
|
||||||
var isHighPowerMode = true; // Track if we're in high power mode
|
var isHighPowerMode = true; // Track if we're in high power mode
|
||||||
|
|
||||||
|
// Custom colors for AMOLED-friendly shadows
|
||||||
|
const VERY_DARK_RED = 0x330000; // #330000
|
||||||
|
const VERY_DARK_GRAY = 0x333333; // #333333
|
||||||
|
|
||||||
|
var useAmoledColors = false; // Whether to use darker colors
|
||||||
|
|
||||||
function initialize() {
|
function initialize() {
|
||||||
WatchFace.initialize();
|
WatchFace.initialize();
|
||||||
|
|
||||||
|
// Check if device likely has AMOLED screen
|
||||||
|
// AMOLED devices typically support always-on display and higher color depths
|
||||||
|
var deviceSettings = System.getDeviceSettings();
|
||||||
|
|
||||||
|
// Check if device supports always-on display (common on AMOLED)
|
||||||
|
// or if we can detect high color support
|
||||||
|
if (deviceSettings has :requiresBurnInProtection) {
|
||||||
|
useAmoledColors = deviceSettings.requiresBurnInProtection;
|
||||||
|
} else {
|
||||||
|
// Fallback: use darker colors if device has round screen (most AMOLED watches)
|
||||||
|
// This is a heuristic, but safer to use dark colors on all devices
|
||||||
|
useAmoledColors = true; // Use darker colors by default for burn-in protection
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load your resources here
|
// Load your resources here
|
||||||
@ -53,13 +73,10 @@ class DecimalWatchFaceView extends WatchUi.WatchFace {
|
|||||||
dc.setColor(Graphics.COLOR_BLACK, Graphics.COLOR_BLACK);
|
dc.setColor(Graphics.COLOR_BLACK, Graphics.COLOR_BLACK);
|
||||||
dc.clear();
|
dc.clear();
|
||||||
|
|
||||||
// Draw the watchface
|
// Draw the watchface (circle, ticks, numbers)
|
||||||
drawWatchFace(dc, useFiveHourMode, isMorning);
|
drawWatchFace(dc, useFiveHourMode, isMorning);
|
||||||
|
|
||||||
// Draw the hands
|
// Draw digital time displays (before hands so hands appear on top)
|
||||||
drawHand(dc, displayTime, useFiveHourMode, show12HourShadow, clockTime);
|
|
||||||
|
|
||||||
// Draw digital time displays
|
|
||||||
if (showNumericTime) {
|
if (showNumericTime) {
|
||||||
// Draw decimal time at bottom
|
// Draw decimal time at bottom
|
||||||
drawDigitalTime(dc, decimalTime);
|
drawDigitalTime(dc, decimalTime);
|
||||||
@ -69,6 +86,9 @@ class DecimalWatchFaceView extends WatchUi.WatchFace {
|
|||||||
drawTraditionalTime(dc, clockTime);
|
drawTraditionalTime(dc, clockTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw the hands last (on top of everything)
|
||||||
|
drawHand(dc, displayTime, useFiveHourMode, show12HourShadow, clockTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when this View is removed from the screen. Save the
|
// Called when this View is removed from the screen. Save the
|
||||||
@ -175,8 +195,7 @@ class DecimalWatchFaceView extends WatchUi.WatchFace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw center dot
|
// Note: Center dot is drawn in drawHand() to ensure it's on top of everything
|
||||||
dc.fillCircle(centerX, centerY, 5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw hour, minute, and second hands for current decimal time
|
// Draw hour, minute, and second hands for current decimal time
|
||||||
@ -200,11 +219,15 @@ class DecimalWatchFaceView extends WatchUi.WatchFace {
|
|||||||
var traditional60MinuteAngle = (minute / 60.0) * 360.0 - 90.0;
|
var traditional60MinuteAngle = (minute / 60.0) * 360.0 - 90.0;
|
||||||
var traditional60MinuteLength = radius - 45; // Same as decimal minute hand
|
var traditional60MinuteLength = radius - 45; // Same as decimal minute hand
|
||||||
|
|
||||||
|
// Choose colors based on screen type (darker for AMOLED burn-in protection)
|
||||||
|
var shadowGray = useAmoledColors ? VERY_DARK_GRAY : Graphics.COLOR_DK_GRAY;
|
||||||
|
var shadowRed = useAmoledColors ? VERY_DARK_RED : Graphics.COLOR_DK_RED;
|
||||||
|
|
||||||
// Draw traditional minute hand (dark gray)
|
// Draw traditional minute hand (dark gray)
|
||||||
drawSingleHand(dc, centerX, centerY, traditional60MinuteAngle, traditional60MinuteLength, 4, Graphics.COLOR_DK_GRAY);
|
drawSingleHand(dc, centerX, centerY, traditional60MinuteAngle, traditional60MinuteLength, 4, shadowGray);
|
||||||
|
|
||||||
// Draw traditional hour hand (dark red)
|
// Draw traditional hour hand (dark red)
|
||||||
drawSingleHand(dc, centerX, centerY, traditional12HourAngle, traditional12HourLength, 6, Graphics.COLOR_DK_RED);
|
drawSingleHand(dc, centerX, centerY, traditional12HourAngle, traditional12HourLength, 6, shadowRed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust scale based on mode
|
// Adjust scale based on mode
|
||||||
@ -223,9 +246,9 @@ class DecimalWatchFaceView extends WatchUi.WatchFace {
|
|||||||
|
|
||||||
// Calculate second hand (shows finer detail)
|
// Calculate second hand (shows finer detail)
|
||||||
// Only visible in high power mode
|
// Only visible in high power mode
|
||||||
var multiplier = useFiveHourMode ? 5.0 : 10.0;
|
var multiplier = 100.0; // 0.01 increments
|
||||||
var secondFractionalPart = (decimalTime * multiplier) - (decimalTime * multiplier).toNumber();
|
var secondFractionalPart = (decimalTime * multiplier) - (decimalTime * multiplier).toNumber();
|
||||||
var secondAngle = secondFractionalPart * 360.0 - 90.0;
|
var secondAngle = secondFractionalPart * 360.0 + 90.0;
|
||||||
var secondHandLength = radius - 35; // Longest hand
|
var secondHandLength = radius - 35; // Longest hand
|
||||||
|
|
||||||
// Draw second hand first (if in high power mode), so it appears behind other hands
|
// Draw second hand first (if in high power mode), so it appears behind other hands
|
||||||
@ -306,8 +329,11 @@ class DecimalWatchFaceView extends WatchUi.WatchFace {
|
|||||||
// Format as HH:MM
|
// Format as HH:MM
|
||||||
var timeString = hour12.format("%d") + ":" + minute.format("%02d");
|
var timeString = hour12.format("%d") + ":" + minute.format("%02d");
|
||||||
|
|
||||||
|
// Choose color based on screen type (darker for AMOLED burn-in protection)
|
||||||
|
var shadowGray = useAmoledColors ? VERY_DARK_GRAY : Graphics.COLOR_DK_GRAY;
|
||||||
|
|
||||||
// Draw at top center in dark gray
|
// Draw at top center in dark gray
|
||||||
dc.setColor(Graphics.COLOR_DK_GRAY, Graphics.COLOR_TRANSPARENT);
|
dc.setColor(shadowGray, Graphics.COLOR_TRANSPARENT);
|
||||||
dc.drawText(
|
dc.drawText(
|
||||||
width / 2,
|
width / 2,
|
||||||
height * 0.25,
|
height * 0.25,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user