Event
Type-safe event definitions and data structures#include <Events.h>
Public Member Functions | |
| Event () | |
| Event (EventType t) | |
| Event (EventType t, int32_t v) | |
| void | setStringData (const String &str) |
| String | getStringData () const |
| bool | hasStringData () const |
| void | clearStringData () |
| void | setWiFiData (const char *ssid, const char *ip="", int32_t connectionTime=0) |
| String | getSSID () const |
| String | getIP () const |
| int32_t | getConnectionTime () const |
| int32_t | getRotationDelta () const |
| int32_t | getPressDuration () const |
| bool | isClockwise () const |
| bool | isLongPress (int32_t threshold=1000) const |
Public Attributes | |
| EventType | type |
| int32_t | value |
| char | stringData [256] |
Detailed Description
Event Data Structure
Unified data container for all event types with optimized memory layout. Designed for efficient FreeRTOS queue transmission and minimal memory usage.
Memory Layout:
- type: 4 bytes (EventType enumeration)
- value: 4 bytes (signed 32-bit integer for counters, timing, codes)
- stringData: 256 bytes (null-terminated string buffer)
- Total: 264 bytes (aligned for efficient queue operations)
Design Principles:
- Fixed size for predictable memory usage
- No pointers to avoid cross-task memory issues
- Embedded string buffer to prevent heap fragmentation
- Helper methods for common data patterns
- Safe defaults and automatic null termination
Constructor & Destructor Documentation
◆ Event() [1/3]
|
inline |
Default constructor - creates safe empty event Initializes with ENCODER_ROTATION type and zero values
◆ Event() [2/3]
|
inline |
Type-only constructor Creates event with specified type and zero values
- Parameters
| t | Event type from EventType enumeration |
◆ Event() [3/3]
|
inline |
Type and value constructor Creates event with specified type and numeric value
- Parameters
| t | Event type from EventType enumeration |
| v | Numeric value (counter, timing, error code, etc.) |
Member Function Documentation
◆ clearStringData()
|
inline |
Clear string data buffer Resets string buffer to empty state
◆ getConnectionTime()
|
inline |
Get WiFi connection time from value field Convenience accessor for connection timing data
- Returns
- Connection time in milliseconds
◆ getIP()
|
inline |
Extract IP address from WiFi event data Parses IP address from "SSID|IP" format string
- Returns
- IP address string, or empty string if no separator found
◆ getPressDuration()
|
inline |
Get encoder press duration Returns button press time for click/long-press differentiation
- Returns
- Press duration in milliseconds
◆ getRotationDelta()
|
inline |
Get encoder rotation delta Returns rotation amount with sign indicating direction
- Returns
- Rotation clicks (positive = clockwise, negative = counter-clockwise)
◆ getSSID()
|
inline |
Extract SSID from WiFi event data Parses SSID from "SSID|IP" format string
- Returns
- SSID string, or complete string if no separator found
◆ getStringData()
|
inline |
Get string payload as Arduino String object Safe accessor that always returns valid string (empty if unset)
- Returns
- String object containing current string data
◆ hasStringData()
|
inline |
Check if string data is present and non-empty
- Returns
- true if string data contains at least one character
◆ isClockwise()
|
inline |
Check if encoder rotation is clockwise
- Returns
- true if rotation value is positive (clockwise)
◆ isLongPress()
|
inline |
Check if encoder press qualifies as long press Uses common threshold of 1000ms for long press detection
- Parameters
| threshold | Long press threshold in milliseconds (default: 1000) |
- Returns
- true if press duration exceeds threshold
◆ setStringData()
|
inline |
Set string payload with automatic truncation and null termination Safely copies string data with bounds checking to prevent buffer overflow
- Parameters
| str | String data to store (will be truncated if > 255 characters) |
◆ setWiFiData()
|
inline |
Set WiFi-specific data using structured format Stores SSID, IP address, and connection timing in standardized format Format: "SSID|IP_ADDRESS" with connection time in value field
- Parameters
| ssid | Network SSID (max ~120 characters) |
| ip | IP address string (typically "192.168.1.100" format) |
| connectionTime | Connection duration in milliseconds (stored in value) |
Member Data Documentation
◆ stringData
| char CloudMouse::Event::stringData[256] |
◆ type
| EventType CloudMouse::Event::type |
◆ value
| int32_t CloudMouse::Event::value |
The documentation for this struct was generated from the following file:
- lib/core/Events.h