Implement Bluetooth

This commit is contained in:
GHOSCHT 2022-04-10 10:27:35 +02:00
parent 6c2f39a4ea
commit 0ee41404e9
No known key found for this signature in database
GPG key ID: A35BD466B8871994
3 changed files with 23 additions and 1 deletions

View file

@ -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);
}

View file

@ -0,0 +1,8 @@
#include <StreamCommunicator.h>
#include "BluetoothSerial.h"
class BluetoothCommunicator : public StreamCommunicator
{
public:
BluetoothCommunicator(BluetoothSerial &p_out, int timeout, __SIZE_TYPE__ bufferSize);
};

View file

@ -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();
}