diff options
author | Daniel Friesel <derf@finalrewind.org> | 2022-05-20 21:45:17 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2022-05-20 21:45:34 +0200 |
commit | f2e4095b8208521bef2f566237b36fe24b949a8a (patch) | |
tree | 17185799fe075615d37bf6ab8ed06f00a1598329 /src/driver/sen5x.cc | |
parent | 1cb46c9d6adbe4271314fddd765d49ce37681ca1 (diff) |
sen5x: add cleanfan and readstatus commands
Diffstat (limited to 'src/driver/sen5x.cc')
-rw-r--r-- | src/driver/sen5x.cc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/driver/sen5x.cc b/src/driver/sen5x.cc index 2a5d6b8..9edbcd0 100644 --- a/src/driver/sen5x.cc +++ b/src/driver/sen5x.cc @@ -11,6 +11,13 @@ #include "driver/soft_i2c.h" #endif +void SEN5x::cleanFan() +{ + txbuf[0] = 0x56; + txbuf[1] = 0x07; + i2c.xmit(address, 2, txbuf, 0, rxbuf); +} + void SEN5x::start() { txbuf[0] = 0x00; @@ -48,4 +55,26 @@ bool SEN5x::read() return true; } +bool SEN5x::readStatus() +{ + txbuf[0] = 0xd2; + txbuf[1] = 0x06; + if (i2c.xmit(address, 2, txbuf, 0, rxbuf)) { + return false; + } + arch.delay_ms(20); + if (i2c.xmit(address, 0, txbuf, 6, rxbuf)) { + return false; + } + + fan_speed_warning = rxbuf[1] & 0x20; + fan_cleaning_active = rxbuf[1] & 0x08; + gas_sensor_error = rxbuf[4] & 0x80; + rht_sensor_error = rxbuf[4] & 0x40; + laser_failure = rxbuf[4] & 0x20; + fan_failure = rxbuf[4] & 0x10; + + return true; +} + SEN5x sen5x; |