diff --git a/platformio.ini b/platformio.ini index 1a3f364..80d8549 100644 --- a/platformio.ini +++ b/platformio.ini @@ -8,12 +8,17 @@ ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html -[env:m5stack-atom] +[env] platform = espressif32 -board = m5stack-atom framework = arduino lib_deps = ttlappalainen/NMEA2000-library @ ^4.17.2 ttlappalainen/NMEA2000_esp32 @ ^1.0.3 ttlappalainen/NMEA0183 @ ^1.7.1 bblanchon/ArduinoJson@^6.18.5 + +[env:m5stack-atom] +board = m5stack-atom +lib_deps = + ${env.lib_deps} +build_flags= -D BOARD_M5ATOM diff --git a/src/index_html.h b/src/index_html.h index 416336c..ad15ab7 100644 --- a/src/index_html.h +++ b/src/index_html.h @@ -4,62 +4,13 @@ const char indexHTML[] PROGMEM = R"=====( -ADC Anzeigeinstrument - +NMEA 2000 Gateway - + function reset(){ + fetch('/api/reset'); + } + - -
-
-Anzeigeinstrument für Kühlschranktemperatur -
-
-
-
-
+ + +
+

NMEA 2000 Gateway

+
)=====" ; -const char gauge[] PROGMEM = R"=====( -var Gauge=function(b){function l(a,b){for(var c in b)"object"==typeof b[c]&&"[object Array]"!==Object.prototype.toString.call(b[c])&&"renderTo"!=c?("object"!=typeof a[c]&&(a[c]={}),l(a[c],b[c])):a[c]=b[c]}function q(){z.width=b.width;z.height=b.height;A=z.cloneNode(!0);B=A.getContext("2d");C=z.width;D=z.height;t=C/2;u=D/2;f=tc;c++)b.majorTicks.push(w(b.minValue+h*c));b.majorTicks.push(w(b.maxValue))}for(c=0;ca;a=Math.abs(a);if(0n?Math.abs(b.minValue-n):0b.maxValue?b.maxValue+d:a=(7-4*b)/11){a=-Math.pow((11-6*b-11*a)/4,2)+Math.pow(c,2);break a}a=void 0}return 1-a},elastic:function(a){a=1-a;return 1-Math.pow(2,10*(a-1))*Math.cos(30*Math.PI/3*a)}},G=null;a.lineCap="round";this.draw=function(){if(!A.i8d){B.clearRect(-t,-u,C,D);B.save();var g={ctx:a};a=B;p();N();J();d();s();b.title&&(a.save(),a.font=24*(f/200)+"px Arial",a.fillStyle=b.colors.title,a.textAlign="center",a.fillText(b.title,0,-f/4.25),a.restore());b.units&&(a.save(),a.font=22*(f/200)+"px Arial", -a.fillStyle=b.colors.units,a.textAlign="center",a.fillText(b.units,0,f/3.25),a.restore());A.i8d=!0;a=g.ctx;delete g.ctx}a.clearRect(-t,-u,C,D);a.save();a.drawImage(A,-t,-u,C,D);if(Gauge.initialized)L(),K(),H||(E.onready&&E.onready(),H=!0);else var e=setInterval(function(){Gauge.initialized&&(clearInterval(e),L(),K(),H||(E.onready&&E.onready(),H=!0))},10);return this}};Gauge.initialized=!1; -(function(){var b=document,l=b.getElementsByTagName("head")[0],q=-1!=navigator.userAgent.toLocaleLowerCase().indexOf("msie"),v="@font-face {font-family: 'Led';src: url('fonts/digital-7-mono."+(q?"eot":"ttf")+"');}",k=b.createElement("style");k.type="text/css";if(q)l.appendChild(k),l=k.styleSheet,l.cssText=v;else{try{k.appendChild(b.createTextNode(v))}catch(e){k.cssText=v}l.appendChild(k);l=k.styleSheet?k.styleSheet:k.sheet||b.styleSheets[b.styleSheets.length-1]}var g=setInterval(function(){if(b.body){clearInterval(g); -var e=b.createElement("div");e.style.fontFamily="Led";e.style.position="absolute";e.style.height=e.style.width=0;e.style.overflow="hidden";e.innerHTML=".";b.body.appendChild(e);setTimeout(function(){Gauge.initialized=!0;e.parentNode.removeChild(e)},250)}},1)})();Gauge.Collection=[]; -Gauge.Collection.get=function(b){if("string"==typeof b)for(var l=0,q=this.length;l #include // This will automatically choose right CAN library and create suitable NMEA2000 object @@ -32,6 +39,7 @@ #include "BoatData.h" + #define ENABLE_DEBUG_LOG 0 // Debug log, set to 1 to enable AIS forward on USB-Serial / 2 for ADC voltage to support calibration #define UDP_Forwarding 0 // Set to 1 for forwarding AIS from serial2 to UDP brodcast #define HighTempAlarm 12 // Alarm level for fridge temperature (higher) @@ -141,14 +149,15 @@ void debug_log(char* str) { #endif } -void Ereignis_Index() // Wenn "http:///" aufgerufen wurde +void web_index() // Wenn "http:///" aufgerufen wurde { webserver.send(200, "text/html", indexHTML); //dann Index Webseite senden } -void Ereignis_js() // Wenn "http:///gauge.min.js" aufgerufen wurde +void js_reset() // Wenn "http:///gauge.min.js" aufgerufen wurde { - webserver.send(200, "text/html", gauge); // dann gauge.min.js senden + Serial.println("Reset Button"); + ESP.restart(); } @@ -169,10 +178,10 @@ void setup() { // Init USB serial port Serial.begin(115200); - + Serial.println("Starting..."); // Init AIS serial port 2 - Serial2.begin(baudrate, rs_config); - NMEA0183.Begin(&Serial2, 3, baudrate); + //Serial2.begin(baudrate, rs_config); + //NMEA0183.Begin(&Serial2, 3, baudrate); if (WLAN_CLIENT == 1) { Serial.println("Start WLAN Client"); // WiFi Mode Client @@ -183,7 +192,7 @@ void setup() { while (WiFi.status() != WL_CONNECTED && wifi_retry < 20) { // Check connection, try 10 seconds wifi_retry++; - delay(500); + delay(5000); Serial.print("."); } } @@ -218,8 +227,8 @@ void setup() { // Start Web Server - webserver.on("/", Ereignis_Index); - webserver.on("/gauge.min.js", Ereignis_js); + webserver.on("/", web_index); + webserver.on("/api/reset", js_reset); webserver.onNotFound(handleNotFound); webserver.begin(); @@ -485,7 +494,7 @@ void loop() { WiFi.mode(WIFI_OFF); WiFi.mode(WIFI_STA); WiFi.begin(CL_ssid, CL_password); - delay(100); + delay(1000); } if (wifi_retry >= 5) { Serial.println("\nReboot"); // Did not work -> restart ESP32