HoermannDoor: Now uses GPIOInternalPin and UARTComponent to communicate.

This commit is contained in:
2025-09-26 21:03:45 +02:00
parent 8198d8f62e
commit d3f0520123
10 changed files with 250 additions and 153 deletions

View File

@@ -1,11 +1,11 @@
#pragma once
#include "door_singleton.h"
#ifdef USE_COVER
class HoermannDoorx;
#include "esphome.h"
#include "Arduino.h"
#include "hoermann.h"
#include "hciemulator.h"
//#include "cover.h"
@@ -13,14 +13,13 @@
#define TX_ON 25
//#define configMAX_PRIORITIES 25
#define TAG "hoermann_door"
namespace esphome {
namespace hoermann_door {
void modBusPolling(void *parameter);
class HoermanDoor : public Component, public cover::Cover
class HoermannDoor : public Component, public cover::Cover
{
private:
HoermannMainComponent* mainComponent;
public:
cover::CoverTraits get_traits() override {
@@ -48,11 +47,11 @@ public:
if(pos == 1.0){
HoermannSingleton::getInstance()->getEmulator()->openDoor();
mainComponent->getEmulator()->openDoor();
manual = false;
}
else if(pos == 0.0){
HoermannSingleton::getInstance()->getEmulator()->closeDoor();
mainComponent->getEmulator()->closeDoor();
manual = false;
}
else{
@@ -61,39 +60,22 @@ public:
}
if (call.get_stop()) {
HoermannSingleton::getInstance()->getEmulator()->stopDoor();
mainComponent->getEmulator()->stopDoor();
}
//if(call.get_close()) {
//emulator.closeDoor();
//}
}
/*
void modBusPolling(void *parameter)
{
while (true)
{
if (lastCall > 0)
{
maxPeriod = _max(micros() - lastCall, maxPeriod);
}
lastCall = micros();
emulator.poll();
vTaskDelay(1);
}
vTaskDelete(NULL);
}
*/
void setup() override
{
HoermannSingleton::getInstance()->initializeEmulator();
//HoermannSingleton::getInstance()->initializeEmulator();
}
void set_emulator_component(HoermannMainComponent* component){
this->mainComponent = component;
}
void open(){
//emulator.openDoor();
}
@@ -109,7 +91,7 @@ void modBusPolling(void *parameter)
u_int8_t pos = 255;
void loop() override
{
u_int8_t position = HoermannSingleton::getInstance()->getEmulator()->getState().doorCurrentPosition;
u_int8_t position = mainComponent->getEmulator()->getState().doorCurrentPosition;
if(pos != position){
this->position = (float) position / 200.0;
this->publish_state();