Skip to content

Commit

Permalink
fix(server): check soft_power_off mode and flag in `read_soft_powerof…
Browse files Browse the repository at this point in the history
…f_flag`
  • Loading branch information
fengyc committed Sep 5, 2022
1 parent 699fbb5 commit d072d32
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pisugar-core/src/pisugar3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ impl PiSugar3 {

pub fn read_soft_poweroff_flag(&self) -> Result<bool> {
let ctr2 = self.read_crt2()?;
Ok((ctr2 & 0b0000_1000) != 0)
// soft poweroff, bit4 and bit3 must be 1 at the same time
Ok((ctr2 & 0b0001_1000) == 0b0001_1000)
}

pub fn clear_soft_poweroff_flag(&self) -> Result<()> {
Expand Down

0 comments on commit d072d32

Please sign in to comment.