diff --git a/README.md b/README.md index aee77b12654153aab529e2514c6d7855b56e5f4f..9bae11723c21027590959207a599e3a8b633eecb 100644 --- a/README.md +++ b/README.md @@ -99,4 +99,33 @@ firefox localhost:9080 ### ESP -@todo \ No newline at end of file +@todo + +## Visualization locale de l'interface utilisateur sans l'arduino. + +Compiler l'application locallement: +``` +export ESP8266ARDUINO=~/devel/workspace/src/arduino_esp8266 +export ARDUINOLIB=~/devel/workspace/src/ +cd ~/devel/workspace/src/ +./host_gui/make.sh +``` +lancer le server: +``` +~/devel/workspace/src/arduino_esp8266/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 +``` \ No newline at end of file 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..ee9b4e795c7ddf3df455f2babf75516243b9776f --- /dev/null +++ b/host_gui/make.sh @@ -0,0 +1,4 @@ +#!/bin/sh -ex +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 ${ARDUINOLIB}/pousseseringue-arduino/pousseseringue-arduino \ No newline at end of file diff --git a/pousseseringue-arduino.cpp b/pousseseringue-arduino.cpp index f50c850bc73eb195d07fce6093d421a98a1b419f..0f4b23d3dc9659cf510d2e8b1d263504746430bb 100644 --- a/pousseseringue-arduino.cpp +++ b/pousseseringue-arduino.cpp @@ -3,7 +3,6 @@ // Feather LCD // Feather motor controler - #if 0 #define STASSID "laas-capture" #define STAPSK "" @@ -53,9 +52,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 <A4988.h> // https://github.com/laurb9/StepperDriver - +#endif // !CORE_MOCK #include "Debouncer.h" // local, debouncer, short counter, long detector #include "common.h" @@ -69,8 +69,10 @@ enum class Modes { TURN, TURNSetup, RPM, RPMSetup, INFO }; millis_t nowMs; // to update on main loop(): "nowMs = millis();" Debouncer<nowMs> bA, bB, bC; +#if !CORE_MOCK A4988 a4988(MOTOR_STEPS, DIR, STEP, SLEEP); SSD1306AsciiWire oled; +#endif // !CORE_MOCK constexpr int DNS_PORT = 53; DNSServer dnsServer; @@ -106,11 +108,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) @@ -151,6 +156,7 @@ void oledRedisplay () default: oled.printf("?"); } +#endif // !CORE_MOCK } void changeMode () @@ -212,20 +218,26 @@ void setup() { Serial.begin(74880); 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 a4988.begin(STEPPER_RPM); // some value is necessary a4988.setEnableActiveState(LOW); a4988.setMicrostep(MICROSTEPS_CONF); a4988.enable(); +#endif // !CORE_MOCK uint8_t mac[6]; WiFi.macAddress(mac); @@ -309,12 +321,16 @@ void loop() if (move >= stepsPerDuration) { move -= stepsPerDuration; +#if !CORE_MOCK a4988.move(stepsPerDuration); // forward revolution +#endif // !CORE_MOCK } if (move <= -stepsPerDuration) { move += stepsPerDuration; +#if !CORE_MOCK a4988.move(-stepsPerDuration); // backward revolution +#endif // !CORE_MOCK } lastMoveMs += stepDurationMs; 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