remove debugging

This commit is contained in:
2025-10-04 15:45:54 +01:00
parent 42c18a6d5a
commit d66914f74f
3 changed files with 6 additions and 29 deletions

View File

@@ -112,8 +112,8 @@ impl Segment {
Segment(0, Brightness::full())
}
pub fn brightness(&mut self, b: u8) -> &mut Self {
self.1 = Brightness(b);
pub fn brightness(&mut self, b: Brightness) -> &mut Self {
self.1 = b;
self
}

View File

@@ -85,8 +85,7 @@ unsafe fn TIMER0_COMPA() {
access_global(&IO_LOOP, cs, |io_loop| {
access_global(&SEGMENT_TIMER, cs, |st| {
let brightness = io_loop.display_on();
let elapsed = st.segment_on_time(brightness.scale_brightness());
io_loop.frame_data = Some((elapsed, brightness.unwrap()));
st.segment_on_time(brightness.scale_brightness());
});
});
});
@@ -116,7 +115,6 @@ pub struct IOLoop {
keyboard: Keyboard,
readount: Option<KeyReadout>,
debounce: Debounce,
frame_data: Option<(u8, u8)>,
}
impl IOLoop {
@@ -130,7 +128,6 @@ impl IOLoop {
keyboard,
readount: None,
debounce: Default::default(),
frame_data: None,
}
}
@@ -185,10 +182,6 @@ impl IOLoop {
pub fn frame(&self) -> (u16, usize) {
(self.frame, self.index)
}
pub fn frame_data(&self) -> Option<(u8, u8)> {
self.frame_data
}
}
#[derive(uDebug)]
@@ -534,7 +527,6 @@ fn main() -> ! {
let mut display = DispalyState::default();
number_input.show(&mut display);
let mut frame_data_index: usize = 0;
let mut calc = Calc::default();
let mut state = State {
transient: TransientState::Done,
@@ -566,12 +558,6 @@ fn main() -> ! {
state.calculator
)
.ok();
match key {
KeyPress::Num(n) => {
frame_data_index = n as usize;
}
_ => (),
}
match state.calculator.on_key(key, &mut number_input, &mut calc) {
Ok(new_state) => state.calculator = new_state,
Err(err) => {
@@ -618,24 +604,16 @@ fn main() -> ! {
.take(calc.len())
{
seg.dp();
}
for (no, seg) in display.slice(0, DISPLAY_SEGMENTS).iter_mut().enumerate() {
seg.brightness(
(no * (Brightness::full().unwrap() as usize) / DISPLAY_SEGMENTS) as u8,
);
seg.brightness(Brightness::full());
}
}
TransientState::Err { .. } => display.error(),
}
let ((frame, index), frame_data) = avr_device::interrupt::free(|cs| {
avr_device::interrupt::free(|cs| {
access_global(&IO_LOOP, cs, |io_loop| {
io_loop.update_display(&display);
(io_loop.frame(), io_loop.frame_data())
})
});
if frame % 64 == 0 && index == frame_data_index {
ufmt::uwriteln!(&mut serial, "[{}, {}] {:?}", frame, index, frame_data).ok();
}
}
}

View File

@@ -43,13 +43,12 @@ impl SegmentTimer {
// Set for how long the segment LEDs should be on in μs
// Controls TIMER0_COMPB interrupt time after TIMER0_COMPA
pub fn segment_on_time(&mut self, segment_on_us: u32) -> u8 {
pub fn segment_on_time(&mut self, segment_on_us: u32) {
let delay: u8 = us_to_ticks(segment_on_us)
.try_into()
.expect("timer init segment_on_us out of rage");
let elapsed = self.timer.tcnt0.read().bits();
// Set the compare value for B match
self.timer.ocr0b.write(|w| w.bits(elapsed + delay));
return elapsed;
}
}