diff --git a/firmware/src/leds.cpp b/firmware/src/leds.cpp index a742223..9230cc4 100644 --- a/firmware/src/leds.cpp +++ b/firmware/src/leds.cpp @@ -29,10 +29,10 @@ inline void outputEnable(uint8_t pin, bool enable) { gpio_put(pin, !enable); } -// we have 4-bit color depth, so 16 levels of brightness -// we go from phase 0 to phase 3 +// we have COLOR_BITS-bit color depth, so 2^COLOR_BITS levels of brightness +// we go from phase 0 to phase (COLOR_BITS-1) uint8_t brightnessPhase = 0; -uint8_t brightnessPhaseDelays[] = {1, 10, 30, 100}; +uint8_t brightnessPhaseDelays[COLOR_BITS] = {0, 1, 6, 20, 60}; // NOTE: Alignment required to allow 4-byte reads uint8_t framebuffer[ROW_COUNT * COL_COUNT] __attribute__((aligned(32))) = {0}; @@ -185,7 +185,7 @@ void leds_render() { } // next brightness phase - brightnessPhase = (brightnessPhase + 1) % 4; + brightnessPhase = (brightnessPhase + 1) % COLOR_BITS; } void leds_initPusher() { diff --git a/firmware/src/leds.h b/firmware/src/leds.h index acab099..b421094 100644 --- a/firmware/src/leds.h +++ b/firmware/src/leds.h @@ -20,6 +20,7 @@ #define COL_MODULES 2 #define COL_COUNT COL_MODULES * 20 +#define COLOR_BITS 5 #define FPS 30 #define MS_PER_FRAME 1000 / FPS diff --git a/firmware/src/leds.pio b/firmware/src/leds.pio index 3b9881b..554e96b 100644 --- a/firmware/src/leds.pio +++ b/firmware/src/leds.pio @@ -2,7 +2,8 @@ .side_set 1 opt .wrap_target public entry_point: - out null, 4 side 0 [0] ; ignore 4 least significant digits + out null, 3 side 0 [0] ; ignore least significant digits out pins, 1 ; set bit (shifted for brightness phase by C code) - out null, 3 side 1 [1] ; ignore remaining bits, latch data, allow time for latching + out null, 4 side 1 [1] ; ignore remaining bits, latch data, allow time for latching + nop side 0 ; return to 0 (weird glitches happen otherwise) .wrap diff --git a/firmware/src/leds.pio.h b/firmware/src/leds.pio.h index 8473de7..12b6992 100644 --- a/firmware/src/leds.pio.h +++ b/firmware/src/leds.pio.h @@ -13,22 +13,23 @@ // -------------- // #define leds_px_pusher_wrap_target 0 -#define leds_px_pusher_wrap 2 +#define leds_px_pusher_wrap 3 #define leds_px_pusher_offset_entry_point 0u static const uint16_t leds_px_pusher_program_instructions[] = { // .wrap_target - 0x7064, // 0: out null, 4 side 0 + 0x7063, // 0: out null, 3 side 0 0x6001, // 1: out pins, 1 - 0x7963, // 2: out null, 3 side 1 [1] + 0x7964, // 2: out null, 4 side 1 [1] + 0xb042, // 3: nop side 0 // .wrap }; #if !PICO_NO_HARDWARE static const struct pio_program leds_px_pusher_program = { .instructions = leds_px_pusher_program_instructions, - .length = 3, + .length = 4, .origin = -1, }; diff --git a/firmware/src/main.cpp b/firmware/src/main.cpp index a9c7e24..1b5249a 100644 --- a/firmware/src/main.cpp +++ b/firmware/src/main.cpp @@ -44,18 +44,18 @@ void loop() { sd_loadNextAudio(); } - // if (Serial.available() > 0) { - // char c = Serial.read(); - // if (c == 'p') { - // Serial.println("Paused. Press any key to continue."); - // leds_disable(); - // while (Serial.available() == 0) { - // Serial.read(); - // delay(50); - // } - // Serial.println("Continuing..."); - // } - // } + if (Serial.available() > 0) { + char c = Serial.read(); + if (c == 'p') { + Serial.println("Paused. Press any key to continue."); + leds_disable(); + while (Serial.available() == 0) { + Serial.read(); + delay(50); + } + Serial.println("Continuing..."); + } + } if (!gfx_decoder_handleLoop()) { Serial.println("Failed to load frame...");