-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutton_control.h
More file actions
26 lines (20 loc) · 1.03 KB
/
button_control.h
File metadata and controls
26 lines (20 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef BUTTON_CONTROL_H__
#define BUTTON_CONTROL_H__
#include <stdint.h>
#include <stdbool.h>
typedef struct {
uint8_t button_id; // Button ID (0-7, from instance_number + pin offset)
uint8_t press_count; // Press count (0-15)
volatile uint32_t last_press_time; // Timestamp of last press (seconds, updated in ISR)
volatile uint8_t current_state; // Current button state (0=released, 1=pressed, updated in ISR)
uint8_t byte_index; // Byte index in dynamicreturndata
uint8_t pin; // GPIO pin number
uint8_t instance_index; // BinaryInputs instance index
bool initialized; // Whether this button is initialized
uint8_t pin_offset; // Pin offset within instance (0-7) for faster ISR lookup
bool inverted; // Inverted flag for this pin (cached for ISR)
} ButtonState;
#define MAX_BUTTONS 32 // Up to 4 instances * 8 pins = 32 buttons max
void button_init(void);
void process_button_events(void);
#endif // BUTTON_CONTROL_H__