Overview
BaseChannel is the main LED controller for AutoLight V3, providing 16+ lighting sequence modes, PCF8574 I2C expander management, multi-modal button systems, and integrated web server control.
Quick Start
#define ENABLE_ADDONS_AUTOLIGHT_V3
#include "Kinematrix.h"
using namespace AutoLight ;
BaseChannel led;
BaseConfig config;
void setup () {
config . setDynamicConfig ( 12 , 2 ); // 12 channels, 2 PCF8574s
led . attachConfig ( config . getConfigData ());
led . initialize ();
led . setButtonMode (BUTTON_MODE_1BUTTON);
}
void loop () {
led . runAutoLight ();
}
Constructor
Create BaseChannel instance
Initialization
Initialize LED control system Returns true if initialization successful
Attach configuration data Pointer to configuration from BaseConfig
Attach button interrupt handler Pointer to ButtonInterrupt instance
Enable I2C configuration mode
Sequence Control
Main execution loop for LED sequences _callbackRun
void (*)(uint32_t)
default: "nullptr"
Optional callback with current sequence index
Change to next sequence mode
Change to specific sequence mode (for web API)
Go to previous sequence mode
Sequence Mapping
Filter and reorder available sequences:
led . enableSequenceMapping ( true );
led . setActiveSequences ( 5 , 2 , 5 , 7 , 10 , 12 ); // Only these modes
led . printSequenceMapping (); // Debug output
Enable sequence filtering
Set active sequence list Pass uint8_t array and count
Pass count followed by sequence numbers
Print current sequence mapping to Serial
Get mapping as formatted string Returns string representation of active sequences
Set button interaction mode BUTTON_MODE_4BUTTON, BUTTON_MODE_1BUTTON, BUTTON_MODE_2BUTTON, BUTTON_MODE_3BUTTON, or BUTTON_MODE_CUSTOM
Set button configuration Button configuration structure
Handle single button cycle (1-button mode)
Toggle between on and off states
Execute smart button action
Web Server Integration
Enable REST API web server Automatically create FreeRTOS task
Enable web server without auto task (manual control)
Get API server manager instance Returns pointer to APIServerManager
State Management
Check if mode changed Returns true if mode change detected
Check if system is on Returns true if LED system is active
Get current sequence index Returns current sequence number (0-15)
Get current timing delay Returns delay in milliseconds
Get complete channel state data Returns ChannelData structure with all state information
LED Control
Force all LEDs off immediately
Get LED state Returns true if LED is on
Get total number of LED channels Returns configured channel count
Configuration
Set initial delay time Delay in milliseconds (30-300)
Set total number of sequences Number of sequences (1-16)
Set parameter change callback
Utility Functions
Check if system is ready Returns true if initialized
Print debug information to Serial
Built-in Sequence Modes
BaseChannel includes 16 pre-programmed lighting sequences:
Mode Name Description 0 OFF All LEDs off 1 ON All LEDs on 2 Blink All Simultaneous blink 3 Fill Two Point Fill from center outward 4 Fill Right Fill from right to left 5 Fill In Fill from both ends inward 6 Blink One by One Sequential blink 7 Blink Two Fill Two LEDs blink while filling 8 Snake and Reverse Snake pattern with reverse 9 Random Random LED activation 10 Wave Wave propagation effect 11 Complex Multi-pattern coordination 12 Pattern Matrix Advanced matrix patterns 13 Blink Pattern Custom blink patterns 14 Advanced Pattern Complex combinations 15 All Sequences Rotation through all modes
ChannelData Structure
class ChannelData {
public:
volatile uint32_t delay_time_; // Current timing delay
volatile uint32_t sequence_index_; // Current sequence
volatile uint32_t sequence_index_apps_; // API sequence index
volatile uint32_t last_active_sequence_; // Last active sequence
volatile bool is_reverse_; // Reverse mode flag
volatile bool is_mode_changed_; // Mode changed flag
volatile bool is_mode_changed_apps_; // API mode change flag
volatile bool is_on_; // System on/off state
};
typedef enum {
BUTTON_MODE_4BUTTON = 0 , // ON/OFF/NEXT/PREV (4 buttons)
BUTTON_MODE_1BUTTON = 1 , // Single cycle: OFF→ON→Mode2-15→OFF
BUTTON_MODE_2BUTTON = 2 , // Toggle + Next (2 buttons)
BUTTON_MODE_3BUTTON = 3 , // Separate ON/OFF/Next (3 buttons)
BUTTON_MODE_CUSTOM = 99 // User-defined handlers
} button_mode_t ;
Example: Complete Setup
#define ENABLE_ADDONS_AUTOLIGHT_V3
#include "Kinematrix.h"
using namespace AutoLight ;
BaseChannel led;
BaseConfig config;
ButtonInterrupt button;
void sequenceCallback ( uint32_t seq ) {
Serial . printf ( "Running sequence: %d \n " , seq);
}
void setup () {
Serial . begin ( 115200 );
// Dynamic PCF configuration
config . setDynamicConfig ( 24 , 3 ); // 24 channels, 3 PCFs
led . attachConfig ( config . getConfigData ());
// Button setup
led . setButtonMode (BUTTON_MODE_1BUTTON);
// Sequence filtering
led . enableSequenceMapping ( true );
led . setActiveSequences ( 5 , 2 , 5 , 7 , 10 , 12 );
// Initialize
led . initialize ();
led . setInitDelay ( 50 );
// Enable web server
led . enableWebServer ( true );
Serial . println ( "AutoLight V3 ready!" );
}
void loop () {
led . runAutoLight (sequenceCallback);
delay ( 10 );
}
BaseChannel requires ESP32 due to FreeRTOS task requirements and memory needs. ESP8266 support is limited.
ESP32 Full support - recommended platform