chore: reorganize source organization to a more modern style
This commit is contained in:
parent
21cb610d31
commit
0425836642
12 changed files with 16 additions and 10 deletions
24
aht.c
24
aht.c
|
|
@ -1,24 +0,0 @@
|
|||
#include "inc/aht.h"
|
||||
|
||||
#include "hardware/i2c.h"
|
||||
#include "pico/stdlib.h" // IWYU pragma: keep
|
||||
|
||||
static const uint8_t AHT_MEASURE[3] = {0xAC, 0x33, 0x00};
|
||||
|
||||
void getAHTData(i2c_inst_t *i2c, double *t, double *h) {
|
||||
uint8_t result[6];
|
||||
uint32_t temperature;
|
||||
uint32_t humidity;
|
||||
|
||||
i2c_write_blocking(i2c, AHT_ADDR, AHT_MEASURE, 3,
|
||||
false); // trigger measurement
|
||||
// now we must delay ~100ms
|
||||
sleep_ms(100);
|
||||
i2c_read_blocking(i2c, AHT_ADDR, result, 6,
|
||||
false); // read 6 bytes back
|
||||
humidity = (result[1] << 12) | (result[2] << 4) | (result[3] & 0xF0) >> 4;
|
||||
temperature = (result[3] & 0x0F) << 16 | (result[4] << 8) | result[5];
|
||||
*t = (((double)temperature / 1048576.0f) * 200.0f) - 50.0f;
|
||||
*h = ((double)humidity / 1048576.0f) * 100.0f;
|
||||
return;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue