Drop-in replacement controller board for the Sunlu S1 filament dryer. Features an STM32C011F4P6 microcontroller, 1.8" ST7735 TFT display, dual NTC temperature sensing, and precise PWM heater control; all optimized to fit in just 16 KB of flash.
Complete replacement for the stock Sunlu S1 control board, maintaining compatibility with the original heating element, chamber, and power connections. Adds a color TFT display in landscape mode and two-button navigation for precise temperature and time control (30–70°C configurable range, exceeding the stock 35–55°C limit).
The firmware uses integer-only math, dirty-check rendering, and batched SPI transfers to fit in the STM32C011's tiny 16 KB flash with room to spare.
Final build
- 1.8" ST7735 TFT: 160×128 px landscape, 16-bit RGB565 color
- Two-button interface: short-press (select/increment), long-press (toggle/cancel)
- Three screens: Main Status, Set Temperature, Set Time
- Smart rendering: dirty-check updates (only changed fields), instant button response
- Dual NTC thermistors: air temp (displayed) + heater element (safety)
- Proportional PWM control (~488 Hz): ramps heater power based on error from target
- Dual safety cutoffs: absolute (85°C) and dynamic (target + 5°C margin)
- Integer-only lookup: 11-point table with linear interpolation, no floating-point library
- Fan control: full speed during drying and overheat emergency
- ~600 lines: single-loop, no RTOS/filesystem
- ~13 KB flash / ~2 KB RAM: 80% flash usage, 33% RAM usage
- Batched SPI: 128-byte buffer (~100× faster than byte-by-byte)
- Minimal font: 5×7 bitmap, 29 glyphs only
- No soft-float: integer NTC lookup saves ~4 KB
Requires arm-none-eabi-gcc, cmake, and cube-cmake installed.
cd Code
cmake --preset Debug
cmake --build build/Debug --target CodedeUsing st-flash:
st-flash write build/Debug/Code.bin 0x08000000Or use the VS Code task "Build and Flash" if configured.
- Top: Air temperature, Countdown timer (HH:MM)
- Middle: Current state (IDLE/RUN/PAUSE), target temperature setting
- Bottom: Action hints: BTN1=set, BTN2=start/pause/resume, hold BTN2=stop/reset
- Value: Current target in °C
- Controls:
- Short BTN1: increment (or decrement if toggled)
- Long BTN1: toggle UP/DOWN mode, hints show current direction
- Short BTN2: confirm & advance to Set TimeTime
- Long BTN2: cancel & return to MainMain
- Value: Target drying time in HH:MM format
- Controls: Same as Set Temp (BTN1 for ±, long BTN1 to toggle, BTN2 to confirm/cancel)
- Press BTN1 on Main Screen → Set Temperature
- Adjust with BTN1 (short = increment, long = toggle direction, watch hints)
- Press BTN2 → Set Time
- Adjust similarly, then press BTN2 → firmware returns to Main and starts drying
- Monitor progress on Main Screen; press BTN2 to pause/resume
- Hold BTN2 to stop and reset (returns to IDLE)
| Function | Pin | Module | Notes |
|---|---|---|---|
| Display CS | PB7 | SPI1 | ST7735 chip select |
| Display DC | PA3 | SPI1 | Data/Command |
| Display RES | PC14 | GPIO | Reset |
| Display BL | PA8 | GPIO | Backlight (always ON) |
| Display SPI | PA5, PA6, PA7 | SPI1 | CLK, MISO, MOSI |
| Button 1 | PA4 | GPIO | Up/Set (active LOW, pull-up) |
| Button 2 | PA5 | GPIO | Select/Confirm (active LOW, pull-up) |
| Heater PWM | PA0 | TIM1_CH1 | 16-bit PWM (0–65535 = 0–100%) |
| Fan PWM | PA1 | TIM17_CH1 | 16-bit PWM (0–65535 = 0–100%) |
| Air NTC | PA11 | ADC_CH11 | 100k thermistor, 3.3 V divider |
| Heater NTC | PA12 | ADC_CH12 | 100k thermistor, 3.3 V divider |
| LED | PA2 | GPIO | Status indicator (on during RUN/PAUSE) |
See Code/Core/Inc/main.h for full pin configuration.
- MCU: STM32C011F4P6 (Cortex-M0+, 32 MHz, 16 KB flash, 6 KB RAM)
- Display: ST7735 1.8" TFT, 160×128 px, 16-bit RGB565, SPI @ 16 MHz
- PWM: TIM1 (heater) + TIM17 (fan), ~488 Hz, 16-bit resolution
- ADC: 12-bit, dual-channel NTC reading @ 500 ms
- Range: 30–70°C (configurable
TMIN/TMAX) - NTC: 100 K, B=3950, ~1°C resolution
- Button poll: 20 ms (30 ms debounce, 1 s long-press)
- Display refresh: 250 ms idle on Main screen, instant on changes
- Countdown: 1 s ticks
- Input: 24 V DC
- Heater: ≤48 W (PWM-controlled)
- Fan: ≤2 W (PWM-controlled)
- MCU + Display: ≤100 mA @ 3.3 V
├── CMakeLists.txt # Build config
├── Core/
│ ├── Inc/
│ │ ├── main.h # Pin definitions, HAL config
│ │ ├── dryer.h # Public firmware API
│ │ └── ...
│ └── Src/
│ ├── main.c # Entry point, HAL init
│ ├── dryer.c # Firmware (600 lines): display driver, UI, control
│ └── ...
├── Drivers/
│ ├── CMSIS/
│ ├── STM32C0xx_HAL_Driver/ # ST HAL
│ └── ...
└── cmake/ # Toolchain files
olchain files
- Temperature limits: edit
TMIN,TMAX,TDEFin Code/Core/Src/dryer.c - Time limits: edit
MMIN,MMAX,MDEF - Safety margin: change
stmp + 5inRegulate()function - NTC calibration: update
ntc[]lookup table in Code/Core/Src/dryer.c
See BOM.csv for the complete component list and part numbers.
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.



.jpg)

.jpg)
