1 #include <marnav/seatalk/message_89.hpp>
9 message_89::message_89()
15 std::unique_ptr
<message
> message_89::parse(const raw
& data
)
17 check_size(data
, SIZE
);
19 std::unique_ptr
<message
> result
= utils::make_unique
<message_89
>();
20 message_89
& msg
= static_cast<message_89
&>(*result
);
26 t
+= 90.0 * ((data
[1] & 0x30) >> 4);
27 t
+= 2.0 * (data
[2] & 0x3f);
28 t
+= 0.5 * ((data
[1] & 0xc0) >> 6);
30 msg
.value_
= std::fmod(t
, 360.0);
35 raw
message_89::get_data() const
37 uint8_t u
= static_cast<uint8_t>(std::floor(value_
/ 90.0)) & 0x03;
38 uint8_t vw
= static_cast<uint8_t>(std::floor((value_
- (90.0 * u
)) / 2.0));
39 u
+= static_cast<uint8_t>(std::floor(std::fmod(value_
, 2.0) * 2.0)) << 2;
41 return raw
{static_cast<uint8_t>(ID
), static_cast<uint8_t>(0x02 | (u
<< 4)), vw
, 0x00, 0x20};
44 /// Sets the heading, this value will be truncated to the interval `[0.0 .. 359.5]`,
45 /// in steps of `0.5` degrees.
47 /// @param[in] t Heading in degrees, steps of `0.5`. The absolute value will be used.
48 void message_89::set_heading(double t
)
50 value_
= std::fmod(std::fabs(t
), 360.0);