migrate callbacks from std::vector to std::map
This commit is contained in:
parent
c635427d64
commit
5f6e586945
11 changed files with 143 additions and 178 deletions
|
@ -5,7 +5,7 @@
|
|||
#include <OneWire.h>
|
||||
#include <DS18B20.h>
|
||||
#include <dhtnew.h>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#define RMT_TX_CHANNEL RMT_CHANNEL_0
|
||||
|
||||
|
@ -60,6 +60,8 @@ class ClimateCard : public ExpansionCard {
|
|||
uint8_t getSensorType();
|
||||
void registerChangeCallback(std::function<void(uint8_t, uint8_t, uint8_t)> callback);
|
||||
void registerSensorCallback(std::function<void(float, float)> callback);
|
||||
void unregisterChangeCallback(uint8_t handler);
|
||||
void unregisterSensorCallback(uint8_t handler);
|
||||
uint8_t getType();
|
||||
private:
|
||||
// Sensor objects
|
||||
|
@ -67,8 +69,10 @@ class ClimateCard : public ExpansionCard {
|
|||
DHTNEW *dht;
|
||||
DS18B20 *ds18b20;
|
||||
// Callbacks
|
||||
std::vector<std::function<void(uint8_t, uint8_t, uint8_t)>> callbacks;
|
||||
std::vector<std::function<void(float, float)>> sensor_callbacks;
|
||||
uint8_t callbacks_handler_count = 0;
|
||||
uint8_t sensor_callbacks_handler_count = 0;
|
||||
std::map<uint8_t,std::function<void(uint8_t, uint8_t, uint8_t)>> callbacks;
|
||||
std::map<uint8_t,std::function<void(float, float)>> sensor_callbacks;
|
||||
// Update functions
|
||||
void updateSensor();
|
||||
void updateAirConditioner();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue