I'll share all the information I can. Ask me anything you need and I'll try to help you. Thanks for looking into this!
This is the command-set of the chip. There are more commands available but aren't used. Some of those commands are also not used but can be deleted after the driver is implemented. There are also definitions for command and data sizes.
#define HT1632_CMD_SYSDIS 0x00 // CMD= 0000-0000-x Turn off oscil
#define HT1632_CMD_SYSON 0x01 // CMD= 0000-0001-x Enable system oscil
#define HT1632_CMD_LEDOFF 0x02 // CMD= 0000-0010-x LED duty cycle gen off
#define HT1632_CMD_LEDON 0x03 // CMD= 0000-0011-x LEDs ON
#define HT1632_CMD_BLOFF 0x08 // CMD= 0000-1000-x Blink OFF
#define HT1632_CMD_BLON 0x09 // CMD= 0000-1001-x Blink On
#define HT1632_CMD_SLVMD 0x10 // CMD= 0001-00xx-x Slave Mode
#define HT1632_CMD_MSTMD 0x14 // CMD= 0001-01xx-x Master Mode
#define HT1632_CMD_RCCLK 0x18 // CMD= 0001-10xx-x Use on-chip clock
#define HT1632_CMD_EXTCLK 0x1C // CMD= 0001-11xx-x Use external clock
#define HT1632_CMD_COMS00 0x20 // CMD= 0010-ABxx-x commons options
#define HT1632_CMD_COMS01 0x24 // CMD= 0010-ABxx-x commons options
#define HT1632_CMD_COMS10 0x28 // CMD= 0010-ABxx-x commons options
#define HT1632_CMD_COMS11 0x2C // P-MOS OUTPUT AND 16COMMON OPTION
#define HT1632_CMD_PWM 0xA0 // CMD= 101x-PPPP-x PWM duty cycle
#define HT1632_ID_LEN 3 // IDs are 3 bits
#define HT1632_CMD_LEN 8 // CMDs are 8 bits
#define HT1632_DATA_LEN 8 // Data are 4*2 bits
#define HT1632_ADDR_LEN 7 // Address are 7 bits
This is the initialization sequence for the chip.
writeDataMSB(3, HT1632_ID_CMD, false); // IDs are 3 bits
writeDataMSB(8, HT1632_CMD_SYSDIS, true); // 8 bits
writeDataMSB(8, HT1632_CMD_SYSON, true); // 8 bits
writeDataMSB(8, HT1632_CMD_COMS11, true); // 8 bits
writeDataMSB(8, HT1632_CMD_LEDON, true); // 8 bits
writeDataMSB(8, HT1632_CMD_BLOFF, true); // 8 bits
writeDataMSB(8, HT1632_CMD_PWM+15, true); // 8 bits
This function writes IDs and command data into the display:
void writeDataMSB(byte cnt, byte data, bool extra) {
for(int8_t i = cnt - 1; i >= 0; i--) {
if ((data >> i) & 1) {
PORT |= 1 << DATA;
}
else {
PORT &= ~(1 << DATA);
}
//_nop();
PORT &= ~(1 << WR);
//_nop();
PORT |= 1 << WR;
//_nop();
}
// Send an extra bit
if (extra) {
PORT |= 1 << DATA;
//_nop();
PORT &= ~(1 << WR);
//_nop();
PORT |= 1 << WR;
}
}
This function writes pixel data onto the display (after the appropriate command has been set):
void write_data(byte cnt, byte data) {
for (byte i = 0; i < cnt; i++) {
if ((data >> i) & 1) {
PORT |= 1 << DATA;
}
else {
PORT &= ~(1 << DATA);
}
PORT &= ~(1 << WR);
PORT |= 1 << WR;
}
}
PORT is the AVR port. DATA is the data pin and WR is the clock pin. Those should be changed to be set by u8glib I guess.
This code is used to write pixel data from a framebuffer:
selectDisplay(dispNum); // selects the display
writeDataMSB(3, HT1632_ID_WR); // Send "write to display" command
writeDataMSB(7, 0); // Send initial address (aka 0)
// Operating in progressive addressing mode
for (uint8_t addr = 0; addr < FB_SIZE; addr++) { // FB_SIZE is 48 bytes
value = framebuffer[addr];
writeDataLSB(8, value);
}
releaseDisplay(dispNum);
I hope that helps!