122 lines
2.4 KiB
C
122 lines
2.4 KiB
C
#ifndef EGGDUINO_H
|
|
#define EGGDUINO_H
|
|
|
|
#include <Arduino.h>
|
|
#ifdef ESP32
|
|
#include <ESP32Servo.h>
|
|
#include <WiFi.h>
|
|
#include <WebServer.h>
|
|
#include <SPIFFS.h>
|
|
#else
|
|
#include <Servo.h>
|
|
#endif
|
|
|
|
#include <FastAccelStepper.h>
|
|
#include "SerialCommand.h"
|
|
#include "button.h"
|
|
|
|
// implemented Eggbot-Protocol-Version v13
|
|
#define initSting "EBBv13_and_above Protocol emulated by Eggduino-Firmware V1.6a"
|
|
|
|
#ifdef ESP32
|
|
|
|
// Rotational Stepper
|
|
#define dir1 16
|
|
#define enableRotMotor 12
|
|
#define step1 26
|
|
#define rotMicrostep 32
|
|
|
|
// Pen Stepper
|
|
#define step2 25
|
|
#define dir2 27
|
|
#define enablePenMotor 12
|
|
#define penMicrostep 32
|
|
|
|
#define servoPin 17
|
|
|
|
|
|
#else
|
|
|
|
// Rotational Stepper
|
|
#define step1 2
|
|
#define dir1 5
|
|
#define enableRotMotor 8
|
|
#define rotMicrostep 16
|
|
|
|
// Pen Stepper
|
|
#define step2 3
|
|
#define dir2 6
|
|
#define enablePenMotor 8
|
|
#define penMicrostep 16
|
|
|
|
#define servoPin 4
|
|
|
|
|
|
#endif
|
|
|
|
struct ConfigParameter {
|
|
const char *key;
|
|
int *value;
|
|
String description;
|
|
int defaultValue;
|
|
};
|
|
|
|
extern FastAccelStepperEngine g_stepEngine;
|
|
extern FastAccelStepper *g_pStepperRotate;
|
|
extern FastAccelStepper *g_pStepperPen;
|
|
|
|
// extern FastAccelStepper rotMotor;
|
|
// extern FastAccelStepper penMotor;
|
|
extern Servo penServo;
|
|
extern SerialCommand SCmd;
|
|
|
|
extern int penMin;
|
|
extern int penMax;
|
|
extern int penUpPos;
|
|
extern int penDownPos;
|
|
extern int servoRateUp;
|
|
extern int servoRateDown;
|
|
extern long rotStepError;
|
|
extern long penStepError;
|
|
extern int penState;
|
|
extern uint32_t nodeCount;
|
|
extern unsigned int layer;
|
|
extern boolean prgButtonState;
|
|
extern uint8_t rotStepCorrection;
|
|
extern uint8_t penStepCorrection;
|
|
extern float rotSpeed;
|
|
extern float penSpeed;
|
|
extern boolean motorsEnabled;
|
|
|
|
extern ConfigParameter configParameters[];
|
|
extern const size_t configParameterCount;
|
|
|
|
void makeComInterface();
|
|
void initHardware();
|
|
void moveOneStep();
|
|
void moveToDestination();
|
|
void sendAck();
|
|
void sendError();
|
|
void motorsOff();
|
|
void motorsOn();
|
|
void toggleMotors();
|
|
void doTogglePen();
|
|
void setprgButtonState();
|
|
bool parseSMArgs(uint16_t *duration, int *penStepsEBB, int *rotStepsEBB);
|
|
void prepareMove(uint16_t duration, int penStepsEBB, int rotStepsEBB);
|
|
void storePenUpPosInEE();
|
|
void storePenDownPosInEE();
|
|
|
|
bool initConfigStore();
|
|
bool loadConfigFromFile();
|
|
bool saveConfigToFile();
|
|
String buildConfigJson();
|
|
bool applyConfigJson(const String &payload, String &errorMessage);
|
|
void startWebInterface();
|
|
void handleWebInterface();
|
|
void Log(const String &message);
|
|
void Log(const char *message);
|
|
String buildLogsJson(uint32_t sinceSeq);
|
|
|
|
#endif
|