Skip to content

Commit 79b1952

Browse files
committed
fix: box display error
1 parent e32a269 commit 79b1952

File tree

4 files changed

+32
-23
lines changed

4 files changed

+32
-23
lines changed

components/hal_driver/lcd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ void lcd_color_fill(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t
125125
}
126126

127127
/* 计算填充区域的宽度 */
128-
uint16_t width = ex - sx + 1;
129-
uint16_t height = ey - sy + 1;
128+
uint16_t width = ex - sx;
129+
uint16_t height = ey - sy;
130130
uint32_t buf_index = 0;
131131

132132
uint16_t *buffer = heap_caps_malloc(width * sizeof(uint16_t), MALLOC_CAP_INTERNAL);

src/app.rs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ async fn select_evt(
6565

6666
tokio::select! {
6767
_ = timeout_f => {
68-
log::info!("Event select timeout");
68+
// log::info!("Event select timeout");
6969
timeout_event
7070
}
7171
Some(evt) = evt_rx.recv() => {
@@ -154,7 +154,7 @@ impl DownloadMetrics {
154154

155155
const SPEED_LIMIT: f64 = 1.0;
156156
const INTERNAL_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(1);
157-
const NORMAL_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(60);
157+
const NORMAL_TIMEOUT: std::time::Duration = std::time::Duration::from_millis(500);
158158

159159
pub async fn main_work<'d>(
160160
mut server: Server,
@@ -196,9 +196,16 @@ pub async fn main_work<'d>(
196196
let mut init_hello = false;
197197
let mut allow_interrupt = false;
198198
let mut timeout = NORMAL_TIMEOUT;
199+
let mut idle_counter = 0u32;
199200

200201
while let Some(evt) = select_evt(&mut evt_rx, &mut server, &notify, wait_notify, timeout).await
201202
{
203+
if let Event::Event(Event::IDLE) = &evt {
204+
idle_counter += 1;
205+
} else {
206+
idle_counter = 0;
207+
}
208+
202209
match evt {
203210
Event::Event(Event::GAIA | Event::K0) => {
204211
log::info!("Received event: k0");
@@ -261,11 +268,18 @@ pub async fn main_work<'d>(
261268
}
262269
Event::Event(Event::YES | Event::K1) => {}
263270
Event::Event(Event::IDLE) => {
264-
if state == State::Listening {
265-
state = State::Idle;
266-
gui.state = "Idle".to_string();
267-
gui.display_flush().unwrap();
268-
server.close().await?;
271+
if NORMAL_TIMEOUT * idle_counter >= std::time::Duration::from_secs(300) {
272+
idle_counter = 0;
273+
log::info!("Idle for 5 minutes, going to Idle state");
274+
if state == State::Listening {
275+
state = State::Idle;
276+
gui.state = "Idle".to_string();
277+
gui.display_flush().unwrap();
278+
server.close().await?;
279+
}
280+
} else {
281+
#[cfg(feature = "box")]
282+
let _ = gui.display_flush();
269283
}
270284
}
271285
Event::Event(Event::NOTIFY) => {

src/audio.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ unsafe fn afe_init() -> (
2626
afe_config.vad_min_noise_ms = 500;
2727
// afe_config.vad_min_speech_ms = 300;
2828
afe_config.vad_mode = esp_sr::vad_mode_t_VAD_MODE_3;
29-
afe_config.agc_init = true;
29+
afe_config.agc_init = false;
3030
// afe_config.afe_linear_gain = 2.0;
3131
afe_config.aec_init = true;
3232
afe_config.aec_mode = esp_sr::aec_mode_t_AEC_MODE_VOIP_HIGH_PERF;
3333
// afe_config.aec_filter_length = 5;
34-
afe_config.ns_init = true;
34+
afe_config.ns_init = false;
3535
afe_config.wakenet_init = false;
3636
afe_config.memory_alloc_mode = esp_sr::afe_memory_alloc_mode_t_AFE_MEMORY_ALLOC_MORE_PSRAM;
3737

src/boards/atom_box.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,15 @@ pub fn lcd_init(
143143
}
144144

145145
pub fn flush_display(color_data: &[u8], x_start: i32, y_start: i32, x_end: i32, y_end: i32) -> i32 {
146-
let panel = unsafe { std::mem::transmute(esp_idf_svc::sys::hal_driver::panel_handle) };
147146
unsafe {
148-
let e = esp_idf_svc::sys::esp_lcd_panel_draw_bitmap(
149-
panel,
150-
x_start,
151-
y_start,
152-
x_end,
153-
y_end,
154-
color_data.as_ptr().cast(),
147+
esp_idf_svc::sys::hal_driver::lcd_color_fill(
148+
x_start as u16,
149+
y_start as u16,
150+
x_end as u16,
151+
y_end as u16,
152+
color_data.as_ptr() as _,
155153
);
156-
if e != 0 {
157-
log::warn!("flush_display error: {}", e);
158-
}
159-
e
154+
0
160155
}
161156
}
162157

0 commit comments

Comments
 (0)