So, I'm using someone else's great porting of a driver for the ADAFruit 16 channel PWM Driver, and I can set PWM output fine but now I'm looking to GET PWM's out of it, so I can check status without re-saving it in another variable (save ram, folks)
so, here is the code that saves the values:
public void setPWM(byte num, UInt16 on, UInt16 off)
{
write8((byte)(LED0_ON_L + 4 * num), (byte)on);
write8((byte)(LED0_ON_H + 4 * num), (byte)(on >> 8));
write8((byte)(LED0_OFF_L + 4 * num), (byte)off);
write8((byte)(LED0_OFF_H + 4 * num), (byte)(off >> 8));
}
write8 takes two arguments, the Address and the value.
I pass in the number of the PWM output (0->15) the value on (0->~4000) and value off (0->~4000) and it bitshifts and sets the the PWM timings (On low, on high, off low and off high). For the most part since i'm driving a light I just pass 0 as the on and something > 0 for off.
I'd like to be able to retrieve either on and off or just the off value I've passed in.
I've tried this:
int power= read8((byte)(LED0_OFF_L + 4 * num)); and it's accurate until it gets above 256.
I've tried this:
int power= read8((byte)(LED0_OFF_H + 4 * num));
power = power << 8;
and it's not accurate.
Any suggestions?
Thanks!