This MakeCode program for the Circuit Playground Express (CPX) shows how to control an Adafruit 4-digit 7-segment display using I2C bus statements. Comments in the program give details, and a related question follows.
I used a Digilent Electronics Explorer board and its Waveforms software Protocol Analyzer to look at CPX I2C bus traffic. I found that these CPX Arduino statements produce the given I2C bus traffic.
dsp7seg.begin(0x70); // default Adafruit 7-seg display I2C address
// Start, hE0 [ h70 | WR ], Stop
// Start, hE0 [ h70 | WR ], h21, Stop
// Start, hE0 [ h70 | WR ], h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, Stop
// Start, hE0 [ h70 | WR ], h81, Stop
// Start, hE0 [ h70 | WR ], hEF, Stop
dsp7seg.println(“0123”);
// no I2C output yet
dsp7seg.writeDisplay();
// Start, hE0 [ h70 | WR ], h00, h3F, h00, h06, h00, h00, h00, h5B, h00, h4F, h00, h00, h00, h00, h00, h00, h00, Stop
The Holtek HT16K33 datasheet (“Command Summary” on page 30) shows what that I2C bus traffic means to the LED display Backpack board. “h21” = System Setup, Oscillator On. “h00” = Display Data Address Pointer (h00) followed by 16 bytes of 0 data. “h81” = Display Setup, Blinking Off, Display On. “hEF” = Dimming Set, 16/16 Duty Cycle. “writeDisplay()” shows where h3F (7-segment ‘0’) h06 (‘1’) h00 (colon off) h5B (‘2’) h4F (‘3’) are positioned. The first “h00” and the “hEF” commands are not required to get the chip into operating condition.
The given MakeCode program produces this I2C bus traffic:
Error!
Start, hE0 [ h70 | WR ], h21, Stop
Start, hE0 [ h70 | WR ], h81, Stop
Start, hE0 [ h70 | WR ], h00, h3F, Stop
Start, hE0 [ h70 | WR ], h02, h06, Stop
Start, hE0 [ h70 | WR ], h04, h00, Stop
Start, hE0 [ h70 | WR ], h06, h5B, Stop
Start, hE0 [ h70 | WR ], h08, h4F, Stop
What is the initial “Error!” and how do I eliminate it using only Adafruit MakeCode statements (not JavaScript)?
I think there is no way to do the equivalent of the Arduino “Start, hE0 [ h70 | WR ], Stop” I2C operation and that this is a required but missing Adafruit MakeCode statement. But someone correct me if that is wrong.