diff --git a/src/display.rs b/src/display.rs index 9ba3dc6..895accb 100644 --- a/src/display.rs +++ b/src/display.rs @@ -227,21 +227,7 @@ impl DispalyState { self.0 = seg; } - pub fn prompt(&mut self) { - self.set([ - SegmentState::Prompt(false), - SegmentState::Prompt(true), - SegmentState::Prompt(false), - SegmentState::Prompt(false), - SegmentState::Prompt(false), - SegmentState::Prompt(false), - SegmentState::Prompt(false), - SegmentState::Prompt(false), - SegmentState::Prompt(false), - ]) - } - - pub fn error(&mut self) { + pub fn empty(&mut self) { self.set([ SegmentState::Off, SegmentState::Dot, @@ -254,6 +240,28 @@ impl DispalyState { SegmentState::Off, ]) } + + pub fn prompt(&mut self, segment: usize) { + self[segment] = if segment == 1 { + SegmentState::Prompt(true) + } else { + SegmentState::Prompt(false) + }; + } + + pub fn error(&mut self) { + self.set([ + SegmentState::Minus, + SegmentState::Minus, + SegmentState::Minus, + SegmentState::Minus, + SegmentState::Minus, + SegmentState::Minus, + SegmentState::Minus, + SegmentState::Minus, + SegmentState::Minus, + ]) + } } // Show data on segment display diff --git a/src/main.rs b/src/main.rs index 42985fe..e9e95d9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -190,7 +190,12 @@ impl NumberInput { impl Show for NumberInput { fn show(&self, display: &mut DispalyState) { - display.prompt(); + display.empty(); + if !self.enter_exponent && self.significant_pos < DISPLAY_SEGMENTS_SIG { + display.prompt(self.significant_pos + 1); + } else if self.enter_exponent && self.exponent_pos < DISPLAY_SEGMENTS_EXP { + display.prompt(DISPLAY_SEGMENTS_SIG + 2 + self.exponent_pos); + } display[DISPLAY_SEGMENT_SIG_MINUS] = if self.minus { SegmentState::Minus } else {