X-Git-Url: http://git.code-monkey.de/?p=gps-watch.git;a=blobdiff_plain;f=src%2Fcommon%2Fdisplay.rs;h=04f6c354d776b36d20ed4df8b3ee597c21277e73;hp=4f09ef5f95a346f4e8438abd03ab4398670c791c;hb=a1fc8859c0fd557c5f9049e77d1c39fed791a042;hpb=f33681815491184edca121e8005de0281aa611ac diff --git a/src/common/display.rs b/src/common/display.rs index 4f09ef5..04f6c35 100644 --- a/src/common/display.rs +++ b/src/common/display.rs @@ -32,6 +32,14 @@ pub struct Display { i2c_slave_address: u8, } +pub enum Icon { + SatelliteBody, + SatelliteWave1, + SatelliteWave2, + Heart, + Alarm, +} + fn delay(u: u32) { let mut r = u; @@ -73,6 +81,8 @@ fn delay2(u: u32) { } } +const ICON_COLUMN: usize = 8; + impl Display { pub fn new(reset_gpio: u32, reset_gpio_pin: u32, i2c_slave_address: u8) -> Display { Display { @@ -114,6 +124,30 @@ impl Display { } } + fn icon_row(&self, icon: Icon) -> usize { + match icon { + Icon::SatelliteBody => 31, + Icon::SatelliteWave1 => 29, + Icon::SatelliteWave2 => 27, + Icon::Heart => 45, + Icon::Alarm => 61, + } + } + + pub fn show_icon(&mut self, icon: Icon) { + let row = self.icon_row(icon); + + self.seek(row, ICON_COLUMN); + self.write_data(0x80); + } + + pub fn hide_icon(&mut self, icon: Icon) { + let row = self.icon_row(icon); + + self.seek(row, ICON_COLUMN); + self.write_data(0x00); + } + pub fn clear(&mut self) { self.seek(0, 0);