Skip to content

Commit

Permalink
Merge pull request #17 from wolffshots/battery-charging-indicator
Browse files Browse the repository at this point in the history
feat: add bolt to show battery charging
  • Loading branch information
wolffshots committed May 11, 2023
2 parents 41060f9 + 9a0fefe commit 6a84988
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 8 deletions.
1 change: 1 addition & 0 deletions resources/drawables/bolt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions resources/drawables/drawables.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,26 @@
<color>000000</color>
</palette>
</bitmap>

<bitmap
id="boltDark"
filename="bolt.svg"
scaleX="3%"
scaleY="3%"
>
<palette disableTransparency="false">
<color>FFFFFF</color>
</palette>
</bitmap>

<bitmap
id="boltLight"
filename="bolt.svg"
scaleX="3%"
scaleY="3%"
>
<palette disableTransparency="false">
<color>000000</color>
</palette>
</bitmap>
</drawables>
55 changes: 47 additions & 8 deletions source/SnoutView.mc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SnoutView extends WatchUi.WatchFace {
private var battery;
private var batteryInDays;
private var batteryWidth;
// private var charging;
private var charging;
private var pressure;
private var altitude;

Expand Down Expand Up @@ -57,6 +57,7 @@ class SnoutView extends WatchUi.WatchFace {
batteryOutlineBitmapCoordinate.Y - 5
);
private var batteryOutlineBitmap;
private var boltBitmap;

private var pressureCoordinate = new Coordinate(25, 110);
private var pressureBitmapCoordinate = new Coordinate(
Expand Down Expand Up @@ -99,6 +100,11 @@ class SnoutView extends WatchUi.WatchFace {
? Rez.Drawables.batteryOutlineDark
: Rez.Drawables.batteryOutlineLight ) as BitmapResource;

boltBitmap = Application.loadResource(
Properties.getValue("DarkMode") as Boolean
? Rez.Drawables.boltDark
: Rez.Drawables.boltLight ) as BitmapResource;

pressureBitmap = Application.loadResource(
Properties.getValue("DarkMode") as Boolean
? Rez.Drawables.pressureDark
Expand Down Expand Up @@ -141,6 +147,10 @@ class SnoutView extends WatchUi.WatchFace {
Properties.getValue("DarkMode") as Boolean
? Rez.Drawables.batteryOutlineDark
: Rez.Drawables.batteryOutlineLight ) as BitmapResource;
boltBitmap = Application.loadResource(
Properties.getValue("DarkMode") as Boolean
? Rez.Drawables.boltDark
: Rez.Drawables.boltLight ) as BitmapResource;
pressureBitmap = Application.loadResource(
Properties.getValue("DarkMode") as Boolean
? Rez.Drawables.pressureDark
Expand Down Expand Up @@ -233,7 +243,7 @@ class SnoutView extends WatchUi.WatchFace {
batteryInDays = systemStats.batteryInDays.format("%d") + " days";
}

// charging = systemStats.charging;
charging = systemStats.charging;
}

// device settings
Expand Down Expand Up @@ -438,12 +448,41 @@ class SnoutView extends WatchUi.WatchFace {
batteryOutlineBitmapCoordinate.Y,
batteryOutlineBitmap
);
dc.fillRectangle(
batteryOutlineBitmapCoordinate.X + 3,
batteryOutlineBitmapCoordinate.Y + 6,
batteryWidth,
3
);
if(charging){
dc.setColor(
Properties.getValue("DarkMode") as Boolean
? 0x000000
: 0xFFFFFF,
Properties.getValue("DarkMode") as Boolean
? 0xFFFFFF
: 0x000000
);
dc.fillRectangle(
batteryOutlineBitmapCoordinate.X + 4,
batteryOutlineBitmapCoordinate.Y + 2,
8,
11
);
dc.setColor(
Properties.getValue("DarkMode") as Boolean
? 0xFFFFFF
: 0x000000,
Graphics.COLOR_TRANSPARENT
);
dc.drawBitmap(
batteryOutlineBitmapCoordinate.X + 1,
batteryOutlineBitmapCoordinate.Y,
boltBitmap
);
}else{
dc.fillRectangle(
batteryOutlineBitmapCoordinate.X + 3,
batteryOutlineBitmapCoordinate.Y + 6,
batteryWidth,
3
);
}


dc.drawText(
batteryCoordinate.X,
Expand Down

0 comments on commit 6a84988

Please sign in to comment.