🧼 Removes server dependencies from service
This commit is contained in:
@@ -17,18 +17,12 @@
|
|||||||
|
|
||||||
ESP32SvelteKit::ESP32SvelteKit(PsychicHttpServer *server)
|
ESP32SvelteKit::ESP32SvelteKit(PsychicHttpServer *server)
|
||||||
:
|
:
|
||||||
#if FT_ENABLED(USE_DOWNLOAD_FIRMWARE)
|
|
||||||
_downloadFirmwareService(server),
|
|
||||||
#endif
|
|
||||||
#if FT_ENABLED(USE_SLEEP)
|
|
||||||
_sleepService(server),
|
|
||||||
#endif
|
|
||||||
#if FT_ENABLED(USE_BATTERY)
|
#if FT_ENABLED(USE_BATTERY)
|
||||||
_batteryService(&_peripherals),
|
_batteryService(&_peripherals),
|
||||||
#endif
|
#endif
|
||||||
_servoController(server, &ESPFS, &_peripherals),
|
_servoController(&_peripherals),
|
||||||
#if FT_ENABLED(USE_MOTION)
|
#if FT_ENABLED(USE_MOTION)
|
||||||
_motionService(_server, &_servoController),
|
_motionService(&_servoController),
|
||||||
#endif
|
#endif
|
||||||
_server(server) {
|
_server(server) {
|
||||||
}
|
}
|
||||||
@@ -209,9 +203,6 @@ void ESP32SvelteKit::startServices() {
|
|||||||
#if FT_ENABLED(USE_NTP)
|
#if FT_ENABLED(USE_NTP)
|
||||||
_ntpService.begin();
|
_ntpService.begin();
|
||||||
#endif
|
#endif
|
||||||
#if FT_ENABLED(USE_SLEEP)
|
|
||||||
_sleepService.begin();
|
|
||||||
#endif
|
|
||||||
#if FT_ENABLED(USE_BATTERY)
|
#if FT_ENABLED(USE_BATTERY)
|
||||||
_batteryService.begin();
|
_batteryService.begin();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
#include <MathUtils.h>
|
#include <MathUtils.h>
|
||||||
|
|
||||||
#define DEFAULT_STATE false
|
#define DEFAULT_STATE false
|
||||||
#define LIGHT_SETTINGS_ENDPOINT_PATH "/api/input"
|
|
||||||
#define ANGLES_EVENT "angles"
|
#define ANGLES_EVENT "angles"
|
||||||
#define INPUT_EVENT "input"
|
#define INPUT_EVENT "input"
|
||||||
#define POSITION_EVENT "position"
|
#define POSITION_EVENT "position"
|
||||||
@@ -20,8 +19,7 @@ enum class MOTION_STATE { DEACTIVATED, IDLE, CALIBRATION, REST, STAND, CRAWL, WA
|
|||||||
|
|
||||||
class MotionService {
|
class MotionService {
|
||||||
public:
|
public:
|
||||||
MotionService(PsychicHttpServer *server, ServoController *servoController)
|
MotionService(ServoController *servoController) : _servoController(servoController) {}
|
||||||
: _server(server), _servoController(servoController) {}
|
|
||||||
|
|
||||||
void begin() {
|
void begin() {
|
||||||
socket.onEvent(INPUT_EVENT, [&](JsonObject &root, int originId) { handleInput(root, originId); });
|
socket.onEvent(INPUT_EVENT, [&](JsonObject &root, int originId) { handleInput(root, originId); });
|
||||||
@@ -144,7 +142,6 @@ class MotionService {
|
|||||||
static void _loopImpl(void *_this) { static_cast<MotionService *>(_this)->_loop(); }
|
static void _loopImpl(void *_this) { static_cast<MotionService *>(_this)->_loop(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PsychicHttpServer *_server;
|
|
||||||
ServoController *_servoController;
|
ServoController *_servoController;
|
||||||
Kinematics kinematics;
|
Kinematics kinematics;
|
||||||
ControllerCommand command = {0, 0, 0, 0, 0, 0, 0, 0};
|
ControllerCommand command = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
|||||||
@@ -17,9 +17,8 @@
|
|||||||
|
|
||||||
class ServoController : public StatefulService<ServoSettings> {
|
class ServoController : public StatefulService<ServoSettings> {
|
||||||
public:
|
public:
|
||||||
ServoController(PsychicHttpServer *server, FS *fs, Peripherals *peripherals)
|
ServoController(Peripherals *peripherals)
|
||||||
: _server(server),
|
: _peripherals(peripherals),
|
||||||
_peripherals(peripherals),
|
|
||||||
endpoint(ServoSettings::read, ServoSettings::update, this),
|
endpoint(ServoSettings::read, ServoSettings::update, this),
|
||||||
_persistence(ServoSettings::read, ServoSettings::update, this, &ESPFS, SERVO_SETTINGS_FILE) {}
|
_persistence(ServoSettings::read, ServoSettings::update, this, &ESPFS, SERVO_SETTINGS_FILE) {}
|
||||||
|
|
||||||
@@ -83,7 +82,6 @@ class ServoController : public StatefulService<ServoSettings> {
|
|||||||
StatefulHttpEndpoint<ServoSettings> endpoint;
|
StatefulHttpEndpoint<ServoSettings> endpoint;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PsychicHttpServer *_server;
|
|
||||||
Peripherals *_peripherals;
|
Peripherals *_peripherals;
|
||||||
FSPersistence<ServoSettings> _persistence;
|
FSPersistence<ServoSettings> _persistence;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user