mirror of https://github.com/espruino/BangleApps
Solar Clock: GPS location now only updates once per day.
parent
1dded3904f
commit
6c96a02a5e
|
@ -296,10 +296,9 @@
|
|||
{"name":"solar_graphic_utils.js","url":"solar_graphic_utils.js"},
|
||||
{"name":"solar_location.js","url":"solar_location.js"},
|
||||
{"name":"solar_math_utils.js","url":"solar_math_utils.js"},
|
||||
{"name":"solar_loc.Iceland.json","url":"solar_loc.Iceland.json"},
|
||||
{"name":"solar_loc.Kauai.json","url":"solar_loc.Kauai.json"},
|
||||
{"name":"solar_loc.Reykjavik.json","url":"solar_loc.Reykjavik.json"},
|
||||
{"name":"solar_loc.Honolulu.json","url":"solar_loc.Honolulu.json"},
|
||||
{"name":"solar_loc.Tokyo.json","url":"solar_loc.Tokyo.json"},
|
||||
{"name":"solar_loc.local.json","url":"solar_loc.local.json"},
|
||||
{"name":"solar_locations.json","url":"solar_locations.json"}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -199,15 +199,18 @@ function write_GPS_status(){
|
|||
}
|
||||
|
||||
const TWILIGHT_X_COORD = 200;
|
||||
const NO_TIME = "--:--";
|
||||
|
||||
var twilight_times_requires_update = true;
|
||||
function write_twilight_times(){
|
||||
if(!twilight_times_requires_update)
|
||||
return;
|
||||
|
||||
var twilight_msg=[];
|
||||
var twilight_msg;
|
||||
if(day_info != null) {
|
||||
twilight_msg = [format_time(day_info.sunrise_date), format_time(day_info.sunset_date)];
|
||||
} else {
|
||||
twilight_msg = [NO_TIME,NO_TIME];
|
||||
}
|
||||
g.setColor(screen_info.screen_bg_color[0],screen_info.screen_bg_color[1],screen_info.screen_bg_color[2]);
|
||||
g.fillRect(TWILIGHT_X_COORD,INFO_PANEL_LINE_Y1,240,INFO_PANEL_LINE_Y2 + 13);
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"coordinates": [-0.12574, 51.50853]
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
const storage = require("Storage");
|
||||
const DateUtils = require("solar_date_utils.js");
|
||||
class LocationManager {
|
||||
constructor(locations) {
|
||||
this.idx=0;
|
||||
|
@ -10,12 +11,26 @@ class LocationManager {
|
|||
this.location_info = null;
|
||||
}
|
||||
init(){
|
||||
this.location_info = storage.readJSON("solar_loc." + this.getName() + ".json");
|
||||
if(this.isGPSLocation() && !this.gps_queried) {
|
||||
console.log("updating local location");
|
||||
this._gpsUpdate();
|
||||
this.gps_queried = true;
|
||||
}
|
||||
try {
|
||||
this.location_info = storage.readJSON("solar_loc." + this.getName() + ".json");
|
||||
} catch(e){
|
||||
console.log("failed to load location:" + this.getName())
|
||||
}
|
||||
if(this.location_info == null){
|
||||
this.location_info = {};
|
||||
}
|
||||
if (this.isGPSLocation() && !this.gps_queried) {
|
||||
//console.log("gps location:" + JSON.stringify(this.location_info));
|
||||
var last_update_str = this.location_info.last_update;
|
||||
if(last_update_str == null ||
|
||||
(Date.now() - new Date(last_update_str).getTime() > DateUtils.DAY_MILLIS ) ){
|
||||
console.log("updating local location last update:" + last_update_str);
|
||||
this._gpsUpdate();
|
||||
this.gps_queried = true;
|
||||
} else {
|
||||
console.log("gps update not required last update:" + last_update_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
setGPSPower(power){
|
||||
this.gpsPower = power;
|
||||
|
|
Loading…
Reference in New Issue