From f32ab8383beab1e3d040c1614365edd10ba14693 Mon Sep 17 00:00:00 2001 From: frederic wagner Date: Mon, 11 Jul 2022 16:51:03 +0200 Subject: [PATCH] gipy : initial commit --- apps/gipy/README.md | 13 ++++++ apps/gipy/app.js | 85 ++++++++++++++++++++++++++++++++++++++++ apps/gipy/gipy.img | Bin 0 -> 1156 bytes apps/gipy/gipy.png | Bin 0 -> 1606 bytes apps/gipy/metadata.json | 22 +++++++++++ 5 files changed, 120 insertions(+) create mode 100644 apps/gipy/README.md create mode 100644 apps/gipy/app.js create mode 100644 apps/gipy/gipy.img create mode 100644 apps/gipy/gipy.png create mode 100644 apps/gipy/metadata.json diff --git a/apps/gipy/README.md b/apps/gipy/README.md new file mode 100644 index 000000000..f28a2ed46 --- /dev/null +++ b/apps/gipy/README.md @@ -0,0 +1,13 @@ +# Gipy + +Development still in progress. Follow compressed gpx traces. +Warns you before reaching intersections and tries to turn off gps. + +## Usage + +WIP. + + +## Creator + +frederic.wagner@imag.fr diff --git a/apps/gipy/app.js b/apps/gipy/app.js new file mode 100644 index 000000000..92ec0ccfc --- /dev/null +++ b/apps/gipy/app.js @@ -0,0 +1,85 @@ + +// screen size is 172x172 +// we want to show 100 meters ahead +// 86 pixels is 100 meters +// 10 meters is 8.6 pixels +// 1 integer unit is 1.1 meter +// 8.6 pixels is 10 / 1.1 integers +// int = 8.6 pix * 1.1 / 10 +// int = 0.946 pixels + +var lat = null; +var lon = null; + +class Path { + constructor(filename) { + let buffer = require("Storage").readArrayBuffer(filename); + this.points_number = (buffer.byteLength - 2*8)/4; + this.view = DataView(buffer); + this.min_lon = this.view.getFloat64(0); + this.min_lat = this.view.getFloat64(8); + this.current_start = 0; // index of first point to be displayed + this.current_x = 0; + this.current_y = 0; + } + + get len() { + return this.points_number; + } +} + +class Point { + constructor(lon, lat) { + this.lon = lon; + this.lat = lat; + } + screen_x() { + return 192/2 + Math.round((this.lon - lon) * 100000.0); + } + screen_y() { + return 192/2 + Math.round((this.lat - lat) * 100000.0); + } +} + +function display(path) { + g.clear(); + let previous_point = null; + let current_x = path.current_x; + let current_y = path.current_y; + for (let i = path.current_start ; i < path.len ; i++) { + current_x += path.view.getInt16(2*8+4*i); + current_y += path.view.getInt16(2*8+4*i+2); + let point = new Point(current_x/100000.0 + path.min_lon, current_y/100000.0 + path.min_lat); + + if (previous_point !== null) { + g.drawLine( + previous_point.screen_x(), + previous_point.screen_y(), + point.screen_x(), + point.screen_y() + ); + } + previous_point = point; + } + g.setColor(1.0, 0.0, 0.0); + g.fillCircle(192/2, 192/2, 5); +} + +let path = new Path("test.gpc"); +lat = path.min_lat; +lon = path.min_lon; + +function set_coordinates(data) { + if (!isNaN(data.lat)) { + lat = data.lat; + } + if (!isNaN(data.lon)) { + lon = data.lon; + } +} + +Bangle.setGPSPower(true, "gipy"); +Bangle.on('GPS', set_coordinates); + +setInterval(display, 1000, path); + diff --git a/apps/gipy/gipy.img b/apps/gipy/gipy.img new file mode 100644 index 0000000000000000000000000000000000000000..9d6a7a9217c6ab57c6e0b17cb8535e24c90b03ef GIT binary patch literal 1156 zcmchVI}*Y$3`E^9xlWFfCikH81#)mKX?JbQ$qWrpFz~#eNY1`rSL%#4(mNw3t2scvQ2IQ3e>p z0Xz<%`|Xbn&~+G?24HufHEWh+$xB8yZ#2ztY8n7^U3aCOKT`lu0l1YZC3upF;7)A?#Cl%ocKpz5V6hfT1bn)f|y}rK9s&=X? zr3(L>2Y|tm$kiZ#`6|An5eWG5_Yg2qEyz>+)$4aU(Oum-ZalHr0U$Xl)W#&IE=k|p z6rCgNb`tdFWyCWN&{?PE0pN*qX`d44S4HUeYvH!fR5`W_kR)D@ALZ`li)W$tSNP_Pu);1oko7EpIdRp1dF6+)21mEspF+eR zStb*n2ILnNi}F`hd%dP3Cje2QHl&)QSfq`PXd0>7{N_n)x=UJ-jdWUQx0f%p52B^a4*+O8G zcYF2Ki}$eOFA8or!z{-F_}i%l6EdaLz72Ri)12hr(+J!_Wx<>w zQpy(CU72FdG^Dm^^WLnjy=EiF8p;p2Uj~5UjONc(@t`*^gGp-!*w&d=ffEs??2?*w ze_A11Dxm5}cF%A)asq%R$u+bjea|@+FR;inmY6?=we5x({vyUCe@)$2iHHfG0iAVm zGaPBatxa4H!QoBYw&iFl?&8q8eIS|zK-#u^H+nIlC9uddHW4vl0jUR%=>)VBqRi91 zuf*N<7KPSr1>$duZ6JjhyDPo3$C!~!r%+jI)@Z@J4?y%UE?Ka9$xF@3QxXFd^m!Tp zo^H>x(&BX?jP$~)4PUFGaYvx)NOn)bya}=90YH$XhO*Xd<@!$m|9d&&0ppZ2)9t~X zr4-v%&7J$ODyl5t*1R`1!Tj*jLvUoX-jb=@*XZ^2Z7f6{0JiNp7Eig7jgTr}I)wrU z-9-!v#0eJ_k8BDi>N()^Y<0S4ih@BJ2Kp=OerewrcM4UuOzOsrQWL>t!NaerPEU71 zu&lFT(hM3)_+#|ru_M}zr679LM6kOdwYL-XN}5c#mRp8I%(AL1psdB+7eosZ3NpNb zL*pMerO?$ImJKEXpW#@^b+eFn-8W{oj14**jFt!{UsKACBjMSF=M zcwbDDil?8-=>%|1B0XjbRX4fgZrpBPsifO7Y0{kr-VoiWEFks#wL$;`Er<@dktPaM z0X;W287ynjL1zvCjRm3gKSejj6c9W-p$~v%)^&OLs@949+qdYtF1mIV4Irp4YVCt? zDI(dY3dIy)7)Ai#E;i&-G>(+r`4TM5>6~`{%oYZ{=D?~7VTO34WX*cz8N~ANTDfQ{ zTR6M7OJEm3!|eN1B20u_f2eMAJVJ+EFa;ORejb8$GSDIGJ_G-NXj)NdUCheU9(D@& zK3*W;%l9x)gV?`@oPn`NxWaGwD>t6)5WNR@fcqH#0oLvGD9P1zN&o-=07*qoM6N<$ Ef?_oAlK=n! literal 0 HcmV?d00001 diff --git a/apps/gipy/metadata.json b/apps/gipy/metadata.json new file mode 100644 index 000000000..9f31726d8 --- /dev/null +++ b/apps/gipy/metadata.json @@ -0,0 +1,22 @@ +{ + "id": "gipy", + "name": "Gipy", + "shortName": "Gipy", + "version": "0.01", + "description": "Follow gpx files", + "allow_emulator":false, + "icon": "gipy.img", + "type": "app", + "tags": "tool,outdoors,gps", + "screenshots": [{"url":"screenshot_gipy.png"}], + "supports": ["BANGLEJS2"], + "readme": "README.md", + "storage": [ + {"name":"gipy.app.js","url":"app.js"}, + {"name":"gipy.img","url":"gipy-icon.js","evaluate":true}, + {"name":"gipy.settings.js","url":"settings.js"} + ], + "data": [ + {"name":"gipy.gpc"} + ] +}