Add check preventing same location being written to flash twice

master
RKBoss6 2025-08-01 16:09:59 -04:00 committed by GitHub
parent b19aa8d0ae
commit f35ce929f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 0 deletions

View File

@ -124,6 +124,7 @@ E.on('notify',msg=>{
"tv.twitch": "Twitch", "tv.twitch": "Twitch",
// could also use NRF.ancsGetAppInfo(msg.appId) here // could also use NRF.ancsGetAppInfo(msg.appId) here
}; };
//if (appNames[msg.appId]) msg.a //if (appNames[msg.appId]) msg.a
if (msg.title === "BangleDumpCalendar") { if (msg.title === "BangleDumpCalendar") {
@ -227,6 +228,12 @@ E.on('notify',msg=>{
lon: d.lon, lon: d.lon,
location:d.city location:d.city
}, require("Storage").readJSON("mylocation.json", true) || {}); }, require("Storage").readJSON("mylocation.json", true) || {});
if(Math.abs(myLocationJson.lat - locationJson.lat) < 0.0001 && Math.abs(myLocationJson.lon -locationJson.lon) < 0.0001){
//same location, do not write
return;
}
myLocationJson.lon=locationJson.lon; myLocationJson.lon=locationJson.lon;
myLocationJson.lat=locationJson.lat; myLocationJson.lat=locationJson.lat;
myLocationJson.location=locationJson.city; myLocationJson.location=locationJson.city;