Skip to content

Commit

Permalink
Merge pull request espruino#3515 from prefectAtEarth/master
Browse files Browse the repository at this point in the history
feat(measuretime): visual improvements
  • Loading branch information
thyttan authored Jul 18, 2024
2 parents 5d6b7fc + fe82233 commit 13f74e1
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 18 deletions.
3 changes: 2 additions & 1 deletion apps/measuretime/ChangeLog
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
0.1: Initial release
0.1: Initial release
0.2: Draw line for 3d effect, fix number alignment
6 changes: 4 additions & 2 deletions apps/measuretime/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Measure Time

Measure time in a fancy way. Inspired by a Watchface I had on my first Pebble Watch.
Icon from [Flaticon created by Smartline]("https://www.flaticon.com/free-icons/scale")

Written by [prefectAtEarth](https://www.github.com/prefectAtEarth/)
Watchface written by [prefectAtEarth](https://www.github.com/prefectAtEarth/)

![](measuretime.png)
![](screenshot_light.png)
![](screenshot_dark.png)
2 changes: 1 addition & 1 deletion apps/measuretime/measuretime-icon.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 19 additions & 11 deletions apps/measuretime/measuretime.app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
require("Font7x11Numeric7Seg").add(Graphics);
g.setFont("7x11Numeric7Seg");
g.setFontAlign(0, 0);

const centerY = g.getHeight() / 2; //88
const lineStart = 25;
Expand All @@ -27,10 +25,10 @@
var steps = [0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
var stepsReversed = steps.slice();
stepsReversed.reverse();
var polyLeftTop = [];
var polyLeftBottom = [];
var polyRightTop = [];
var polyRightBottom = [];
var polyLeftTop = [0, 0];
var polyLeftBottom = [0, g.getHeight()];
var polyRightTop = [g.getWidth() - 1, 0];
var polyRightBottom = [g.getWidth() - 1, g.getHeight()];
let xL = 0;
let xR = g.getWidth() - 1;
let yT = centerY - 13;
Expand Down Expand Up @@ -70,6 +68,16 @@
g.fillPolyAA(polyRightBottom, true);
};

let hourStringXOffset = function (hour) {
if (hour == 1) {
return lineEndFull - 5;
}
if (hour < 10 || hour >= 20) {
return lineEndFull + 5;
}
return lineEndFull - 5;
};

let drawTime = function () {
g.clear();
var d = new Date();
Expand All @@ -86,19 +94,19 @@

var lineEnd = lineEndDefault;
g.setFont("7x11Numeric7Seg", 2);
g.setFontAlign(0, 0);
g.setFontAlign(-1, 0);

// gone
do {
switch (yTopLines - 88 + mins) {
case -60:
lineEnd = lineEndFull;
g.drawString(d.getHours() - 1, lineEnd + 10, yTopLines, true);
g.drawString(d.getHours()-1, hourStringXOffset(d.getHours()-1), yTopLines, true);
break;
case 0:
case 60:
lineEnd = lineEndFull;
g.drawString(d.getHours(), lineEnd + 10, yTopLines, true);
g.drawString(d.getHours(), hourStringXOffset(d.getHours()), yTopLines, true);
break;
case 45:
case -45:
Expand Down Expand Up @@ -128,11 +136,11 @@
case 0:
case 60:
lineEnd = lineEndFull;
g.drawString(d.getHours() + 1, lineEnd + 10, yBottomLines, true);
g.drawString(d.getHours() + 1, hourStringXOffset(d.getHours()+1), yBottomLines, true);
break;
case 120:
lineEnd = lineEndFull;
g.drawString(d.getHours() + 2, lineEnd + 10, yBottomLines, true);
g.drawString(d.getHours() + 2, hourStringXOffset(d.getHours()+2), yBottomLines, true);
break;
case 15:
case 75:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions apps/measuretime/metadata.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"id": "measuretime",
"name": "Measure Time",
"version": "0.1",
"version": "0.2",
"description": "Measure Time in a fancy way.",
"icon": "small_measuretime.png",
"screenshots": [{ "url": "measuretime.png" }],
"icon": "measuretime_icon.png",
"screenshots": [
{ "url": "screenshot_light.png" },
{ "url": "screenshot_dark.png" }
],
"type": "clock",
"tags": "clock",
"supports": ["BANGLEJS2"],
Expand Down
Binary file added apps/measuretime/screenshot_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/measuretime/screenshot_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed apps/measuretime/small_measuretime.png
Binary file not shown.

0 comments on commit 13f74e1

Please sign in to comment.