mirror of
https://github.com/Oleg-Stepanenko-owo/IEBUS.git
synced 2026-08-22 22:02:53 +00:00
Added bluetooth module
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
//--------------------------------------------------------------------------------
|
||||
#include "AVCLan_BT.h"
|
||||
#include <SoftwareSerial.h>
|
||||
#include <avr/pgmspace.h>
|
||||
//--------------------------------------------------------------------------------
|
||||
SoftwareSerial mySerial(4, 3); // RX | TX
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
void AVCLanBT::begin()
|
||||
//--------------------------------------------------------------------------------
|
||||
{
|
||||
mySerial.begin(9600);
|
||||
mySerial.println("BlueTooth is ready");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
void AVCLanBT::println( char* val )
|
||||
//--------------------------------------------------------------------------------
|
||||
{
|
||||
mySerial.println( val );
|
||||
mySerial.println( "\n\r" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
void AVCLanBT::print( const char* val )
|
||||
//--------------------------------------------------------------------------------
|
||||
{
|
||||
mySerial.print( val );
|
||||
}
|
||||
|
||||
AVCLanBT avclanBT;
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
*/
|
||||
#ifndef AVCLanBT_h
|
||||
#define AVCLanBT_h
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
#include "Arduino.h"
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
class AVCLanBT
|
||||
{
|
||||
public:
|
||||
void begin (); // initialisation, obligatory method
|
||||
|
||||
void println( char*);
|
||||
void print(const char*);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
extern AVCLanBT avclanBT;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
#include "AVCLanDrv.h"
|
||||
#include "AVCLanHonda.h"
|
||||
#include "AVCLan_BT.h"
|
||||
#include "config.h"
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
@@ -11,6 +12,9 @@
|
||||
#define HONDA_DIS_ON sbi(LED_PORT, COMMUT_OUT);
|
||||
#define HONDA_DIS_OFF cbi(LED_PORT, COMMUT_OUT);
|
||||
|
||||
static int MAX_ERROR_COUNT = 30;
|
||||
byte errorID;
|
||||
int error_count;
|
||||
//--------------------------------------------------------------------------------
|
||||
void setup()
|
||||
//--------------------------------------------------------------------------------
|
||||
@@ -20,6 +24,11 @@ void setup()
|
||||
|
||||
avclan.begin();
|
||||
avclanHonda.begin();
|
||||
errorID = 0;
|
||||
error_count = 0;
|
||||
|
||||
avclanBT.begin();
|
||||
avclanBT.println("Start HONDA avclan.");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
@@ -43,10 +52,22 @@ void loop()
|
||||
if ( INPUT_IS_SET ) {
|
||||
byte res = avclan.readMessage();
|
||||
if ( !res ) {
|
||||
error_count = 0;
|
||||
|
||||
avclanHonda.getActionID();
|
||||
if ( avclan.actionID != ACT_NONE ) {
|
||||
avclanHonda.processAction( (AvcActionID)avclan.actionID );
|
||||
}
|
||||
} else {
|
||||
if ( errorID == res ) error_count++;
|
||||
else error_count = 1;
|
||||
|
||||
errorID = res;
|
||||
|
||||
if ( error_count > MAX_ERROR_COUNT ) {
|
||||
error_count = 0;
|
||||
avclanHonda.setHondaDis(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +81,13 @@ void loop()
|
||||
HONDA_DIS_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !error_count && errorID ) {
|
||||
char BUFFF[15];
|
||||
sprintf(BUFFF, "Error: %d", errorID);
|
||||
avclanBT.println( BUFFF );
|
||||
delay(2000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,10 +29,7 @@
|
||||
#define LED_DDR DDRC
|
||||
#define LED_PORT PORTC
|
||||
#define LED_PIN PINC
|
||||
//#define LED_OUT 5
|
||||
|
||||
// Commutate pin 11
|
||||
#define COMMUT_OUT 1
|
||||
#define COMMUT_OUT 0
|
||||
|
||||
|
||||
// AZFM board activate
|
||||
|
||||
Reference in New Issue
Block a user