You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
boolsetPowerSaveTimeout(unsignedlong timeoutMs); // Configure timeoutboolenablePowerSave(); // Enable power save modebooldisablePowerSave(); // Disable power save modeboolisPowerSaveEnabled() const; // Check if enabledvoidsleep(); // Enter power save modevoidwake(); // Exit power save modeboolisInPowerSave() const; // Check current state
Callbacks
Callback Types and Setters
// Matrix button eventstypedefvoid (*MatrixCallback)(int profile, int row, int col, bool state);
voidsetMatrixCallback(MatrixCallback callback);
// GPIO button eventstypedefvoid (*GpioCallback)(int profile, int gpio, bool state);
voidsetGpioCallback(GpioCallback callback);
// MCP23017 eventstypedefvoid (*McpCallback)(int profile, int device, int pin, bool state);
voidsetMcpCallback(McpCallback callback);
// Encoder rotationtypedefvoid (*EncoderCallback)(int profile, int encoder, int direction);
voidsetEncoderCallback(EncoderCallback callback);
// Encoder buttonstypedefvoid (*EncoderButtonCallback)(int profile, int encoder, bool pressed);
voidsetEncoderButtonCallback(EncoderButtonCallback callback);
// Error eventstypedefbool (*ErrorCallback)(const ControllerError& error);
voidsetErrorCallback(ErrorCallback callback);
Callback Parameters
profile: Current active profile (0 to numProfiles-1)
row: Matrix row index
col: Matrix column index
gpio: GPIO pin index
device: MCP23017 device index
pin: MCP23017 pin number (0-15)
state: Button state (true=pressed)
encoder: Encoder index
direction: 1 for clockwise, -1 for counter-clockwise
pressed: true for press, false for release
error: ControllerError structure with error details
encoderIndex: Index of encoder (0 to numEncoders-1)
divisor: Encoder sensitivity (1-4, default: 4)
position: Encoder position value
profile: Profile number (0 to numProfiles-1)
State Queries
Matrix, GPIO and MCP23017
boolgetMatrixState(int row, int col) const; // Get matrix button stateboolgetGpioState(int gpio) const; // Get GPIO button stateboolgetMcpState(uint8_t device, uint8_t pin) const; // Get MCP pin state
Encoders
int32_tgetEncoderPosition(int index) const; // Get current positionint8_tgetEncoderDirection(int index) const; // Get last directionuint16_tgetEncoderSpeed(int index) const; // Get rotation speedboolisEncoderValid(int index) const; // Check for errorsboolgetEncoderButtonState(int index) const; // Get button state
System State
intgetProfile() const; // Get current profileboolisInPowerSave() const; // Get power save stateboolisUpdateInProgress() const; // Get update state
ControllerError getLastError() const; // Get last error
Return Values
getMatrixState: true if button pressed
getGpioState: true if button pressed
getMcpState: true if pin active
getProfile: Current active profile
getEncoderPosition: Current encoder position
getEncoderDirection: Last encoder direction (1/-1)
#defineMAX_MCP_DEVICES8// Maximum MCP23017 devices
#defineI2C_TIMEOUT_MS100// I2C operation timeout
#defineMIN_POWER_SAVE_MS5000// Minimum power save timeout
#defineMAX_POWER_SAVE_MS3600000// Maximum power save timeout (1 hour)
#defineMAX_ERROR_COUNT100// Maximum encoder error count