Skip to content

Commit

Permalink
Fix missing pin states in clear() and all_on()
Browse files Browse the repository at this point in the history
  • Loading branch information
emeric-martineau committed Mar 23, 2024
1 parent 0385b54 commit a46ef90
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ keywords = ["embedded", "PCF8574", "PCF8575", "Esp32"]
license = "MIT"
readme = "README.md"
repository = "https://github.com/emeric-martineau/pcf857x-simple-rs"
version = "0.1.0"
version = "0.1.1"
edition = "2021"


Expand Down
8 changes: 6 additions & 2 deletions src/pcf8574.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ where

/// Turn off all pins
pub fn clear(&mut self) -> Result<(), <I as i2c::Write>::Error> {
self.i2c.write(self.address, &[0])
self.i2c.write(self.address, &[0])?;
self.pins_state = 0;
Ok(())
}

/// Turn on all pins
pub fn all_on(&mut self) -> Result<(), <I as i2c::Write>::Error> {
self.i2c.write(self.address, &[0xff])
self.i2c.write(self.address, &[0xff])?;
self.pins_state = 0xff;
Ok(())
}

/// Send two bytes
Expand Down
8 changes: 6 additions & 2 deletions src/pcf8575.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ where

/// Turn off all pins
pub fn clear(&mut self) -> Result<(), <I as i2c::Write>::Error> {
self.i2c.write(self.address, &[0, 0])
self.i2c.write(self.address, &[0, 0])?;
self.pins_state = 0;
Ok(())
}

/// Turn on all pins
pub fn all_on(&mut self) -> Result<(), <I as i2c::Write>::Error> {
self.i2c.write(self.address, &[0xff, 0xff])
self.i2c.write(self.address, &[0xff, 0xff])?;
self.pins_state = 0xffff;
Ok(())
}

/// Send two bytes
Expand Down

0 comments on commit a46ef90

Please sign in to comment.