Documentation Index
Fetch the complete documentation index at: https://mintlify.com/MrJefter/sdvx-controller/llms.txt
Use this file to discover all available pages before exploring further.
The firmware exposes all tuneable behaviour through #define constants concentrated in two source files: Core/Src/main.c for input handling, encoder decoding, and USB reporting, and Core/Src/visEffect.c for the full LED effect pipeline. No HAL configuration files or .ioc regeneration is required to change these values — edit the relevant #define, rebuild the project (Ctrl + B), and reflash. The constants are grouped below by subsystem.
Input Constants (main.c)
These constants govern button debouncing, the main loop rate, and how long START must be held to trigger a firmware reset into DFU.
| Constant | Default | Description |
|---|
DEBOUNCE_LOCKOUT_MS | 3 | Milliseconds to ignore button state changes after a detected edge |
MAIN_LOOP_DELAY_MS | 1 | Main loop delay in ms; controls overall polling rate |
DFU_HOLD_TIME_MS | 5000 | How long (ms) to hold START before entering DFU bootloader |
DFU_BUTTON_INDEX | 6 | Index in buttons[] array for the DFU-triggering button (START) |
// main.c — Input constants
#define DEBOUNCE_LOCKOUT_MS 3
#define MAIN_LOOP_DELAY_MS 1
#define DFU_HOLD_TIME_MS 5000
#define DFU_BUTTON_INDEX 6 // START button
Encoder Constants (main.c)
These constants control how the hardware timer counters are interpreted and how the encoder axis values are smoothed before being placed into the HID report.
| Constant | Default | Description |
|---|
ENCODER_TIMER_PERIOD | 0xFFFF | Timer auto-reload period (65535); sets encoder counter wrap range |
ENCODER_SMOOTHING_ALPHA | 0.15f | EMA alpha: higher = more responsive, lower = smoother |
JOYSTICK_REPORT_SIZE | 5 | USB HID report size in bytes (fixed; do not change) |
// main.c — Encoder constants
#define ENCODER_TIMER_PERIOD 0xFFFF // 65535
#define ENCODER_SMOOTHING_ALPHA 0.15f
#define JOYSTICK_REPORT_SIZE 5
JOYSTICK_REPORT_SIZE must remain at 5 to match the HID report descriptor defined in usbd_custom_hid_if.c. The descriptor declares 1 button byte + 4 axis bytes. Changing this value without updating the descriptor will cause the host OS to reject or misinterpret the HID reports.
Increase ENCODER_SMOOTHING_ALPHA toward 0.4f–0.6f for a more immediate, less lag-prone encoder feel during fast play. Lower values (closer to 0.05f) produce very smooth but sluggish axis movement. The tradeoff is between responsiveness and noise rejection.
LED Fog Effect Constants (visEffect.c)
The fog effect is the ambient background layer. It uses a sum-of-sines noise function evaluated per LED coordinate to produce a slowly drifting colour field. Brightness is modulated between MIN_BRIGHTNESS and MAX_BRIGHTNESS, with white mixed in above BRIGHTENING_THRESHOLD.
| Constant | Default | Description |
|---|
FOG_BASE_R | 150.0f | Base red component of the fog colour |
FOG_BASE_G | 0.0f | Base green component of the fog colour |
FOG_BASE_B | 255.0f | Base blue component of the fog colour |
TIME_SCALE | 0.0030f | Speed of the fog animation (multiplier on HAL_GetTick()) |
MIN_BRIGHTNESS | 0.5f | Minimum fog brightness (0.0–1.0) |
MAX_BRIGHTNESS | 0.8f | Maximum fog brightness |
BRIGHTENING_THRESHOLD | 0.65f | Noise level above which white is mixed in |
BRIGHTENING_MIX | 0.5f | Amount of white mixed in above the threshold |
// visEffect.c — Fog effect constants
#define FOG_BASE_R 150.0f
#define FOG_BASE_G 0.0f
#define FOG_BASE_B 255.0f
#define TIME_SCALE 0.0030f
#define MIN_BRIGHTNESS 0.5f
#define MAX_BRIGHTNESS 0.8f
#define BRIGHTENING_THRESHOLD 0.65f
#define BRIGHTENING_MIX 0.5f
Changing FOG_BASE_R, FOG_BASE_G, and FOG_BASE_B is the easiest way to retheme the controller’s ambient lighting. The defaults produce a deep purple. Setting FOG_BASE_R = 0, FOG_BASE_G = 255, FOG_BASE_B = 100 would produce a green teal ambient, for example.
LED Pulse Effect Constants (visEffect.c)
When any button is pressed, the LEDs mapped to that button flash with a linear fade-out pulse. These constants control the duration, peak brightness, and colour of that flash.
| Constant | Default | Description |
|---|
PULSE_DURATION_MS | 250 | Duration of the button-press flash in ms |
PULSE_MAX_BRIGHTNESS | 255.0f | Peak brightness of the pulse |
PULSE_COLOR_R | 255.0f | Red component of the pulse colour (white by default) |
PULSE_COLOR_G | 255.0f | Green component of the pulse colour |
PULSE_COLOR_B | 255.0f | Blue component of the pulse colour |
// visEffect.c — Pulse effect constants
#define PULSE_DURATION_MS 250UL
#define PULSE_MAX_BRIGHTNESS 255.0f
#define PULSE_COLOR_R 255.0f
#define PULSE_COLOR_G 255.0f
#define PULSE_COLOR_B 255.0f
LED Encoder Glow Constants (visEffect.c)
Encoder rotation drives a glow effect on the LEDs physically surrounding each knob. VOL-L glows cyan and VOL-R glows magenta. Activity is clamped to a 0–1 range based on the per-frame encoder delta and decays multiplicatively each frame.
| Constant | Default | Description |
|---|
ENCODER_VIS_MAX_DELTA | 50.0f | Encoder delta (counts/frame) that maps to full (1.0) activity |
ENCODER_VIS_MAX_BRIGHTNESS | 200.0f | Maximum brightness contribution from the encoder glow layer |
ENCODER1_COLOR_R | 0.0f | Red component of VOL-L glow (cyan) |
ENCODER1_COLOR_G | 255.0f | Green component of VOL-L glow |
ENCODER1_COLOR_B | 255.0f | Blue component of VOL-L glow |
ENCODER2_COLOR_R | 255.0f | Red component of VOL-R glow (magenta) |
ENCODER2_COLOR_G | 0.0f | Green component of VOL-R glow |
ENCODER2_COLOR_B | 255.0f | Blue component of VOL-R glow |
ENCODER_ACTIVITY_DECAY | 0.955f | Per-frame decay multiplier for encoder glow (lower = faster fade) |
ENCODER_ACTIVITY_THRESHOLD | 0.01f | Activity level below which the encoder glow snaps to zero |
ENCODER_INTENSITY_SCALE | 2.0f | Multiplier scaling the activity level to LED intensity |
// visEffect.c — Encoder glow constants
#define ENCODER_VIS_MAX_DELTA 50.0f
#define ENCODER_VIS_MAX_BRIGHTNESS 200.0f
#define ENCODER1_COLOR_R 0.0f
#define ENCODER1_COLOR_G 255.0f
#define ENCODER1_COLOR_B 255.0f
#define ENCODER2_COLOR_R 255.0f
#define ENCODER2_COLOR_G 0.0f
#define ENCODER2_COLOR_B 255.0f
#define ENCODER_ACTIVITY_DECAY 0.955f
#define ENCODER_ACTIVITY_THRESHOLD 0.01f
#define ENCODER_INTENSITY_SCALE 2.0f
WS2812B Driver Constants (ws2812b.h)
These constants are defined in the driver header and control the physical LED strip layout and DMA timing. They should only be changed if the LED hardware configuration is modified.
| Constant | Default | Description |
|---|
WS2812B_NUMBER_OF_LEDS | 12 | Total number of LEDs in the strip |
WS2812_BUFFER_COUNT | 1 | Number of parallel LED strip outputs |
WS2812_RESET_PERIOD | 50 | PWM periods used to generate the 50 µs WS2812B reset signal |
// ws2812b.h — Driver constants
#define WS2812B_NUMBER_OF_LEDS 12
#define WS2812_BUFFER_COUNT 1
#define WS2812_RESET_PERIOD 50
The strip is driven on PB0 via Timer PWM and DMA. If you extend the strip to more LEDs, update WS2812B_NUMBER_OF_LEDS in ws2812b.h and the matching NUM_LEDS define in visEffect.c, as well as the frameBuffer size and led_coords array.