From acc579520b4213f45f95e0b2cdf6630ef9c50511 Mon Sep 17 00:00:00 2001 From: Radko Najman Date: Fri, 7 Oct 2022 09:29:56 +0200 Subject: [PATCH 1/4] optimization --- manifest.xml | 2 +- source/SmartArcsView.mc | 190 +++++++++++++++++----------------------- 2 files changed, 81 insertions(+), 111 deletions(-) diff --git a/manifest.xml b/manifest.xml index 9417c70..dc3be99 100644 --- a/manifest.xml +++ b/manifest.xml @@ -1,5 +1,5 @@ - + diff --git a/source/SmartArcsView.mc b/source/SmartArcsView.mc index 25c524e..61d6811 100644 --- a/source/SmartArcsView.mc +++ b/source/SmartArcsView.mc @@ -30,7 +30,7 @@ class SmartArcsView extends WatchUi.WatchFace { //TRYING TO KEEP AS MUCH PRE-COMPUTED VALUES AS POSSIBLE IN MEMORY TO SAVE CPU UTILIZATION //AND HOPEFULLY PROLONG BATTERY LIFE. PRE-COMPUTED VARIABLES DON'T NEED TO BE COMPUTED - //AGAIN AND AGAND ON EACH SCREEN UPDATE. THAT'S THE REASON FOR LONG LIST OF GLOBAL VARIABLES. + //AGAIN AND AGAIN ON EACH SCREEN UPDATE. THAT'S THE REASON FOR LONG LIST OF GLOBAL VARIABLES. //global variables var isAwake = false; @@ -42,12 +42,11 @@ class SmartArcsView extends WatchUi.WatchFace { var needComputeConstants; var lastMeasuredHR; var powerSaverDrawn = false; + var sunArcsOffset; //global variables for pre-computation var screenWidth; var screenRadius; - var arcRadius; - var twoPI = Math.PI * 2; var dualTimeLocationY; var dualTimeTimeY; var dualTimeAmPmY; @@ -65,7 +64,6 @@ class SmartArcsView extends WatchUi.WatchFace { var fontHeight; var startPowerSaverMin; var endPowerSaverMin; - var screenResolutionRatio; var powerSaverIconRatio; var sunriseStartAngle = 0; var sunriseEndAngle = 0; @@ -108,8 +106,6 @@ class SmartArcsView extends WatchUi.WatchFace { var showBatteryIndicator; var datePosition; var dateFormat; - var arcsStyle; - var arcPenWidth; var hrColor; var hrRefreshInterval; var powerSaver; @@ -152,9 +148,9 @@ class SmartArcsView extends WatchUi.WatchFace { var clockTime = System.getClockTime(); //refresh whole screen before drawing power saver icon - if (powerSaver && shouldPowerSave() && !isAwake && powerSaverDrawn) { + if (powerSaverDrawn && shouldPowerSave()) { //should be screen refreshed in given intervals? - if (powerSaverRefreshInterval == -999 || !(clockTime.min % powerSaverRefreshInterval == 0)) { + if (powerSaverRefreshInterval == offSettingFlag || !(clockTime.min % powerSaverRefreshInterval == 0)) { return; } } @@ -194,19 +190,47 @@ class SmartArcsView extends WatchUi.WatchFace { targetDc.fillCircle(screenRadius, screenRadius, screenRadius + 2); if (showBatteryIndicator) { - drawBattery(targetDc); + var batStat = System.getSystemStats().battery; + if (oneColor != offSettingFlag) { + drawSmartArc(targetDc, oneColor, Graphics.ARC_CLOCKWISE, 180, 180 - 0.9 * batStat); + } else { + if (batStat > 30) { + drawSmartArc(targetDc, battery100Color, Graphics.ARC_CLOCKWISE, 180, 180 - 0.9 * batStat); + drawSmartArc(targetDc, battery30Color, Graphics.ARC_CLOCKWISE, 180, 153); + drawSmartArc(targetDc, battery15Color, Graphics.ARC_CLOCKWISE, 180, 166.5); + } else if (batStat <= 30 && batStat > 15) { + drawSmartArc(targetDc, battery30Color, Graphics.ARC_CLOCKWISE, 180, 180 - 0.9 * batStat); + drawSmartArc(targetDc, battery15Color, Graphics.ARC_CLOCKWISE, 180, 166.5); + } else { + drawSmartArc(targetDc, battery15Color, Graphics.ARC_CLOCKWISE, 180, 180 - 0.9 * batStat); + } + } } - if (notificationColor != offSettingFlag) { - drawNotifications(targetDc, deviceSettings.notificationCount); + + var itemCount = deviceSettings.notificationCount; + if (notificationColor != offSettingFlag && itemCount > 0) { + if (itemCount < 11) { + drawSmartArc(targetDc, notificationColor, Graphics.ARC_CLOCKWISE, 90, 90 - 30 - ((itemCount - 1) * 6)); + } else { + drawSmartArc(targetDc, notificationColor, Graphics.ARC_CLOCKWISE, 90, 0); + } } - if (bluetoothColor != offSettingFlag) { - drawBluetooth(targetDc, deviceSettings.phoneConnected); + + if (bluetoothColor != offSettingFlag && deviceSettings.phoneConnected) { + drawSmartArc(targetDc, bluetoothColor, Graphics.ARC_CLOCKWISE, 0, -30); } - if (dndColor != offSettingFlag) { - drawDoNotDisturb(targetDc, deviceSettings.doNotDisturb); + + if (dndColor != offSettingFlag && deviceSettings.doNotDisturb) { + drawSmartArc(targetDc, dndColor, Graphics.ARC_COUNTER_CLOCKWISE, 270, -60); } - if (alarmColor != offSettingFlag) { - drawAlarms(targetDc, deviceSettings.alarmCount); + + itemCount = deviceSettings.alarmCount; + if (alarmColor != offSettingFlag && itemCount > 0) { + if (itemCount < 11) { + drawSmartArc(targetDc, alarmColor, Graphics.ARC_CLOCKWISE, 270, 270 - 30 - ((itemCount - 1) * 6)); + } else { + drawSmartArc(targetDc, alarmColor, Graphics.ARC_CLOCKWISE, 270, 0); + } } drawSun(targetDc); @@ -252,7 +276,7 @@ class SmartArcsView extends WatchUi.WatchFace { //output the offscreen buffers to the main display if required. drawBackground(dc); - if (powerSaver && shouldPowerSave() && !isAwake) { + if (shouldPowerSave()) { drawPowerSaverIcon(dc); return; } @@ -323,7 +347,6 @@ class SmartArcsView extends WatchUi.WatchFace { dualTimeColor = app.getProperty("dualTimeColor"); dateColor = app.getProperty("dateColor"); hrColor = app.getProperty("hrColor"); - arcsStyle = app.getProperty("arcsStyle"); useBatterySecondHandColor = app.getProperty("useBatterySecondHandColor"); @@ -403,8 +426,8 @@ class SmartArcsView extends WatchUi.WatchFace { secondHandLength = (100 * screenResolutionRatio).toNumber(); handsTailLength = (15 * screenResolutionRatio).toNumber(); - powerSaverIconRatio = 1.0 * screenResolutionRatio; //big icon - if (powerSaverRefreshInterval != -999) { + powerSaverIconRatio = screenResolutionRatio; //big icon + if (powerSaverRefreshInterval != offSettingFlag) { powerSaverIconRatio = 0.6 * screenResolutionRatio; //small icon } @@ -459,13 +482,6 @@ class SmartArcsView extends WatchUi.WatchFace { } } - if (arcsStyle == 2) { - arcPenWidth = screenRadius; - } else { - arcPenWidth = 10; - } - arcRadius = screenRadius - (arcPenWidth / 2); - computeSunConstants(); //constants pre-computed, doesn't need to be computed again @@ -493,7 +509,7 @@ class SmartArcsView extends WatchUi.WatchFace { //to save the memory compute only a quarter of the ticks, the rest will be mirrored. //I believe it will still save some CPU utilization for (var i = 0; i < 16; i++) { - angle = i * twoPI / 60.0; + angle = i * Math.PI * 2 / 60.0; if ((i % 15) == 0) { //quarter tick if (ticks15MinWidth > 0) { ticks[i] = computeTickRectangle(angle, 20, ticks15MinWidth); @@ -531,68 +547,10 @@ class SmartArcsView extends WatchUi.WatchFace { return rect; } - function drawBattery(dc) { - var batStat = System.getSystemStats().battery; - dc.setPenWidth(arcPenWidth); - if (oneColor != offSettingFlag) { - dc.setColor(oneColor, Graphics.COLOR_TRANSPARENT); - dc.drawArc(screenRadius, screenRadius, arcRadius, Graphics.ARC_CLOCKWISE, 180, 180 - 0.9 * batStat); - } else { - if (batStat > 30) { - dc.setColor(battery100Color, Graphics.COLOR_TRANSPARENT); - dc.drawArc(screenRadius, screenRadius, arcRadius, Graphics.ARC_CLOCKWISE, 180, 180 - 0.9 * batStat); - dc.setColor(battery30Color, Graphics.COLOR_TRANSPARENT); - dc.drawArc(screenRadius, screenRadius, arcRadius, Graphics.ARC_CLOCKWISE, 180, 153); - dc.setColor(battery15Color, Graphics.COLOR_TRANSPARENT); - dc.drawArc(screenRadius, screenRadius, arcRadius, Graphics.ARC_CLOCKWISE, 180, 166.5); - } else if (batStat <= 30 && batStat > 15){ - dc.setColor(battery30Color, Graphics.COLOR_TRANSPARENT); - dc.drawArc(screenRadius, screenRadius, arcRadius, Graphics.ARC_CLOCKWISE, 180, 180 - 0.9 * batStat); - dc.setColor(battery15Color, Graphics.COLOR_TRANSPARENT); - dc.drawArc(screenRadius, screenRadius, arcRadius, Graphics.ARC_CLOCKWISE, 180, 166.5); - } else { - dc.setColor(battery15Color, Graphics.COLOR_TRANSPARENT); - dc.drawArc(screenRadius, screenRadius, arcRadius, Graphics.ARC_CLOCKWISE, 180, 180 - 0.9 * batStat); - } - } - } - - function drawNotifications(dc, notifications) { - if (notifications > 0) { - drawItems(dc, notifications, 90, notificationColor); - } - } - - function drawBluetooth(dc, phoneConnected) { - if (phoneConnected) { - dc.setColor(bluetoothColor, Graphics.COLOR_TRANSPARENT); - dc.setPenWidth(arcPenWidth); - dc.drawArc(screenRadius, screenRadius, arcRadius, Graphics.ARC_CLOCKWISE, 0, -30); - } - } - - function drawDoNotDisturb(dc, doNotDisturb) { - if (doNotDisturb) { - dc.setColor(dndColor, Graphics.COLOR_TRANSPARENT); - dc.setPenWidth(arcPenWidth); - dc.drawArc(screenRadius, screenRadius, arcRadius, Graphics.ARC_COUNTER_CLOCKWISE, 270, -60); - } - } - - function drawAlarms(dc, alarms) { - if (alarms > 0) { - drawItems(dc, alarms, 270, alarmColor); - } - } - - function drawItems(dc, count, angle, color) { + function drawSmartArc(dc, color, arcDirection, startAngle, endAngle) { + dc.setPenWidth(10); dc.setColor(color, Graphics.COLOR_TRANSPARENT); - dc.setPenWidth(arcPenWidth); - if (count < 11) { - dc.drawArc(screenRadius, screenRadius, arcRadius, Graphics.ARC_CLOCKWISE, angle, angle - 30 - ((count - 1) * 6)); - } else { - dc.drawArc(screenRadius, screenRadius, arcRadius, Graphics.ARC_CLOCKWISE, angle, angle - 90); - } + dc.drawArc(screenRadius, screenRadius, screenRadius - 5, arcDirection, startAngle, endAngle); } function drawTicks(dc) { @@ -714,7 +672,7 @@ class SmartArcsView extends WatchUi.WatchFace { //Handle the partial update event function onPartialUpdate(dc) { //refresh whole screen before drawing power saver icon - if (powerSaver && shouldPowerSave() && !isAwake && powerSaverDrawn) { + if (powerSaverDrawn && shouldPowerSave()) { return; } @@ -785,7 +743,7 @@ class SmartArcsView extends WatchUi.WatchFace { drawHR(dc, refreshHR); } - if (powerSaver && shouldPowerSave() && !isAwake) { + if (shouldPowerSave()) { requestUpdate(); } } @@ -980,21 +938,24 @@ class SmartArcsView extends WatchUi.WatchFace { } function shouldPowerSave() { - var refreshDisplay = true; - var time = System.getClockTime(); - var timeMinOfDay = (time.hour * 60) + time.min; - - if (startPowerSaverMin <= endPowerSaverMin) { - if ((startPowerSaverMin <= timeMinOfDay) && (timeMinOfDay < endPowerSaverMin)) { - refreshDisplay = false; + if (powerSaver && !isAwake) { + var refreshDisplay = true; + var time = System.getClockTime(); + var timeMinOfDay = (time.hour * 60) + time.min; + + if (startPowerSaverMin <= endPowerSaverMin) { + if ((startPowerSaverMin <= timeMinOfDay) && (timeMinOfDay < endPowerSaverMin)) { + refreshDisplay = false; + } + } else { + if ((startPowerSaverMin <= timeMinOfDay) || (timeMinOfDay < endPowerSaverMin)) { + refreshDisplay = false; + } } + return !refreshDisplay; } else { - if ((startPowerSaverMin <= timeMinOfDay) || (timeMinOfDay < endPowerSaverMin)) { - refreshDisplay = false; - } + return false; } - - return !refreshDisplay; } function drawPowerSaverIcon(dc) { @@ -1023,7 +984,7 @@ class SmartArcsView extends WatchUi.WatchFace { var loc = posInfo.position.toRadians(); var hasLocation = (loc[0].format("%.2f").equals("3.14") && loc[1].format("%.2f").equals("3.14")) || (loc[0] == 0 && loc[1] == 0) ? false : true; - if (!hasLocation && locationLatitude != -999) { + if (!hasLocation && locationLatitude != offSettingFlag) { loc[0] = locationLatitude; loc[1] = locationLongitude; } @@ -1039,13 +1000,22 @@ class SmartArcsView extends WatchUi.WatchFace { sunriseEndAngle = computeSunAngle(sc.calculate(time_now, loc, SunCalc.SUNRISE)); sunsetStartAngle = computeSunAngle(sc.calculate(time_now, loc, SunCalc.SUNSET)); sunsetEndAngle = computeSunAngle(sc.calculate(time_now, loc, SunCalc.DUSK)); + + if (((sunriseStartAngle < sunsetStartAngle) && (sunriseStartAngle > sunsetEndAngle)) || + ((sunriseEndAngle < sunsetStartAngle) && (sunriseEndAngle > sunsetEndAngle)) || + ((sunsetStartAngle < sunriseStartAngle) && (sunsetStartAngle > sunriseEndAngle)) || + ((sunsetEndAngle < sunriseStartAngle) && (sunsetEndAngle > sunriseEndAngle))) { + sunArcsOffset = 13; + } else { + sunArcsOffset = 17; + } } } function computeSunAngle(time) { var timeInfo = Time.Gregorian.info(time, Time.FORMAT_SHORT); var angle = ((timeInfo.hour % 12) * 60.0) + timeInfo.min; - angle = angle / (12 * 60.0) * twoPI; + angle = angle / (12 * 60.0) * Math.PI * 2; return -(angle - Math.PI/2) * 180 / Math.PI; } @@ -1053,7 +1023,7 @@ class SmartArcsView extends WatchUi.WatchFace { dc.setPenWidth(7); //draw sunrise - if (sunriseColor != offSettingFlag && locationLatitude != -999) { + if (sunriseColor != offSettingFlag && locationLatitude != offSettingFlag) { dc.setColor(sunriseColor, Graphics.COLOR_TRANSPARENT); if (sunriseStartAngle > sunriseEndAngle) { dc.drawArc(screenRadius, screenRadius, screenRadius - 17, Graphics.ARC_CLOCKWISE, sunriseStartAngle, sunriseEndAngle); @@ -1063,12 +1033,12 @@ class SmartArcsView extends WatchUi.WatchFace { } //draw sunset - if (sunsetColor != offSettingFlag && locationLatitude != -999) { + if (sunsetColor != offSettingFlag && locationLatitude != offSettingFlag) { dc.setColor(sunsetColor, Graphics.COLOR_TRANSPARENT); if (sunsetStartAngle > sunsetEndAngle) { - dc.drawArc(screenRadius, screenRadius, screenRadius - 13, Graphics.ARC_CLOCKWISE, sunsetStartAngle, sunsetEndAngle); + dc.drawArc(screenRadius, screenRadius, screenRadius - sunArcsOffset, Graphics.ARC_CLOCKWISE, sunsetStartAngle, sunsetEndAngle); } else { - dc.drawArc(screenRadius, screenRadius, screenRadius - 13, Graphics.ARC_COUNTER_CLOCKWISE, sunsetStartAngle, sunsetEndAngle); + dc.drawArc(screenRadius, screenRadius, screenRadius - sunArcsOffset, Graphics.ARC_COUNTER_CLOCKWISE, sunsetStartAngle, sunsetEndAngle); } } } From 96e10a737b40818e717183973ca2d14044d68780 Mon Sep 17 00:00:00 2001 From: Radko Najman Date: Fri, 7 Oct 2022 10:49:01 +0200 Subject: [PATCH 2/4] optimization --- manifest.xml | 2 +- resources/settings/properties.xml | 2 +- source/SmartArcsView.mc | 18 +++++++++++------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/manifest.xml b/manifest.xml index dc3be99..fb6a27c 100644 --- a/manifest.xml +++ b/manifest.xml @@ -1,5 +1,5 @@ - + diff --git a/resources/settings/properties.xml b/resources/settings/properties.xml index 9289356..655234f 100644 --- a/resources/settings/properties.xml +++ b/resources/settings/properties.xml @@ -52,7 +52,7 @@ -999 - 1573331777 + 1665387621 -999 diff --git a/source/SmartArcsView.mc b/source/SmartArcsView.mc index 61d6811..65de4dc 100644 --- a/source/SmartArcsView.mc +++ b/source/SmartArcsView.mc @@ -97,6 +97,7 @@ class SmartArcsView extends WatchUi.WatchFace { var ticks15MinWidth; var eventName; var eventDate; + var daysToEvent; var dualTimeOffset; var dualTimeUTC; var dualTimeLocation; @@ -169,8 +170,6 @@ class SmartArcsView extends WatchUi.WatchFace { computeSunConstants(); } - var today = Time.today(); - //we always want to refresh the full screen when we get a regular onUpdate call. fullScreenRefresh = true; @@ -244,10 +243,11 @@ class SmartArcsView extends WatchUi.WatchFace { } if (eventColor != offSettingFlag) { - //compute days to event - var eventDateMoment = new Time.Moment(eventDate); - var daysToEvent = (eventDateMoment.value() - today.value()) / Gregorian.SECONDS_PER_DAY.toFloat(); - + if (clockTime.hour == 0 && clockTime.min == 0) { + //compute days to event + var eventDateMoment = new Time.Moment(eventDate); + daysToEvent = (eventDateMoment.value() - Time.today().value()) / Gregorian.SECONDS_PER_DAY.toFloat(); + } if (daysToEvent < 0) { //hide event when it is over eventColor = offSettingFlag; @@ -262,7 +262,7 @@ class SmartArcsView extends WatchUi.WatchFace { } if (dateColor != offSettingFlag) { - drawDate(targetDc, today); + drawDate(targetDc, Time.today()); } if (handsOnTop) { @@ -353,6 +353,10 @@ class SmartArcsView extends WatchUi.WatchFace { if (eventColor != offSettingFlag) { eventName = app.getProperty("eventName"); eventDate = app.getProperty("eventDate"); + + //compute days to event + var eventDateMoment = new Time.Moment(eventDate); + daysToEvent = (eventDateMoment.value() - Time.today().value()) / Gregorian.SECONDS_PER_DAY.toFloat(); } if (dualTimeColor != offSettingFlag) { From 8292202cfefccfa839df8951c3a867fef6ca3220 Mon Sep 17 00:00:00 2001 From: Radko Najman Date: Tue, 11 Oct 2022 08:31:09 +0200 Subject: [PATCH 3/4] optimization --- manifest.xml | 2 +- source/SmartArcsView.mc | 25 ++++++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/manifest.xml b/manifest.xml index fb6a27c..ce3aaf1 100644 --- a/manifest.xml +++ b/manifest.xml @@ -1,5 +1,5 @@ - + diff --git a/source/SmartArcsView.mc b/source/SmartArcsView.mc index 65de4dc..1e502b7 100644 --- a/source/SmartArcsView.mc +++ b/source/SmartArcsView.mc @@ -71,6 +71,7 @@ class SmartArcsView extends WatchUi.WatchFace { var sunsetEndAngle = 0; var locationLatitude; var locationLongitude; + var dateInfo; //user settings var bgColor; @@ -168,6 +169,8 @@ class SmartArcsView extends WatchUi.WatchFace { //recompute sunrise/sunset constants every hour - to address new location when traveling if (clockTime.min == 0) { computeSunConstants(); + //not needed to get date on every refresh event + dateInfo = Gregorian.info(Time.today(), Time.FORMAT_MEDIUM); } //we always want to refresh the full screen when we get a regular onUpdate call. @@ -243,11 +246,11 @@ class SmartArcsView extends WatchUi.WatchFace { } if (eventColor != offSettingFlag) { - if (clockTime.hour == 0 && clockTime.min == 0) { + if (clockTime.hour == 0 && clockTime.min == 0) { //compute days to event var eventDateMoment = new Time.Moment(eventDate); daysToEvent = (eventDateMoment.value() - Time.today().value()) / Gregorian.SECONDS_PER_DAY.toFloat(); - } + } if (daysToEvent < 0) { //hide event when it is over eventColor = offSettingFlag; @@ -262,7 +265,7 @@ class SmartArcsView extends WatchUi.WatchFace { } if (dateColor != offSettingFlag) { - drawDate(targetDc, Time.today()); + drawDate(targetDc); } if (handsOnTop) { @@ -486,6 +489,8 @@ class SmartArcsView extends WatchUi.WatchFace { } } + dateInfo = Gregorian.info(Time.today(), Time.FORMAT_MEDIUM); + computeSunConstants(); //constants pre-computed, doesn't need to be computed again @@ -882,20 +887,18 @@ class SmartArcsView extends WatchUi.WatchFace { } } - function drawDate(dc, today) { - var info = Gregorian.info(today, Time.FORMAT_MEDIUM); - + function drawDate(dc) { var dateString; switch (dateFormat) { - case 0: dateString = info.day; + case 0: dateString = dateInfo.day; break; - case 1: dateString = Lang.format("$1$ $2$", [info.day_of_week.substring(0, 3), info.day]); + case 1: dateString = Lang.format("$1$ $2$", [dateInfo.day_of_week.substring(0, 3), dateInfo.day]); break; - case 2: dateString = Lang.format("$1$ $2$", [info.day, info.day_of_week.substring(0, 3)]); + case 2: dateString = Lang.format("$1$ $2$", [dateInfo.day, dateInfo.day_of_week.substring(0, 3)]); break; - case 3: dateString = Lang.format("$1$ $2$", [info.day, info.month.substring(0, 3)]); + case 3: dateString = Lang.format("$1$ $2$", [dateInfo.day, dateInfo.month.substring(0, 3)]); break; - case 4: dateString = Lang.format("$1$ $2$", [info.month.substring(0, 3), info.day]); + case 4: dateString = Lang.format("$1$ $2$", [dateInfo.month.substring(0, 3), dateInfo.day]); break; } dc.setColor(dateColor, Graphics.COLOR_TRANSPARENT); From 3634f87ae732156681748ed0b13c98f0b4a7ba34 Mon Sep 17 00:00:00 2001 From: Radko Najman Date: Mon, 24 Oct 2022 10:37:04 +0200 Subject: [PATCH 4/4] code optimization --- CHANGELOG.md | 3 +++ manifest.xml | 2 +- manifest.xml.beta | 2 +- manifest.xml.prod | 2 +- resources/settings/properties.xml | 13 ------------ source/SmartArcsView.mc | 35 +++++++++++++------------------ 6 files changed, 20 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aba7a5e..c18cbac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 1.7.1 (October 24, 2022) +* code optimization + # 1.7.0 (April 25, 2022) * 64 colors support diff --git a/manifest.xml b/manifest.xml index ce3aaf1..505a9f1 100644 --- a/manifest.xml +++ b/manifest.xml @@ -1,5 +1,5 @@ - + diff --git a/manifest.xml.beta b/manifest.xml.beta index 7a497e4..6868481 100644 --- a/manifest.xml.beta +++ b/manifest.xml.beta @@ -1,5 +1,5 @@ - + diff --git a/manifest.xml.prod b/manifest.xml.prod index 9417c70..505a9f1 100644 --- a/manifest.xml.prod +++ b/manifest.xml.prod @@ -1,5 +1,5 @@ - + diff --git a/resources/settings/properties.xml b/resources/settings/properties.xml index 655234f..bc95957 100644 --- a/resources/settings/properties.xml +++ b/resources/settings/properties.xml @@ -64,8 +64,6 @@ 1 0xAAAAAA - 1 - -999 3 @@ -208,10 +206,6 @@ - Off - - Indicators style - Classic - Extravagant (experimental) - Heart rate color (off or color) Heart rate refresh interval (seconds) 1 @@ -612,13 +606,6 @@ - - - @Strings.arcsDecent - @Strings.arcsExtravagant - - - @Strings.off diff --git a/source/SmartArcsView.mc b/source/SmartArcsView.mc index 1e502b7..7fecd87 100644 --- a/source/SmartArcsView.mc +++ b/source/SmartArcsView.mc @@ -34,12 +34,12 @@ class SmartArcsView extends WatchUi.WatchFace { //global variables var isAwake = false; + var partialUpdatesAllowed = false; var curClip; var fullScreenRefresh; var offscreenBuffer; var offSettingFlag = -999; var font = Graphics.FONT_TINY; - var needComputeConstants; var lastMeasuredHR; var powerSaverDrawn = false; var sunArcsOffset; @@ -117,9 +117,7 @@ class SmartArcsView extends WatchUi.WatchFace { var sunsetColor; function initialize() { - loadUserSettings(); WatchFace.initialize(); - fullScreenRefresh = true; } //load resources here @@ -136,6 +134,12 @@ class SmartArcsView extends WatchUi.WatchFace { offscreenBuffer = null; } + partialUpdatesAllowed = (Toybox.WatchUi.WatchFace has :onPartialUpdate); + loadUserSettings(); + computeConstants(dc); + computeSunConstants(); + fullScreenRefresh = true; + curClip = null; } @@ -161,13 +165,8 @@ class SmartArcsView extends WatchUi.WatchFace { var deviceSettings = System.getDeviceSettings(); - //compute what does not need to be computed on each update - if (needComputeConstants) { - computeConstants(dc); - } - - //recompute sunrise/sunset constants every hour - to address new location when traveling if (clockTime.min == 0) { + //recompute sunrise/sunset constants every hour - to address new location when traveling computeSunConstants(); //not needed to get date on every refresh event dateInfo = Gregorian.info(Time.today(), Time.FORMAT_MEDIUM); @@ -235,7 +234,9 @@ class SmartArcsView extends WatchUi.WatchFace { } } - drawSun(targetDc); + if (locationLatitude != offSettingFlag) { + drawSun(targetDc); + } if (ticks != null) { drawTicks(targetDc); @@ -284,7 +285,7 @@ class SmartArcsView extends WatchUi.WatchFace { return; } - if ((Toybox.WatchUi.WatchFace has :onPartialUpdate) && (hrColor != offSettingFlag || showSecondHand == 2)) { + if (partialUpdatesAllowed && (hrColor != offSettingFlag || showSecondHand == 2)) { onPartialUpdate(dc); } @@ -414,9 +415,6 @@ class SmartArcsView extends WatchUi.WatchFace { locationLatitude = app.getProperty("locationLatitude"); locationLongitude = app.getProperty("locationLongitude"); - //ensure that constants will be pre-computed - needComputeConstants = true; - //ensure that screen will be refreshed when settings are changed powerSaverDrawn = false; } @@ -490,11 +488,6 @@ class SmartArcsView extends WatchUi.WatchFace { } dateInfo = Gregorian.info(Time.today(), Time.FORMAT_MEDIUM); - - computeSunConstants(); - - //constants pre-computed, doesn't need to be computed again - needComputeConstants = false; } function parsePowerSaverTime(time) { @@ -1030,7 +1023,7 @@ class SmartArcsView extends WatchUi.WatchFace { dc.setPenWidth(7); //draw sunrise - if (sunriseColor != offSettingFlag && locationLatitude != offSettingFlag) { + if (sunriseColor != offSettingFlag) { dc.setColor(sunriseColor, Graphics.COLOR_TRANSPARENT); if (sunriseStartAngle > sunriseEndAngle) { dc.drawArc(screenRadius, screenRadius, screenRadius - 17, Graphics.ARC_CLOCKWISE, sunriseStartAngle, sunriseEndAngle); @@ -1040,7 +1033,7 @@ class SmartArcsView extends WatchUi.WatchFace { } //draw sunset - if (sunsetColor != offSettingFlag && locationLatitude != offSettingFlag) { + if (sunsetColor != offSettingFlag) { dc.setColor(sunsetColor, Graphics.COLOR_TRANSPARENT); if (sunsetStartAngle > sunsetEndAngle) { dc.drawArc(screenRadius, screenRadius, screenRadius - sunArcsOffset, Graphics.ARC_CLOCKWISE, sunsetStartAngle, sunsetEndAngle);