v1.8.8 - DAC Manager Module Refactoring (2025-11-24)¶
What Changed?¶
This release refactors the SPI DAC control module for clarity and efficiency. The module is renamed from spi_control to dac_manager to better reflect its responsibility (DAC management, not generic SPI operations). Function names are standardized with dac_* prefix, redundant channel-specific wrappers are removed, and the API is simplified by eliminating vestigial parameters. The SPI settings are now cached as a static object for improved memory efficiency.
What's New¶
Module Refactoring: SPI Control β DAC Manager¶
What it does: Restructures the Digital-to-Analog Converter (DAC) management module with clearer naming, simpler API, and improved efficiency. No functional behavior changesβall existing DAC operations work identically.
Key improvements:
- Module name clarity -
spi_controlβdac_managerreflects true responsibility - Unified function prefix - All functions use
dac_*instead of mixedspi_*naming - Simplified API - Removed unused
clockSpeedparameter fromdac_init() - Memory efficiency - Static SPI settings cached, avoiding repeated object creation
- Better documentation - Added detailed parameter explanations for SPI configuration
Code example:
// Before (v1.8.7)
#include "spi_control.h"
spi_init(100000); // Unused parameter
// After (v1.8.8)
#include "dac_manager.h"
dac_init(); // Cleaner API, fixed 100 kHz clock
// SPI settings now cached statically
// Arguments: clock speed (100 kHz), bit order (MSB first),
// data mode (SPI mode 0 - clock idle low, data sampled on rising edge)
static SPISettings g_dac_settings(100000, MSBFIRST, SPI_MODE0);
Installation¶
Quick Start¶
# Get the release
git checkout vX.Y.Z
# Build
task build
# Upload
task upload
# Check it works
task monitor
What's Different from the Last Version?¶
β Added¶
- Static SPI settings cache (
g_dac_settings) for improved memory efficiency - Detailed parameter documentation for SPI configuration (clock speed, bit order, data mode)
π§ Changed¶
- Module rename:
spi_control.hβdac_manager.h(file-level clarification of responsibility) - Function renames:
spi_init(clockSpeed)βdac_init()(removed vestigial parameter)spi_send_dac_command(ch, ...)βdac_send(ch, ...)(unified naming)- Removed redundant
spi_send_dac1/2/3()wrappers (use unifieddac_send(channel, ...)) encode_dac_threshold()βdac_encode_threshold()(consistent prefix)- Global variable renames: Applied
g_prefix convention for scope clarity spi_vspiβg_dac_spispi_clock_speedβ removed (hardcoded 100 kHz)- SPI transaction optimization: Each transaction now reuses cached
SPISettingsinstead of creating temporary objects
π Fixed¶
- Removed unused
SPI_DEFAULT_CLOCKmacro (hardcoded 100 kHz DAC requirement) - Eliminated compiler warnings for unused parameters via proper documentation
Is It Safe to Upgrade?¶
Backward Compatible: Partially (API changes required)
Impact on users:
- Code using
spi_controlmodule must update includes:#include "dac_manager.h" - Function calls must use new names:
dac_init(),dac_send(),dac_encode_threshold() - If directly calling
spi_init(100000), change todac_init()(no parameters) - If using channel-specific wrappers (
spi_send_dac1/2/3), replace with unified:dac_send(channel, byte1, byte2) - Hardware behavior: Identicalβonly API and naming changed
- Firmware size: Slightly improved (no repeated SPI settings object creation)
Tests Passed¶
- β Builds without errors (esp32dev-dev profile)
- β RAM usage: 7.3% (unchanged)
- β Flash usage: 24.0% (unchanged, optimized SPI settings offset by reduced code)
- β Serial communication: functional at 115200 baud
- β DAC threshold encoding: verified with protocol compliance
Release Details¶
- Date: 2025-11-24
- Version: v1.8.8
- Files Changed: 5 (
dac_manager.h,dac_manager.cpp,main.cpp,runtime_config.cpp,binary_protocol_handler.cpp,text_protocol_handler.cpp) - Commits: 83fc011 (refactor: simplify API and optimize), 90c094b (docs: parameter explanation)
Next Steps¶
- Continue module-based refactoring of other SPI/I2C interfaces for consistency
- Evaluate other modules for YAGNI principle application (remove vestigial parameters and unused configuration)
- Consider applying
g_prefix convention to other global static variables throughout the codebase