The M5StickC is an ideal development tool for various projects. The ESP32 enables almost universal application possibilities and with the 160x80 RGB pixel display the M5StickC can also be used for graphically complex applications.
But sometimes only a simple text output is needed. Similar to a terminal, where the text scrolls up with every new line.
Generally the display driver supports scrolling in hardware, but I haven't found a solution to scroll text with the driver in landscape orientation. So I programmed a simple text buffer and corresponding drawing functions to display the buffer on the display.
To use the text buffer display, it only needs to be included in the project:
#include "tb_display.h"
Then it can be initialized with the desired orientation:
// init the text buffer display and print welcome text on the display
tb_display_init(screen_orientation);
Display orientationThe value for the orientation can be seen in this image:
Two functions are available to output either single characters or a whole string. Here is an example for the output of a single character received via the serial interface:
// check for serial input and print the received characters
while(Serial.available() > 0){
char data = Serial.read();
tb_display_print_char(data);
Serial.write(data);
}
And here for the output of a string:
tb_display_print_String(" M5StickC\n\n Textbuffer Display\n\n");
Update #1:Version 1.1 allows an additional (optional) parameter for the print string function. The optional parameter "chr_delay" allows a "character by character" processing of the String. Then, it looks like Teletype or Typewriter. The delay is in milliseconds. Thanks to LeRoy Miller for the idea.
// with 85ms Character delay, the display looks more
// like Teletype or a typewriter
tb_display_print_String("The quick brown fox jumps over the lazy dog and was surprised that he used all letters of the alphabet.", 85);
QWERTY keyboard HATTogether with the keyboard HAT you have a simple way to enter and display texts or values.
Nao (n602) constructed a very nice frame for the keyboard HAT. With this frame the keyboard can be used much better and is optically enhanced. Check it out on thingiverse.
These can be, for example, access data to an access point, or login data. Or notes that come to mind at the breakfast table.
Update:The library now supports the M5StickC and the M5StickCPlus.
// Choose the type of M5Stick here:
// #define M5STICKC
#define M5STICKCPLUS
FeedbackI hope this code can prove to be useful to the wider community. Feel free to message me here if you have questions or comments.
Enjoy!
Regards,
Hans-Günther
Comments