pack method
pack() should produce a message data payload that can be parsed by a corresponding parser in the frameside application (Lua) The 0x01 (raw user data marker) byte and the msgCode byte are prepended to each bluetooth write() call by the Frame BLE sendDataRaw() method, followed by the maximum amount of payload data that will fit until the whole message is sent.
Implementation
@override
Uint8List pack() {
// several doubles in the range 0 to 1, so map that to an unsigned byte 0..255
// by multiplying by 255 and rounding
int intExp = (_exposure * 255).round() & 0xFF;
int intExpSpeed = (_exposureSpeed * 255).round() & 0xFF;
int intWhiteBalanceSpeed = (_whiteBalanceSpeed * 255).round() & 0xFF;
// shutter limit has a range 4..16384 so just map it to a Uint16 over 2 bytes
int intShutLimMsb = (_shutterLimit >> 8) & 0xFF;
int intShutLimLsb = _shutterLimit & 0xFF;
// RGB gain limit has a range 0..1023 so just map it to a Uint16 over 2 bytes
int intRgbGainLimMsb = (_rgbGainLimit >> 8) & 0xFF;
int intRgbGainLimLsb = _rgbGainLimit & 0xFF;
// 9 bytes of auto exposure settings. sendMessage will prepend the data byte & msgCode to each packet
// and the Uint16 payload length to the first packet
return Uint8List.fromList([
_meteringIndex & 0xFF,
intExp,
intExpSpeed,
intShutLimMsb,
intShutLimLsb,
_analogGainLimit & 0xFF,
intWhiteBalanceSpeed,
intRgbGainLimMsb,
intRgbGainLimLsb,
]);
}