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

7 segment display - 6 digits #1

Closed
davidginn524 opened this issue Dec 6, 2020 · 9 comments
Closed

7 segment display - 6 digits #1

davidginn524 opened this issue Dec 6, 2020 · 9 comments

Comments

@davidginn524
Copy link
Contributor

hello. I have used one of your examples in your source and I have problems with the display. Everything is hooked up
When I do a write to the display it will display it wrong. For example I have a 6 digit 7 segment display
when I do a display.display((int32_t)123456); After flashing it will display 321654.
if I do a display of display.display((int32_t)321654); After flashing it will display 123456
same with anything I put in, doesn't have to be just digits
This is the display I have, clearly they have wired it up differently than what you're library is expecting
https://www.aliexpress.com/item/4001286892567.html?spm=a2g0o.productlist.0.0.6c88d123AoF4eu&algo_pvid=308db7c9-2fcd-4e33-bf3c-d85a9a2e4365&algo_expid=308db7c9-2fcd-4e33-bf3c-d85a9a2e4365-7&btsid=2100bdd516072143080114867e3c5d&ws_ab_test=searchweb0_0,searchweb201602_,searchweb201603_

What I was going to do is go into yoru library and rearrange the way it outputs the digits as I did that on another tm1637 library. However this one is soooo much more complicated that I don't know where to start.
I would like to use this library because it supports everything I need, strings, digits, "-" and "." some only support digits or strings with no "." or "-"

@smdn
Copy link
Owner

smdn commented Dec 6, 2020

Thank you for using my library and reporting issue.

Rearranging output digits is not supported currently.
To rearrange output digits, you have to rearrange the array m_segmentBits[0..5] in the class TM1637_7SegmentLEDCustomSegmentAddressingController.

The modified code will be like below. (not tested with actual display modules)

  if (NUM_OF_GRIDS_FOR_USE <= grid)
    return; // out of range

  //m_segmentBits[grid] = segmentBits; /* current code. we have to change this. */

  // rearrange specified 'grid' to actual display's one
  unsigned int rearrangedGrid = 0

  switch (grid) {
    case 0: rearrangedGrid = 2; // 1 -> 3
    case 1: rearrangedGrid = 1; // 2 -> 2
    case 2: rearrangedGrid = 0; // 3 -> 1
    case 3: rearrangedGrid = 5; // 4 -> 6
    case 4: rearrangedGrid = 4; // 5 -> 5
    case 5: rearrangedGrid = 3; // 6 -> 4
  }

  m_segmentBits[rearrangedGrid] = segmentBits; // set data bits to display's digit

The codes that will need to be fixed are here.

m_segmentBits[grid] = 0b00000000;

m_segmentBits[grid] &= TSegmentAddressing::SEGMENTBITS_MASK_DECIMALPOINT;

m_segmentBits[grid] &= TSegmentAddressing::SEGMENTBITS_MASK_CHARACTER;

m_segmentBits[grid] = segmentBits;

m_segmentBits[grid] |= segmentBits;

m_segmentBits[grid] &= ~segmentBits;

m_segmentBits[digit] = segmentBits;

setSegmentBitsAt(digit, (m_segmentBits[digit] & TSegmentAddressing::SEGMENTBITS_MASK_DECIMALPOINT) | TSegmentAddressing::CHARS_HEXADECIMALS[decimalNumber], flush);

setSegmentBitsAt(digit, (m_segmentBits[digit] & TSegmentAddressing::SEGMENTBITS_MASK_DECIMALPOINT) | TSegmentAddressing::CHARS_HEXADECIMALS[hexadecimalNumber], flush);

m_segmentBits[grid] = segmentBits[grid];

I thing it is required feature to rearrange output digit, so I would like to add some functions to do that.

@davidginn524
Copy link
Contributor Author

Thanks for the fast reply! I will try and give this a go modifying your library :) Will report back hopefully in a few days to see if I got it working or not :)

@smdn
Copy link
Owner

smdn commented Dec 8, 2020

Added modification for rearranging output digits. (see #2)
Would you please try this?
With this modification, you can rearrange output digits like below.

/* current code */
auto display = TM1637_7SegmentLEDController<6>(
  PIN_DIO,
  PIN_CLK
);

/* modified code */
auto display = TM1637_7SegmentLEDController<6>(
  PIN_DIO,
  PIN_CLK,
  {2, 1, 0, 5, 4, 3} // <-- specify display module's digit order here
);

If there's no problems, I will merge this to main branch and release it.

@davidginn524
Copy link
Contributor Author

hot dang! that was so quick. I was still trying to merge your example. Thanks I will try this right now.

@davidginn524
Copy link
Contributor Author

Just tried it with your basic example in example folders and it worked perfectly. Can now rearrange with ease and displays the correct output of what is to be expected in the example. You can merge it.

One last question is there a way to display a degree symbol?
Example - https://upload.wikimedia.org/wikipedia/commons/thumb/e/ed/7_Segment_Display_with_Labeled_Segments.svg/1024px-7_Segment_Display_with_Labeled_Segments.svg.png
To display a degree symbol it would have to light up - ABGF - from the linked picture.

@smdn
Copy link
Owner

smdn commented Dec 8, 2020

Thank you for fast reporting!
I will be going to merge #2 after adding some documents and examples for this modification.

I was still trying to merge your example.

Sorry for wasting your work😥

is there a way to display a degree symbol?

You can do it like this.

// sets numbers and 'F' sign of ℉
display.displayNumericalString("12.34 F", false);
//                                   ^- place holder for degree sign
//
// ('false' means write to internal buffer only, does not light up immediately)

// sets degree sign of ℉ on 5th digit and light them up
display.setSegmentBitsAt(4, 0b01100011);
//                            /|||||||
//         bit for segment: DP GFEDCBA
//         0: light off   1: light on

// Then display shows like "12.34°F"

@davidginn524
Copy link
Contributor Author

ahh yes I missed that. I was going to guess you had a manual segment call somewhere. Thanks. Stay awesome 👍

@smdn
Copy link
Owner

smdn commented Dec 9, 2020

I found regression in PR #2. So it takes some more times to fix it and release. Sorry😣

@smdn
Copy link
Owner

smdn commented Dec 10, 2020

Released v1.1.0, sorry to keep you waiting.
https://github.com/smdn/TM1637Controller/releases/tag/v1.1.0

Thank you for your reporting and helping!😄

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

2 participants