fw-rust: Improve control/display toggle times
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Optimize the control data/display data slope timing. This closes #1.
This commit is contained in:
parent
58d903c9e6
commit
e6bf3e780e
2 changed files with 22 additions and 51 deletions
|
@ -4,7 +4,7 @@ use atmega_hal::{
|
|||
Spi,
|
||||
};
|
||||
use core::convert::TryInto;
|
||||
use embedded_hal::{blocking::delay::DelayMs, spi::FullDuplex};
|
||||
use embedded_hal::{blocking::delay::DelayUs, spi::FullDuplex};
|
||||
use nb::block;
|
||||
|
||||
use crate::{assets::SYMBOL_TABLE, eeprom, DefaultClock, CONTRAST};
|
||||
|
@ -22,13 +22,7 @@ impl Lcd {
|
|||
}
|
||||
|
||||
pub fn init(&mut self) {
|
||||
let mut delay = Delay::<DefaultClock>::new();
|
||||
|
||||
// TODO: Test if delay is really needed
|
||||
delay.delay_ms(1_u8);
|
||||
self.rst.set_high();
|
||||
// TODO: Try to reduce delay to a minimum
|
||||
delay.delay_ms(1_u8);
|
||||
|
||||
let init_sequence = [
|
||||
0x40, // (6) Set Scroll Line: Display start line 0
|
||||
|
@ -47,9 +41,6 @@ impl Lcd {
|
|||
for i in init_sequence.iter() {
|
||||
block!(self.spi.send(*i)).unwrap();
|
||||
}
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
}
|
||||
|
||||
pub fn set_contrast(&mut self, contrast: u8) {
|
||||
|
@ -74,16 +65,14 @@ impl Lcd {
|
|||
|
||||
self.move_cursor(segment, page);
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
delay.delay_us(5_u8);
|
||||
self.cd.set_high();
|
||||
|
||||
for _ in 0..width {
|
||||
block!(self.spi.send(data)).unwrap();
|
||||
}
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
delay.delay_us(5_u8);
|
||||
self.cd.set_low();
|
||||
}
|
||||
|
||||
|
@ -101,8 +90,7 @@ impl Lcd {
|
|||
for i in 0..2 {
|
||||
self.move_cursor(segment, page + i);
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
delay.delay_us(5_u8);
|
||||
self.cd.set_high();
|
||||
|
||||
block!(self.spi.send(0x00)).unwrap();
|
||||
|
@ -115,8 +103,7 @@ impl Lcd {
|
|||
}
|
||||
block!(self.spi.send(0x00)).unwrap();
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
delay.delay_us(5_u8);
|
||||
self.cd.set_low();
|
||||
}
|
||||
}
|
||||
|
@ -127,8 +114,7 @@ impl Lcd {
|
|||
for i in 0..2 {
|
||||
self.move_cursor(segment, page + i);
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
delay.delay_us(5_u8);
|
||||
self.cd.set_high();
|
||||
|
||||
block!(self.spi.send(0xFF)).unwrap();
|
||||
|
@ -141,8 +127,7 @@ impl Lcd {
|
|||
}
|
||||
block!(self.spi.send(0xFF)).unwrap();
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
delay.delay_us(5_u8);
|
||||
self.cd.set_low();
|
||||
}
|
||||
}
|
||||
|
@ -160,8 +145,7 @@ impl Lcd {
|
|||
for i in 0..2 {
|
||||
self.move_cursor(segment, page + i);
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
delay.delay_us(5_u8);
|
||||
self.cd.set_high();
|
||||
|
||||
block!(self.spi.send(0x00)).unwrap();
|
||||
|
@ -174,8 +158,7 @@ impl Lcd {
|
|||
}
|
||||
block!(self.spi.send(0x00)).unwrap();
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
delay.delay_us(5_u8);
|
||||
self.cd.set_low();
|
||||
}
|
||||
}
|
||||
|
@ -193,8 +176,7 @@ impl Lcd {
|
|||
for i in 0..2 {
|
||||
self.move_cursor(segment, page + i);
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
delay.delay_us(5_u8);
|
||||
self.cd.set_high();
|
||||
|
||||
block!(self.spi.send(0xFF)).unwrap();
|
||||
|
@ -207,8 +189,7 @@ impl Lcd {
|
|||
}
|
||||
block!(self.spi.send(0xFF)).unwrap();
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
delay.delay_us(5_u8);
|
||||
self.cd.set_low();
|
||||
}
|
||||
}
|
||||
|
@ -227,8 +208,7 @@ impl Lcd {
|
|||
for i in 0..2 {
|
||||
self.move_cursor(segment, page + i);
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
delay.delay_us(5_u8);
|
||||
self.cd.set_high();
|
||||
|
||||
block!(self.spi.send(0x00)).unwrap();
|
||||
|
@ -261,8 +241,7 @@ impl Lcd {
|
|||
}
|
||||
block!(self.spi.send(0x00)).unwrap();
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
delay.delay_us(5_u8);
|
||||
self.cd.set_low();
|
||||
}
|
||||
}
|
||||
|
@ -282,8 +261,7 @@ impl Lcd {
|
|||
for i in 0..2 {
|
||||
self.move_cursor(segment, page + i);
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
delay.delay_us(5_u8);
|
||||
self.cd.set_high();
|
||||
|
||||
block!(self.spi.send(0x00)).unwrap();
|
||||
|
@ -334,8 +312,7 @@ impl Lcd {
|
|||
}
|
||||
block!(self.spi.send(0x00)).unwrap();
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
delay.delay_us(5_u8);
|
||||
self.cd.set_low();
|
||||
}
|
||||
}
|
||||
|
@ -344,16 +321,14 @@ impl Lcd {
|
|||
let mut delay = Delay::<DefaultClock>::new();
|
||||
self.move_cursor(segment, page);
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
delay.delay_us(5_u8);
|
||||
self.cd.set_high();
|
||||
|
||||
for c in symbol {
|
||||
block!(self.spi.send(*c)).unwrap();
|
||||
}
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
delay.delay_us(5_u8);
|
||||
self.cd.set_low();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::{
|
|||
DefaultClock,
|
||||
};
|
||||
use atmega_hal::delay::Delay;
|
||||
use embedded_hal::{blocking::delay::DelayMs, spi::FullDuplex};
|
||||
use embedded_hal::{blocking::delay::DelayUs, spi::FullDuplex};
|
||||
use nb::block;
|
||||
|
||||
pub struct Splash;
|
||||
|
@ -16,32 +16,28 @@ impl Splash {
|
|||
for (i, page) in SACRED_CHAO.iter().enumerate() {
|
||||
lcd.move_cursor(31, 1 + i as u8);
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
delay.delay_us(5_u8);
|
||||
lcd.cd.set_high();
|
||||
|
||||
for segment in page {
|
||||
block!(lcd.spi.send(*segment)).unwrap();
|
||||
}
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
delay.delay_us(5_u8);
|
||||
lcd.cd.set_low();
|
||||
}
|
||||
|
||||
for (i, page) in ONDERS_ORG.iter().enumerate() {
|
||||
lcd.move_cursor(27, 6 + i as u8);
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
delay.delay_us(5_u8);
|
||||
lcd.cd.set_high();
|
||||
|
||||
for segment in page {
|
||||
block!(lcd.spi.send(*segment)).unwrap();
|
||||
}
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
delay.delay_us(5_u8);
|
||||
lcd.cd.set_low();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue