TinyCircuits Forum

TinyCircuits Products => Thumby => Topic started by: bkumanchik on October 15, 2021, 05:56:28 PM

Title: Font size
Post by: bkumanchik on October 15, 2021, 05:56:28 PM
Will there eventually be a smaller font? maybe a 4 x 5 (4 = 3 plus space)
Title: Re: Font size
Post by: Ben Rose on October 15, 2021, 07:16:43 PM
Hi- the answer for 'eventually' is definitely. We'd like 5x7 default, with maybe some smaller options. Right now we're testing out implementation in pure MicroPython, but it's pretty slow and we'll probably need to implement it within the firmware, so that will delay initial availability of it for testing etc- if anyone has input on that, let us know!

Thanks,
ben
Title: Re: Font size
Post by: acedent on October 16, 2021, 06:31:06 AM
@Ben - Have you looked at the arduboy2 lib for blitting fonts?
What is the bottleneck?
Title: Re: Font size
Post by: bkumanchik on October 16, 2021, 12:57:26 PM
Thanks for the answer!
Title: Re: Font size
Post by: Ben Rose on October 21, 2021, 01:11:32 PM
@acedent- I thought that would be a quick answer! I've been playing around with a bunch of stuff in MicroPython for the last day or two, and I think the answer is that blits with the built in FrameBuffer object are just a bit slow. It's extremely general purpose and can handle tons of use cases outside of our simple 1bpp need. The arduboy2 font section looks like a very reasonable C/C++ implementation for 1bpp, I've written(adapted?) similar stuff for TinyScreen etc. After a while, I was able to do something similar in a MicroPython Viper code block, and it actually runs faster than the built in stuff for this very specific need.. I'll see if I can get something far enough along for other people to take a look at.
Title: Re: Font size
Post by: CoolieCoolster on October 21, 2021, 01:33:01 PM
I'll have to see if I can adapt it for use with text rather than just numbers, but here's a set of functions someone wrote for me to let me use 3x5 number sprites rather than regular text for keeping score:

# Prints numbers to scoreboard
def PrintNumber(number,totalDigits,x,y):
    scoreString=str(number)
    digits=len(scoreString)
    xPos=x
    yPos=y
    zerosToAdd=totalDigits-digits
    for i in range(totalDigits):
        if i < zerosToAdd:
            PrintDigit(0,xPos,yPos)
        else:
            PrintDigit(int(scoreString[i-zerosToAdd]),xPos,yPos)
        xPos += 4

# Locates sprite data for numbers
def PrintDigit(num,x,y):
    thumby.display.blit(n[num],x,y,3,5)

Perhaps it wouldn't run as well if it had to sort through letters in addition to numbers, but it seems to work well for keeping score, at the very least.
Title: Re: Font size
Post by: bkumanchik on October 21, 2021, 01:38:41 PM
This would be cool if it worked.
Title: Re: Font size
Post by: CoolieCoolster on October 21, 2021, 03:21:00 PM
Not quite done with it yet, but here's NanoMem (adapted from TinyMem), which uses the functions I listed to keep track of the current score and how many inputs there are left to enter.
Title: Re: Font size
Post by: bkumanchik on October 21, 2021, 06:36:19 PM
Cool, I'll try this out ASAP!