@@ -31,14 +31,15 @@ namespace modm
3131// / @brief Relative motion since the last read
3232struct adns9800 ::Data
3333{
34+ using Span = std::span<uint8_t , 6 >;
35+
3436 const modm::Vector<DeltaType, 2 > delta;
3537
3638protected:
37- static constexpr size_t length = 6 ;
38- Data (std::span<uint8_t , length> buffer)
39+ Data (Span data)
3940 : delta{
40- static_cast <DeltaType>(buffer [3 ] << 8 | buffer [2 ]),
41- static_cast <DeltaType>(buffer [5 ] << 8 | buffer [4 ])
41+ static_cast <DeltaType>(data [3 ] << 8 | data [2 ]),
42+ static_cast <DeltaType>(data [5 ] << 8 | data [4 ])
4243 }
4344 {}
4445
@@ -54,11 +55,11 @@ struct adns9800::Data_Fails : public adns9800::Data
5455 const bool isRunningSROMCode : 1 ;
5556
5657protected:
57- Data_Fails (std::span< uint8_t , length> buffer )
58- : Data(buffer ),
59- LaserFaultDetected (buffer [0 ] & Bit6),
60- LaserPowerValid(buffer [0 ] & Bit5),
61- isRunningSROMCode(buffer [1 ] & Bit6)
58+ Data_Fails (Span data )
59+ : Data(data ),
60+ LaserFaultDetected (data [0 ] & Bit6),
61+ LaserPowerValid(data [0 ] & Bit5),
62+ isRunningSROMCode(data [1 ] & Bit6)
6263 {}
6364
6465 template <class , class >
@@ -68,6 +69,8 @@ struct adns9800::Data_Fails : public adns9800::Data
6869// / @brief Relative motion, laser fault detection flags and metrics from the shutter unit.
6970struct adns9800 ::Data_Fails_Monitoring : public adns9800::Data_Fails
7071{
72+ using Span = std::span<uint8_t , adns9800::Data_Fails::Span::extent + 8 >;
73+
7174 struct Statistics
7275 {
7376 /* *
@@ -83,12 +86,12 @@ struct adns9800::Data_Fails_Monitoring : public adns9800::Data_Fails
8386 // frame
8487 const uint8_t pixel_sum;
8588 // Minium and maximum Pixel value in current frame. Range: 0 to 127.
86- const uint8_t max_pixel;
87- const uint8_t min_pixel;
89+ const Color max_pixel;
90+ const Color min_pixel;
8891 } statistics;
8992
90- uint8_t
91- getAveragePixelValue () const
93+ Color
94+ getAveragePixel () const
9295 {
9396 return statistics.pixel_sum << 9 / FrameSize;
9497 }
@@ -113,18 +116,17 @@ struct adns9800::Data_Fails_Monitoring : public adns9800::Data_Fails
113116 };
114117
115118protected:
116- static constexpr size_t length = 14 ;
117- Data_Fails_Monitoring (std::span<uint8_t , length> buffer)
118- : Data_Fails(buffer.subspan<0 , Data_Fails::length>()),
119+ Data_Fails_Monitoring (Span data)
120+ : Data_Fails(data.subspan<0 , Data_Fails::Span::extent>()),
119121 statistics{
120- surface_quality : buffer [6 ],
121- pixel_sum : buffer [7 ],
122- max_pixel : buffer [8 ],
123- min_pixel : buffer [9 ]
122+ surface_quality : data [6 ],
123+ pixel_sum : data [7 ],
124+ max_pixel : data [8 ],
125+ min_pixel : data [9 ]
124126 },
125127 shutter{
126- exposure : static_cast <PeriodType>(buffer [10 ] << 8 | buffer [11 ]),
127- period : static_cast <PeriodType>(buffer [12 ] << 8 | buffer [13 ])
128+ exposure : static_cast <PeriodType>(data [10 ] << 8 | data [11 ]),
129+ period : static_cast <PeriodType>(data [12 ] << 8 | data [13 ])
128130 }
129131 {}
130132
0 commit comments