HoermannDoor: Now uses GPIOInternalPin and UARTComponent to communicate.
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
#ifndef __hciemulator_h
|
||||
#define __hciemulator_h
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Stream.h>
|
||||
#include <SoftwareSerial.h>
|
||||
#ifdef USE_ESP_IDF
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <algorithm>
|
||||
#include "esp_idf.h"
|
||||
#endif
|
||||
|
||||
#include "esphome/components/uart/uart.h"
|
||||
|
||||
#define LL_OFF 0
|
||||
#define LL_ERROR 1
|
||||
@@ -26,7 +31,9 @@
|
||||
// intercharacter must be 1.5T or 1.5 times longer than a normal character and thus
|
||||
// 1.5T = 1.04167ms * 1.5 = 1.5625ms. A frame delay is 3.5T.
|
||||
#define T1_5 750
|
||||
#define T3_5 4800 // 1750
|
||||
#define T3_5 4800 //
|
||||
|
||||
static const char *const TAG = "HCIEmulator";
|
||||
|
||||
enum DoorState : uint8_t
|
||||
{
|
||||
@@ -75,7 +82,7 @@ class HCIEmulator
|
||||
public:
|
||||
typedef std::function<void(const SHCIState &)> callback_function_t;
|
||||
|
||||
HCIEmulator();
|
||||
HCIEmulator(esphome::InternalGPIOPin* pin, esphome::uart::UARTComponent* uart);
|
||||
|
||||
void poll();
|
||||
|
||||
@@ -114,7 +121,10 @@ protected:
|
||||
|
||||
private:
|
||||
callback_function_t m_statusCallback;
|
||||
Stream *m_port;
|
||||
|
||||
esphome::InternalGPIOPin* m_pin;
|
||||
esphome::uart::UARTComponent* m_port;
|
||||
|
||||
SHCIState m_state;
|
||||
StateMachine m_statemachine;
|
||||
|
||||
@@ -135,4 +145,20 @@ private:
|
||||
bool m_skipFrame;
|
||||
};
|
||||
|
||||
// Now, let's just define micros and millis and delay and delayMicros just so we know
|
||||
#ifdef USE_ESP_IDF
|
||||
unsigned long micros(){
|
||||
return (unsigned long) esp_timer_get_time();
|
||||
}
|
||||
unsigned long millis(){
|
||||
return (unsigned long) esp_timer_get_time() / 1000;
|
||||
}
|
||||
void delay(uint32 duration){
|
||||
|
||||
}
|
||||
void delayMicroseconds(uint32 duration){
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user