Added wind to datapoints.

pull/1419/head
David Peer 2022-02-10 22:17:18 +01:00
parent 1882f08838
commit 6bdf68d39b
5 changed files with 64 additions and 43 deletions

View File

@ -12,4 +12,5 @@
0.12: Added humidity as an option to display.
0.13: Improved battery visualization.
0.14: Added altitude as an option to display.
0.15: Using wpedom to count steps.
0.15: Using wpedom to count steps.
0.16: Improved stability. Wind can now be shown.

View File

@ -1,8 +1,9 @@
# LCARS clock
A simple LCARS inspired clock.
Note: To display the steps, the health app is required. If this app is not installed, the data will not be shown.
To contribute you can open a PR at this [GitHub Repo]( https://github.com/peerdavid/BangleApps)
Note: To display the steps, the wpedom app is required. To show weather data
such as temperature, humidity or window you BangleJS must be connected
with Gadgetbride and the weather app must be installed.
## Control
* Tap left / right to change between screens.
@ -25,6 +26,7 @@ To contribute you can open a PR at this [GitHub Repo]( https://github.com/peerda
* HRM - Last measured HRM
* Temp - Weather temperature loaded via the weather module + gadgetbridge
* Humidity - Humidity loaded via the weather module + gadgetbridge
* Wind - Wind loaded via the weather module + gadgetbridge
* Altitude - Shows the altitude in m.
* CoreT - Temperature of device
@ -35,9 +37,6 @@ Access different screens via tap on the left/ right side of the screen
![](screenshot_2.png)
# Ideas
- Tap top / bottom to disable steps (also icon) and start a timer
## Contributors
- [David Peer](https://github.com/peerdavid).
- [Adam Schmalhofer](https://github.com/adamschmalhofer).

View File

@ -122,17 +122,17 @@ function printRow(text, value, y, c){
g.setFontAntonioMedium();
g.setFontAlign(-1,-1,0);
g.setColor(c);
g.fillRect(79, y-2, 85 ,y+18);
g.fillRect(77, y-2, 83 ,y+18);
g.setFontAlign(0,-1,0);
g.drawString(value, 110, y);
g.setColor(c);
g.setFontAlign(-1,-1,0);
g.fillRect(133, y-2, 165 ,y+18);
g.fillCircle(161, y+8, 10);
g.fillRect(135, y-2, 165 ,y+18);
g.fillCircle(163, y+8, 10);
g.setColor(cBlack);
g.drawString(text, 135, y);
g.drawString(text, 137, y);
}
@ -174,6 +174,11 @@ function _drawData(key, y, c){
var weather = getWeather();
value = weather.hum;
} else if (key == "WIND"){
text = "WND";
var weather = getWeather();
value = weather.wind;
} else if (key == "ALTITUDE"){
should_print= false;
text = "ALT";
@ -248,16 +253,16 @@ function drawState(){
hours % 4 == 1 ? iconMars :
hours % 4 == 2 ? iconMoon :
iconEarth;
g.drawImage(iconImg, 24, 118);
g.drawImage(iconImg, 23, 118);
g.setColor(cWhite);
g.drawString("STATUS", 24+25, 108);
g.drawString("STATUS", 23+25, 108);
} else {
// Alarm within symbol
g.setColor(cOrange);
g.drawString("ALARM", 24+25, 108);
g.drawString("ALARM", 23+25, 108);
g.setColor(cWhite);
g.setFontAntonioLarge();
g.drawString(getAlarmMinutes(), 24+25, 108+35);
g.drawString(getAlarmMinutes(), 23+25, 108+35);
}
g.setFontAlign(-1, -1, 0);
@ -425,18 +430,24 @@ function drawPosition1(){
}
function draw(){
// First handle alarm to show this correctly afterwards
handleAlarm();
// Next draw the watch face
g.reset();
g.clearRect(0, 0, g.getWidth(), g.getHeight());
try{
// First handle alarm to show this correctly afterwards
handleAlarm();
// Draw current lcars position
if(lcarsViewPos == 0){
drawPosition0();
} else if (lcarsViewPos == 1) {
drawPosition1();
// Next draw the watch face
g.reset();
g.clearRect(0, 0, g.getWidth(), g.getHeight());
// Draw current lcars position
if(lcarsViewPos == 0){
drawPosition0();
} else if (lcarsViewPos == 1) {
drawPosition1();
}
} catch (ex){
// In case of an exception, we simply queue
// and try it in one minute again...
}
// Queue draw in one minute
@ -463,29 +474,39 @@ function getSteps() {
function getWeather(){
var weather;
var weatherJson;
try {
weather = require('weather').get();
weatherJson = storage.readJSON('weather.json');
} catch(ex) {
// Return default
}
if (weather === undefined){
weather = {
temp: "-",
hum: "-",
txt: "-",
wind: "-",
wdir: "-",
wrose: "-"
};
} else {
weather.temp = locale.temp(Math.round(weather.temp-273.15))
if(weatherJson){
var weather = weatherJson.weather;
// Temperature
const temp = locale.temp(weather.temp-273.15).match(/^(\D*\d*)(.*)$/);
weather.temp = temp[1] + " " + temp[2].toUpperCase();
// Humidity
weather.hum = weather.hum + "%";
// Wind
const wind = locale.speed(weather.wind).match(/^(\D*\d*)(.*)$/);
weather.wind = wind[1] + wind[2].toUpperCase();
return weather
}
return weather;
return {
temp: "-",
hum: "-",
txt: "-",
wind: "-",
wdir: "-",
wrose: "-"
};
}

View File

@ -18,14 +18,14 @@
storage.write(SETTINGS_FILE, settings)
}
var data_options = ["Steps", "Battery", "VREF", "HRM", "Temp", "Humidity", "Altitude", "CoreT"];
var data_options = ["Steps", "Battery", "VREF", "HRM", "Temp", "Humidity", "Wind", "Altitude", "CoreT"];
E.showMenu({
'': { 'title': 'LCARS Clock' },
'< Back': back,
'Row 1': {
value: 0 | data_options.indexOf(settings.dataRow1),
min: 0, max: 7,
min: 0, max: 8,
format: v => data_options[v],
onchange: v => {
settings.dataRow1 = data_options[v];
@ -34,7 +34,7 @@
},
'Row 2': {
value: 0 | data_options.indexOf(settings.dataRow2),
min: 0, max: 7,
min: 0, max: 8,
format: v => data_options[v],
onchange: v => {
settings.dataRow2 = data_options[v];
@ -43,7 +43,7 @@
},
'Row 3': {
value: 0 | data_options.indexOf(settings.dataRow3),
min: 0, max: 7,
min: 0, max: 8,
format: v => data_options[v],
onchange: v => {
settings.dataRow3 = data_options[v];

View File

@ -3,7 +3,7 @@
"name": "LCARS Clock",
"shortName":"LCARS",
"icon": "lcars.png",
"version":"0.15",
"version":"0.16",
"readme": "README.md",
"supports": ["BANGLEJS2"],
"description": "Library Computer Access Retrieval System (LCARS) clock.",