fw-rust: Prepare to implement Si5351 commands
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Show settings of Si5351 channels on home screen. Initialize I2c and Si5351.
This commit is contained in:
parent
134db298f6
commit
52bf0e6eec
8 changed files with 188 additions and 13 deletions
|
@ -32,10 +32,9 @@ impl Lcd {
|
|||
delay.delay_ms(1_u8);
|
||||
|
||||
let init_sequence = [
|
||||
0x40, // (6) Set Scroll Line: Display start line 0
|
||||
0x40, // (6) Set Scroll Line: Display start line 0
|
||||
0xA1, // (13) Set SEG direction: SEG reverse
|
||||
0xC0, // (14) Set COM direction: Normal COM0 - COM63
|
||||
// 0xA4, // (10) Set All Pixel On: Disable -> Set All Pixel to ON
|
||||
0xA6, // (11) Set Inverse Display: Display inverse off
|
||||
0xA2, // (17) Set LCD Bias Ratio: Set Bias 1/9 (Duty 1/65)
|
||||
0x2F, // (5) Set Power Control: Booster, Regulator and Follower on
|
||||
|
@ -43,8 +42,6 @@ impl Lcd {
|
|||
0xEE, // (18) Reset Cursor Update Mode
|
||||
0x81, // (9) Set Electronic Volume: Set Contrast
|
||||
nb::block!(eeprom::read_byte(&CONTRAST)).unwrap(), // (9) Set Electronic Volume: Set Contrast
|
||||
// 0xFA, // (25) Set Adv. Program Control 0: Set Temperature compensation curve to -0.11%/°C
|
||||
// 0x90, // (25) Set Adv. Program Control 0: Set Temperature compensation curve to -0.11%/°C
|
||||
0xAF, // (12) Set Display Enable: Display on
|
||||
];
|
||||
|
||||
|
@ -112,7 +109,7 @@ impl Lcd {
|
|||
block!(self.spi.send(0x00)).unwrap();
|
||||
block!(self.spi.send(0x00)).unwrap();
|
||||
for c in string.chars() {
|
||||
for segment in SYMBOL_TABLE[c as usize - 48][i as usize] {
|
||||
for segment in SYMBOL_TABLE[c as usize - 46][i as usize] {
|
||||
block!(self.spi.send(*segment)).unwrap();
|
||||
}
|
||||
block!(self.spi.send(0x00)).unwrap();
|
||||
|
@ -138,7 +135,7 @@ impl Lcd {
|
|||
block!(self.spi.send(0xFF)).unwrap();
|
||||
block!(self.spi.send(0xFF)).unwrap();
|
||||
for c in string.chars() {
|
||||
for segment in SYMBOL_TABLE[c as usize - 48][i as usize] {
|
||||
for segment in SYMBOL_TABLE[c as usize - 46][i as usize] {
|
||||
block!(self.spi.send(!*segment)).unwrap();
|
||||
}
|
||||
block!(self.spi.send(0xFF)).unwrap();
|
||||
|
@ -157,7 +154,7 @@ impl Lcd {
|
|||
|
||||
let mut array = [0usize; 3];
|
||||
for (i, item) in array.iter_mut().enumerate() {
|
||||
*item = ((data / 10_u8.pow(i.try_into().unwrap())) % 10).into();
|
||||
*item = (((data / 10_u8.pow(i.try_into().unwrap())) % 10) + 2).into();
|
||||
}
|
||||
array.reverse();
|
||||
|
||||
|
@ -190,7 +187,7 @@ impl Lcd {
|
|||
|
||||
let mut array = [0usize; 3];
|
||||
for (i, item) in array.iter_mut().enumerate() {
|
||||
*item = ((data / 10_u8.pow(i.try_into().unwrap())) % 10).into();
|
||||
*item = (((data / 10_u8.pow(i.try_into().unwrap())) % 10) + 2).into();
|
||||
}
|
||||
array.reverse();
|
||||
|
||||
|
@ -216,4 +213,75 @@ impl Lcd {
|
|||
self.cd.set_low();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_freq(&mut self, segment: u8, page: u8, data: u32) {
|
||||
let mut delay = Delay::<MHz8>::new();
|
||||
|
||||
let mut array = [0usize; 9];
|
||||
for (i, item) in array.iter_mut().enumerate() {
|
||||
*item = (((data / 10_u32.pow(i.try_into().unwrap())) % 10) + 2)
|
||||
.try_into()
|
||||
.unwrap();
|
||||
}
|
||||
array.reverse();
|
||||
|
||||
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);
|
||||
self.cd.set_high();
|
||||
|
||||
block!(self.spi.send(0x00)).unwrap();
|
||||
block!(self.spi.send(0x00)).unwrap();
|
||||
for j in 0..3 {
|
||||
for segment in SYMBOL_TABLE[array[j as usize]][i as usize] {
|
||||
block!(self.spi.send(*segment)).unwrap();
|
||||
}
|
||||
block!(self.spi.send(0x00)).unwrap();
|
||||
}
|
||||
for segment in SYMBOL_TABLE[0][i as usize] {
|
||||
block!(self.spi.send(*segment)).unwrap();
|
||||
}
|
||||
block!(self.spi.send(0x00)).unwrap();
|
||||
for j in 3..6 {
|
||||
for segment in SYMBOL_TABLE[array[j as usize]][i as usize] {
|
||||
block!(self.spi.send(*segment)).unwrap();
|
||||
}
|
||||
block!(self.spi.send(0x00)).unwrap();
|
||||
}
|
||||
for segment in SYMBOL_TABLE[0][i as usize] {
|
||||
block!(self.spi.send(*segment)).unwrap();
|
||||
}
|
||||
block!(self.spi.send(0x00)).unwrap();
|
||||
for j in 6..9 {
|
||||
for segment in SYMBOL_TABLE[array[j as usize]][i as usize] {
|
||||
block!(self.spi.send(*segment)).unwrap();
|
||||
}
|
||||
block!(self.spi.send(0x00)).unwrap();
|
||||
}
|
||||
block!(self.spi.send(0x00)).unwrap();
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_u8);
|
||||
self.cd.set_low();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_icon(&mut self, segment: u8, page: u8, symbol: &[u8]) {
|
||||
let mut delay = Delay::<MHz8>::new();
|
||||
self.move_cursor(segment, page);
|
||||
|
||||
// TODO: This delay fixes issues, try find a better solution
|
||||
delay.delay_ms(1_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);
|
||||
self.cd.set_low();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue