mirror of
https://github.com/FYSETC/ESPWebDAV.git
synced 2026-02-19 17:51:22 +01:00
97 lines
2.1 KiB
C++
97 lines
2.1 KiB
C++
// Using the WebDAV server with Rigidbot 3D printer.
|
|
// Printer controller is a variation of Rambo running Marlin firmware
|
|
|
|
#include "serial.h"
|
|
#include "parser.h"
|
|
#include "config.h"
|
|
#include "network.h"
|
|
#include "gcode.h"
|
|
#include "sdControl.h"
|
|
|
|
// LED is connected to GPIO2 on this board
|
|
#define INIT_LED {pinMode(2, OUTPUT);}
|
|
#define LED_ON {digitalWrite(2, LOW);}
|
|
#define LED_OFF {digitalWrite(2, HIGH);}
|
|
|
|
// ------------------------
|
|
void setup() {
|
|
SERIAL_INIT(115200);
|
|
INIT_LED;
|
|
blink();
|
|
|
|
sdcontrol.setup();
|
|
|
|
// ----- WIFI -------
|
|
if(config.load() == 1) { // Connected before
|
|
if(!network.start()) {
|
|
SERIAL_ECHOLN("Connect fail, please check your INI file or set the wifi config and connect again");
|
|
SERIAL_ECHOLN("- M50: Set the wifi ssid , 'M50 ssid-name'");
|
|
SERIAL_ECHOLN("- M51: Set the wifi password , 'M51 password'");
|
|
SERIAL_ECHOLN("- M52: Start to connect the wifi");
|
|
SERIAL_ECHOLN("- M53: Check the connection status");
|
|
}
|
|
}
|
|
else {
|
|
SERIAL_ECHOLN("Welcome to FYSETC: www.fysetc.com");
|
|
SERIAL_ECHOLN("Please set the wifi config first");
|
|
SERIAL_ECHOLN("- M50: Set the wifi ssid , 'M50 ssid-name'");
|
|
SERIAL_ECHOLN("- M51: Set the wifi password , 'M51 password'");
|
|
SERIAL_ECHOLN("- M52: Start to connect the wifi");
|
|
SERIAL_ECHOLN("- M53: Check the connection status");
|
|
}
|
|
}
|
|
|
|
// ------------------------
|
|
void loop() {
|
|
// handle the request
|
|
network.handle();
|
|
|
|
// Handle gcode
|
|
gcode.Handle();
|
|
|
|
// blink
|
|
statusBlink();
|
|
}
|
|
|
|
// ------------------------
|
|
void blink() {
|
|
// ------------------------
|
|
LED_ON;
|
|
delay(100);
|
|
LED_OFF;
|
|
delay(400);
|
|
}
|
|
|
|
// ------------------------
|
|
void errorBlink() {
|
|
// ------------------------
|
|
for(int i = 0; i < 100; i++) {
|
|
LED_ON;
|
|
delay(50);
|
|
LED_OFF;
|
|
delay(50);
|
|
}
|
|
}
|
|
|
|
void statusBlink() {
|
|
static unsigned long time = 0;
|
|
if(millis() > time + 1000 ) {
|
|
if(network.isConnecting()) {
|
|
LED_OFF;
|
|
}
|
|
else if(network.isConnected()) {
|
|
LED_ON;
|
|
delay(50);
|
|
LED_OFF;
|
|
}
|
|
else {
|
|
LED_ON;
|
|
}
|
|
time = millis();
|
|
}
|
|
|
|
// SPI bus not ready
|
|
//if(millis() < spiBlockoutTime)
|
|
// blink();
|
|
}
|