Implement Bluetooth
This commit is contained in:
parent
87b51e55b1
commit
5d6aa75ea8
3 changed files with 23 additions and 1 deletions
|
@ -0,0 +1,8 @@
|
|||
#include <BluetoothCommunicator.h>
|
||||
#include <BluetoothSerial.h>
|
||||
|
||||
BluetoothCommunicator::BluetoothCommunicator(BluetoothSerial &p_out, int timeout, __SIZE_TYPE__ bufferSize) : StreamCommunicator(p_out, bufferSize)
|
||||
{
|
||||
p_out.begin("Heliox");
|
||||
p_out.setTimeout(timeout);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
#include <StreamCommunicator.h>
|
||||
#include "BluetoothSerial.h"
|
||||
|
||||
class BluetoothCommunicator : public StreamCommunicator
|
||||
{
|
||||
public:
|
||||
BluetoothCommunicator(BluetoothSerial &p_out, int timeout, __SIZE_TYPE__ bufferSize);
|
||||
};
|
|
@ -1,24 +1,30 @@
|
|||
#include <Arduino.h>
|
||||
#include <LightController.h>
|
||||
#include <SerialCommunicator.h>
|
||||
#include <I2CCommunicator.h>
|
||||
#include <BluetoothCommunicator.h>
|
||||
#include <PinMap.h>
|
||||
|
||||
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();
|
||||
}
|
Loading…
Reference in a new issue