@@ -31,14 +31,15 @@ namespace modm
31
31
// / @brief Relative motion since the last read
32
32
struct adns9800 ::Data
33
33
{
34
+ using Span = std::span<uint8_t , 6 >;
35
+
34
36
const modm::Vector<DeltaType, 2 > delta;
35
37
36
38
protected:
37
- static constexpr size_t length = 6 ;
38
- Data (std::span<uint8_t , length> buffer)
39
+ Data (Span data)
39
40
: 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 ])
42
43
}
43
44
{}
44
45
@@ -54,11 +55,11 @@ struct adns9800::Data_Fails : public adns9800::Data
54
55
const bool isRunningSROMCode : 1 ;
55
56
56
57
protected:
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)
62
63
{}
63
64
64
65
template <class , class >
@@ -68,6 +69,8 @@ struct adns9800::Data_Fails : public adns9800::Data
68
69
// / @brief Relative motion, laser fault detection flags and metrics from the shutter unit.
69
70
struct adns9800 ::Data_Fails_Monitoring : public adns9800::Data_Fails
70
71
{
72
+ using Span = std::span<uint8_t , adns9800::Data_Fails::Span::extent + 8 >;
73
+
71
74
struct Statistics
72
75
{
73
76
/* *
@@ -83,12 +86,12 @@ struct adns9800::Data_Fails_Monitoring : public adns9800::Data_Fails
83
86
// frame
84
87
const uint8_t pixel_sum;
85
88
// 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;
88
91
} statistics;
89
92
90
- uint8_t
91
- getAveragePixelValue () const
93
+ Color
94
+ getAveragePixel () const
92
95
{
93
96
return statistics.pixel_sum << 9 / FrameSize;
94
97
}
@@ -113,18 +116,17 @@ struct adns9800::Data_Fails_Monitoring : public adns9800::Data_Fails
113
116
};
114
117
115
118
protected:
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>()),
119
121
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 ]
124
126
},
125
127
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 ])
128
130
}
129
131
{}
130
132
0 commit comments