diff --git a/ArduinoController/ArduinoController.ino b/ArduinoController/ArduinoController.ino index 92d340b..0cc4161 100644 --- a/ArduinoController/ArduinoController.ino +++ b/ArduinoController/ArduinoController.ino @@ -14,22 +14,24 @@ const uint32_t CONTROLLER_CNT = 13u; class IController* controllers[CONTROLLER_CNT]; void setup() { + delay(1); Serial.begin(115200); Serial1.begin(9600); + DMSGN("Due Ready!"); SerialTools::writeString("Ready!", 6); controllers[0]= new KillSwitchController(controllers, CONTROLLER_CNT); attachInterrupt( - digitalPinToInterrupt(KILLSWITCH_PIN), - [](){((KillSwitchController*)controllers[0])->isr(KILLSWITCH_PIN);}, + digitalPinToInterrupt(GpioPin::KILLSWITCH_PIN), + [](){((KillSwitchController*)controllers[0])->isr(GpioPin::KILLSWITCH_PIN);}, CHANGE ); - controllers[1] = new ThrustController(PWM::MOVE_PIN); - controllers[2] = new ThrustController(PWM::STRAFE_PIN); - controllers[3] = new ThrustController(PWM::DIVE_PIN); - controllers[4] = new ThrustController(PWM::YAW_PIN); - controllers[5] = new ThrustController(PWM::PITCH_PIN); - controllers[6] = new ThrustController(PWM::ROLL_PIN); + controllers[1] = new ThrustController(PwmPin::MOVE_PIN); + controllers[2] = new ThrustController(PwmPin::STRAFE_PIN); + controllers[3] = new ThrustController(PwmPin::DIVE_PIN); + controllers[4] = new ThrustController(PwmPin::YAW_PIN); + controllers[5] = new ThrustController(PwmPin::PITCH_PIN); + controllers[6] = new ThrustController(PwmPin::ROLL_PIN); controllers[7] = new EscController(); controllers[8] = new LedController(); controllers[9] = new PingController(); @@ -47,4 +49,4 @@ void loop() { DMSG("Controller: "); DMSGN(controllerIndex); controllers[controllerIndex]->execute(); } -} \ No newline at end of file +} diff --git a/ArduinoController/EscController.h b/ArduinoController/EscController.h index 42e7d58..dd90274 100644 --- a/ArduinoController/EscController.h +++ b/ArduinoController/EscController.h @@ -6,12 +6,12 @@ class EscController : public IController { private: uint8_t GPIO_PINS[GPIO_CNT] = { - GPIO::ESC_S1_PIN, - GPIO::ESC_S2_PIN, - GPIO::ESC_S3_PIN, - GPIO::ESC_S4_PIN, - GPIO::ESC_S5_PIN, - GPIO::ESC_S6_PIN + GpioPin::ESC_S1_PIN, + GpioPin::ESC_S2_PIN, + GpioPin::ESC_S3_PIN, + GpioPin::ESC_S4_PIN, + GpioPin::ESC_S5_PIN, + GpioPin::ESC_S6_PIN }; public: EscController() { diff --git a/ArduinoController/IController.h b/ArduinoController/IController.h index 41de84c..e9b886e 100644 --- a/ArduinoController/IController.h +++ b/ArduinoController/IController.h @@ -1,5 +1,5 @@ -#ifndef ITHRUSTER_H -#define ITHRUSTER_H +#ifndef ICONTROLLER_H +#define ICONTROLLER_H #include "Arduino.h" #include "SerialTools.h" diff --git a/ArduinoController/KillSwitchController.h b/ArduinoController/KillSwitchController.h index 4fda513..4b32236 100644 --- a/ArduinoController/KillSwitchController.h +++ b/ArduinoController/KillSwitchController.h @@ -12,7 +12,7 @@ class KillSwitchController : public IController { KillSwitchController(IController ** _list_, int _count_) { list = _list_; count = _count_; - pinMode(GPIO::LED_STAT_PIN, OUTPUT); + pinMode(GpioPin::LED_STAT_PIN, OUTPUT); } void execute() { @@ -31,7 +31,7 @@ class KillSwitchController : public IController { active = !digitalRead(interrupt); if(active) kill(); - digitalWrite(GPIO::LED_STAT_PIN, active); + digitalWrite(GpioPin::LED_STAT_PIN, active); interrupts(); } }; diff --git a/ArduinoController/LedController.h b/ArduinoController/LedController.h index fd6f758..4bba665 100644 --- a/ArduinoController/LedController.h +++ b/ArduinoController/LedController.h @@ -4,18 +4,18 @@ class LedController : public IController { private: public: LedController() { - pinMode(GPIO::LED_CTRL_PIN, OUTPUT); - digitalWrite(GPIO::LED_CTRL_PIN, LOW); + pinMode(GpioPin::LED_CTRL_PIN, OUTPUT); + digitalWrite(GpioPin::LED_CTRL_PIN, LOW); } void execute() { for(int i = 0; i < 2; i++) { - digitalWrite(GPIO::LED_CTRL_PIN, HIGH); + digitalWrite(GpioPin::LED_CTRL_PIN, HIGH); delay(250); - digitalWrite(GPIO::LED_CTRL_PIN, LOW); + digitalWrite(GpioPin::LED_CTRL_PIN, LOW); delay(250); } } void kill() { - digitalWrite(GPIO::LED_CTRL_PIN, LOW); + digitalWrite(GpioPin::LED_CTRL_PIN, LOW); } }; \ No newline at end of file diff --git a/ArduinoController/LightController.h b/ArduinoController/LightController.h index 442d5bd..a357dd4 100644 --- a/ArduinoController/LightController.h +++ b/ArduinoController/LightController.h @@ -3,11 +3,11 @@ class LightController : public IController { public: LightController() { - pinMode(GPIO::LIGHTS_PIN, OUTPUT); - digitalWrite(GPIO::LIGHTS_PIN, HIGH); + pinMode(GpioPin::LIGHTS_PIN, OUTPUT); + digitalWrite(GpioPin::LIGHTS_PIN, HIGH); } void execute() { - digitalWrite(GPIO::LIGHTS_PIN, !SerialTools::readByte()); + digitalWrite(GpioPin::LIGHTS_PIN, !SerialTools::readByte()); } void kill() { } }; \ No newline at end of file diff --git a/ArduinoController/PinMap.h b/ArduinoController/PinMap.h index 1e6d4e4..2ba3f74 100644 --- a/ArduinoController/PinMap.h +++ b/ArduinoController/PinMap.h @@ -1,7 +1,7 @@ #ifndef PIN_MAP_H #define PIN_MAP_H -enum GPIO { +enum GpioPin { KILLSWITCH_PIN = 50, LED_STAT_PIN = 22, LED_CTRL_PIN = 52, @@ -13,15 +13,15 @@ enum GPIO { ESC_S5_PIN = 49, ESC_S6_PIN = 53, VOLT_PIN = 10, -} +}; -enum PWM { +enum PwmPin { MOVE_PIN = 13, STRAFE_PIN = 12, DIVE_PIN = 11, YAW_PIN = 9, PITCH_PIN = 8, ROLL_PIN = 7, -} +}; #endif \ No newline at end of file diff --git a/ArduinoController/ThrustController.h b/ArduinoController/ThrustController.h index 99662ca..9ededd7 100644 --- a/ArduinoController/ThrustController.h +++ b/ArduinoController/ThrustController.h @@ -1,3 +1,6 @@ +#ifndef ITHRUSTER_H +#define ITHRUSTER_H + #include #include "IController.h" @@ -8,7 +11,7 @@ class ThrustController : public IController { const uint16_t REVERSE = 1000; Servo servo_; public: - ThrustController(PWM servoPin) { + ThrustController(PwmPin servoPin) { servo_.attach(servoPin); servo_.writeMicroseconds(IDLE); } @@ -27,4 +30,6 @@ class ThrustController : public IController { else if(value < REVERSE) return REVERSE; else return value; } -}; \ No newline at end of file +}; + +#endif \ No newline at end of file diff --git a/ArduinoController/VoltageController.h b/ArduinoController/VoltageController.h index 8a222ac..f9276d9 100644 --- a/ArduinoController/VoltageController.h +++ b/ArduinoController/VoltageController.h @@ -6,11 +6,11 @@ class VoltageController : public IController { const double R2 = 7500.0; public: VoltageController() { - pinMode(GPIO::VOLT_PIN, INPUT); + pinMode(GpioPin::VOLT_PIN, INPUT); } void execute() { - int value = analogRead(GPIO::VOLT_PIN); + int value = analogRead(GpioPin::VOLT_PIN); /* * Measured Values for Calibration * P1 = (11.32, 700); P2 = (8.38, 517)