diff --git a/Firmware/lib/BluetoothCommunicator/BluetoothCommunicator.cpp b/Firmware/lib/BluetoothCommunicator/BluetoothCommunicator.cpp new file mode 100644 index 0000000..e572651 --- /dev/null +++ b/Firmware/lib/BluetoothCommunicator/BluetoothCommunicator.cpp @@ -0,0 +1,8 @@ +#include +#include + +BluetoothCommunicator::BluetoothCommunicator(BluetoothSerial &p_out, int timeout, __SIZE_TYPE__ bufferSize) : StreamCommunicator(p_out, bufferSize) +{ + p_out.begin("Heliox"); + p_out.setTimeout(timeout); +} \ No newline at end of file diff --git a/Firmware/lib/BluetoothCommunicator/BluetoothCommunicator.h b/Firmware/lib/BluetoothCommunicator/BluetoothCommunicator.h new file mode 100644 index 0000000..d8ec316 --- /dev/null +++ b/Firmware/lib/BluetoothCommunicator/BluetoothCommunicator.h @@ -0,0 +1,8 @@ +#include +#include "BluetoothSerial.h" + +class BluetoothCommunicator : public StreamCommunicator +{ +public: + BluetoothCommunicator(BluetoothSerial &p_out, int timeout, __SIZE_TYPE__ bufferSize); +}; diff --git a/Firmware/src/main.cpp b/Firmware/src/main.cpp index 0eb6daa..6f6cc36 100644 --- a/Firmware/src/main.cpp +++ b/Firmware/src/main.cpp @@ -1,24 +1,30 @@ #include #include #include -#include +#include #include StreamCommunicator *computer; +StreamCommunicator *phone; LightController *light; const int STEPS = 5; +BluetoothSerial bt; void setup() { int bjtCount = 4; const int bjtPin[bjtCount] = {SIG1A, SIG1B, SIG2A, SIG2B}; computer = new SerialCommunicator(Serial, 9600, 5, 50); + phone = new BluetoothCommunicator(bt,5,50); light = new LightController(bjtPin, bjtCount); } void loop() { light->updateState(computer->receiveMessage(), STEPS); + light->updateState(phone->receiveMessage(), STEPS); computer->sendMessage(light->getBjtState(), light->getBjtCount()); computer->clearBuffer(); + phone->sendMessage(light->getBjtState(), light->getBjtCount()); + phone->clearBuffer(); } \ No newline at end of file