summaryrefslogtreecommitdiff
path: root/src/drivers/Hrs3300.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/Hrs3300.cpp')
-rw-r--r--src/drivers/Hrs3300.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/drivers/Hrs3300.cpp b/src/drivers/Hrs3300.cpp
index edb9e81d..ec620af2 100644
--- a/src/drivers/Hrs3300.cpp
+++ b/src/drivers/Hrs3300.cpp
@@ -4,9 +4,9 @@
C++ port Copyright (C) 2021 Jean-François Milants
*/
+#include "drivers/Hrs3300.h"
#include <algorithm>
#include <nrf_gpio.h>
-#include "Hrs3300.h"
#include <FreeRTOS.h>
#include <task.h>
@@ -36,8 +36,8 @@ void Hrs3300::Init() {
// HRS and ALS both in 16-bit mode
WriteRegister(static_cast<uint8_t>(Registers::Res), 0x88);
- // 64x gain
- WriteRegister(static_cast<uint8_t>(Registers::Hgain), 0x10);
+ // 8x gain, non default, reduced value for better readings
+ WriteRegister(static_cast<uint8_t>(Registers::Hgain), 0xc);
}
void Hrs3300::Enable() {
@@ -54,18 +54,18 @@ void Hrs3300::Disable() {
WriteRegister(static_cast<uint8_t>(Registers::Enable), value);
}
-uint16_t Hrs3300::ReadHrs() {
+uint32_t Hrs3300::ReadHrs() {
auto m = ReadRegister(static_cast<uint8_t>(Registers::C0DataM));
auto h = ReadRegister(static_cast<uint8_t>(Registers::C0DataH));
auto l = ReadRegister(static_cast<uint8_t>(Registers::C0dataL));
- return (m << 8) | ((h & 0x0f) << 4) | (l & 0x0f) | ((l & 0x30) << 12);
+ return ((l & 0x30) << 12) | (m << 8) | ((h & 0x0f) << 4) | (l & 0x0f);
}
-uint16_t Hrs3300::ReadAls() {
+uint32_t Hrs3300::ReadAls() {
auto m = ReadRegister(static_cast<uint8_t>(Registers::C1dataM));
auto h = ReadRegister(static_cast<uint8_t>(Registers::C1dataH));
auto l = ReadRegister(static_cast<uint8_t>(Registers::C1dataL));
- return (m << 3) | ((h & 0x3f) << 11) | (l & 0x07);
+ return ((h & 0x3f) << 11) | (m << 3) | (l & 0x07);
}
void Hrs3300::SetGain(uint8_t gain) {