Browse Source

AP_Notify: scale NCP5623 for for data range

we were overflowing the RGB max of 0x1f, leading to LED being off at
high power
zr-v5.1
Andrew Tridgell 4 years ago
parent
commit
5a7e870cfb
  1. 2
      libraries/AP_Notify/NCP5623.cpp

2
libraries/AP_Notify/NCP5623.cpp

@ -45,6 +45,8 @@ NCP5623::NCP5623(uint8_t bus) @@ -45,6 +45,8 @@ NCP5623::NCP5623(uint8_t bus)
bool NCP5623::write(uint8_t reg, uint8_t data)
{
uint8_t msg[1] = { 0x00 };
// scale to 0 to 0x1F
data = (data * 255U) / 0x1FU;
msg[0] = ((reg & 0xe0) | (data & 0x1f));
bool ret = _dev->transfer(msg, 1, nullptr, 0);
return ret;

Loading…
Cancel
Save