Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made it compatible with other devices #209

Open
wants to merge 218 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
218 commits
Select commit Hold shift + click to select a range
a791281
Made it compatible with other devices
SylvainGa Sep 23, 2021
210e1b6
Delete fonts.xml
SylvainGa Sep 23, 2021
051f664
Delete .gitignore
SylvainGa Sep 23, 2021
2d01fac
Create .gitignore
SylvainGa Nov 29, 2021
8322532
Added a Tesla battery level as an indicator
SylvainGa Mar 24, 2022
309493b
Better handling of errors and can now refresh an access token through…
SylvainGa Mar 25, 2022
52b56a3
Will show by a '+' sign after the % when the car is charginh
SylvainGa Mar 26, 2022
836d089
Better handling of 408 error
SylvainGa Mar 26, 2022
8b3d876
Not as chatty debugging code and needs to handle more than one event …
SylvainGa Mar 27, 2022
f11aa18
More debugging code
SylvainGa Mar 27, 2022
bb399b6
Now display a 's' after the % if the car is sleeping
SylvainGa Mar 27, 2022
ade7252
Now preempt token expiry and ask for a new one if it's about to expire
SylvainGa Mar 27, 2022
1c77cf8
Fixed bug 210
SylvainGa Mar 27, 2022
7d6cc11
More elegant and faster way of testing if the token is empty
SylvainGa Mar 27, 2022
6524842
Started getting -403 error so ended up removing some debugging code t…
SylvainGa Mar 27, 2022
4775051
Moved from vehicle_state to charge_state which receives 1.5KB of data…
SylvainGa Mar 27, 2022
8d12455
Revert "Moved from vehicle_state to charge_state which receives 1.5KB…
SylvainGa Mar 28, 2022
63ee980
Revert "Started getting -403 error so ended up removing some debuggin…
SylvainGa Mar 28, 2022
73eb8d2
Revert "More elegant and faster way of testing if the token is empty"
SylvainGa Mar 28, 2022
9f09a2d
Revert "Fixed bug 210"
SylvainGa Mar 28, 2022
638bb5f
Revert "Now preempt token expiry and ask for a new one if it's about…
SylvainGa Mar 28, 2022
4367c76
Removed most of the stuff I did yesterday because I hit a memory limi…
SylvainGa Mar 28, 2022
b86e96a
Debug code to show when the access token expires
SylvainGa Mar 28, 2022
445be47
Reinstate the preemptive refresh close to the expiration time. If we …
SylvainGa Mar 30, 2022
cb2a8a0
Removed some debugging line and receiving a token no longer stales th…
SylvainGa Mar 31, 2022
fea7f4a
Now toggles between battery charge, sentry mode, preconditioning and …
SylvainGa Apr 3, 2022
ae3d6cf
Adjustment to the display times of the Tesla stuff
SylvainGa Apr 3, 2022
bfc57eb
Rewritten Propertie TeslaBatterieLevel to TeslaInfo since it does mor…
SylvainGa Apr 3, 2022
84829af
Crash in debug code when starting from fresh
SylvainGa Apr 3, 2022
47d2597
Fix code to display if we have an error, fix code that disables Tesla…
SylvainGa Apr 4, 2022
369fa63
Removal of debug code to reduce the size of the executable and additi…
SylvainGa Apr 5, 2022
8395941
Addition of Epix2 to the supported watches
SylvainGa Apr 7, 2022
a236358
Disables background service on watches that doesn't support it.
SylvainGa Apr 7, 2022
de8bcc1
Fix sunrise showing todays instead of tomorrow when sunset has been r…
SylvainGa Apr 9, 2022
6513254
GarminWeather can be used instead of OpenWeatherMap
SylvainGa Apr 9, 2022
e864b5b
Tidying the code a bit
SylvainGa Apr 9, 2022
ee2391b
Modification to the Garmin Weather code so it can run on most 64KB wa…
SylvainGa Apr 10, 2022
742a7e8
Fixed a crash when no Garmin Weather data returned. Associated the gl…
SylvainGa Apr 11, 2022
8386e05
Update DataFields.mc
SylvainGa Apr 15, 2022
e027395
Update to altitude code to keep previous value if GPS is lost
SylvainGa Apr 15, 2022
b68f22c
Removal of Garmin Swim 2
SylvainGa Apr 15, 2022
9453d33
Merge branch 'master' of https://github.com/SylvainGa/crystal-face
SylvainGa Apr 15, 2022
d1c5328
Second attempt at fixing the Altitude code so it stays put, even if t…
SylvainGa Apr 17, 2022
0eeddc1
Fixed the seconds not displaying by code introduced to fix a crash on…
SylvainGa Apr 18, 2022
8c3da67
Add floors climbed as a data field
SylvainGa Apr 18, 2022
eaa2574
Fix the '/' in the titillium-web-semibold-28 font in 280x280 plus add…
SylvainGa Apr 19, 2022
6cf44bf
Added Descent Mk1, Mk2 and MK2S as well as 'Do Not Disturb' as indicator
SylvainGa May 10, 2022
4caf6c3
AOD Shows Tesla's battery level
SylvainGa May 10, 2022
cd31fc7
Added images for ConnectIQ
SylvainGa May 10, 2022
94811bf
Removal of watches with not enough memory to run reliably
SylvainGa May 11, 2022
3cecb97
Added SolarIntensity as a data field
SylvainGa Jul 15, 2022
e3ec96f
Added Body Battery as a data field. Bug fix for Solar Intensity on 39…
SylvainGa Jul 21, 2022
cbd96a2
Addition of Forerunner 255, 255 Music, 255s, 255s Music
SylvainGa Jul 21, 2022
7cef244
Text that needs to be translated
SylvainGa Jul 30, 2022
c310c69
Fixed 'Û' missing in the 280x280 font file.
SylvainGa Aug 26, 2022
d73c099
Fix Dutch translations
ChristopheMB Sep 2, 2022
bcb1434
Merge pull request #1 from ChristopheMB/ChristopheMB-patch-1
ChristopheMB Sep 2, 2022
4724816
Added the Enduro, Venu SQ 2 and Venu SQ 2 Music
SylvainGa Sep 16, 2022
805a86f
Merge pull request #6 from ChristopheMB/master
SylvainGa Sep 16, 2022
15b32ec
Fixed AlwaysOnDisplay of Venu SQ 2 and Venu SQ 2 Music
SylvainGa Sep 16, 2022
cf0d3ef
Added Recovery Time left as a data field
SylvainGa Sep 27, 2022
4525f1e
Fixed 30 minutes offset time zone, allows Tesla's server to be specif…
SylvainGa Dec 1, 2022
7f28035
Update README.md
SylvainGa Dec 1, 2022
b5ee937
Updated App version
SylvainGa Dec 1, 2022
3c587bc
Merge branch 'master' of https://github.com/SylvainGa/crystal-face
SylvainGa Dec 1, 2022
65323de
Update README.md
SylvainGa Dec 1, 2022
6f05ef2
Update README.md
SylvainGa Dec 1, 2022
9d61109
Update README.md
SylvainGa Dec 1, 2022
66d6088
Update README.md
SylvainGa Dec 1, 2022
96639e5
Update README.md
SylvainGa Dec 1, 2022
76b0d45
Update README.md
SylvainGa Dec 5, 2022
c9d17b6
Removed troubleshooting code left by mistake
SylvainGa Dec 8, 2022
d24f3cb
Merge branch 'master' of https://github.com/SylvainGa/crystal-face
SylvainGa Dec 8, 2022
55f6bb7
Update README.md
SylvainGa Dec 8, 2022
f4a1e62
Added BodyBattery as a Goal Meter
SylvainGa Jan 6, 2023
db2942b
Added Body Battery as a Goal Meter
SylvainGa Jan 6, 2023
32321d0
Remove warning at build time
SylvainGa Jan 6, 2023
a55c94a
"Hide seconds" has been changed from a checkbox to a list with three …
SylvainGa Jan 11, 2023
c754168
Update README.md
SylvainGa Jan 11, 2023
d864c85
Update README.md
SylvainGa Jan 11, 2023
cbf086f
Update README.md
SylvainGa Jan 12, 2023
1f84ed6
Compiled with Connect IQ 4.2.1 which added the Forerunner 265, 265s a…
SylvainGa Mar 6, 2023
4c00ee3
Revert "Compiled with Connect IQ 4.2.1 which added the Forerunner 265…
SylvainGa Mar 6, 2023
93086ef
Revert "Revert "Compiled with Connect IQ 4.2.1 which added the Foreru…
SylvainGa Mar 6, 2023
60dd0ce
X
SylvainGa Mar 6, 2023
3292bd5
Revert "Compiled with Connect IQ 4.2.1 which added the Forerunner 265…
SylvainGa Mar 6, 2023
e2b10d5
Revert "X"
SylvainGa Mar 6, 2023
7b830f1
Brought back device dependencies. Added BodyBattery to FR55 and adjus…
SylvainGa Mar 6, 2023
646aab7
Update README.md
SylvainGa Mar 6, 2023
df94fab
Removed two unused variables
SylvainGa Mar 6, 2023
3363f2f
Update monkey.jungle
SylvainGa Mar 7, 2023
c02c70f
2.14.2
SylvainGa Mar 10, 2023
d37f59a
Update README.md
SylvainGa Mar 11, 2023
455cc06
Increased time for for 454x454 watch and check for phone connection t…
SylvainGa Mar 11, 2023
59ae498
Update README.md
SylvainGa Mar 11, 2023
7c53ca2
Increased 454x454 devices time and date font
SylvainGa Mar 11, 2023
94ee879
Update README.md
SylvainGa Mar 11, 2023
9488447
Update README.md
SylvainGa Mar 11, 2023
8791a73
2.15.0
SylvainGa Mar 14, 2023
c71d2a4
Update README.md
SylvainGa Mar 14, 2023
95babaa
Update README.md
SylvainGa Mar 14, 2023
fb03c96
2.15.1
SylvainGa Mar 15, 2023
fbb5c3a
Update README.md
SylvainGa Mar 15, 2023
693e32d
2.15.2
SylvainGa Apr 2, 2023
09341b2
2.16.0
SylvainGa Apr 2, 2023
aeb36ec
Fixed the Venu2 SQ font
SylvainGa Apr 2, 2023
8795438
Reformat comments and reactivate current debug one
SylvainGa Apr 2, 2023
55ddfeb
Update CrystalView.mc
SylvainGa Apr 2, 2023
858210c
Cleaned up strings.xml, reorganized properties.xml to match order in …
SylvainGa Apr 5, 2023
288e61d
Update .gitignore
SylvainGa Apr 5, 2023
110aadf
Fixed the missing "+" character in the semibold 28pt font.
SylvainGa Apr 8, 2023
b6f94e1
Merge branch 'master' of https://github.com/SylvainGa/crystal-face
SylvainGa Apr 8, 2023
0d1a25c
Removed manifest.xml from .gitignore
SylvainGa Apr 8, 2023
0956dbb
Need to think to update the version before compiling
SylvainGa Apr 8, 2023
fbff054
Update README.md
SylvainGa Apr 8, 2023
c627da2
No point building betas for watches I don't have
SylvainGa Apr 8, 2023
1614253
Changed setProperties/getProperties for setValue/getValue and limited…
SylvainGa Apr 16, 2023
1ca50c0
Update DataFields.mc
SylvainGa Apr 16, 2023
39c23c3
2.16.5 - Fixed a crash when entering a City in the "Add a local time …
SylvainGa Apr 16, 2023
72cbc89
2.16.5a - Fixed two crashes reported through the Error Reporting Appl…
SylvainGa Apr 20, 2023
598a805
2.16.5b Fixed a crash reported through the Error Reporting Applicatio…
SylvainGa Apr 26, 2023
a917d15
Update strings.xml
SylvainGa Apr 26, 2023
d1266be
V2.17.0 interim
SylvainGa May 1, 2023
c4560ba
V2.17.0 released
SylvainGa May 1, 2023
76ba8e1
Reinstated logging after release
SylvainGa May 1, 2023
5390741
Prepping for V2.17.1
SylvainGa May 2, 2023
6b2f772
Fixed step and floor goals for Complication since they don't have any…
SylvainGa May 2, 2023
016787c
One more crash because mDrawable is null in AoD
SylvainGa May 2, 2023
507afe7
Made Complications optional, added some sanity check around Goals val…
SylvainGa May 3, 2023
8dea4cf
V2.17.2
SylvainGa May 3, 2023
b66ce75
Trying to fix wierd AoD crash when main display activated
SylvainGa May 3, 2023
75d51d8
More fix before releasing V2.17.2
SylvainGa May 3, 2023
e8f78a8
Fixed a crash when Theme color override was invalid
SylvainGa May 3, 2023
06ec5b4
V2.17.2
SylvainGa May 3, 2023
499c267
Replaced the 'T' symbol for Tesla in the AoD for the real Tesla icon
SylvainGa May 3, 2023
963ff54
Hardened the Properties.getValue calls
SylvainGa May 4, 2023
39cfbc2
2.17.4 - One more attempt at fixing the crash because of the Settings…
SylvainGa May 4, 2023
6d8222b
Changed version in string file
SylvainGa May 4, 2023
f467885
Optimize global function calling time, fix bug in themelight dectection
SylvainGa May 5, 2023
36bb8b7
New Global.mc file. Moved stuff away from App class. Starting new Tes…
SylvainGa May 6, 2023
df07e1f
Redid Tesla code. Fixed Steps Complication where above 10,000 becomes…
SylvainGa May 8, 2023
6e58a8a
Added the TeslaLink property
SylvainGa May 8, 2023
a16c4ff
Do not read the whole weather map from storage every seconds, only wh…
SylvainGa May 8, 2023
0344d7a
Updated the version to 2.17.5
SylvainGa May 8, 2023
29b43bf
Code finished, hopefully
SylvainGa May 9, 2023
62523b4
Starting implementing weather Complications
SylvainGa May 9, 2023
e830334
Weather, sunrise, recovery time addition and bug fix in weather
SylvainGa May 10, 2023
ab72380
Moved Weather calculation to onExitSleep for efficiency and fixed bug…
SylvainGa May 10, 2023
c06e0e2
RecoveryTime from complication is in minutes, not second, and Tesla h…
SylvainGa May 11, 2023
0c6defc
Bug fix in TeslaVehicleIndex and added that property
SylvainGa May 11, 2023
d36f36b
Update README.md
SylvainGa May 11, 2023
7f40281
New code for offline vehicle
SylvainGa May 11, 2023
276f215
Tweaking what shows up when an error is received
SylvainGa May 11, 2023
f14a317
Done
SylvainGa May 12, 2023
6ce5fd7
Showing when Tesla Complication received
SylvainGa May 13, 2023
2ae8096
Had to reinstate the original sunrise/sunset routine because some wat…
SylvainGa May 14, 2023
d3d4ea4
Consolidated debug statements
SylvainGa May 14, 2023
83f54b2
Some debug fix
SylvainGa May 14, 2023
edf4b39
Update manifest.xml
SylvainGa May 14, 2023
ba4aebc
V2.18.1
SylvainGa May 15, 2023
30aa74a
Gave the Forerunner 55 access to the weather and humidity since it su…
SylvainGa May 15, 2023
7f56fcb
Needed for the 240 x 240 watches
SylvainGa May 15, 2023
eba42cd
V2.18.2
SylvainGa May 15, 2023
103bf1a
Reinstated debug statements
SylvainGa May 15, 2023
26f2b53
Reinstated debug statements
SylvainGa May 15, 2023
da4b457
For 2.18.3
SylvainGa May 17, 2023
79ac979
Fixed AOD and Tesla battery not showing and added debug log message f…
SylvainGa May 17, 2023
1d33134
Made some annotation to help devices with low memory to exclude stuff…
SylvainGa May 18, 2023
38eb3e8
Saw a weird crash in onPress so I added type checking to prevent it f…
SylvainGa May 18, 2023
c1a6263
Reduced the logMessage quantity to get more lines in log file
SylvainGa May 19, 2023
3536ebf
Fix for mDigitStyle and mShowWeatherStationName not included when in …
SylvainGa May 20, 2023
4a2f62c
try/catch to prevent out of memory in Bg.exit
SylvainGa May 22, 2023
d4ec93a
2.18.6
SylvainGa Jun 2, 2023
fe18389
Update BackgroundService.mc
SylvainGa Jun 2, 2023
4cc1166
Added support for new watches
SylvainGa Jun 2, 2023
d44374f
Added support for the Venu3 and Venu3S
SylvainGa Aug 30, 2023
cf9da49
2.18.8 - Added support for the VivoActive5
SylvainGa Sep 20, 2023
f760cd7
Extend Longitude to between -180 to +180
AdrienChenu Sep 21, 2023
fe3b81c
2.18.9 Adjusted the fonts of the Venu Sq2
SylvainGa Sep 27, 2023
ebd3efb
Fixed DEDUG for DEBUG
SylvainGa Sep 27, 2023
39eea3d
Merge pull request #8 from AdrienChenu/bug-local-city-time
SylvainGa Oct 3, 2023
c78bd42
V2.19.0 Adds the following
SylvainGa Nov 6, 2023
61da380
2.18.12 (in progress)
SylvainGa Dec 5, 2023
f966359
V2.18.12 (in progress)
SylvainGa Dec 9, 2023
d2e8934
Update README.md
SylvainGa Dec 9, 2023
c2393ad
2.18.13
SylvainGa Apr 29, 2024
fa4fbe5
V2.18.4 Added the Descent MK3 variants
SylvainGa Apr 30, 2024
5dbc710
2.19.0
SylvainGa Jul 10, 2024
fff0c31
Update CrystalView.mc
SylvainGa Jul 11, 2024
37b0b90
Small optimization of the Complication code
SylvainGa Jul 22, 2024
3646c3f
Bugfix in Tesla code and new handling of Tesla data since 'asleep' ha…
SylvainGa Jul 23, 2024
8ea8658
Fix for Tesla error 412
SylvainGa Jul 25, 2024
f0abca7
Bug fix in Tesla online/offline detection
SylvainGa Aug 1, 2024
de95120
Update strings.xml
SylvainGa Aug 1, 2024
9e9ad99
Debug code for TeslaInfo
SylvainGa Aug 2, 2024
9206e54
Fixed timezone from preventing goals to be displayed
SylvainGa Aug 2, 2024
c828403
Updated readme
SylvainGa Aug 2, 2024
b5fd71a
Update README.md
SylvainGa Aug 2, 2024
4a55c15
Added Enduro3 and new Fenix8 watches. Small code optimisation for Te…
SylvainGa Sep 5, 2024
5eef54d
Added Recovery Time as a MoveBar option
SylvainGa Nov 22, 2024
93a2331
MoveBar Recovery time can be a Complication and launch its widget whe…
SylvainGa Nov 24, 2024
eebfc71
MoveBar Recovery time can be a Complication and launch its widget whe…
SylvainGa Nov 24, 2024
5d9a655
Doc update
SylvainGa Nov 24, 2024
4407d34
Merge branch 'master' of https://github.com/SylvainGa/crystal-face
SylvainGa Nov 24, 2024
973137f
Removed weather station name
SylvainGa Nov 29, 2024
9a4ec58
Added back OWM and the queueing of requests. Fixed for -403 error.
SylvainGa Dec 2, 2024
8e929b6
Previous code was working on the simulator but not a real device :-<
SylvainGa Dec 4, 2024
d3d384b
Show 200 for httpInternalErrorTesla when all is fine
SylvainGa Dec 14, 2024
53e0dde
No changes but compiled with CIQ 7.4.3
SylvainGa Dec 16, 2024
75c5fe7
Update README.md
SylvainGa Dec 16, 2024
703d4cf
Duplicated 2.20.2 changes
SylvainGa Dec 17, 2024
c1b0fbe
Syntax error
SylvainGa Dec 17, 2024
ae6d890
Testing for empty data
SylvainGa Dec 18, 2024
73bd9f7
Bug fix when Tesla data is a dict instead of a string. Enumerate data…
SylvainGa Dec 19, 2024
f9fed04
Bug fix
SylvainGa Dec 19, 2024
4a0a491
Fail safe in case background data returns null
SylvainGa Dec 19, 2024
e2668a6
Fixed the MoveBar to not stay hidden when coming back from AOD
SylvainGa Jan 2, 2025
9e7a2c6
Update manifest.xml.prd
SylvainGa Jan 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

build/

.project
.settings/
bin/
.vscode/launch.json
.vscode/tasks.json
.vscode/settings.json
527 changes: 289 additions & 238 deletions README.md

Large diffs are not rendered by default.

117 changes: 97 additions & 20 deletions always-on-source/AlwaysOnDisplay.mc
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ using Toybox.System as Sys;
using Toybox.Application as App;
using Toybox.Time;
using Toybox.Time.Gregorian;
using Toybox.Application.Storage;

// Draw time, line, date, battery.
// Combine stripped down versions of ThickThinTime and DateLine.
// Change vertical offset every minute to comply with burn-in protection requirements.
class AlwaysOnDisplay extends Ui.Drawable {

private var mBurnInYOffsets;
private var mHoursFont, mMinutesFont, mSecondsFont, mDateFont, mBatteryFont;
private var mHoursFont, mMinutesFont, mSecondsFont, mDateFont, mBatteryFont, mTeslaFont;

// Wide rectangle: time should be moved up slightly to centre within available space.
private var mAdjustY = 0;
Expand Down Expand Up @@ -68,13 +69,18 @@ class AlwaysOnDisplay extends Ui.Drawable {
var dateFontOverride = Ui.loadResource(Rez.Strings.DATE_FONT_OVERRIDE);
var dateFont = (resourceMap.hasKey(dateFontOverride)) ? resourceMap[dateFontOverride] : rezFonts.AlwaysOnDateFont;
mDateFont = Ui.loadResource(dateFont);

if (Storage.getValue("Tesla") != null) {
mTeslaFont = Ui.loadResource(Rez.Fonts.IconsFont);
}

}

function draw(dc) {

// TIME.
var clockTime = Sys.getClockTime();
var formattedTime = App.getApp().getFormattedTime(clockTime.hour, clockTime.min);
var formattedTime = App.getApp().getFormattedTime(clockTime.hour, clockTime.min, clockTime.sec);
formattedTime[:amPm] = formattedTime[:amPm].toUpper();

// Change vertical offset every minute.
Expand All @@ -83,13 +89,14 @@ class AlwaysOnDisplay extends Ui.Drawable {
var hours = formattedTime[:hour];
var minutes = formattedTime[:min];
var amPmText = formattedTime[:amPm];
var colon = ":"; // SG Addition

var halfDCWidth = dc.getWidth() / 2;

// Centre combined hours and minutes text (not the same as right-aligning hours and left-aligning minutes).
// Font has tabular figures (monospaced numbers) even across different weights, so does not matter which of hours or
// minutes font is used to calculate total width.
var totalWidth = dc.getTextWidthInPixels(hours + minutes, mHoursFont);
var totalWidth = dc.getTextWidthInPixels(hours + colon + minutes, mHoursFont); // SG Added colon
var x = halfDCWidth - (totalWidth / 2);
var y = mTimeY + mAdjustY + burnInYOffset;

Expand All @@ -105,6 +112,16 @@ class AlwaysOnDisplay extends Ui.Drawable {
);
x += dc.getTextWidthInPixels(hours, mHoursFont);

// SG Addition - Colon.
dc.drawText(
x,
y,
mHoursFont,
colon,
Graphics.TEXT_JUSTIFY_LEFT | Graphics.TEXT_JUSTIFY_VCENTER
);
x += dc.getTextWidthInPixels(colon, mHoursFont);

// Minutes.
dc.drawText(
x,
Expand All @@ -128,7 +145,7 @@ class AlwaysOnDisplay extends Ui.Drawable {

// LINE.
y = mLineY + burnInYOffset;
dc.setPenWidth(/* mLineStroke */ 2);
dc.setPenWidth(/* mLineStroke */ 1); // SG From 2 to 1
dc.drawLine(halfDCWidth - (mLineWidth / 2), y, halfDCWidth + (mLineWidth / 2), y);

// DATA.
Expand Down Expand Up @@ -181,22 +198,82 @@ class AlwaysOnDisplay extends Ui.Drawable {

// Date.
y = mDataY + burnInYOffset;
dc.drawText(
mDataLeft,
y,
mDateFont,
Lang.format("$1$ $2$ $3$", [mDayOfWeekString, day, mMonthString]),
Graphics.TEXT_JUSTIFY_LEFT | Graphics.TEXT_JUSTIFY_VCENTER
);
if (Storage.getValue("Tesla") == null) {
dc.drawText(
mDataLeft,
y,
mDateFont,
Lang.format("$1$ $2$ $3$", [mDayOfWeekString, day, mMonthString]),
Graphics.TEXT_JUSTIFY_LEFT | Graphics.TEXT_JUSTIFY_VCENTER
);

// Battery.
var battery = Math.floor(Sys.getSystemStats().battery);
dc.drawText(
dc.getWidth() - mDataLeft,
y,
mBatteryFont,
battery.format(INTEGER_FORMAT) + "%",
Graphics.TEXT_JUSTIFY_RIGHT | Graphics.TEXT_JUSTIFY_VCENTER
);
// Battery.
var battery = Math.floor(Sys.getSystemStats().battery);
dc.drawText(
dc.getWidth() - mDataLeft,
y,
mBatteryFont,
battery.format(INTEGER_FORMAT) + "%",
Graphics.TEXT_JUSTIFY_RIGHT | Graphics.TEXT_JUSTIFY_VCENTER
);
}
else {
dc.drawText(
mDataLeft,
y,
mDateFont,
Lang.format("$1$ $2$", [day, mMonthString]),
Graphics.TEXT_JUSTIFY_LEFT | Graphics.TEXT_JUSTIFY_VCENTER
);

// Batteries.
var watchBattery = Math.floor(Sys.getSystemStats().battery);

var teslaInfo = Storage.getValue("TeslaInfo");
if (teslaInfo == null) {
teslaInfo = {};
}
var chargingState = teslaInfo.get("ChargingState");
var error = teslaInfo.get("httpErrorTesla");

if (chargingState != null) {
if (chargingState.equals("Charging")) {
chargingState = 1;
} else if (chargingState.equals("Sleeping")) {
chargingState = 2;
} else {
chargingState = 0;
}
} else {
chargingState = 0;
}

var vehicleBattery = teslaInfo.get("BatteryLevel");
if (error != null && error != 200) {
vehicleBattery = error.toNumber().format(INTEGER_FORMAT);
} else if (vehicleBattery == null) {
vehicleBattery = "???";
} else {
vehicleBattery = vehicleBattery.toNumber().format(INTEGER_FORMAT) + "%" + (chargingState == 1 ? "+" : (chargingState == 2 ? "s" : ""));
}

var text = vehicleBattery + " " + watchBattery.format(INTEGER_FORMAT) + "%";
var widthText = dc.getTextWidthInPixels(text, mBatteryFont);

dc.drawText(
dc.getWidth() - mDataLeft - widthText,
y,
mTeslaFont,
"T",
Graphics.TEXT_JUSTIFY_RIGHT | Graphics.TEXT_JUSTIFY_VCENTER
);
dc.drawText(
dc.getWidth() - mDataLeft,
y,
mBatteryFont,
vehicleBattery + " " + watchBattery.format(INTEGER_FORMAT) + "%",
Graphics.TEXT_JUSTIFY_RIGHT | Graphics.TEXT_JUSTIFY_VCENTER
);
}
}
}
78 changes: 10 additions & 68 deletions manifest.xml
Original file line number Diff line number Diff line change
@@ -1,78 +1,20 @@
<!-- 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="CrystalApp" id="bde5c058244911e8b4670ed5f89f718b" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="1.4.0" name="@Strings.AppName" type="watchface" version="2.5.0">
<?xml version="1.0"?>
<!-- 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="CrystalApp" id="0969495b-a01f-4078-bc0f-f038ec98844d" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="2.4.0" name="@Strings.AppName" type="watchface" version="2.21.0">
<iq:products>
<iq:product id="approachs60"/>
<iq:product id="approachs62"/>
<iq:product id="d2air"/>
<iq:product id="d2bravo"/>
<iq:product id="d2bravo_titanium"/>
<iq:product id="d2charlie"/>
<iq:product id="d2delta"/>
<iq:product id="d2deltapx"/>
<iq:product id="d2deltas"/>
<iq:product id="descentmk1"/>
<iq:product id="descentmk2"/>
<iq:product id="fenix3"/>
<iq:product id="fenix3_hr"/>
<iq:product id="fenix5"/>
<iq:product id="fenix5plus"/>
<iq:product id="fenix5s"/>
<iq:product id="fenix5splus"/>
<iq:product id="fenix5x"/>
<iq:product id="fenix5xplus"/>
<iq:product id="fenix6"/>
<iq:product id="fenix6pro"/>
<iq:product id="fenix6s"/>
<iq:product id="fenix6spro"/>
<iq:product id="fenix6xpro"/>
<iq:product id="fenixchronos"/>
<iq:product id="fr230"/>
<iq:product id="fr235"/>
<iq:product id="fr245"/>
<iq:product id="fr245m"/>
<iq:product id="fr45"/>
<iq:product id="fr630"/>
<iq:product id="fr645"/>
<iq:product id="fr645m"/>
<iq:product id="fr735xt"/>
<iq:product id="fr745"/>
<iq:product id="fr920xt"/>
<iq:product id="fr935"/>
<iq:product id="fr945"/>
<iq:product id="garminswim2"/>
<iq:product id="legacyherocaptainmarvel"/>
<iq:product id="legacyherofirstavenger"/>
<iq:product id="legacysagadarthvader"/>
<iq:product id="legacysagarey"/>
<iq:product id="marqadventurer"/>
<iq:product id="marqathlete"/>
<iq:product id="marqaviator"/>
<iq:product id="marqcaptain"/>
<iq:product id="marqcommander"/>
<iq:product id="marqdriver"/>
<iq:product id="marqexpedition"/>
<iq:product id="marqgolfer"/>
<iq:product id="venu"/>
<iq:product id="venu2"/>
<iq:product id="venu2s"/>
<iq:product id="venud"/>
<iq:product id="venusq"/>
<iq:product id="venusqm"/>
<iq:product id="vivoactive"/>
<iq:product id="vivoactive3"/>
<iq:product id="vivoactive3d"/>
<iq:product id="vivoactive3m"/>
<iq:product id="vivoactive3mlte"/>
<iq:product id="vivoactive4"/>
<iq:product id="fenix7spro"/>
<iq:product id="venu2plus"/>
<iq:product id="vivoactive4s"/>
<iq:product id="vivoactive_hr"/>
<iq:product id="vivolife"/>
<iq:product id="vivoactive5"/>
</iq:products>
<iq:permissions>
<iq:uses-permission id="Background"/>
<iq:uses-permission id="Communications"/>
<iq:uses-permission id="ComplicationSubscriber"/>
<iq:uses-permission id="Positioning"/>
<iq:uses-permission id="SensorHistory"/>
<iq:uses-permission id="UserProfile"/>
</iq:permissions>
<iq:languages>
<iq:language>ces</iq:language>
Expand All @@ -99,4 +41,4 @@
</iq:languages>
<iq:barrels/>
</iq:application>
</iq:manifest>
</iq:manifest>
Loading