-
Notifications
You must be signed in to change notification settings - Fork 20
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
bug in flipdisplay with colon : #18
Comments
HI @stef-ladefense - thanks for opening this issue! The ProblemThe challenge we have with flipping the display is that the "colon" is hardwired to be set by the 2nd digit in "non-flip" orientation. The same happens for "decimal" displays where the digit to the left of the decimal is what sets that dot. For example: Non-Flip Display Flip Display Over The flip code in the library knows that the colon moves and shifts the setting, but it can only set values in the range of digits you give it (for minutes, you are telling it to limit the change to only length=2 spaces - digits index 0 and 1). If we go outside the length value, we would need to know the value in index 2 (my example = "1") to be able to toggle the colon bit. The Fix?The function that drives the setting of the segments and dots is TM1637TinyDisplay::setSegments() - If you have any suggestions on how we could adjust it to handle this situation, I would love help. For your particular use case, I would recommend making a slight change to your function that would work in both orientations, something like this: void ShowTime(uint8_t _mins, uint8_t _secs, bool _Colon, bool _zns) {
int output = _secs + (100 * _mins);
display.showNumberDec(output, 0b01000000 * _Colon, _zns);
} Alternatively, since there is only one "colon" the the display, you could cheat and force a colon set for all digits: void ShowTime(uint8_t _mins, uint8_t _secs, bool _Colon, bool _zns) {
display.showNumberDec(_mins, 0b11110000 * _Colon, _zns, 2, 0);
display.showNumberDec(_secs, 0b11110000 * _Colon, true, 2, 2);
} |
thank I need to think about how to send it |
Ah, yes, you are correct! Sorry about that. Here is a possible workaround, not elegant but works: void ShowTime3(uint8_t _mins, uint8_t _secs, bool _Colon, bool _zns) {
char output[MAXDIGITS+1];
if(_zns) sprintf(output, "%02d%02d", _mins, _secs);
else sprintf(output, "%2d%02d", _mins, _secs);
display.showString(output, 4, 0, 0b01000000 * _Colon);
} I'll see if there is something more we can do to setSegments() to make this more intuitive. |
The challenge is really caused by the approach of using direct address writes (position and length) to the display. If we were to use a intermediate memory buffer (e.g. digits[]) for manipulation of the display so that showNumber(), etc., calls just update the buffer and then always write the full buffer to the display, we would be able to control the decimal/colon flip. It is a bit of a rewrite but could be worth it. I doubt it would introduce much latency and could likely reduce some code. I'll run some tests. |
Hi @stef-ladefense - I created a test class (TM1637TinyDisplayB) using my buffer idea. It seems to work well but I plan to run more tests. It works with your original ShowTime() function. I would love your thoughts on this. #include <TM1637TinyDisplayB.h>
TM1637TinyDisplayB display(CLK, DIO);
void setup() {
display.setBrightness(BRIGHT_HIGH);
display.clear();
}
void ShowTime(uint8_t _mins, uint8_t _secs, bool _Colon, bool _zns) {
display.showNumberDec(_mins, 0b01000000 * _Colon, _zns, 2, 0);
display.showNumber(_secs, true, 2, 2);
}
void loop() {
display.flipDisplay(false);
display.showNumber(1234);
delay(5000);
display.flipDisplay(true); // with flip will render w/o redraw
delay(5000);
ShowTime(0, 5, true, false);
delay(5000);
ShowTime(0, 5, true, true);
delay(5000);
} |
i test your B |
question |
Thanks @stef-ladefense ! The tests all look good for me too so I'm going to fold it into TM1637TinyDisplay and TM1637TinyDisplay6 and release it to Arduino, along with your brightness update. For the string question, are you talking about sending a specific pattern not in the string dictionary? If so, you would use uint8_t data[] = { 0x03, 0x18, 0x0c, 0x21 };
display.setSegments(data) If you wanted a mix, you can use the position and length and position parameters: uint8_t data[] = { 0x2a, 0x00, 0x00, 0x00 };
display.showString("YES ");
display.setSegments(data, 1, 3); You can use this tool to get the codes for the pattern: https://jasonacox.github.io/TM1637TinyDisplay/examples/7-segment-animator.html |
yes I know that, but what bothers me is having to declare a data[] variable of 4 bytes to be able to use setSegments.
which allows me to write a byte of segments wherever I want |
Great suggestion! I'll add it. |
hi,
i use this for write time
void ShowTime(uint8_t _mins, uint8_t _secs, bool _Colon, bool _zns) {
display.showNumberDec(_mins, 0b01000000 * _Colon, _zns, 2, 0);
display.showNumber(_secs, true, 2, 2);
}
but with display.flipDisplay(true) not colon write ...
The text was updated successfully, but these errors were encountered: