Add check preventing same location being written to flash twice
parent
b19aa8d0ae
commit
f35ce929f4
|
|
@ -125,6 +125,7 @@ E.on('notify',msg=>{
|
||||||
// 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") {
|
||||||
// parse the message body into json:
|
// parse the message body into json:
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue