avishorp / TM1637

Arduino library for TM1637 (LED Driver)
GNU Lesser General Public License v3.0
427 stars 218 forks source link

Added showString() to display text #66

Closed jasonacox closed 4 years ago

jasonacox commented 4 years ago

This PR adds an ASCII character to 7-segment LED map and a showString() function to allow sending strings of ASCII text to the display. For strings longer than the display (4 characters) the function will scroll the string using default scrollDelay value or param.

void showString(char s[], unsigned int scrollDelay = 200, 
                 uint8_t length = 4, uint8_t pos = 0);

uint8_t TM1637Display::encodeASCII(uint8_t chr);

The following is also added to the TM1637Test.ino test sketch:

  // String tests
  display.clear();
  display.showString("String Test 1234");
  delay(TEST_DELAY);
  display.clear();
  display.showString("25\xB0\C");
  delay(TEST_DELAY);
  display.clear();
  display.showString("abcdefghijklmnopqrstuvwxyz.-=ABCDEFGHIJKLMNOPQRSTUVWXYZ");
  delay(TEST_DELAY);
  display.clear();
  display.showString("The");
  delay(TEST_DELAY);
  display.clear();
  display.showString("End");
  delay(TEST_DELAY);
avishorp commented 4 years ago

Thanks for the effort, but I don't think a 4-digit 7-Segment display is the appropriate device for showing arbitrary text messages, so I'm not going to pull this PR.

jasonacox commented 4 years ago

I respect that. Thanks for the consideration. I have a need to display strings as well as sequence patterns and animations for indicators on this incredibly tiny and simple display. I know that sounds crazy. I'll create a new library based on your great work and extend and share it just in case there are other crazies like me (https://github.com/jasonacox/TM1637TinyDisplay). Thanks for your excellent library!

filipopo commented 4 years ago

It seems like I've opened another PR for this when there were not one but two people who made similar requests 🥴. You're not the only crazy person but you're crazier than me, I only have letters whereas you have punctuation and sings and I'm also making my own library but from scratch🥴

jasonacox commented 4 years ago

Ha! Thanks @Filip98 I'll check our your library. If you want to be crazier, feel free to use my 7-segment animator tool to build your own symbols/characters or animation sequences: https://jasonacox.github.io/TM1637TinyDisplay/examples/7-segment-animator.html. :-)

filipopo commented 4 years ago

There isn't anything special to check out yet as it was in my mini-projects repo but I guess I'll put it up as it's own repository even tho it's currently WIP and not optimized(I'm using a bool matrix for bit representations and my code blew up when I switched to a uint8_t or short array) https://github.com/Filip98/7sd Nice, it can be seen it's in heavy development so some things don't look exactly as I think they should but this thing is great