File tree Expand file tree Collapse file tree
app/firmware/src/io/i2c/peripherals
sensor_apds9960/instance/impl
sensor_vl53l4cx/instance/impl Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66#pragma once
77
88#include < array>
9+ #include < cstddef>
910#include < cstdint>
1011
1112namespace opendeck ::firmware::io::i2c::sensor_apds9960
@@ -73,6 +74,9 @@ namespace opendeck::firmware::io::i2c::sensor_apds9960
7374 constexpr inline uint8_t APDS9960_CONTROL_LED_DRIVE_SHIFT = 6 ;
7475 constexpr inline uint8_t APDS9960_CONTROL_PROXIMITY_GAIN_SHIFT = 2 ;
7576
77+ constexpr inline int64_t APDS9960_UPDATE_INTERVAL_MS = 30 ;
78+ constexpr inline size_t APDS9960_LIGHT_DATA_SIZE = 8 ;
79+
7680 constexpr inline uint8_t APDS9960_DEFAULT_ATIME = 246 ;
7781 constexpr inline uint8_t APDS9960_DEFAULT_WTIME = 246 ;
7882 constexpr inline uint8_t APDS9960_DEFAULT_PPULSE = 0x87 ;
Original file line number Diff line number Diff line change @@ -26,8 +26,6 @@ Mapper::Result Mapper::proximity_result(uint8_t value) const
2626
2727Mapper::Result Mapper::ambient_light_result (uint16_t value) const
2828{
29- const auto info = read_database_info ();
30-
3129 return {
3230 .osc = {
3331 .payload = opendeck::firmware::signaling::OscSensorAmbientLightSignal{
@@ -40,8 +38,6 @@ Mapper::Result Mapper::ambient_light_result(uint16_t value) const
4038
4139Mapper::Result Mapper::rgb_result (uint16_t red, uint16_t green, uint16_t blue) const
4240{
43- const auto info = read_database_info ();
44-
4541 return {
4642 .osc = {
4743 .payload = opendeck::firmware::signaling::OscSensorRgbSignal{
Original file line number Diff line number Diff line change @@ -174,7 +174,7 @@ constexpr std::string_view SensorApds9960::name() const
174174
175175int64_t SensorApds9960::update_interval_ms ()
176176{
177- return 30 ;
177+ return APDS9960_UPDATE_INTERVAL_MS ;
178178}
179179
180180std::span<const uint8_t > SensorApds9960::i2c_addresses () const
@@ -258,17 +258,17 @@ bool SensorApds9960::read_ambient_light_and_rgb(uint8_t status)
258258 return true ;
259259 }
260260
261- std::array<uint8_t , 8 > light = {};
261+ std::array<uint8_t , APDS9960_LIGHT_DATA_SIZE > light = {};
262262
263263 if (!read_register_block (APDS9960_REGISTER_CDATAL , std::span<uint8_t >(light)))
264264 {
265265 return recoverable_i2c_read_failure ();
266266 }
267267
268- const auto ambient_light = sys_get_le16 (& light[ 0 ] );
269- const auto red = sys_get_le16 (& light[ 2 ] );
270- const auto green = sys_get_le16 (& light[ 4 ] );
271- const auto blue = sys_get_le16 (& light[ 6 ] );
268+ const auto ambient_light = sys_get_le16 (light. data () );
269+ const auto red = sys_get_le16 (light. data () + 2 );
270+ const auto green = sys_get_le16 (light. data () + 4 );
271+ const auto blue = sys_get_le16 (light. data () + 6 );
272272
273273 if (ambient_light_enabled &&
274274 _ambient_light_filter.update ({ ambient_light },
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ namespace
2525 constexpr uint32_t RESPONSE_FAST_TIMING_BUDGET_US = 33333 ;
2626 constexpr uint32_t RESPONSE_BALANCED_TIMING_BUDGET_US = 66000 ;
2727 constexpr uint32_t RESPONSE_STABLE_TIMING_BUDGET_US = 100000 ;
28+ constexpr uint32_t MICROSECONDS_PER_MILLISECOND = 1000 ;
2829 constexpr int32_t SOFT_RESET_DELAY_MS = 100 ;
2930 constexpr uint8_t SOFT_RESET_ASSERTED = 0x00 ;
3031 constexpr uint8_t SOFT_RESET_RELEASED = 0x01 ;
@@ -59,7 +60,7 @@ namespace
5960
6061 const auto timing_budget_us = response_timing_budget_us (response);
6162
62- return static_cast <int64_t >((timing_budget_us + SCAN_MARGIN ) / 1000 );
63+ return static_cast <int64_t >((timing_budget_us + SCAN_MARGIN ) / MICROSECONDS_PER_MILLISECOND );
6364 }
6465
6566 constexpr VL53L4CX_DistanceModes driver_distance_mode (DistanceMode mode)
You can’t perform that action at this time.
0 commit comments