Smart Panlee SC01 Plus#
Smart Panlee SC01 Plus#
The Smart Panlee SC01 Plus is an ESP32-S3 touchscreen display module with a 3.5-inch 320x480 ST7796 LCD, FT5x06 capacitive touch, direct I2S speaker playback, SPI microSD support, and published I2S / RS-485 / expansion GPIO pin maps.
The espp::SmartPanleeSc01Plus component provides a singleton hardware abstraction for the display, touch, backlight, audio output, and microSD card, while also exposing the board’s documented peripheral pins for application use. Its LCD path uses the object-style espp::St7796 controller integration.
API Reference#
Header File#
Classes#
-
class SmartPanleeSc01Plus : public espp::BaseComponent#
The SmartPanleeSc01Plus class provides an interface to the Smart Panlee SC01 Plus development board.
The class provides access to the following features:
ST7796 3.5-inch 320x480 display over an 8-bit Intel 8080 style bus
FT5x06 capacitive touch controller
PWM backlight control
I2S audio playback for the onboard speaker path (espp::Audio)
SPI microSD card mounting helpers
Published I2S, RS-485, and expansion pin maps
The class is a singleton and can be accessed using the get() method.
Example#
auto &board = espp::SmartPanleeSc01Plus::get(); if (!board.initialize_lcd()) { logger.error("Failed to initialize LCD!"); return; } if (!board.initialize_display(board.display_width() * 40)) { logger.error("Failed to initialize display!"); return; } // the click sound sets the playback rate; the stream is sized so one // play_audio() call queues the whole click (about 35 KB of 44.1 kHz stereo) size_t wav_size = 0; size_t wav_sample_rate = 44100; if (load_audio(wav_size, wav_sample_rate)) { logger.info("Loaded {} bytes of audio at {} Hz", wav_size, wav_sample_rate); } else { logger.warn("Could not load the embedded click sound"); } board.volume(30.0f); board.mute(false); auto audio_config = board.default_audio_config(); audio_config.sample_rate = static_cast<uint32_t>(wav_sample_rate); audio_config.playback_buffer_size = 36 * 1024; if (!board.initialize_audio(audio_config)) { logger.warn("Audio initialization did not complete cleanly"); } board.brightness(80.0f); if (!board.initialize_sdcard()) { logger.info("No microSD card mounted"); } auto i2s = board.i2s_pins(); auto rs485 = board.rs485_pins(); logger.info("I2S pins: bclk={}, ws={}, dout={}", i2s.bclk, i2s.ws, i2s.dout); logger.info("RS485 pins: rts={}, rxd={}, txd={}", rs485.rts, rs485.rxd, rs485.txd); // create the GUI: builds the UI (info label, buttons, circle layer) and // starts the task which updates LVGL. All of its public methods are // thread-safe, so the touch callback below can call them directly. static Gui gui({.log_level = espp::Logger::Verbosity::INFO}); gui.set_label_text( fmt::format("Smart Panlee SC01 Plus\n\nTouch the screen to draw and play a click.\nPress " "{} to rotate.\nPress {} to clear.\nThe Audio tab plays the click sound and " "adjusts / mutes the volume.\nCheck serial output for SD card, pin, and audio " "info.", LV_SYMBOL_REFRESH, LV_SYMBOL_TRASH)); // the play button on the audio row plays the same click sound as a touch gui.set_play_callback([&]() { play_click(board); }); // initialize the touchpad after the GUI exists so touch events can update // it immediately; each touch draws a circle and plays a click sound auto touch_callback = [&](const auto &touch) { static auto previous_touchpad_data = board.touchpad_convert(touch); auto touchpad_data = board.touchpad_convert(touch); if (touchpad_data != previous_touchpad_data) { previous_touchpad_data = touchpad_data; if (touchpad_data.num_touch_points > 0 && gui.draw_page_active()) { play_click(board); gui.draw_circle(touchpad_data.x, touchpad_data.y, 10); } } }; // NOTE: this example raises the BSP interrupt-task stack size via // sdkconfig.defaults (CONFIG_SMARTPANLEE_SC01_PLUS_INTERRUPT_STACK_SIZE=8192); // the touch controller is read from that task and its error-logging path // needs more than the 4 KB BSP default. See the example README. if (!board.initialize_touch(touch_callback)) { logger.warn("Touch initialization did not complete cleanly"); }
Public Types
-
using Pixel = lv_color16_t#
Alias for the pixel type used by the display.
-
using TouchpadData = espp::TouchpadData#
Alias for the touch data structure exposed to callers.
-
using touch_callback_t = std::function<void(const TouchpadData&)>#
Callback type invoked when fresh touch data is available.
-
using AudioConfig = espp::Audio::AppConfig#
How initialize_audio() sets the audio system up: the application’s side of espp::Audio (the board’s wiring is filled in by initialize_audio()). Start from default_audio_config() to keep this board’s defaults. The board has a speaker path only (no microphone): initialize_audio() needs playback_enabled and fails with recording_enabled.
sample_rate: the audio sample rate, in Hz
playback_buffer_size / playback_buffer_caps: the stream play_audio() queues into (0: about 67 ms of audio; larger lets one play_audio() call queue a whole UI sound)
playback_task_config: the playback task (recording_task_config is unused)
Public Functions
-
SmartPanleeSc01Plus(const SmartPanleeSc01Plus&) = delete#
Deleted copy constructor.
-
SmartPanleeSc01Plus &operator=(const SmartPanleeSc01Plus&) = delete#
Deleted copy assignment operator.
-
SmartPanleeSc01Plus(SmartPanleeSc01Plus&&) = delete#
Deleted move constructor.
-
SmartPanleeSc01Plus &operator=(SmartPanleeSc01Plus&&) = delete#
Deleted move assignment operator.
-
inline I2c &internal_i2c()#
Get the internal I2C bus used for touch and board peripherals.
- Returns:
Reference to the internal I2C instance.
-
inline espp::Interrupt &interrupts()#
Get the interrupt manager used by the BSP.
- Returns:
Reference to the interrupt manager.
-
bool initialize_touch(const touch_callback_t &callback = nullptr)#
Initialize the touch controller and optional interrupt-driven callback.
- Parameters:
callback – Callback invoked when touch data changes.
- Returns:
True if touch support was initialized, false otherwise.
-
inline std::shared_ptr<TouchpadInput> touchpad_input() const#
Get the LVGL touch input wrapper created by initialize_display().
- Returns:
Shared pointer to the touchpad input wrapper, or nullptr if not initialized.
-
TouchpadData touchpad_data() const#
Get the most recently cached touch data.
- Returns:
Latest cached touchpad data.
-
void touchpad_read(uint8_t *num_touch_points, uint16_t *x, uint16_t *y, uint8_t *btn_state)#
Read the cached touch data using the signature expected by TouchpadInput.
- Parameters:
num_touch_points – Filled with the number of active touch points.
x – Filled with the x coordinate of the primary touch point.
y – Filled with the y coordinate of the primary touch point.
btn_state – Filled with the button state for LVGL compatibility.
-
TouchpadData touchpad_convert(const TouchpadData &data) const#
Convert raw touch data into display-oriented coordinates.
- Parameters:
data – Raw cached touch data.
- Returns:
Touch data transformed for the current display rotation and inversion settings.
-
bool initialize_lcd()#
Initialize the low-level LCD transport and backlight control.
- Returns:
True if the LCD interface was initialized, false otherwise.
-
bool initialize_display(size_t pixel_buffer_size = 320 * 40)#
Initialize the LVGL display wrapper.
- Parameters:
pixel_buffer_size – Display buffer size in pixels.
- Returns:
True if the display wrapper was initialized, false otherwise.
-
inline std::shared_ptr<Display<Pixel>> display() const#
Get the high-level LVGL display wrapper.
- Returns:
Shared pointer to the display wrapper, or nullptr if not initialized.
-
inline const std::shared_ptr<DisplayDriver> &display_driver() const#
Get a shared pointer to the low-level display driver.
- Returns:
Shared pointer to the display driver, or a typed-null handle if not initialized.
-
void brightness(float brightness)#
Set the display backlight brightness.
- Parameters:
brightness – Brightness percentage in the range [0, 100].
-
float brightness() const#
Get the display backlight brightness.
- Returns:
Brightness percentage in the range [0, 100].
-
size_t rotated_display_width() const#
Get the current display width after applying LVGL rotation.
- Returns:
Rotated width in pixels.
-
size_t rotated_display_height() const#
Get the current display height after applying LVGL rotation.
- Returns:
Rotated height in pixels.
-
void write_lcd_lines(int xs, int ys, int xe, int ye, const uint8_t *data, uint32_t user_data)#
Write lines to the LCD using the legacy scanline-oriented transport signature.
Note
This method queues the panel transfer asynchronously and may return before the write has completed.
- Parameters:
xs – Inclusive start X coordinate.
ys – Inclusive start Y coordinate.
xe – Inclusive end X coordinate.
ye – Inclusive end Y coordinate.
data – Pointer to pixel payload data.
user_data – Opaque user data passed by the caller.
-
bool initialize_audio()#
Initialize the audio system with the default AudioConfig: playback at 44.1 kHz
- Returns:
true if the audio system was successfully initialized, false otherwise
-
bool initialize_audio(const AudioConfig &config)#
Initialize the audio system (stereo playback to the speaker path on the board’s published I2S pins; volume and mute are applied in software)
Note
A failure part way through undoes what was set up before it (the I2S channel and its DMA ring, the stream buffer, the task), so the call can be retried.
- Parameters:
config – The sample rate, the playback buffer and the task configuration
- Returns:
true if the audio system was successfully initialized, false otherwise
-
bool initialize_audio(uint32_t sample_rate)#
Initialize the audio system at the specified sample rate
- Parameters:
sample_rate – Audio sample rate in Hz.
- Returns:
True if audio playback support was initialized, false otherwise.
-
bool initialize_audio(uint32_t sample_rate, const espp::Task::BaseConfig &task_config)#
Initialize the audio system using a custom task configuration
-
void deinitialize_audio()#
Stop the audio system and free what initialize_audio() set up. Idempotent.
Note
The audio methods below may be called from any task meanwhile, but initialize_audio() and deinitialize_audio() must not run concurrently with each other.
-
inline bool is_audio_initialized() const#
Whether the audio system is initialized
- Returns:
True if initialize_audio() succeeded (until deinitialize_audio())
-
inline std::shared_ptr<espp::Audio> audio() const#
The audio component, for anything the BSP methods below do not expose
Note
deinitialize_audio() releases the hardware even while the returned pointer is held: the object is then uninitialized (its methods fail / return 0), and a later initialize_audio() makes a new one.
- Returns:
The audio component, or nullptr before initialize_audio()
-
bool audio_sample_rate(uint32_t sample_rate)#
Set the audio sample rate. The audio queued for playback is dropped, since it was for the old rate.
- Parameters:
sample_rate – Audio sample rate in Hz.
- Returns:
True on success (false before initialize_audio(): the rate is then AudioConfig::sample_rate)
-
uint32_t audio_sample_rate() const#
Get the active audio sample rate.
- Returns:
Audio sample rate in Hz, or 0 if audio is not initialized.
-
size_t audio_buffer_size() const#
Get the audio buffer size
- Returns:
The size of one playback block, in bytes (1/60 s of audio)
-
void mute(bool mute)#
Mute or unmute speaker playback.
Note
Before initialize_audio() the value is stored and applied when playback starts.
- Parameters:
mute – True to mute playback, false to unmute it.
-
bool is_muted() const#
Query whether speaker playback is muted.
- Returns:
True if playback is muted.
-
void volume(float volume)#
Set the software playback volume.
Note
Before initialize_audio() the value is stored and applied when playback starts.
- Parameters:
volume – Volume percentage in the range [0, 100].
-
float volume() const#
Get the software playback volume.
- Returns:
Volume percentage in the range [0, 100].
-
size_t play_audio(std::span<const uint8_t> data)#
Queue raw PCM audio bytes for playback (16-bit signed stereo samples).
Note
Must be called from task context, not from an ISR.
- Parameters:
data – Audio payload to play.
- Returns:
The number of bytes actually queued (may be less than the data size if the internal stream buffer is full); stream longer data by calling repeatedly, advancing by the returned count (or make the buffer larger: AudioConfig::playback_buffer_size)
-
size_t play_audio(const uint8_t *data, size_t num_bytes)#
Queue raw PCM audio bytes for playback (16-bit signed stereo samples).
Note
Must be called from task context, not from an ISR.
- Parameters:
data – Pointer to PCM audio bytes.
num_bytes – Number of bytes to play.
- Returns:
The number of bytes actually queued (may be less than
num_bytesif the internal stream buffer is full); stream longer data by calling repeatedly, advancing by the returned count (or make the buffer larger: AudioConfig::playback_buffer_size)
-
void clear_audio()#
Drop any queued (not yet played) audio so a subsequent play_audio() starts immediately instead of waiting behind previously queued sound.
-
bool initialize_sdcard()#
Initialize and mount the optional microSD card with default settings.
- Returns:
True if the card was mounted successfully, false otherwise.
-
bool initialize_sdcard(const SdCardConfig &config)#
Initialize and mount the optional microSD card with custom settings.
- Parameters:
config – Mount configuration.
- Returns:
True if the card was mounted successfully, false otherwise.
-
inline sdmmc_card_t *sdcard() const#
Get the microSD card.
Note
nullptr until initialize_sdcard() succeeded. The card stays valid while its volume is unmounted (sdcard_component()->unmount()), e.g. to hand it to a USB host through espp::UsbDevice’s MSC function.
- Returns:
Pointer to the sdmmc_card_t, or nullptr if not initialized
-
inline espp::SdCard *sdcard_component() const#
Get the SD card component: mount() / unmount() (e.g. to hand the card to a USB host with the usb_device MSC function), format(), card_info(), volume_info(), …
- Returns:
The component, or nullptr until initialize_sdcard() succeeded
-
bool is_sd_card_available() const#
Check whether the microSD card is initialized and its volume is currently mounted (false after sdcard_component()->unmount()).
- Returns:
True if the card is mounted and available.
-
bool get_sd_card_info(uint32_t *size_mb, uint32_t *free_mb) const#
Query mounted microSD capacity and free space.
- Parameters:
size_mb – Optional output for total capacity in megabytes.
free_mb – Optional output for free space in megabytes.
- Returns:
True if card information was retrieved successfully, false otherwise.
-
inline const std::string &get_name() const#
Get the name of the component
Note
This is the tag of the logger
- Returns:
A const reference to the name of the component
-
template<typename T = void>
inline void set_log_tag(const std::string_view&)# Not available: the tag is fixed at construction (pass it to the constructor). Enable CONFIG_ESPP_LOGGER_MUTABLE_TAG (menuconfig: ESPP Logger -> Mutable tag) to change it afterwards.
-
inline espp::Logger::Verbosity get_log_level() const#
Get the log level for the logger
See also
See also
- Returns:
The verbosity level of the logger
-
inline void set_log_level(espp::Logger::Verbosity level)#
Set the log level for the logger
See also
See also
- Parameters:
level – The verbosity level to use for the logger
-
inline void set_log_verbosity(espp::Logger::Verbosity level)#
Set the log verbosity for the logger
See also
See also
See also
Note
This is a convenience method that calls set_log_level
- Parameters:
level – The verbosity level to use for the logger
-
inline espp::Logger::Verbosity get_log_verbosity() const#
Get the log verbosity for the logger
See also
See also
See also
Note
This is a convenience method that calls get_log_level
- Returns:
The verbosity level of the logger
-
inline void set_log_rate_limit(std::chrono::duration<float> rate_limit)#
Set the rate limit for the logger
See also
Note
Only calls to the logger that have _rate_limit suffix will be rate limited
- Parameters:
rate_limit – The rate limit to use for the logger
Public Static Functions
-
static inline SmartPanleeSc01Plus &get()#
Access the singleton instance.
- Returns:
Reference to the singleton board-support instance.
-
static inline I2sPins i2s_pins()#
Get the published I2S pin mapping for the board.
- Returns:
I2S pin mapping.
-
static inline SdCardPins sd_card_pins()#
Get the published SPI microSD pin mapping for the board.
- Returns:
MicroSD pin mapping.
-
static inline Rs485Pins rs485_pins()#
Get the published RS-485 pin mapping for the board.
- Returns:
RS-485 pin mapping.
-
static inline ExternalPins external_pins()#
Get the published external expansion GPIO mapping for the board.
- Returns:
External GPIO mapping.
-
static inline size_t bytes_per_pixel()#
Get the number of bytes per pixel used by the panel.
- Returns:
Bytes per pixel.
-
static inline size_t display_width()#
Get the native display width.
- Returns:
Width in pixels.
-
static inline size_t display_height()#
Get the native display height.
- Returns:
Height in pixels.
-
static AudioConfig default_audio_config()#
The board’s default AudioConfig: playback at 44.1 kHz, and the task “sc01+ audio out” on core 1 with the stack from Kconfig (SMARTPANLEE_SC01_PLUS_AUDIO_TASK_STACK_SIZE).
- Returns:
The default AudioConfig
Public Static Attributes
-
static char mount_point[] = "/sdcard"#
Mount point used when the optional microSD card is mounted.
-
struct I2sPins#
Published I2S pins for the SC01 Plus speaker interface.
-
struct SdCardPins#
SPI microSD pin mapping published for the board.
-
struct Rs485Pins#
RS-485 UART control and data pins published for the board.
-
struct ExternalPins#
External expansion GPIOs published for the board.
-
struct SdCardConfig#
Configuration for mounting the optional microSD card.