remove debugging
This commit is contained in:
@@ -112,8 +112,8 @@ impl Segment {
|
|||||||
Segment(0, Brightness::full())
|
Segment(0, Brightness::full())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn brightness(&mut self, b: u8) -> &mut Self {
|
pub fn brightness(&mut self, b: Brightness) -> &mut Self {
|
||||||
self.1 = Brightness(b);
|
self.1 = b;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
28
src/main.rs
28
src/main.rs
@@ -85,8 +85,7 @@ unsafe fn TIMER0_COMPA() {
|
|||||||
access_global(&IO_LOOP, cs, |io_loop| {
|
access_global(&IO_LOOP, cs, |io_loop| {
|
||||||
access_global(&SEGMENT_TIMER, cs, |st| {
|
access_global(&SEGMENT_TIMER, cs, |st| {
|
||||||
let brightness = io_loop.display_on();
|
let brightness = io_loop.display_on();
|
||||||
let elapsed = st.segment_on_time(brightness.scale_brightness());
|
st.segment_on_time(brightness.scale_brightness());
|
||||||
io_loop.frame_data = Some((elapsed, brightness.unwrap()));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -116,7 +115,6 @@ pub struct IOLoop {
|
|||||||
keyboard: Keyboard,
|
keyboard: Keyboard,
|
||||||
readount: Option<KeyReadout>,
|
readount: Option<KeyReadout>,
|
||||||
debounce: Debounce,
|
debounce: Debounce,
|
||||||
frame_data: Option<(u8, u8)>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IOLoop {
|
impl IOLoop {
|
||||||
@@ -130,7 +128,6 @@ impl IOLoop {
|
|||||||
keyboard,
|
keyboard,
|
||||||
readount: None,
|
readount: None,
|
||||||
debounce: Default::default(),
|
debounce: Default::default(),
|
||||||
frame_data: None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,10 +182,6 @@ impl IOLoop {
|
|||||||
pub fn frame(&self) -> (u16, usize) {
|
pub fn frame(&self) -> (u16, usize) {
|
||||||
(self.frame, self.index)
|
(self.frame, self.index)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn frame_data(&self) -> Option<(u8, u8)> {
|
|
||||||
self.frame_data
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(uDebug)]
|
#[derive(uDebug)]
|
||||||
@@ -534,7 +527,6 @@ fn main() -> ! {
|
|||||||
let mut display = DispalyState::default();
|
let mut display = DispalyState::default();
|
||||||
number_input.show(&mut display);
|
number_input.show(&mut display);
|
||||||
|
|
||||||
let mut frame_data_index: usize = 0;
|
|
||||||
let mut calc = Calc::default();
|
let mut calc = Calc::default();
|
||||||
let mut state = State {
|
let mut state = State {
|
||||||
transient: TransientState::Done,
|
transient: TransientState::Done,
|
||||||
@@ -566,12 +558,6 @@ fn main() -> ! {
|
|||||||
state.calculator
|
state.calculator
|
||||||
)
|
)
|
||||||
.ok();
|
.ok();
|
||||||
match key {
|
|
||||||
KeyPress::Num(n) => {
|
|
||||||
frame_data_index = n as usize;
|
|
||||||
}
|
|
||||||
_ => (),
|
|
||||||
}
|
|
||||||
match state.calculator.on_key(key, &mut number_input, &mut calc) {
|
match state.calculator.on_key(key, &mut number_input, &mut calc) {
|
||||||
Ok(new_state) => state.calculator = new_state,
|
Ok(new_state) => state.calculator = new_state,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
@@ -618,24 +604,16 @@ fn main() -> ! {
|
|||||||
.take(calc.len())
|
.take(calc.len())
|
||||||
{
|
{
|
||||||
seg.dp();
|
seg.dp();
|
||||||
}
|
seg.brightness(Brightness::full());
|
||||||
for (no, seg) in display.slice(0, DISPLAY_SEGMENTS).iter_mut().enumerate() {
|
|
||||||
seg.brightness(
|
|
||||||
(no * (Brightness::full().unwrap() as usize) / DISPLAY_SEGMENTS) as u8,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TransientState::Err { .. } => display.error(),
|
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| {
|
access_global(&IO_LOOP, cs, |io_loop| {
|
||||||
io_loop.update_display(&display);
|
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,13 +43,12 @@ impl SegmentTimer {
|
|||||||
|
|
||||||
// Set for how long the segment LEDs should be on in μs
|
// Set for how long the segment LEDs should be on in μs
|
||||||
// Controls TIMER0_COMPB interrupt time after TIMER0_COMPA
|
// 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)
|
let delay: u8 = us_to_ticks(segment_on_us)
|
||||||
.try_into()
|
.try_into()
|
||||||
.expect("timer init segment_on_us out of rage");
|
.expect("timer init segment_on_us out of rage");
|
||||||
let elapsed = self.timer.tcnt0.read().bits();
|
let elapsed = self.timer.tcnt0.read().bits();
|
||||||
// Set the compare value for B match
|
// Set the compare value for B match
|
||||||
self.timer.ocr0b.write(|w| w.bits(elapsed + delay));
|
self.timer.ocr0b.write(|w| w.bits(elapsed + delay));
|
||||||
return elapsed;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user