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
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include <ExpansionCard.hpp>
|
||||
#include <PCF8574.h>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#define CARD_TYPE_DIGITAL_INPUT 0x01
|
||||
|
||||
|
@ -28,7 +28,7 @@ class DigitalInputCard : public ExpansionCard {
|
|||
// Register a callback function to be called when a pin changes
|
||||
void registerCallback(std::function<void(uint8_t, bool)> callback);
|
||||
// Unregister the callback function
|
||||
//void unregisterCallback(std::function<void(uint8_t, bool)> callback);
|
||||
void unregisterCallback(uint8_t handler);
|
||||
// Load a new pin map
|
||||
void loadPinMap(uint8_t pinMap[16]);
|
||||
// Get type of card
|
||||
|
@ -48,7 +48,8 @@ class DigitalInputCard : public ExpansionCard {
|
|||
uint8_t pinMap[16];
|
||||
// A map of the virtual pin to the physical pin
|
||||
uint8_t virtualPinMap[16];
|
||||
std::vector<std::function<void(uint8_t, bool)>> callbacks;
|
||||
uint8_t callbacks_handler_index = 0;
|
||||
std::map<uint8_t, std::function<void(uint8_t, bool)>> callbacks;
|
||||
void refreshInputBankA();
|
||||
void refreshInputBankB();
|
||||
void handlePinChange(int pin, uint8_t& currentBuffer, uint8_t& previousBuffer);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue