1use crate::common::{u16_get_u8_high, u16_get_u8_low, u8_high_low_get_u16, Index, MESSAGE_LENGTH};
2
3pub fn get(response: [u8; MESSAGE_LENGTH]) -> u16 {
4 let voltage_value_mv_by10 = u8_high_low_get_u16(response[3], response[4]);
5
6 voltage_value_mv_by10 * 10
7}
8
9pub fn set(voltage_mv: u16, message: &mut [u8; MESSAGE_LENGTH]) {
10 let command_voltage_value_mv_by10 = voltage_mv / 10;
11
12 message[Index::SetValueHigh as usize] = u16_get_u8_high(command_voltage_value_mv_by10);
13 message[Index::SetValueLow as usize] = u16_get_u8_low(command_voltage_value_mv_by10);
14}
15
16#[cfg(test)]
17#[path = "./test_voltage.rs"]
18mod test_voltage;