Skip to content

Commit 26a5aa4

Browse files
committed
Some rebase tweaks
1 parent b42e820 commit 26a5aa4

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

src/mode/terminal.rs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ where
124124
DI: DisplayInterface,
125125
{
126126
/// Clear the display and reset the cursor to the top left corner
127-
pub fn clear(&mut self) -> Result<(), ()> {
127+
pub fn clear(&mut self) -> Result<(), DI::Error> {
128128
let display_size = self.properties.get_size();
129129

130130
let numchars = match display_size {
@@ -151,16 +151,20 @@ where
151151
}
152152

153153
/// Reset display
154-
pub fn reset<RST, DELAY>(&mut self, rst: &mut RST, delay: &mut DELAY)
155-
where
156-
RST: OutputPin,
157-
DELAY: DelayMs<u8>,
154+
pub fn reset<RST, DELAY, PinE>(
155+
&mut self,
156+
rst: &mut RST,
157+
delay: &mut DELAY,
158+
) -> Result<(), Error<(), PinE>>
159+
where
160+
RST: OutputPin<Error = PinE>,
161+
DELAY: DelayMs<u8>,
158162
{
159-
rst.set_high();
163+
rst.set_high().map_err(Error::Pin)?;
160164
delay.delay_ms(1);
161-
rst.set_low();
165+
rst.set_low().map_err(Error::Pin)?;
162166
delay.delay_ms(10);
163-
rst.set_high();
167+
rst.set_high().map_err(Error::Pin)
164168
}
165169

166170
/// Write out data to display. This is a noop in terminal mode.
@@ -169,7 +173,7 @@ where
169173
}
170174

171175
/// Print a character to the display
172-
pub fn print_char(&mut self, c: char) -> Result<(), ()> {
176+
pub fn print_char(&mut self, c: char) -> Result<(), DI::Error> {
173177
match c {
174178
'\n' => {
175179
let CursorWrapEvent(new_line) = self.ensure_cursor()?.advance_line();
@@ -195,18 +199,24 @@ where
195199
/// Initialise the display in page mode (i.e. a byte walks down a column of 8 pixels) with
196200
/// column 0 on the left and column _(display_width - 1)_ on the right, but no automatic line
197201
/// wrapping.
198-
pub fn init(&mut self) -> Result<(), ()> {
202+
pub fn init(&mut self) -> Result<(), DI::Error> {
199203
self.properties.init_with_mode(AddrMode::Page)?;
200204
self.reset_pos()?;
201205
Ok(())
202206
}
203207

204208
/// Set the display rotation
205-
pub fn set_rotation(&mut self, rot: DisplayRotation) -> Result<(), ()> {
209+
pub fn set_rotation(&mut self, rot: DisplayRotation) -> Result<(), DI::Error> {
206210
// we don't need to touch the cursor because rotating 90º or 270º currently just flips
207211
self.properties.set_rotation(rot)
208212
}
209213

214+
/// Turn the display on or off. The display can be drawn to and retains all
215+
/// of its memory even while off.
216+
pub fn display_on(&mut self, on: bool) -> Result<(), DI::Error> {
217+
self.properties.display_on(on)
218+
}
219+
210220
/// Get the current cursor position, in character coordinates.
211221
/// This is the (column, row) that the next character will be written to.
212222
pub fn get_position(&self) -> Result<(u8, u8), ()> {

src/properties.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ where
9999
/// Set the column address in the framebuffer of the display where any sent data should be
100100
/// drawn.
101101
/// Only works in Page addressing mode.
102-
pub fn set_column(&mut self, column: u8) -> Result<(), DI::Error> {
102+
pub fn set_column(&mut self, column: u8) -> Result<(), ()> {
103103
match self.addr_mode {
104104
AddrMode::Page => Command::ColStart(column).send(&mut self.iface),
105-
_ => Err(()), // TODO
105+
_ => Err(()),
106106
}
107107
}
108108

@@ -111,10 +111,10 @@ where
111111
/// Note that the parameter is in pixels, but the page will be set to the start of the 8px
112112
/// row which contains the passed-in row.
113113
/// Only works in Page addressing mode.
114-
pub fn set_row(&mut self, row: u8) -> Result<(), DI::Error> {
114+
pub fn set_row(&mut self, row: u8) -> Result<(), ()> {
115115
match self.addr_mode {
116116
AddrMode::Page => Command::PageStart(row.into()).send(&mut self.iface),
117-
_ => Err(()), // TODO
117+
_ => Err(()),
118118
}
119119
}
120120

@@ -189,11 +189,12 @@ where
189189
}
190190
};
191191

192-
Ok(())
192+
Ok(())
193193
}
194194

195195
/// Turn the display on or off. The display can be drawn to and retains all
196196
/// of its memory even while off.
197197
pub fn display_on(&mut self, on: bool) -> Result<(), DI::Error> {
198198
Command::DisplayOn(on).send(&mut self.iface)
199+
}
199200
}

0 commit comments

Comments
 (0)