pigpio's i2cWriteBlockData cf. i2cset -y 1 ... i
Posted: Sun Apr 26, 2015 8:33 pm
I have a couple of I2C "display" devices that require a "block of data" to be sent to a dummy register (which is actually a "command code") :
http://www.cpmspectrepi.webspace.virgin ... ackpack_V2
http://www.cpmspectrepi.webspace.virgin ... SSD1306.29
Whilst this can be easily (but somewhat slowly for the second device) achieved via (a 'C' system call to) i2cset such as in this example (diagnostic output from my program):
where 0x01 is the dummy register of the display backpack equivalent to the "print string" command,
if I attempt to use pigpio's "i2cWriteBlockData" function thus (similar diagnostics):
an extra byte appears to be inserted after the register/command code, resulting in an extra "graphics block-like" character before the wanted display string ("CL1 LCM1602 #1" in the above example).
Is this to be expected? Would I be better off using pigpio's "i2cWriteDevice" function instead? (How?). Or can anyone suggest another 'C' I2C library/method that provides equivalent behaviour to i2cset (wiringPi doesn't)?
Note: It's not that much of an issue for the backpack as there is a workaround via it's "write a single character" command - the major problem lies with the OLED display as the SSD1306 controller has commands (dummy registers) requiring up to 7 bytes of parameter data, all preceded by a command/data mode selection byte (ie. it's really a SPI device operating in an I2C "fashion").
Trev.
http://www.cpmspectrepi.webspace.virgin ... ackpack_V2
http://www.cpmspectrepi.webspace.virgin ... SSD1306.29
Whilst this can be easily (but somewhat slowly for the second device) achieved via (a 'C' system call to) i2cset such as in this example (diagnostic output from my program):
Code: Select all
i2cset -y 1 0x3a 0x01 0x43 0x4c 0x31 0x20 0x4c 0x43 0x4d 0x31 0x36 0x30 0x32 0x20 0x23 0x31 i
if I attempt to use pigpio's "i2cWriteBlockData" function thus (similar diagnostics):
Code: Select all
i2cWriteBlockData: handle=0 i2cReg=0x01 count=14...
... buf=0x43 0x4c 0x31 0x20 0x4c 0x43 0x4d 0x31 0x36 0x30 0x32 0x20 0x23 0x31
Is this to be expected? Would I be better off using pigpio's "i2cWriteDevice" function instead? (How?). Or can anyone suggest another 'C' I2C library/method that provides equivalent behaviour to i2cset (wiringPi doesn't)?
Note: It's not that much of an issue for the backpack as there is a workaround via it's "write a single character" command - the major problem lies with the OLED display as the SSD1306 controller has commands (dummy registers) requiring up to 7 bytes of parameter data, all preceded by a command/data mode selection byte (ie. it's really a SPI device operating in an I2C "fashion").
Trev.