diff --git a/README.md b/README.md index aee77b12654153aab529e2514c6d7855b56e5f4f..8b0fbc41b6667c3aeee4d926a60ec27639faef66 100644 --- a/README.md +++ b/README.md @@ -99,4 +99,34 @@ firefox localhost:9080 ### ESP -@todo \ No newline at end of file +@todo + +## Visualization locale de l'interface utilisateur sans l'arduino. + +Compiler l'application localement: +``` +# se positionner dans pousseseringue-arduino/ +export ESP8266ARDUINO=~/devel/workspace/src/arduino_esp8266 +export ARDUINOLIB=~/devel/workspace/src/ +cd host_gui +./make.sh +``` +lancer le server: +``` +${ESP8266ARDUINO}/tests/host/bin/pousseseringue-arduino/pousseseringue-arduino +``` + +## Some code details explanation + +### CORE_MOCK + +Ce `CORE_MOCK` permet d'ignorer les ligne qui sont spécifique au micro-controller +afin de compiler le driver sur le PC local. Cela permet notamment de visualiser +le gui sans avoir la carte éléctronique physiquement et de la flasher. +``` +#if !CORE_MOCK + // on the target +#else // !CORE_MOCK + // on host +#endif // !CORE_MOCK +``` diff --git a/host_gui/clean b/host_gui/clean new file mode 100755 index 0000000000000000000000000000000000000000..54ab35854277022aac900156c3f3674d592f948f --- /dev/null +++ b/host_gui/clean @@ -0,0 +1,3 @@ +#!/bin/sh -ex +cd ${ESP8266ARDUINO}/tests/host +make clean diff --git a/host_gui/make.sh b/host_gui/make.sh new file mode 100755 index 0000000000000000000000000000000000000000..56fb9f7caed59379b764cce7cb1e0d894dd3e88e --- /dev/null +++ b/host_gui/make.sh @@ -0,0 +1,5 @@ +#!/bin/sh -ex +pwd=$(pwd) +cd ${ESP8266ARDUINO}/tests/host +make FORCE32=0 ssl +make -j 10 FORCE32=0 D=1 USERCFLAGS="-I ${ARDUINOLIB}/emuAsync/replacement" ULIBDIRS=${ARDUINOLIB}/emuAsync:${ARDUINOLIB}/ESPUI:${ARDUINOLIB}/ArduinoJson:${ARDUINOLIB}/arduinoWebSockets ${pwd}/../pousseseringue-arduino \ No newline at end of file diff --git a/pousseseringue-arduino.cpp b/pousseseringue-arduino.cpp index 0bc11844a59ac7f76cf079a0363a7d7a7ca1cf49..22bd1e117e9db7da227ea547ea5819a027218ebe 100644 --- a/pousseseringue-arduino.cpp +++ b/pousseseringue-arduino.cpp @@ -3,8 +3,6 @@ // Feather LCD // Feather motor controler -#pragma once // necessary for arduino IDE environment ino source file - #if 0 #define STASSID "laas-capture" #define STAPSK "" @@ -52,9 +50,10 @@ #include <ESP8266WiFi.h> // internal, wifi library #include <DNSServer.h> // internal, access point mode +#if !CORE_MOCK #include <SSD1306AsciiWire.h> // https://github.com/greiman/SSD1306Ascii #include <AccelStepper.h> - +#endif // !CORE_MOCK #include "Debouncer.h" // local, debouncer, short counter, long detector #include "common.h" @@ -67,10 +66,10 @@ millis_t nowMs; // to update on main loop(): "nowMs = millis();" Debouncer<nowMs> bA, bB, bC; +#if !CORE_MOCK AccelStepper stepper(AccelStepper::DRIVER, STEP,DIR); - - SSD1306AsciiWire oled; +#endif // !CORE_MOCK constexpr int DNS_PORT = 53; DNSServer dnsServer; @@ -108,11 +107,14 @@ const char* oledMode () void oledPrintMode () { +#if !CORE_MOCK oled.printf("\n mode: %s", oledMode()); +#endif // !CORE_MOCK } void oledRedisplay () { +#if !CORE_MOCK oled.clear(); switch (mode) @@ -153,6 +155,7 @@ void oledRedisplay () default: oled.printf("?"); } +#endif // !CORE_MOCK } void changeMode () @@ -214,21 +217,24 @@ void setup() { Serial.begin(9600); Serial.setDebugOutput(true); +#if !CORE_MOCK Wire.begin(); Wire.setClock(400000L); +#endif // !CORE_MOCK delay(500); +#if !CORE_MOCK oled.begin(&OLED_HW, OLED_I2C); oled.setFont(System5x7); oled.setScrollMode(SCROLL_MODE_AUTO); oled.clear(); oled.println("Booting...\n"); - +#endif // !CORE_MOCK +#if !CORE_MOCK stepper.setMaxSpeed(10000); stepper.setAcceleration(10000); stepper.moveTo(200); - - +#endif // !CORE_MOCK uint8_t mac[6]; WiFi.macAddress(mac); @@ -298,13 +304,14 @@ void loop() } // Stepper - + #if !CORE_MOCK if (stepper.distanceToGo() == 0) { stepper.moveTo(-stepper.currentPosition()); Serial.println("Rotating Motor in opposite direction..."); } stepper.run(); + #endif // !CORE_MOCK webLoop(); dnsServer.processNextRequest(); // AP redirection diff --git a/pousseseringue-arduino.ino b/pousseseringue-arduino.ino index 6d5ef8acb9dba760eac38a8e3b8af38ff6bf1f36..9207b3375a8c57e97944e3c5108a586406edd119 100644 --- a/pousseseringue-arduino.ino +++ b/pousseseringue-arduino.ino @@ -1,2 +1,8 @@ // please edit this file: pousseseringue-arduino.cpp + +// Pour la compilation local sur le PC +#if CORE_MOCK + #include "pousseseringue-arduino.cpp" + #include "web.cpp" +#endif // !CORE_MOCK