Selaa lähdekoodia

Restore consistent GPIO handler interface before worker refactor

SybexXx 3 päivää sitten
vanhempi
sitoutus
978236a131
1 muutettua tiedostoa jossa 5 lisäystä ja 21 poistoa
  1. 5 21
      code/components/jomjol_controlGPIO/server_GPIO.h

+ 5 - 21
code/components/jomjol_controlGPIO/server_GPIO.h

@@ -8,11 +8,7 @@
 #include <esp_http_server.h>
 #include <map>
 #include <string>
-#include <mutex>
-#include <atomic>
 #include "driver/gpio.h"
-#include "freertos/queue.h"
-#include "freertos/semphr.h"
 
 #include "SmartLeds.h"
 
@@ -31,12 +27,6 @@ typedef enum {
 struct GpioResult {
     gpio_num_t gpio;
     int value;
-    bool stopEvent;
-};
-
-struct GpioIsrContext {
-    QueueHandle_t eventQueue;
-    gpio_num_t gpio;
 };
 
 typedef enum {
@@ -50,7 +40,7 @@ public:
     GpioPin(gpio_num_t gpio, const char* name, gpio_pin_mode_t mode, gpio_int_type_t interruptType, uint8_t dutyResolution, std::string mqttTopic, bool httpEnable);
     ~GpioPin();
 
-    bool init(QueueHandle_t eventQueue);
+    bool init();
     bool getValue(std::string* errorText);
     void setValue(bool value, gpio_set_source setSource, std::string* errorText);
 #ifdef ENABLE_MQTT
@@ -71,11 +61,11 @@ private:
     std::string _mqttTopic;
     bool _httpEnable = false;
     bool _isrRegistered = false;
-    GpioIsrContext _isrContext = {};
     int currentState = -1;
 };
 
 esp_err_t callHandleHttpRequest(httpd_req_t *req);
+void taskGpioHandler(void *pvParameter);
 
 class GpioHandler {
 public:
@@ -89,7 +79,7 @@ public:
     void taskHandler();
     void gpioInterrupt(GpioResult* gpioResult);  
     void flashLightEnable(bool value);
-    bool isEnabled() const { return _isEnabled.load(); }
+    bool isEnabled() { return _isEnabled; }
 #ifdef ENABLE_MQTT
     void handleMQTTconnect();
 #endif //ENABLE_MQTT
@@ -98,11 +88,8 @@ private:
     std::string _configFile;
     httpd_handle_t _httpServer;
     std::map<gpio_num_t, GpioPin*> *gpioMap = NULL;
-    QueueHandle_t _eventQueue = NULL;
-    TaskHandle_t _workerTask = NULL;
-    SemaphoreHandle_t _workerStoppedSemaphore = NULL;
-    std::mutex _mapMutex;
-    std::atomic<bool> _isEnabled{false};
+    TaskHandle_t xHandleTaskGpio = NULL;
+    bool _isEnabled = false;
 
     int LEDNumbers = 2;
     Rgb LEDColor = Rgb{ 255, 255, 255 };
@@ -113,9 +100,6 @@ private:
 
     bool readConfig();
     void clear();
-    void clearUnlocked();
-    static void taskEntry(void *arg);
-    void workerLoop();
     
     gpio_pin_mode_t resolvePinMode(std::string input);
     gpio_int_type_t resolveIntType(std::string input);