Text Functions

A project log for Retro Alphanumeric LED Displays + Libraries

Exactly as the title says, these are a few retro led displays I've strung together to make 16x2 modules with some software I wrote

sjm4306sjm4306 06/09/2021 at 16:120 Comments

My plan is to make a wifi clock with the pdsp display I've designed, and have it also show the weather which it'll grab with the use of the openweather api. I wanted to explain a bit how my library handles text to be displayed. There's two types if text my library can display, static text that once written is permanently displayed until erased/overwritten and scrolling text (which obviously scrolls). The static text uses the function writeString which takes arguments x, y and str. X and Y are the coordinates where the first character in the string str will be written. In my 16x4 display example, x=0 y=0 would start the text at the very first character in the upper left corner of the display (indices start at zero, where 0<=x<=15 and 0<=y<=3). If the string is longer than 16 characters, the width of the display, the string will wrap around to the next line until the entire display is filled but will cut off the string after the last character in the lower right character.

For scrolling text, I've written the function scroll which takes the arguments line, pos and str. My implementation is pretty simple and could definitely be simplified more to require less user intervention but it's simple and it works so I'll leave it alone for now. Line tells the function which line you want to scroll, pos is the current scoll position, and str once again is the string to scroll. So for example:

String test="Now: Sunny 74, 3PM: Cloudy 68 ";

int t=0;





Here the string test will be displayed on the last row and will scroll at the rate defined in the delay (in milliseconds, decreasing number will speed up scrolling). It's necessary to check the position each iteration so that the nothing beyond the end of the string will be displayed (which would likely just spit out unintended junk characters out of bounds of the string). Scroll direction or even starting position could easily be changed by tweaking the t++ to decrement instead and the initialization value of t, respectively.

Finally I've implemented a control function to allow changing brightness/flashing functionality built into the led controller modules, a clear function to clear the entire display, and a UDC function (user defined character). Each led module can store up to 8 user defined 5x7 characters to allow custom icons or fonts. At any time the UDC function can change any of the eight udc characters. It take three arguments: addrUDC, chr, and c. This gets a little confusing but basically my 16x4 display is really made up of 8 led modules (where 0<=c<=7). So you have to tell the function which of those 8 modules you want to talk to. Then addrUDC will tell that module which of the 8 user defined characters you want to overwrite. Finally the character array chr contains the custom bitmap character you want displayed. After a UDC is defined and saved to one of the modules, then you can tell the module to display it, for example:

unsigned char custom[] = {0b01110,



The custom character array 'custom' represents the horizontal slices of the desired image (I wrote it out as binary so you can visually see the character, in this case it's the uppercase letter A).

The UDC function call takes that custom array and writes it to UDC0 of display 1.

The disp_write function then selects disp1 is module 1 where UDC0 and ChrRAM|7 tells it you want to display UDC0 at position 7. I'll admit it's a very convoluted way of doing things, but it works well enough once you understand it.