Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP3d integration for ESP32 boards #16515

Merged
merged 8 commits into from
Jan 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2823,12 +2823,15 @@
/**
* WiFi Support (Espressif ESP32 WiFi)
*/
//#define WIFISUPPORT
#if ENABLED(WIFISUPPORT)
//#define WIFISUPPORT // Marlin embedded WiFi managenent
//#define ESP3D_WIFISUPPORT // ESP3D Library WiFi management (https://github.com/luc-github/ESP3DLib)

#if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT)
#define WIFI_SSID "Wifi SSID"
#define WIFI_PWD "Wifi Password"
//#define WEBSUPPORT // Start a webserver with auto-discovery
//#define WEBSUPPORT // Start a webserver (which may include auto-discovery)
//#define OTASUPPORT // Support over-the-air firmware updates
//#define CUSTOM_COMMAND // Accept feature (e.g., WiFi ESP3D) config commands from the host
#endif

/**
Expand Down
32 changes: 20 additions & 12 deletions Marlin/src/HAL/HAL_ESP32/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,14 @@

#include "../../inc/MarlinConfigPre.h"

#if ENABLED(WEBSUPPORT)
#include "spiffs.h"
#endif

#if ENABLED(WIFISUPPORT)
#include <ESPAsyncWebServer.h>
#include "wifi.h"
#if ENABLED(OTASUPPORT)
#include "ota.h"
#endif
#if ENABLED(WEBSUPPORT)
#include "spiffs.h"
#include "web.h"
#endif
#endif
Expand Down Expand Up @@ -78,29 +75,40 @@ volatile int numPWMUsed = 0,
// Public functions
// ------------------------

void HAL_init() {
i2s_init();
}
#if ENABLED(CUSTOM_COMMAND)

bool custom_command(char * const command_ptr) {
#if ENABLED(ESP3D_WIFISUPPORT)
return esp3dlib.parse(command_ptr);
#else
UNUSED(command_ptr);
return false;
#endif
}

#endif

void HAL_init() { i2s_init(); }

void HAL_init_board() {
#if ENABLED(WEBSUPPORT)
spiffs_init();
#endif

#if ENABLED(WIFISUPPORT)
#if ENABLED(ESP3D_WIFISUPPORT)
esp3dlib.init();
#elif ENABLED(WIFISUPPORT)
wifi_init();
#if ENABLED(OTASUPPORT)
OTA_init();
#endif
#if ENABLED(WEBSUPPORT)
spiffs_init();
web_init();
#endif
server.begin();
#endif
}

void HAL_idletask() {
#if ENABLED(OTASUPPORT)
#if BOTH(WIFISUPPORT, OTASUPPORT)
OTA_handle();
#endif
}
Expand Down
18 changes: 14 additions & 4 deletions Marlin/src/HAL/HAL_ESP32/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@

#include "timers.h"

#include "WebSocketSerial.h"
#if ENABLED(WIFISUPPORT)
#include "WebSocketSerial.h"
#endif

#if ENABLED(ESP3D_WIFISUPPORT)
#include "esp3dlib.h"
#endif

#include "FlushableHardwareSerial.h"

// ------------------------
Expand All @@ -47,8 +54,12 @@ extern portMUX_TYPE spinlock;

#define MYSERIAL0 flushableSerial

#if ENABLED(WIFISUPPORT)
#define MYSERIAL1 webSocketSerial
#if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT)
#if ENABLED(ESP3D_WIFISUPPORT)
#define MYSERIAL1 Serial2Socket
#else
#define MYSERIAL1 webSocketSerial
#endif
#define NUM_SERIAL 2
#else
#define NUM_SERIAL 1
Expand All @@ -60,7 +71,6 @@ extern portMUX_TYPE spinlock;
#define ENABLE_ISRS() if (spinlock.owner != portMUX_FREE_VAL) portEXIT_CRITICAL(&spinlock)
#define DISABLE_ISRS() portENTER_CRITICAL(&spinlock)


// Fix bug in pgm_read_ptr
#undef pgm_read_ptr
#define pgm_read_ptr(addr) (*(addr))
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/HAL/HAL_ESP32/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@
#if TMC_HAS_SW_SERIAL
#error "TMC220x Software Serial is not supported on this platform."
#endif

#if BOTH(WIFISUPPORT, ESP3D_WIFISUPPORT)
#error "Only enable one WiFi option, either WIFISUPPORT or ESP3D_WIFISUPPORT."
#endif
5 changes: 2 additions & 3 deletions Marlin/src/HAL/HAL_ESP32/ota.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "../../inc/MarlinConfigPre.h"

#if ENABLED(OTASUPPORT)
#if BOTH(WIFISUPPORT, OTASUPPORT)

#include <WiFi.h>
#include <ESPmDNS.h>
Expand Down Expand Up @@ -67,6 +67,5 @@ void OTA_handle() {
ArduinoOTA.handle();
}

#endif // OTASUPPORT

#endif // WIFISUPPORT && OTASUPPORT
#endif // ARDUINO_ARCH_ESP32
4 changes: 2 additions & 2 deletions Marlin/src/HAL/HAL_ESP32/spiffs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "../../inc/MarlinConfigPre.h"

#if ENABLED(WEBSUPPORT)
#if BOTH(WIFISUPPORT, WEBSUPPORT)

#include "../../core/serial.h"

Expand All @@ -40,5 +40,5 @@ void spiffs_init() {
SERIAL_ERROR_MSG("SPIFFS mount failed");
}

#endif // WEBSUPPORT
#endif // WIFISUPPORT && WEBSUPPORT
#endif // ARDUINO_ARCH_ESP32
9 changes: 4 additions & 5 deletions Marlin/src/HAL/HAL_ESP32/web.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@

#ifdef ARDUINO_ARCH_ESP32

#include <SPIFFS.h>
#undef DISABLED // esp32-hal-gpio.h

#include "../../inc/MarlinConfigPre.h"

#if ENABLED(WEBSUPPORT)
#if BOTH(WIFISUPPORT, WEBSUPPORT)

#undef DISABLED // esp32-hal-gpio.h
#include <SPIFFS.h>
#include "wifi.h"

AsyncEventSource events("/events"); // event source (Server-Sent events)
Expand All @@ -43,5 +42,5 @@ void web_init() {
server.onNotFound(onNotFound);
}

#endif // WEBSUPPORT
#endif // WIFISUPPORT && WEBSUPPORT
#endif // ARDUINO_ARCH_ESP32
10 changes: 9 additions & 1 deletion Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include "gcode.h"
GcodeSuite gcode;

#if ENABLED(CUSTOM_COMMAND)
extern bool custom_command(char * const command_ptr);
#endif

#include "parser.h"
#include "queue.h"
#include "../module/motion.h"
Expand Down Expand Up @@ -841,7 +845,11 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {

case 'T': T(parser.codenum); break; // Tn: Tool Change

default: parser.unknown_command_error();
default:
#if ENABLED(CUSTOM_COMMAND)
if (custom_command(parser.command_ptr)) break;
#endif
parser.unknown_command_error();
}

if (!no_ok) queue.ok_to_send();
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class DGUSScreenVariableHandler {
static void HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr);
static void HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr);
#if HAS_PID_HEATING
// Hook for "Change this temperature PID para"
// Hook for "Change this temperature PID para"
static void HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr);
// Hook for PID autotune
static void HandlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/pins/esp32/pins_MRR_ESPE.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@

#elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)

#define BEEPER_PIN 152
#define BEEPER_PIN 151

//#define LCD_PINS_D5 150
//#define LCD_PINS_D6 151
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/pins/stm32/pins_MKS_ROBIN_MINI.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@

#define FLASH_EEPROM_EMULATION
// 2K in a AT24C16N
#define EEPROM_PAGE_SIZE (uint16)0x800 // 2048
#define EEPROM_START_ADDRESS ((uint32)(0x8000000 + 512 * 1024 - 2 * EEPROM_PAGE_SIZE))
#define EEPROM_PAGE_SIZE (uint16)0x800 // 2048
#define EEPROM_START_ADDRESS ((uint32)(0x8000000 + 512 * 1024 - 2 * EEPROM_PAGE_SIZE))
#define E2END (EEPROM_PAGE_SIZE - 1)

//
Expand Down
Loading