diff options
| author | Michele Bini <michele.bini@gmail.com> | 2022-04-10 12:23:54 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2022-04-10 12:23:54 (GMT) |
| commit | 01c53e32e7508381e64de20ee91feeb46adf8bea (patch) | |
| tree | 938715139494147403a42e3889ea283ced8e509c /src/drivers/Bma421.cpp | |
| parent | 107877a9f88534f6d37c1589c6c02c9dfda25409 (diff) | |
Watchface digital display: seconds and temperature
Diffstat (limited to 'src/drivers/Bma421.cpp')
| -rw-r--r-- | src/drivers/Bma421.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/drivers/Bma421.cpp b/src/drivers/Bma421.cpp index 2f60f42..c5d55cc 100644 --- a/src/drivers/Bma421.cpp +++ b/src/drivers/Bma421.cpp @@ -102,9 +102,7 @@ Bma421::Values Bma421::Process() { uint32_t steps = 0; bma423_step_counter_output(&steps, &bma); - int32_t temperature; - bma4_get_temperature(&temperature, BMA4_DEG, &bma); - temperature = temperature / 1000; + RefreshTemperature(); uint8_t activity = 0; bma423_activity_output(&activity, &bma); @@ -112,6 +110,19 @@ Bma421::Values Bma421::Process() { // X and Y axis are swapped because of the way the sensor is mounted in the PineTime return {steps, data.y, data.x, data.z}; } + +void Bma421::RefreshTemperature() { + // uint8_t temperature_last_read_value; + // uint8_t temperature_last_result; + // uint8_t temperature_read_counter; + uint8_t data[BMA4_TEMP_DATA_SIZE] = { 0 }; + temperature_last_result = bma4_read_regs(BMA4_TEMPERATURE_ADDR, data, BMA4_TEMP_DATA_SIZE, &bma); + if (temperature_last_result == BMA4_OK) { + temperature_last_read_value = data[BMA4_TEMP_BYTE]; + temperature_read_counter++; + } +} + bool Bma421::IsOk() const { return isOk; } |
