Working with binary data
Posted: Thu Apr 01, 2021 9:52 pm
I'm working on a project that uses the MAX7219 for a few 7-segment led displays. The libraries I've found do a good job of displaying text, numbers, etc. I updated one function to do a more flexible way of display text, so the last update I need to do is light up the individual segments, because I couldn't find a library that does that. I've adopted a function from my Arduino project, but am having an issue manipulating the binary data. I think I've narrowed the issue to the formatting of the binary data. When I run this code:
I get:
There are times where I get an extra space padded to the end
Then when I run this through any iteration, I get:
So my code seems to be concatenating the binary values, but I don't understand why that '@' is being appended to the binary value. I'm thinking this is causing the problem, but am not sure.
I can include all the other code if this is not enough.
Code: Select all
>>>bi = 0b01000000
>>>digit = 0
>>>bytearray([digit, bi])
Code: Select all
bytearray(b'\x00@')
Code: Select all
bytearray(b'\x00 ')
Code: Select all
bytearray(b'\x00\x10')
I can include all the other code if this is not enough.