Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Displaying text #14

Closed
tmedelnick opened this issue Jan 9, 2024 · 3 comments
Closed

Displaying text #14

tmedelnick opened this issue Jan 9, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@tmedelnick
Copy link

Some findings for text for a 16x16 display.
The app code is not that clear what to set for other sizes.
I've got some code which works, but needs some more work.

Text generally displays some bitmap data with some text color and background color.

Following is for a 16x16 display, the app code is not very clear what to set in bitmap_header and header for other display sizes, see below.
Need to compare the data, which is sent over bluetooth.

Bitmap data needs to be 8 pixel wide, 16 pixel high (for 16x16 display)

The app generates bitmap data from painting on a canvas. Font size is fixed to 8x12 (???)
The app code also contains data for a 5x8 pixel font (which is not used???).

Font 5x8 bitmap for character 'A' and 'B' (upper 3 bits always 0)

 | b0| b1| b2| b3| b4| b5| b6| b7|   
    -+-------------------------------+
     | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | Byte0
     | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | Byte1
     | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | Byte2
     | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | Byte3
 A   | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | Byte4
     | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | Byte5
     | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | Byte6
     | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | Byte7
     +-------------------------------+
     | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | Byte8
     | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | Byte9
     | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | Byte10
 B   | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | Byte11
     | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | Byte12
     | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | Byte13
     | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | Byte14
     | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | Byte15
     +-------------------------------+

Bitmap data for 16x16 display
One character: bitmap height 16 pixel, width 8 pixel
2 lines of characters with 5x8 pixel font possible

Data per character
bitmap_header per character + bitmap data

bitmap_header = bytearray(
    [
        0x02,   # bitmap height 16 pixel -> 16 bytes per character (not clear for other sizes)
        0xff, 0xff, 0xff, # fixed
    ]
)

Header for complete bitmap

     text_header = bytearray(
            [
                1,   # text length lobyte, number of 8 pixel blocks
                0,   # text length hibyte
                0,   # fixed
                1,   # fixed
                0,   # mode (0=fixed, 1=left scrolling, ...) as per App
                50,  # speed 
                1,   # color mode
                255, # color red
                255, # color green
                0,   # color blue
                8,   # background mode
                0,   # background color red
                0,   # background color green
                0,   # background color blue
            ]
        )

Chunking like in GIF code

     header = bytearray(
            [
                255,    # chunk length
                255,    # 
                3,      # fixed
                0,      # fixed
                0,      # 0 if first chunk, else 2
                255,    # length payload
                255,    
                255,
                255,
                255,    # CRC
                255,
                255,
                255,
                0,      # works for 16x16, not clear for other sizes 
                0,      # works for 16x16, not clear for other sizes 
                12,     # works for 16x16, not clear for other sizes 
            ]
        )
@derkalle4
Copy link
Owner

Hi @tmedelnick

many thanks for your report! Will look into that. Currently not really able to work on this due to long COVID but it gets better. I already have some source code from issue #4 which may comes in handy as well. Haven't looked it up yet but it is on my road map for EOW :)

I only do have 32x32 pixel display (waiting for the second one to arrive) and I have no plans to extend my personal displays to 16x16 as well, therefore I would kindly ask you to test everything once I got sorted it out.

Thanks in advance!

Kind Regards,
Kalle

@derkalle4 derkalle4 self-assigned this Jan 12, 2024
@derkalle4 derkalle4 added the enhancement New feature or request label Jan 12, 2024
@derkalle4
Copy link
Owner

Hi,

ability to display text has been added. Still not perfect, but good enough for a first test run :)

@derkalle4
Copy link
Owner

Hi @tmedelnick,

looked further into the source code and checked for possible display sizes like 16x16 and 32x32. I only have the 32x32 model and can use your findings to have a smaller text displayed correctly. Unfortunately it seems impossible to generate custom sizes like 14x14 pixels per character and concatenate them. This will not be displayed properly.

See derkalle4/python3-idotmatrix-library@c59d956 for my changes made to the library.

To achieve a correct font spacing for 16x16 (and also 32x32) I would use the following settings:

image_width = 8
image_height = 16
separator = b"\x02\xff\xff\xff"

when I use the default settings I have a bigger spacing, which is way too big for me:

image_width = 16
image_height = 32
separator = b"\x05\xff\xff\xff"

Haven't tested all settings in between but they didn't seem to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants