1 #ifndef TLC59116_Unmanaged_h
2 #define TLC59116_Unmanaged_h
64 #ifndef TLC59116_LOWLEVEL
65 #define TLC59116_LOWLEVEL 0
72 #define TLC59116_DEV 1
74 #define TLC59116_DEV 0
79 #ifndef TLC59116_WARNINGS
81 #define TLC59116_WARNINGS 1
83 #define TLC59116_WARNINGS 0
89 template <
typename T>
void inline TLC59116Warn(
const T msg) {Serial.print(msg);}
90 template <
typename T>
void inline TLC59116Warn(T msg,
int format) {
92 Serial.print(F(
"0b"));
93 for(byte i=0; i < (
sizeof(msg) * 8); i++) {
94 Serial.print( (msg & ((T)1 << (
sizeof(msg) * 8 - 1))) ?
"1" :
"0");
99 if (format == HEX) Serial.print(F(
"0x"));
100 Serial.print(msg, format);
105 template <
typename T>
void inline TLC59116Warn(
const T msg,
int format=0) {}
115 template <
typename T>
void inline TLC59116Dev(T msg,
int format) {}
119 #if TLC59116_LOWLEVEL
220 static void LEDx_set_mode(byte registers[] , byte to_what, word which);
240 static byte
i_out(byte CM, byte HC, byte CC,
int Rext=
Rext_Min);
242 return i_out( iref_value >> 7 & 1, iref_value >> 6 & 1, iref_value &
IREF_CC_mask, Rext );
268 byte to_change = mask & new_bits;
269 byte unchanged = ~mask & was;
270 byte new_value = unchanged | to_change;
280 for(byte i=0;i<6;i++) D |= ((CC>>i) & 0b1)<<(5-i);
309 void control_register(byte count,
const byte *register_num,
const byte data[]);
319 bus.beginTransmission(addr);
320 bus.write(register_num);
323 static void _begin_trans(TwoWire& bus, byte addr, byte auto_mode, byte register_num) {
331 int stat = bus.endTransmission();
350 static void describe_iref(byte* registers);
351 static void describe_addresses(byte* registers);
352 static void describe_mode2(byte *registers);
353 static void describe_outputs(byte* registers);
354 static void describe_error_flag(byte* registers);
356 void update_ledx_registers(byte addr, byte to_what, byte led_start_i, byte led_end_i);
357 void update_ledx_registers(byte addr,
const byte* want_ledx , byte led_start_i, byte led_end_i);
358 void update_ledx_registers(byte addr, byte to_what, word bit_pattern);
373 for(byte i=0; i<found; i++) {
static const byte MODE2_EFCLR
Definition: TLC59116_Unmanaged.h:185
static const byte LEDOUT_PWM
Definition: TLC59116_Unmanaged.h:194
static const byte Auto_PWM_GRP
Definition: TLC59116_Unmanaged.h:171
static byte SUBADRx_Register(byte i)
Definition: TLC59116_Unmanaged.h:228
static const byte MODE1_OSC_mask
Definition: TLC59116_Unmanaged.h:176
static byte LEDx_digital_on_bits(byte led_num)
Definition: TLC59116_Unmanaged.h:225
static const byte IREF_Register
Definition: TLC59116_Unmanaged.h:234
static void _begin_trans(TwoWire &bus, byte addr, byte register_num)
Definition: TLC59116_Unmanaged.h:317
static bool is_device_range_addr(byte address)
Definition: TLC59116_Unmanaged.h:155
static const byte Max_Addr
Definition: TLC59116_Unmanaged.h:154
static const byte MODE1_ALLCALL_mask
Definition: TLC59116_Unmanaged.h:182
void TLC59116Warn(const T msg, int format=0)
Definition: TLC59116_Unmanaged.h:105
static const byte Base_Addr
Definition: TLC59116_Unmanaged.h:144
static const byte LEDOUT_DigitalOff
Definition: TLC59116_Unmanaged.h:197
static const byte EFLAG1_Register
Definition: TLC59116_Unmanaged.h:245
static const byte IREF_CC_mask
Definition: TLC59116_Unmanaged.h:237
static const byte LEDOUT0_Register
Definition: TLC59116_Unmanaged.h:191
static byte LEDx_pwm_bits(byte led_num)
Definition: TLC59116_Unmanaged.h:222
TLC59116_Unmanaged & describe_actual()
Definition: TLC59116_Unmanaged.cpp:83
TLC59116_Unmanaged & operator=(const TLC59116_Unmanaged &)
static const byte MODE2_DMBLNK
Definition: TLC59116_Unmanaged.h:184
static const byte MODE1_SUB2_mask
Definition: TLC59116_Unmanaged.h:179
bool is_any()
Definition: TLC59116_Unmanaged.h:368
static const byte IREF_HC_mask
Definition: TLC59116_Unmanaged.h:236
static const byte LEDOUT_Mask
Definition: TLC59116_Unmanaged.h:193
void _begin_trans(byte register_num)
Definition: TLC59116_Unmanaged.h:312
void _begin_trans(byte auto_mode, byte register_num)
Definition: TLC59116_Unmanaged.h:313
static const byte MODE2_Register
Definition: TLC59116_Unmanaged.h:183
static byte PWMx_Register(byte led_num)
Definition: TLC59116_Unmanaged.h:188
static const byte SUBADR1
Definition: TLC59116_Unmanaged.h:147
byte shadow_registers[Control_Register_Max+1]
Definition: TLC59116_Unmanaged.h:340
static const byte Control_Register_Max
Definition: TLC59116_Unmanaged.h:247
byte fetch_registers(byte start_r, byte count, byte registers[])
Definition: TLC59116_Unmanaged.cpp:58
byte first_addr()
Definition: TLC59116_Unmanaged.h:371
static byte normalize_address(byte address)
Definition: TLC59116_Unmanaged.h:257
static void _begin_trans(TwoWire &bus, byte addr, byte auto_mode, byte register_num)
Definition: TLC59116_Unmanaged.h:323
static byte set_with_mask(byte was, byte mask, byte new_bits)
Definition: TLC59116_Unmanaged.h:267
static const byte Channels
Definition: TLC59116_Unmanaged.h:139
static const byte MODE1_Register
Definition: TLC59116_Unmanaged.h:175
static const byte MODE1_SUB3_mask
Definition: TLC59116_Unmanaged.h:180
const byte * device_addresses()
Definition: TLC59116_Unmanaged.h:370
static byte LEDx_gpwm_bits(byte led_num)
Definition: TLC59116_Unmanaged.h:223
static const char * Device
Definition: TLC59116_Unmanaged.h:252
static const byte Reset_Addr
Definition: TLC59116_Unmanaged.h:149
static const byte GRPFREQ_Register
Definition: TLC59116_Unmanaged.h:190
static byte LEDx_Register_bits(byte led_num, byte register_value)
Definition: TLC59116_Unmanaged.h:211
static const byte IREF_CM_mask
Definition: TLC59116_Unmanaged.h:235
static const byte SUBADR3
Definition: TLC59116_Unmanaged.h:152
void TLC59116Dev(const T msg)
Definition: TLC59116_Unmanaged.h:114
static void describe_registers(byte *registers)
Definition: TLC59116_Unmanaged.cpp:98
static void set_with_mask(byte *was, byte mask, byte new_bits)
Definition: TLC59116_Unmanaged.h:273
static const byte GRPPWM_Register
Definition: TLC59116_Unmanaged.h:189
static const byte LEDOUT_GRPPWM
Definition: TLC59116_Unmanaged.h:195
static Scan & scanner()
Definition: TLC59116_Unmanaged.h:365
static const byte PWM0_Register
Definition: TLC59116_Unmanaged.h:187
static void describe_group_mode(byte *registers)
Definition: TLC59116_Unmanaged.cpp:228
static const int Rext_Min
Definition: TLC59116_Unmanaged.h:238
Definition: TLC59116_Unmanaged.h:133
static byte best_iref(byte ma, int Rext=Rext_Min)
Definition: TLC59116_Unmanaged.cpp:156
static const byte AllCall_Addr_Register
Definition: TLC59116_Unmanaged.h:233
static const byte MODE1_SUB1_mask
Definition: TLC59116_Unmanaged.h:178
static const byte EFLAG2_Register
Definition: TLC59116_Unmanaged.h:246
static const byte LEDOUT_DigitalOn
Definition: TLC59116_Unmanaged.h:196
Definition: TLC59116_Unmanaged.h:403
static byte LEDx_to_Register_bits(byte led_num, byte out_mode)
Definition: TLC59116_Unmanaged.h:215
void TLC59116LowLevel(T msg)
Definition: TLC59116_Unmanaged.h:124
int _end_trans()
Definition: TLC59116_Unmanaged.h:327
TwoWire & i2cbus
Definition: TLC59116_Unmanaged.h:285
static bool is_default_SUBADR(byte address)
Definition: TLC59116_Unmanaged.h:158
static byte LEDx_Register_mask(byte led_num)
Definition: TLC59116_Unmanaged.h:207
bool is_SUBADR_bit(byte mode1_value, byte which)
Definition: TLC59116_Unmanaged.h:181
void get_control_registers(byte count, const byte *register_num, byte data[])
TLC59116_Unmanaged(TwoWire &bus, byte address)
Definition: TLC59116_Unmanaged.h:290
static void LEDOUTx_CHECK(int line, byte led_num)
Definition: TLC59116_Unmanaged.h:200
static const byte AllCall_Addr
Definition: TLC59116_Unmanaged.h:146
~TLC59116_Unmanaged()
Definition: TLC59116_Unmanaged.h:293
static byte i_out_d(byte CM, byte HC, byte D, int Rext=Rext_Min)
Definition: TLC59116_Unmanaged.cpp:151
static const byte LEDOUTx_Max
Definition: TLC59116_Unmanaged.h:192
static byte LEDx_set_mode(byte was, byte led_num, byte mode)
Definition: TLC59116_Unmanaged.h:216
static byte LEDOUTx_Register(byte led_num)
Definition: TLC59116_Unmanaged.h:198
Definition: TLC59116_Unmanaged.h:361
byte address()
Definition: TLC59116_Unmanaged.h:303
static const byte SUBADR2
Definition: TLC59116_Unmanaged.h:148
static const byte Auto_All
Definition: TLC59116_Unmanaged.h:168
static bool is_control_register(byte register_num)
Definition: TLC59116_Unmanaged.h:248
bool is_OSC_bit(byte mode1_value)
Definition: TLC59116_Unmanaged.h:177
static const byte MODE2_OCH
Definition: TLC59116_Unmanaged.h:186
bool is_AllCall_default()
static bool is_default_single_addr(byte address)
Definition: TLC59116_Unmanaged.h:161
static const byte Auto_PWM
Definition: TLC59116_Unmanaged.h:169
static byte i_out(byte CM, byte HC, byte CC, int Rext=Rext_Min)
Definition: TLC59116_Unmanaged.cpp:145
static const byte Auto_GRP
Definition: TLC59116_Unmanaged.h:170
byte control_register(byte register_num)
static const byte SUBADR1_Register
Definition: TLC59116_Unmanaged.h:227
static byte is_valid_led(byte v)
Definition: TLC59116_Unmanaged.h:199
static byte reverse_cc(byte CC)
Definition: TLC59116_Unmanaged.h:277
static const byte Control_Register_Min
Definition: TLC59116_Unmanaged.h:174
static int _end_trans(TwoWire &bus)
Definition: TLC59116_Unmanaged.h:329
static byte LEDx_digital_off_bits(byte led_num)
Definition: TLC59116_Unmanaged.h:224
static Scan & scan(void)
Definition: TLC59116_Unmanaged.h:399
byte count()
Definition: TLC59116_Unmanaged.h:369
static const word Reset_Bytes
Definition: TLC59116_Unmanaged.h:151
static byte i_out(byte iref_value, int Rext=Rext_Min)
Definition: TLC59116_Unmanaged.h:241