Add the "limit-fps" feature
This commit is contained in:
parent
a788894a3b
commit
9ecf066abe
|
|
@ -8,7 +8,7 @@ repository = "https://github.com/haobogu/rmk"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["ble", "usb-log"]
|
default = ["usb-log", "limit-fps"]
|
||||||
no-usb = ["rmk/_no_usb"]
|
no-usb = ["rmk/_no_usb"]
|
||||||
ble = ["rmk/esp32s3_ble"]
|
ble = ["rmk/esp32s3_ble"]
|
||||||
# Use alternative logging via GPIO5 as RX and GPIO12 as TX.
|
# Use alternative logging via GPIO5 as RX and GPIO12 as TX.
|
||||||
|
|
@ -17,6 +17,7 @@ ble = ["rmk/esp32s3_ble"]
|
||||||
alt-log = []
|
alt-log = []
|
||||||
# Standard logging implementation over USB.
|
# Standard logging implementation over USB.
|
||||||
usb-log = ["esp-backtrace/panic-handler"]
|
usb-log = ["esp-backtrace/panic-handler"]
|
||||||
|
limit-fps = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rmk = { version = "0.8.2", default-features = false, features = [
|
rmk = { version = "0.8.2", default-features = false, features = [
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ use bt_hci::controller::ExternalController;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||||
use embassy_sync::signal::Signal;
|
use embassy_sync::signal::Signal;
|
||||||
|
use embassy_time::Duration;
|
||||||
use esp_alloc::{HeapRegion, MemoryCapability};
|
use esp_alloc::{HeapRegion, MemoryCapability};
|
||||||
use esp_hal::clock::CpuClock;
|
use esp_hal::clock::CpuClock;
|
||||||
use esp_hal::dma::{BurstConfig, DmaDescriptor, DmaTxBuf, ExternalBurstConfig};
|
use esp_hal::dma::{BurstConfig, DmaDescriptor, DmaTxBuf, ExternalBurstConfig};
|
||||||
|
|
@ -42,7 +43,6 @@ use log::{LevelFilter, error, info};
|
||||||
use rmk::channel::EVENT_CHANNEL;
|
use rmk::channel::EVENT_CHANNEL;
|
||||||
use rmk::config::{BehaviorConfig, PositionalConfig, RmkConfig, StorageConfig, VialConfig};
|
use rmk::config::{BehaviorConfig, PositionalConfig, RmkConfig, StorageConfig, VialConfig};
|
||||||
use rmk::debounce::default_debouncer::DefaultDebouncer;
|
use rmk::debounce::default_debouncer::DefaultDebouncer;
|
||||||
use rmk::embassy_futures::yield_now;
|
|
||||||
use rmk::input_device::Runnable;
|
use rmk::input_device::Runnable;
|
||||||
use rmk::{join_all};
|
use rmk::{join_all};
|
||||||
use rmk::keyboard::Keyboard;
|
use rmk::keyboard::Keyboard;
|
||||||
|
|
@ -74,6 +74,7 @@ mod console;
|
||||||
esp_bootloader_esp_idf::esp_app_desc!();
|
esp_bootloader_esp_idf::esp_app_desc!();
|
||||||
|
|
||||||
const LOG_LEVEL_FILTER: LevelFilter = LevelFilter::Info;
|
const LOG_LEVEL_FILTER: LevelFilter = LevelFilter::Info;
|
||||||
|
const FRAME_DURATION_MIN: Duration = Duration::from_millis(40); // 25 FPS
|
||||||
|
|
||||||
static PSRAM_ALLOCATOR: esp_alloc::EspHeap = esp_alloc::EspHeap::empty();
|
static PSRAM_ALLOCATOR: esp_alloc::EspHeap = esp_alloc::EspHeap::empty();
|
||||||
|
|
||||||
|
|
@ -350,7 +351,8 @@ async fn run_renderer_task(backend: SlintBackend) {
|
||||||
loop {
|
loop {
|
||||||
slint::run_event_loop().unwrap();
|
slint::run_event_loop().unwrap();
|
||||||
SIGNAL_LCD_SUBMIT.signal(());
|
SIGNAL_LCD_SUBMIT.signal(());
|
||||||
// Timer::after_millis(50).await;
|
#[cfg(feature = "limit-fps")]
|
||||||
|
embassy_time::Timer::after(FRAME_DURATION_MIN).await;
|
||||||
SIGNAL_UI_RENDER.wait().await;
|
SIGNAL_UI_RENDER.wait().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -508,6 +510,7 @@ async fn run_lcd(mut st7701s: St7701s<'static, Blocking>, framebuffer: &'static
|
||||||
// the flash to be accessed, which interferes with the framebuffer transfer.
|
// the flash to be accessed, which interferes with the framebuffer transfer.
|
||||||
// For that reason, it is disabled, and this task blocks the first core, until the transfer
|
// For that reason, it is disabled, and this task blocks the first core, until the transfer
|
||||||
// is complete.
|
// is complete.
|
||||||
|
#[cfg(not(feature = "limit-fps"))]
|
||||||
while !transfer.is_done() {
|
while !transfer.is_done() {
|
||||||
// Timer::after_millis(1).await;
|
// Timer::after_millis(1).await;
|
||||||
yield_now().await;
|
yield_now().await;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue