Skip to content

Commit

Permalink
fix: fixed CCS811
Browse files Browse the repository at this point in the history
  • Loading branch information
AsCress committed Aug 12, 2024
1 parent 91e8666 commit 622ae2d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/src/main/java/io/pslab/communication/sensors/CCS811.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,16 @@ public class CCS811 {
// Figure 25: CCS811 Bootloader Register Map
// Address Register R/W Size Description
private static final int HW_Version = 0x21;
private static final int APP_START = 0xF4;

public CCS811(I2C i2c, ScienceLab scienceLab) throws Exception {
this.i2c = i2c;
if (scienceLab.isConnected()) {
fetchID();
softwareReset();
appStart();
}
}

private void softwareReset() throws IOException {
i2c.write(ADDRESS, new int[]{0x11, 0xE5, 0x72, 0x8A}, SW_RESET);
}

private void fetchID() throws IOException, InterruptedException {
int hardwareId = i2c.read(ADDRESS, 1, HW_ID).get(0) & 0xFF;
Thread.sleep(20);
Expand All @@ -51,6 +48,10 @@ private void fetchID() throws IOException, InterruptedException {
Log.d("CCS811", "App Version: " + appVersion);
}

private void appStart() throws IOException {
i2c.write(ADDRESS, new int[]{}, APP_START);
}

private String decodeError(int error) {
String e = "";
if ((error & (1)) > 0) {
Expand Down

0 comments on commit 622ae2d

Please sign in to comment.