Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom 6-Digit Display TM1637 #43

Open
jasonacox opened this issue Dec 9, 2024 · 0 comments
Open

Custom 6-Digit Display TM1637 #43

jasonacox opened this issue Dec 9, 2024 · 0 comments

Comments

@jasonacox
Copy link
Owner

Request from email related to supporting a custom built 6 digit display:

While searching for a library to handle 6 DIGIs, I came across your TM1637TinyDisplay driver library – amazing work, by the way!

I’ve connected 6 seven-segment LEDs to the TM1637, arranged from left to right on GRID1 to GRID6.

For testing, I’m using the following commands:
display.showNumber(123456);
or
display.showNumberDec(123456);

However, the display shows “321654.”

I’m not very experienced in this field
In the TM1637TinyDisplay6.cpp file, I found the following:
const uint8_t digitmap[] = { 2, 1, 0, 5, 4, 3 };

Changing it to:
const uint8_t digitmap[] = { 0, 1, 2, 3, 4, 5 };
makes the display show “543216.”

I’ve tried various combinations without success:
// Digit sequence map for 6 digit displays
const uint8_t digitmap[] = { 2, 1, 0, 5, 4, 3 }; // 321654
// const uint8_t digitmap[] = { 0, 1, 2, 3, 4, 5 }; // 543216
// const uint8_t digitmap[] = { 2, 4, 5, 1, 0, 3 }; //
// const uint8_t digitmap[] = { 3, 5, 1, 2, 4, 0 }; // 654321
// const uint8_t digitmap[] = { 0, 4, 2, 1, 5, 3 }; // 321654
// const uint8_t digitmap[] = { 2, 4, 0, 3, 5, 1 }; // 165432

I suspect there might also be something else in the code that needs adjusting.

Could you please guide me on what I need to change to ensure the DIGIs are addressed in the correct order? GRID1 should correspond to DIGI 1 (left), and GRID6 to DIGI 6 (right).

For the 6 digit displays you buy from Amazon and AliExpress, the digits are not sequential (requires a map) and the 7-segment LED data must be uploaded in reverse order:

Digit 1 - GRID3
Digit 2 - GRID2
Digit 3 - GRID1
Digit 4 - GRID6
Digit 5 - GRID5
Digit 6 - GRID4

The default TM1637TinyDisplay code is set to work with that. If you want to change the code to make it work with a more logical wiring:

// original
const uint8_t digitmap[] = { 0, 1, 2, 3, 4, 5 }; 

You may need to update this function to handle the start command:

void TM1637TinyDisplay6::writeBuffer()
{
  uint8_t dot = 0;
  
  // Write COMM1
  start();
  writeByte(TM1637_I2C_COMM1);
  stop();

  // Write COMM2 + start with last digit address on 6-digit display
  start();
  writeByte(TM1637_I2C_COMM2 + (3 & 0x07)); // may need to change 3 to something else, e.g. 0-7

  // Write the data bytes
  if(m_flipDisplay) {
    for (uint8_t k=0; k < MAXDIGITS; k++) {
      dot = 0;
      if((k - 1) >= 0 ) {
        dot = digitsbuf[k - 1] & 0b10000000;
      }
      uint8_t orig = digitsbuf[k];
      uint8_t flip = ((orig >> 3) & 0b00000111) + 
        ((orig << 3) & 0b00111000) + (orig & 0b01000000) + dot;
      writeByte(flip);
    } 
  }
  else {
    for (uint8_t k=0; k < MAXDIGITS; k++) {
      // 6 digit display - send in reverse order
      writeByte(digitsbuf[MAXDIGITS - 1 - k]); 
    }
  }
  stop();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant