diff --git a/lib/Syren50/src/Syren50.cpp b/lib/Syren50/src/Syren50.cpp deleted file mode 100644 index c60abc0..0000000 --- a/lib/Syren50/src/Syren50.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "Arduino.h" -#include -#include "Syren50.h" - -void Syren50::init() { - Serial1.begin(9600); - delay(1000); // Give about 1 second to boot up, per datasheet - Serial.write(0b10101010); -} - -void Syren50::command(uint8_t command, uint8_t data) { - Serial1.write(0x80); // Address - Serial1.write(command); // Command - Serial1.write(data); - Serial1.write((0x80 + command + data) & 0b01111111); // Checksum - Serial1.flush(); -} - -void Syren50::forwards(uint8_t speed) { - command(0x00, speed); -} - -void Syren50::reverse(uint8_t speed) { - command(0x01, speed); -} - -void Syren50::move(int8_t direction, uint8_t speed) { - if (direction == 1) { - forwards(speed); - } else if (direction == -1) { - reverse(speed); - } else { - forwards(0); - } -} - -void Syren50::minInputVoltage(float voltage) { - command(0x03, (uint8_t)((voltage - 6.0) * 5.0)); -} diff --git a/lib/Syren50/src/Syren50.h b/lib/Syren50/src/Syren50.h deleted file mode 100644 index 94f956d..0000000 --- a/lib/Syren50/src/Syren50.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef SYREN50_H -#define SYREN50_H - -#include - -class Syren50 { -public: - void init(); - void forwards(uint8_t speed); - void reverse(uint8_t speed); - void move(int8_t direction, uint8_t speed); - void minInputVoltage(float voltage); - - private: - void command(uint8_t command, uint8_t data); -}; - -#endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 9a53495..427f4a7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,49 +2,28 @@ #include "screen.h" #include "wifi.h" #include "controls.h" -#include "Syren50.h" #include #include #include using namespace std; -Syren50 motor; - void setup() { Serial.begin(9600); displayInit(); controlsInit(); WiFi.softAP(WIFI_SSID, WIFI_PASS); displayWiFiInformation(WIFI_SSID, WIFI_PASS); - delay(1000); - motor.init(); } float throttle = 0.0f; -int direction = 0; +uint8_t direction = 0; bool horn = false; bool bell = false; bool lights = false; -int last_direction = 0; -float last_throttle = 0.0f; - -void inertia(float throttle, int direction, float &inertial_throttle, int &inertial_direction) { - - inertial_throttle = throttle; - inertial_direction = direction; -} - - void loop() { getControlsState(throttle, direction, horn, bell, lights); - - float motor_throttle; - int motor_direction; - inertia(throttle, direction, motor_throttle, motor_direction); - - displayControlStatus(motor_throttle, motor_direction, horn, bell, lights); - motor.move(motor_direction, motor_throttle * 127.0f); - + displayControlStatus(throttle, direction, horn, bell, lights); + //sendControlOutputs(throttle, direction, horn, bell, lights); delay(1); } \ No newline at end of file