Moin Roland
meinst du soetwas???
Dazu musst du deine Palette erweitern
node-red-contrib-compass
Das Auto muss dazu fahren, um eine genauere Anzeige zu bekommen im Stillstand funktioniert das nicht richtig.
Edit:
Ich habe das noch mal überarbeitet, hab das eben bei der Fahrt getest, der Pfeil zeigte in die falsche Richtung, und ich habe noch etwas reingebracht das bei geschwindigkeit unter 6 Kmh die Daten nicht an die Gauge weitergeleitet werden. Da das ja kein Magnetischer Sensor ist, spinnt die Anzeige im Stillstand.
[{"id":"78fde06682e35be7","type":"function","z":"2f9d5339148076f5","name":"berechnung","func":"// Speichern des vorherigen Punktes im context\nvar prev = context.get('prev') || {lat: msg.payload.lat, lon: msg.payload.lon};\n\nvar lat1 = prev.lat * Math.PI / 180;\nvar lat2 = msg.payload.lat * Math.PI / 180;\nvar lon1 = prev.lon * Math.PI / 180;\nvar lon2 = msg.payload.lon * Math.PI / 180;\n\n// Berechnung der Differenz\nvar dLon = (lon2 - lon1);\n\n// Richtung berechnen\nvar y = Math.sin(dLon) * Math.cos(lat2);\nvar x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon);\nvar bearing = Math.atan2(y, x) * 180 / Math.PI;\n\n// Ergebnis normalisieren (0-360 Grad)\nmsg.payload.heading = (bearing + 360) % 360;\n\n// Aktuellen Punkt für nächste Berechnung speichern\ncontext.set('prev', {lat: msg.payload.lat, lon: msg.payload.lon});\n\nreturn msg;\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":390,"y":2040,"wires":[["afd6f886a2153612","a48886a240904630","3ca68826ac647fed"]]},{"id":"b8dc2fd90eebbce8","type":"inject","z":"2f9d5339148076f5","name":"360","props":[{"p":"payload.heading","v":"360","vt":"num"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":370,"y":2160,"wires":[["afd6f886a2153612","a48886a240904630"]]},{"id":"565e3e3485fd0104","type":"inject","z":"2f9d5339148076f5","name":"90","props":[{"p":"payload.heading","v":"90","vt":"num"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":370,"y":2220,"wires":[["afd6f886a2153612","a48886a240904630"]]},{"id":"4206f25681dbcf8c","type":"inject","z":"2f9d5339148076f5","name":"180","props":[{"p":"payload.heading","v":"180","vt":"num"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":370,"y":2280,"wires":[["afd6f886a2153612","a48886a240904630"]]},{"id":"956d731418d6c353","type":"inject","z":"2f9d5339148076f5","name":"270","props":[{"p":"payload.heading","v":"270","vt":"num"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":370,"y":2340,"wires":[["afd6f886a2153612","a48886a240904630"]]},{"id":"7219bd077fd83373","type":"ui_gauge","z":"2f9d5339148076f5","name":"Compas","group":"e797d7dc72663634","order":3,"width":0,"height":0,"gtype":"compass","title":"Compas","label":"{{msg.payload.unit}}","format":"{{msg.payload.value}}°","min":"360","max":"0","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","diff":false,"className":"","x":1060,"y":2220,"wires":[]},{"id":"ca6b7a3f0369dc1f","type":"debug","z":"2f9d5339148076f5","name":"debug 63","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":1040,"y":2040,"wires":[]},{"id":"00316a9dc61c0127","type":"function","z":"2f9d5339148076f5","name":"function 1","func":"let unit = (msg.payload.description);\nlet speed = global.get(\"GV_Geschw\");\n\n\n msg.payload = unit;\n global.set(\"direction\",unit)\n return msg;\n \n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":880,"y":2100,"wires":[["3a6e303991abe252"]]},{"id":"3a6e303991abe252","type":"debug","z":"2f9d5339148076f5","name":"debug 64","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1040,"y":2100,"wires":[]},{"id":"a48886a240904630","type":"function","z":"2f9d5339148076f5","name":"function 2","func":"let unit = global.get(\"direction\");\nlet value = msg.payload.heading;\nvalue = Math.round(value);\nlet speed = global.get(\"GV_Geschw\");\n\nif (speed >= 6){\nmsg.payload={\n \"unit\":unit,\n \"value\":value\n}\nreturn ([msg, null])\n}\nif (speed <6){\n return ([null,msg])\n}\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":880,"y":2220,"wires":[["7219bd077fd83373","55ebec98b18d73f1"]]},{"id":"afd6f886a2153612","type":"compass-point","z":"2f9d5339148076f5","direction":"toCompass","subset":"secondary","language":"de","inputField":"payload.heading","outputField":"payload","name":"","x":820,"y":2040,"wires":[["ca6b7a3f0369dc1f","00316a9dc61c0127"]]},{"id":"3ca68826ac647fed","type":"debug","z":"2f9d5339148076f5","name":"debug 173","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":390,"y":2100,"wires":[]},{"id":"2a4913dbfc0cb56c","type":"comment","z":"2f9d5339148076f5","name":"node-red-contrib-compass","info":"","x":810,"y":2000,"wires":[]},{"id":"08e238fa385eef45","type":"inject","z":"2f9d5339148076f5","name":"7 kmh","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"7","payloadType":"num","x":210,"y":2200,"wires":[["3421f0b92f57602a"]]},{"id":"8a2a3bbfd7724bd3","type":"inject","z":"2f9d5339148076f5","name":"5 kmh","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"5","payloadType":"num","x":210,"y":2260,"wires":[["3421f0b92f57602a"]]},{"id":"55ebec98b18d73f1","type":"debug","z":"2f9d5339148076f5","name":"debug 65","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1020,"y":2300,"wires":[]},{"id":"3421f0b92f57602a","type":"function","z":"2f9d5339148076f5","name":"function 3","func":"global.set(\"GV_Geschw\",msg.payload);\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":220,"y":2340,"wires":[[]]},{"id":"e797d7dc72663634","type":"ui_group","name":"Schalter","tab":"c0f2413f38763126","order":1,"disp":true,"width":6,"collapse":false},{"id":"c0f2413f38763126","type":"ui_tab","name":"GPS","icon":"map","order":38,"disabled":false,"hidden":false}]