Skip to main content

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.
ConstantDefaultDescription
DEBOUNCE_LOCKOUT_MS3Milliseconds to ignore button state changes after a detected edge
MAIN_LOOP_DELAY_MS1Main loop delay in ms; controls overall polling rate
DFU_HOLD_TIME_MS5000How long (ms) to hold START before entering DFU bootloader
DFU_BUTTON_INDEX6Index 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.
ConstantDefaultDescription
ENCODER_TIMER_PERIOD0xFFFFTimer auto-reload period (65535); sets encoder counter wrap range
ENCODER_SMOOTHING_ALPHA0.15fEMA alpha: higher = more responsive, lower = smoother
JOYSTICK_REPORT_SIZE5USB 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.4f0.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.
ConstantDefaultDescription
FOG_BASE_R150.0fBase red component of the fog colour
FOG_BASE_G0.0fBase green component of the fog colour
FOG_BASE_B255.0fBase blue component of the fog colour
TIME_SCALE0.0030fSpeed of the fog animation (multiplier on HAL_GetTick())
MIN_BRIGHTNESS0.5fMinimum fog brightness (0.0–1.0)
MAX_BRIGHTNESS0.8fMaximum fog brightness
BRIGHTENING_THRESHOLD0.65fNoise level above which white is mixed in
BRIGHTENING_MIX0.5fAmount 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.
ConstantDefaultDescription
PULSE_DURATION_MS250Duration of the button-press flash in ms
PULSE_MAX_BRIGHTNESS255.0fPeak brightness of the pulse
PULSE_COLOR_R255.0fRed component of the pulse colour (white by default)
PULSE_COLOR_G255.0fGreen component of the pulse colour
PULSE_COLOR_B255.0fBlue 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.
ConstantDefaultDescription
ENCODER_VIS_MAX_DELTA50.0fEncoder delta (counts/frame) that maps to full (1.0) activity
ENCODER_VIS_MAX_BRIGHTNESS200.0fMaximum brightness contribution from the encoder glow layer
ENCODER1_COLOR_R0.0fRed component of VOL-L glow (cyan)
ENCODER1_COLOR_G255.0fGreen component of VOL-L glow
ENCODER1_COLOR_B255.0fBlue component of VOL-L glow
ENCODER2_COLOR_R255.0fRed component of VOL-R glow (magenta)
ENCODER2_COLOR_G0.0fGreen component of VOL-R glow
ENCODER2_COLOR_B255.0fBlue component of VOL-R glow
ENCODER_ACTIVITY_DECAY0.955fPer-frame decay multiplier for encoder glow (lower = faster fade)
ENCODER_ACTIVITY_THRESHOLD0.01fActivity level below which the encoder glow snaps to zero
ENCODER_INTENSITY_SCALE2.0fMultiplier 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.
ConstantDefaultDescription
WS2812B_NUMBER_OF_LEDS12Total number of LEDs in the strip
WS2812_BUFFER_COUNT1Number of parallel LED strip outputs
WS2812_RESET_PERIOD50PWM 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.

Build docs developers (and LLMs) love