Rewrite MUX: WS2812C LEDs (NeoPixel) + 74HC165 buttons
PixelStomp MUX uses: - WS2812C LEDs: one data line via DAT (GPIO 9), NeoPixel protocol - 74HC165 shift register: LD/CLK/DI for reading 8 button states Changes: - Use Adafruit NeoPixel library for LED control - Proper 74HC165 parallel-load shift-in for buttons - 8 switches + 8 LEDs (was incorrectly 10) - Diagnostic commands: dump, ledtest, red, green, blue, read
This commit is contained in:
+11
-10
@@ -1,22 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
|
||||
class PixelStompMux {
|
||||
public:
|
||||
static const uint8_t NUM_INPUTS = 10;
|
||||
static const uint8_t NUM_OUTPUTS = 10;
|
||||
static const uint8_t NUM_BUTTONS = 8;
|
||||
static const uint8_t NUM_LEDS = 8;
|
||||
|
||||
PixelStompMux(uint8_t dat_pin, uint8_t ld_pin, uint8_t clk_pin, uint8_t di_pin);
|
||||
|
||||
void begin();
|
||||
|
||||
uint16_t read_buttons();
|
||||
uint8_t read_buttons();
|
||||
bool is_button_pressed(uint8_t index);
|
||||
|
||||
void write_leds(uint16_t led_state);
|
||||
void set_led(uint8_t index, bool on);
|
||||
void set_led_color(uint8_t index, uint8_t r, uint8_t g, uint8_t b);
|
||||
void set_led_brightness(uint8_t brightness);
|
||||
void clear_all();
|
||||
void show();
|
||||
|
||||
void dump();
|
||||
|
||||
@@ -26,10 +28,9 @@ private:
|
||||
uint8_t pin_clk;
|
||||
uint8_t pin_di;
|
||||
|
||||
uint16_t last_button_state;
|
||||
uint16_t current_led_state;
|
||||
Adafruit_NeoPixel* strip;
|
||||
|
||||
void shift_out(uint16_t data, uint8_t bits);
|
||||
uint16_t shift_in(uint8_t bits);
|
||||
void pulse_pin(uint8_t pin, uint8_t level, uint16_t duration_us = 1);
|
||||
uint8_t last_button_state;
|
||||
|
||||
uint8_t shift_in_74hc165();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user