I’m trying to simplify the II transmission code on the Teletype.
At the moment there are 3 different ways to send an message over i2c. tele_ii, tele_ii_tx and tele_ii_tx_now.
tele_ii_tx and tele_ii_tx_now are identical, I think tele_ii_tx used to use the event queue and the i2c buffer. I’m going to delete tele_ii_tx_now as well as the i2c buffer code.
tele_ii is the original II sending function designed for use with the trilogy modules. It posts an event to the event queue which is then ultimately sent using the same i2c_master_tx function. I think it’s redundant to use the event queue to send II messages like this as we’re now moving to a situation where all code that sends i2c is run from the event queue already.
My plan is to update the one instance where tele_ii is used to instead use tele_ii_tx.
@tehn is this the correct way to send messages to Trilogy modules?
void op_simple_i2c(const void *data, scene_state_t *ss,
exec_state_t *es, command_state_t *cs) {
int16_t message = (intptr_t)data;
int16_t value = cs_pop(cs);
uint8_t address = message & 0xF0;
uint8_t message_type = message & 0xFF;
uint8_t buffer[3] = { message_type, value >> 8, value & 0xFF };
tele_ii_tx(address, buffer, 3);
}
where data will be a constant from ii.h, e.g.
#define WW_PRESET 0x11
#define WW_POS 0x12
#define WW_SYNC 0x13
My reading of a constant such as WW_PRESET, is that the first 4 bits define the address, but the entire value is the message. Only for Trilogy modules though. Right?
I should be able to test it by using the simulator to print the messages sent.