Skip to content

Commit

Permalink
twilights indicator fix - hide indicator if position is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
Radko Najman committed Apr 1, 2022
1 parent 5bdbda5 commit fa58ff6
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 1.6.2 (April 1, 2022)
* twilights indicator fix - hide indicator if position is not available

# 1.6.1 (March 6, 2022)
* small bugfix for twilights indicator

Expand Down
Binary file added connect_iq_store/black_cover_ukraine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion manifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- This is a generated file. It is highly recommended that you DO NOT edit this file. --><iq:manifest xmlns:iq="http://www.garmin.com/xml/connectiq" version="3">
<iq:application entry="SmartArcsApp" id="f9b0f982693411e9a9231681be663d3e" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watchface" version="1.6.1">
<iq:application entry="SmartArcsApp" id="f9b0f982693411e9a9231681be663d3e" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watchface" version="1.6.2">
<iq:products>
<iq:product id="approachs62"/>
<iq:product id="d2air"/>
Expand Down
2 changes: 1 addition & 1 deletion manifest.xml.beta
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- This is a generated file. It is highly recommended that you DO NOT edit this file. --><iq:manifest xmlns:iq="http://www.garmin.com/xml/connectiq" version="3">
<iq:application entry="SmartArcsApp" id="2eafd80f81794ced90db35ccfcb29945" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watchface" version="1.6.0">
<iq:application entry="SmartArcsApp" id="2eafd80f81794ced90db35ccfcb29945" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watchface" version="1.6.20">
<iq:products>
<iq:product id="approachs62"/>
<iq:product id="d2charlie"/>
Expand Down
2 changes: 1 addition & 1 deletion manifest.xml.prod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- This is a generated file. It is highly recommended that you DO NOT edit this file. --><iq:manifest xmlns:iq="http://www.garmin.com/xml/connectiq" version="3">
<iq:application entry="SmartArcsApp" id="f9b0f982693411e9a9231681be663d3e" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watchface" version="1.6.1">
<iq:application entry="SmartArcsApp" id="f9b0f982693411e9a9231681be663d3e" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watchface" version="1.6.2">
<iq:products>
<iq:product id="approachs62"/>
<iq:product id="d2air"/>
Expand Down
2 changes: 2 additions & 0 deletions resources/settings/properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@

<property id="sunriseColor" type="number">0xAA0000</property>
<property id="sunsetColor" type="number">0x0000FF</property>
<property id="locationLatitude" type="number">-999</property>
<property id="locationLongitude" type="number">-999</property>

<property id="eventName" type="string"></property>
<property id="eventDate" type="number">1573331777</property>
Expand Down
27 changes: 23 additions & 4 deletions source/SmartArcsView.mc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ class SmartArcsView extends WatchUi.WatchFace {
var sunriseEndAngle = 0;
var sunsetStartAngle = 0;
var sunsetEndAngle = 0;

var locationLatitude;
var locationLongitude;

//user settings
var bgColor;
var handsColor;
Expand Down Expand Up @@ -379,6 +381,9 @@ class SmartArcsView extends WatchUi.WatchFace {
powerSaverRefreshInterval = app.getProperty("powerSaverRefreshInterval");
powerSaverIconColor = app.getProperty("powerSaverIconColor");

locationLatitude = app.getProperty("locationLatitude");
locationLongitude = app.getProperty("locationLongitude");

//ensure that constants will be pre-computed
needComputeConstants = true;

Expand Down Expand Up @@ -1015,7 +1020,21 @@ class SmartArcsView extends WatchUi.WatchFace {
if (posInfo != null && posInfo.position != null) {
var sc = new SunCalc();
var time_now = Time.now();
var loc = posInfo.position.toRadians();
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) {
loc[0] = locationLatitude;
loc[1] = locationLongitude;
}

if (hasLocation) {
Application.getApp().setProperty("locationLatitude", loc[0]);
Application.getApp().setProperty("locationLongitude", loc[1]);
locationLatitude = loc[0];
locationLongitude = loc[1];
}

sunriseStartAngle = computeSunAngle(sc.calculate(time_now, loc, SunCalc.DAWN));
sunriseEndAngle = computeSunAngle(sc.calculate(time_now, loc, SunCalc.SUNRISE));
sunsetStartAngle = computeSunAngle(sc.calculate(time_now, loc, SunCalc.SUNSET));
Expand All @@ -1034,7 +1053,7 @@ class SmartArcsView extends WatchUi.WatchFace {
dc.setPenWidth(7);

//draw sunrise
if (sunriseColor != offSettingFlag) {
if (sunriseColor != offSettingFlag && locationLatitude != -999) {
dc.setColor(sunriseColor, Graphics.COLOR_TRANSPARENT);
if (sunriseStartAngle > sunriseEndAngle) {
dc.drawArc(screenRadius, screenRadius, screenRadius - 17, Graphics.ARC_CLOCKWISE, sunriseStartAngle, sunriseEndAngle);
Expand All @@ -1044,7 +1063,7 @@ class SmartArcsView extends WatchUi.WatchFace {
}

//draw sunset
if (sunsetColor != offSettingFlag) {
if (sunsetColor != offSettingFlag && locationLatitude != -999) {
dc.setColor(sunsetColor, Graphics.COLOR_TRANSPARENT);
if (sunsetStartAngle > sunsetEndAngle) {
dc.drawArc(screenRadius, screenRadius, screenRadius - 13, Graphics.ARC_CLOCKWISE, sunsetStartAngle, sunsetEndAngle);
Expand Down

0 comments on commit fa58ff6

Please sign in to comment.