fw-rust: Use DefaultClock
type alias everywhere
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
b51511dbab
commit
791a0a0245
3 changed files with 15 additions and 15 deletions
|
@ -1,5 +1,4 @@
|
||||||
use atmega_hal::{
|
use atmega_hal::{
|
||||||
clock::MHz8,
|
|
||||||
delay::Delay,
|
delay::Delay,
|
||||||
port::{mode::Output, Pin, PB0, PB1},
|
port::{mode::Output, Pin, PB0, PB1},
|
||||||
Spi,
|
Spi,
|
||||||
|
@ -8,7 +7,7 @@ use core::convert::TryInto;
|
||||||
use embedded_hal::{blocking::delay::DelayMs, spi::FullDuplex};
|
use embedded_hal::{blocking::delay::DelayMs, spi::FullDuplex};
|
||||||
use nb::block;
|
use nb::block;
|
||||||
|
|
||||||
use crate::{assets::SYMBOL_TABLE, eeprom, CONTRAST};
|
use crate::{assets::SYMBOL_TABLE, eeprom, DefaultClock, CONTRAST};
|
||||||
|
|
||||||
// TODO: Make `cd` and `rst` pins generic pins
|
// TODO: Make `cd` and `rst` pins generic pins
|
||||||
pub struct Lcd {
|
pub struct Lcd {
|
||||||
|
@ -23,7 +22,7 @@ impl Lcd {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(&mut self) {
|
pub fn init(&mut self) {
|
||||||
let mut delay = Delay::<MHz8>::new();
|
let mut delay = Delay::<DefaultClock>::new();
|
||||||
|
|
||||||
// TODO: Test if delay is really needed
|
// TODO: Test if delay is really needed
|
||||||
delay.delay_ms(1_u8);
|
delay.delay_ms(1_u8);
|
||||||
|
@ -71,7 +70,7 @@ impl Lcd {
|
||||||
|
|
||||||
fn fill(&mut self, segment: u8, page: u8, width: u8, data: u8) {
|
fn fill(&mut self, segment: u8, page: u8, width: u8, data: u8) {
|
||||||
assert!(segment + width <= 102);
|
assert!(segment + width <= 102);
|
||||||
let mut delay = Delay::<MHz8>::new();
|
let mut delay = Delay::<DefaultClock>::new();
|
||||||
|
|
||||||
self.move_cursor(segment, page);
|
self.move_cursor(segment, page);
|
||||||
|
|
||||||
|
@ -97,7 +96,7 @@ impl Lcd {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print(&mut self, segment: u8, page: u8, string: &str) {
|
pub fn print(&mut self, segment: u8, page: u8, string: &str) {
|
||||||
let mut delay = Delay::<MHz8>::new();
|
let mut delay = Delay::<DefaultClock>::new();
|
||||||
|
|
||||||
for i in 0..2 {
|
for i in 0..2 {
|
||||||
self.move_cursor(segment, page + i);
|
self.move_cursor(segment, page + i);
|
||||||
|
@ -123,7 +122,7 @@ impl Lcd {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_inverted(&mut self, segment: u8, page: u8, string: &str) {
|
pub fn print_inverted(&mut self, segment: u8, page: u8, string: &str) {
|
||||||
let mut delay = Delay::<MHz8>::new();
|
let mut delay = Delay::<DefaultClock>::new();
|
||||||
|
|
||||||
for i in 0..2 {
|
for i in 0..2 {
|
||||||
self.move_cursor(segment, page + i);
|
self.move_cursor(segment, page + i);
|
||||||
|
@ -150,7 +149,7 @@ impl Lcd {
|
||||||
|
|
||||||
pub fn print_u8(&mut self, segment: u8, page: u8, digits: u8, data: u8) {
|
pub fn print_u8(&mut self, segment: u8, page: u8, digits: u8, data: u8) {
|
||||||
assert!(digits <= 3);
|
assert!(digits <= 3);
|
||||||
let mut delay = Delay::<MHz8>::new();
|
let mut delay = Delay::<DefaultClock>::new();
|
||||||
|
|
||||||
let mut array = [0usize; 3];
|
let mut array = [0usize; 3];
|
||||||
for (i, item) in array.iter_mut().enumerate() {
|
for (i, item) in array.iter_mut().enumerate() {
|
||||||
|
@ -183,7 +182,7 @@ impl Lcd {
|
||||||
|
|
||||||
pub fn print_u8_inverted(&mut self, segment: u8, page: u8, digits: u8, data: u8) {
|
pub fn print_u8_inverted(&mut self, segment: u8, page: u8, digits: u8, data: u8) {
|
||||||
assert!(digits <= 3);
|
assert!(digits <= 3);
|
||||||
let mut delay = Delay::<MHz8>::new();
|
let mut delay = Delay::<DefaultClock>::new();
|
||||||
|
|
||||||
let mut array = [0usize; 3];
|
let mut array = [0usize; 3];
|
||||||
for (i, item) in array.iter_mut().enumerate() {
|
for (i, item) in array.iter_mut().enumerate() {
|
||||||
|
@ -215,7 +214,7 @@ impl Lcd {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_freq(&mut self, segment: u8, page: u8, data: u32) {
|
pub fn print_freq(&mut self, segment: u8, page: u8, data: u32) {
|
||||||
let mut delay = Delay::<MHz8>::new();
|
let mut delay = Delay::<DefaultClock>::new();
|
||||||
|
|
||||||
let mut array = [0usize; 9];
|
let mut array = [0usize; 9];
|
||||||
for (i, item) in array.iter_mut().enumerate() {
|
for (i, item) in array.iter_mut().enumerate() {
|
||||||
|
@ -269,7 +268,7 @@ impl Lcd {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_freq_digit(&mut self, segment: u8, page: u8, data: u32, digit: u8) {
|
pub fn print_freq_digit(&mut self, segment: u8, page: u8, data: u32, digit: u8) {
|
||||||
let mut delay = Delay::<MHz8>::new();
|
let mut delay = Delay::<DefaultClock>::new();
|
||||||
|
|
||||||
let mut array = [0usize; 9];
|
let mut array = [0usize; 9];
|
||||||
for (i, item) in array.iter_mut().enumerate() {
|
for (i, item) in array.iter_mut().enumerate() {
|
||||||
|
@ -342,7 +341,7 @@ impl Lcd {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_icon(&mut self, segment: u8, page: u8, symbol: &[u8]) {
|
pub fn print_icon(&mut self, segment: u8, page: u8, symbol: &[u8]) {
|
||||||
let mut delay = Delay::<MHz8>::new();
|
let mut delay = Delay::<DefaultClock>::new();
|
||||||
self.move_cursor(segment, page);
|
self.move_cursor(segment, page);
|
||||||
|
|
||||||
// TODO: This delay fixes issues, try find a better solution
|
// TODO: This delay fixes issues, try find a better solution
|
||||||
|
|
|
@ -52,7 +52,7 @@ struct ClockGenerator {
|
||||||
exint: EXINT,
|
exint: EXINT,
|
||||||
encoder: Rotary<Pin<port::mode::Input<PullUp>, PB6>, Pin<port::mode::Input<PullUp>, PB7>>,
|
encoder: Rotary<Pin<port::mode::Input<PullUp>, PB6>, Pin<port::mode::Input<PullUp>, PB7>>,
|
||||||
button: Pin<port::mode::Input<PullUp>, PC0>,
|
button: Pin<port::mode::Input<PullUp>, PC0>,
|
||||||
delay: Delay<MHz8>,
|
delay: Delay<DefaultClock>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClockGenerator {
|
impl ClockGenerator {
|
||||||
|
@ -93,7 +93,7 @@ impl ClockGenerator {
|
||||||
),
|
),
|
||||||
tc1: dp.TC1,
|
tc1: dp.TC1,
|
||||||
exint: dp.EXINT,
|
exint: dp.EXINT,
|
||||||
delay: Delay::<MHz8>::new(),
|
delay: Delay::<DefaultClock>::new(),
|
||||||
encoder: Rotary::new(pins.pb6.into_pull_up_input(), pins.pb7.into_pull_up_input()),
|
encoder: Rotary::new(pins.pb6.into_pull_up_input(), pins.pb7.into_pull_up_input()),
|
||||||
button: pins.pc0.into_pull_up_input(),
|
button: pins.pc0.into_pull_up_input(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
assets::{ONDERS_ORG, SACRED_CHAO},
|
assets::{ONDERS_ORG, SACRED_CHAO},
|
||||||
lcd::Lcd,
|
lcd::Lcd,
|
||||||
|
DefaultClock,
|
||||||
};
|
};
|
||||||
use atmega_hal::{clock::MHz8, delay::Delay};
|
use atmega_hal::delay::Delay;
|
||||||
use embedded_hal::{blocking::delay::DelayMs, spi::FullDuplex};
|
use embedded_hal::{blocking::delay::DelayMs, spi::FullDuplex};
|
||||||
use nb::block;
|
use nb::block;
|
||||||
|
|
||||||
|
@ -10,7 +11,7 @@ pub struct Splash;
|
||||||
|
|
||||||
impl Splash {
|
impl Splash {
|
||||||
pub fn draw(&self, lcd: &mut Lcd) {
|
pub fn draw(&self, lcd: &mut Lcd) {
|
||||||
let mut delay = Delay::<MHz8>::new();
|
let mut delay = Delay::<DefaultClock>::new();
|
||||||
|
|
||||||
for (i, page) in SACRED_CHAO.iter().enumerate() {
|
for (i, page) in SACRED_CHAO.iter().enumerate() {
|
||||||
lcd.move_cursor(31, 1 + i as u8);
|
lcd.move_cursor(31, 1 + i as u8);
|
||||||
|
|
Loading…
Reference in a new issue