Pico Display and Fonts

Thanks for the suggestion.

Yes, I’m fond of the old teletype style of printing, but the option is a great idea, so I have added it in.
You can now choose display.update() on printchar(), delchar(), and printstring()

printstring now has two extra args (charupdate, strupdate), to say whether you want a slow tty style update, or a fast string update.
If you like, you can set them both to False, print all your strings, then call a display.update() manually. Useful if you want to do a page of text fast

I have added it into src/picofonts1.1.py with credit in the comments and an addendum in the readme.

Cheers!

Les

Awesome! Glad you find it useful. There is an updated version 1.1 in src now, following a suggestion below.
Cheers!

Les

Hi,
I’ve just watched the Video from Les Wright on the fonts (great video) and I’ve created an application in Visual basic that can be used to generate the binary string similar to that in the excel macro.

It is a first off attempt at the moment but if anyone is interested I could post a link to it here.

Phil

1 Like

I’m finding these post very useful.
Yes, please post your link.

This is the first time I’ve done this outside a corporate network so not sure if it works, here is a link to a zip file in my onedrive, download the zip file extract it and run setup.exe.

Let me know any issues you find or if there are enhancements you want and I’ll see what I can do.

Phil

Nobody interested in trying it?

I downloaded it but am unsure how to run it. I used Visual Basic 20+ years ago but no longer in my current PC.

Please give me a hint

Just extract the files then run the setup.exe and it should just install as a program.

Windows 10 did not want me to install it!
Once I’d installed .NET runtime I got it working. Very nice. I’m sure it will be useful. Thanks

Yes installing untrusted/unsigned apps can be a bit difficult, glad it’s useful let me know if there are any improvements you can think of.

Hi Les. Great code, Thanks!
I’d like to suggest or ask if it is possible to rewrite this part below to easily support more sizes. I mean to draw a rectangle sized “size"X"size” such that you support 1x1, 2x2, 3x3, etc.
"
if bit == ‘1’:
display.pixel(xpos,ypos)
if size==2:
display.pixel(xpos,ypos+1)
display.pixel(xpos+1,ypos)
display.pixel(xpos+1,ypos+1)
"
something like: display.rectangle(xpos, ypos, size, size)…

Hi,
I’m using both, Tonygo2’s DisplayWorkout3.py and Les Wright’s picofonts stuff, with the enhancements from Steve Borg. In short: love it!!! So much more useful stuff for my applications I don’t need to re-invent - and I can read these fonts now!! :-).
But - there’s a but: I’m struggling with memory management issues when switching back and forth between .py codes created from above mentioned code. The pico seems to crash in Thonny when I switch from DisplayWorkout3 to picofonts, needing the pico to re-boot. Once that reboot is done, I can re-run the code as often as I like. Before the code crashes, I observed the display_buffer not being erased entirely by the clear() command. And - there is this strange 'display_buffer <could not serialize: memory allocation failed, allocating xxx bytes> error in the variables window of Thonny. This error ALWAYS seems to happen, even when the code runs nicely after a re-boot.
More details in screenshots attached.
Has anybody faced similar issues? Any clues?
Thanks, HMH (being new to the forum)
ahh - just learned I’m allowed only to share one screenshot at a time, being a newcomer :-(

Added some more modifications like:
charwidth = 5 * size
charheight = 9 * size
and
spacing = 2 + 6 * size
Now it works well with sizes 1,2,3,4,5,…
Big like for Les

Are you getting random pixels at the bottom of the screen?

I’ve had such a problem with large programs and multiply edits + test run. I think there may be a MicroPython problem here as I’ve been getting bottom of the display corruption with another screen as well, WaveShare Pico LCD 1.8" Display.

All that code in the Pico - you probably need a Pico Lipo - large size! Have fun

I got this issue of corrupted display buffer as well. I worked around this problem by enlarging the display buffer by additional 10 rows (height()+10)

Low space 7 segment like characters for the Explorer or Display.
Updated version

# 7 segment LED characters on Explorer
# 12 July 2021 - Tony Goodhew -Vers 2
import picoexplorer as display
import utime, random
from machine import Pin
width = display.get_width()
height = display.get_height()
display_buffer = bytearray(width * height * 2)
display.init(display_buffer)

def blk():
    display.set_pen(0,0,0)
    display.clear()
    display.update()

# One row per digit/character
nums =[1,1,1,1,1,1,0,  # 0  
       0,1,1,0,0,0,0,  # 1
       1,1,0,1,1,0,1,  # 2
       1,1,1,1,0,0,1,  # 3
       0,1,1,0,0,1,1,  # 4
       1,0,1,1,0,1,1,  # 5
       1,0,1,1,1,1,1,  # 6
       1,1,1,0,0,0,0,  # 7
       1,1,1,1,1,1,1,  # 8
       1,1,1,0,0,1,1,  # 9
       0,0,0,0,0,0,1,  # -
       0,0,0,0,0,0,0]  # Blank

def seg7(xx,yy,n,f):
    # (x, y, number, size-factor)
    p = n * 7
    display.set_pen(0,0,0) # Background colour
    if (nums[p+0] == 0):display.rectangle(xx+1*f,yy+0*f,3*f,1*f)
    if (nums[p+1] == 0):display.rectangle(xx+4*f,yy+1*f,1*f,3*f)
    if (nums[p+2] == 0):display.rectangle(xx+4*f,yy+5*f,1*f,3*f)
    if (nums[p+3] == 0):display.rectangle(xx+1*f,yy+8*f,3*f,1*f)
    if (nums[p+4] == 0):display.rectangle(xx+0*f,yy+5*f,1*f,3*f)
    if (nums[p+5] == 0):display.rectangle(xx+0*f,yy+1*f,1*f,3*f)
    if (nums[p+6] == 0):display.rectangle(xx+1*f,yy+4*f,3*f,1*f)
    display.set_pen(200,200,0) # LED colour
    if (nums[p+0] == 1):display.rectangle(xx+1*f,yy+0*f,3*f,1*f)
    if (nums[p+1] == 1):display.rectangle(xx+4*f,yy+1*f,1*f,3*f)
    if (nums[p+2] == 1):display.rectangle(xx+4*f,yy+5*f,1*f,3*f)
    if (nums[p+3] == 1):display.rectangle(xx+1*f,yy+8*f,3*f,1*f)
    if (nums[p+4] == 1):display.rectangle(xx+0*f,yy+5*f,1*f,3*f)
    if (nums[p+5] == 1):display.rectangle(xx+0*f,yy+1*f,1*f,3*f)
    if (nums[p+6] == 1):display.rectangle(xx+1*f,yy+4*f,3*f,1*f)
    display.update()

x0 = 6
y0 = 10
for f in range(1,14):
    x1 = x0 + (14-f) *5
    y1 = y0 + (14-f) *7
    blk()
    display.set_pen(255,100,0)
    display.text("7-Seg LED", 35, 187, 200, 4)
    display.set_pen(190,190,190)
    display.text("Size: "+str(f), 80, 160, 200, 3)
    display.set_pen(0,0,170)
    display.text("Tony Goodhew", 23, 220, 240, 3)  
    display.update()
    for c in range(10):
        nn = random.randint(0,999)
        hnds = int(nn/100)
        nn = nn - (hnds * 100)
        tens = int(nn / 10)
        units = nn - (tens * 10)
        seg7(x1,y1,hnds,f)
        seg7(x1 + f*6,y1,tens,f)
        seg7(x1 + f*12,y1,units,f)
        display.update()
        utime.sleep(0.3)

Yes, it’s random pixels - literally! Depends on what code (using bytearray()) I ran before :-). Many things point to a RP2040 MicroPython implementation issue, in my opinion. Memory assignment works well as long as the bytearray() object size is below 15 bits. You can try this by typing a = bytearray(0x7fff) in the REPL. Thonny’s variable window shows memory assignment being successful. Then type b = bytearray(0x1) and you will see memory assignment fail. MicroPython tries to be gentle and is allocating a random number of bytes. If you are lucky, it’s more than you need and you don’t get these random pixels.

I tried the same with other MicroPython implementations such as the TI-Nspire CXII Python calculator and Thonny’s Python 3.7.9 interpreter and I don’t see the issue there.

This is getting to be a real problem. It has been know about for some time (see the RaspPi Pico forums) but as yet little prospect of a cure.
While editing the, quite short, 7-seg chars program above Thonny kept losing connection to the Pico. I find this very annoying.

I’ve had so many issues with Thonny losing connection and ctrl-C and the Stop button having no effect and having to resort to using the nuke program quite often just to get my Pico working again that I’ve given up on microPython altogether. Coding is harder in C++ but at least the environment behaves itself.

Captain Resetti is my best friend :-). This cute little board from Pimoroni does its job. Haven’t had to nuke my Picos so far. In wise anticipation, Pimoroni spent a reset button on their Tiny2040. And a USB-C connector. These don’t wear out so quickly.

By the way, Tony, I like the 7-seg chars program a lot! These remind me of my 1978 TM990/189 University board, which had half of a calculator (keyboard & 7-seg display) to enter TM990 assembler code, later Basic. That board still is working.