v.0.2.1 is_letter_assigned_right
This commit is contained in:
@@ -61,8 +61,9 @@ font_5x7 = {
|
|||||||
'z': [0x00, 0x00, 0x1F, 0x02, 0x04, 0x08, 0x1F], # Width: 5
|
'z': [0x00, 0x00, 0x1F, 0x02, 0x04, 0x08, 0x1F], # Width: 5
|
||||||
# Numbers (0-9) - Optimized for consistent width
|
# Numbers (0-9) - Optimized for consistent width
|
||||||
'0': [0x0E, 0x11, 0x13, 0x15, 0x19, 0x11, 0x0E], # Width: 5
|
'0': [0x0E, 0x11, 0x13, 0x15, 0x19, 0x11, 0x0E], # Width: 5
|
||||||
# '1': [0x04, 0x0C, 0x04, 0x04, 0x04, 0x04, 0x0E], # Width: 3
|
|
||||||
'1': [0x02, 0x06, 0x02, 0x02, 0x02, 0x02, 0x07], # Width: 3
|
'1': [0x02, 0x06, 0x02, 0x02, 0x02, 0x02, 0x07], # Width: 3
|
||||||
|
# '1': [0x04, 0x0C, 0x04, 0x04, 0x04, 0x04, 0x0E], # Width: 3
|
||||||
|
# '1': [0x08, 0x18, 0x08, 0x08, 0x08, 0x08, 0x1C], # Width: 3
|
||||||
'2': [0x0E, 0x11, 0x01, 0x02, 0x04, 0x08, 0x1F], # Width: 5
|
'2': [0x0E, 0x11, 0x01, 0x02, 0x04, 0x08, 0x1F], # Width: 5
|
||||||
'3': [0x1F, 0x02, 0x04, 0x02, 0x01, 0x11, 0x0E], # Width: 5
|
'3': [0x1F, 0x02, 0x04, 0x02, 0x01, 0x11, 0x0E], # Width: 5
|
||||||
'4': [0x02, 0x06, 0x0A, 0x12, 0x1F, 0x02, 0x02], # Width: 5
|
'4': [0x02, 0x06, 0x0A, 0x12, 0x1F, 0x02, 0x02], # Width: 5
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ class NeoPixel_64x64(NeoPixel):
|
|||||||
print(letter)
|
print(letter)
|
||||||
for row in range(self.font_height):
|
for row in range(self.font_height):
|
||||||
row_data = char_data[row]
|
row_data = char_data[row]
|
||||||
print(number_to_bitarray_msb(row_data))
|
|
||||||
for col in range(char_width):
|
for col in range(char_width):
|
||||||
# Check if pixel should be lit (MSB first)
|
# Check if pixel should be lit (MSB first)
|
||||||
# Only check bits within the actual character width
|
# Only check bits within the actual character width
|
||||||
|
|||||||
@@ -1,11 +1,63 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
def show_byte_matrix(char, matrix):
|
||||||
|
print(f'byte_matrix: char({char})')
|
||||||
|
matrix_str = [f'0x{byte:02X}' for byte in matrix]
|
||||||
|
[print(f'{matrix_str[idx]} {number_to_bitarray_msb(byte)}') for idx, byte in enumerate(matrix)]
|
||||||
|
|
||||||
|
|
||||||
def number_to_bitarray_msb(number):
|
def number_to_bitarray_msb(number):
|
||||||
"""Convert 8-bit number to bit array (MSB first)"""
|
"""Convert 8-bit number to bit array (MSB first)"""
|
||||||
return [(number >> i) & 1 for i in range(7, -1, -1)]
|
return [(number >> i) & 1 for i in range(7, -1, -1)]
|
||||||
|
|
||||||
|
|
||||||
|
def is_letter_assigned_right(char, letter) -> bool:
|
||||||
|
"""Prüfe ob das Zeichen auch komplett nach rechts gezogen ist
|
||||||
|
|
||||||
|
Args:
|
||||||
|
letter (_type_): Array[0..nBytes]
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: _description_
|
||||||
|
"""
|
||||||
|
|
||||||
|
def isLetterRight(letter):
|
||||||
|
def isByteRight(byte):
|
||||||
|
return True if 1 & byte == 1 else False
|
||||||
|
|
||||||
|
for byte in letter:
|
||||||
|
if isByteRight(byte):
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
def shiftLetterRight(letter):
|
||||||
|
def shift(letter):
|
||||||
|
return [byte >> 1 for byte in letter]
|
||||||
|
|
||||||
|
shifted = letter
|
||||||
|
for i in range(8): # max 1 Bit's
|
||||||
|
shifted = shift(shifted)
|
||||||
|
if isLetterRight(shifted):
|
||||||
|
break
|
||||||
|
|
||||||
|
return shifted
|
||||||
|
|
||||||
|
if isLetterRight(letter):
|
||||||
|
return True
|
||||||
|
|
||||||
|
# letter is not right shifted
|
||||||
|
shifted = shiftLetterRight(letter)
|
||||||
|
|
||||||
|
print('origin:')
|
||||||
|
show_byte_matrix(char, letter)
|
||||||
|
print('shifted')
|
||||||
|
show_byte_matrix(char, shifted)
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_datetime_string(format='full'):
|
def get_datetime_string(format='full'):
|
||||||
"""
|
"""
|
||||||
Return date/time as string with different formats
|
Return date/time as string with different formats
|
||||||
|
|||||||
11
main.py
11
main.py
@@ -40,8 +40,6 @@ def emoji_test():
|
|||||||
|
|
||||||
display.write()
|
display.write()
|
||||||
|
|
||||||
show_system_load()
|
|
||||||
|
|
||||||
|
|
||||||
def weather_check():
|
def weather_check():
|
||||||
wlan = Wlan('WOKWI-Guest', '12345678')
|
wlan = Wlan('WOKWI-Guest', '12345678')
|
||||||
@@ -105,11 +103,13 @@ def bit_arrays():
|
|||||||
# c = 'A'
|
# c = 'A'
|
||||||
# print(c)
|
# print(c)
|
||||||
# [print(utils.number_to_bitarray_msb(num)) for num in font_5x7[c]]
|
# [print(utils.number_to_bitarray_msb(num)) for num in font_5x7[c]]
|
||||||
char_row = '¶•'
|
char_row = '1'
|
||||||
[display.write_text(c, 0, idx, YELLOW) for idx, c in enumerate(char_row)]
|
[display.write_text(c, 0, idx, YELLOW) for idx, c in enumerate(char_row)]
|
||||||
|
|
||||||
display.write_text(char_row, 0, len(char_row), ORANGE)
|
utils.is_letter_assigned_right(char_row, font_5x7[char_row])
|
||||||
display.write_text('Kiel', 0, 7, BLUE)
|
|
||||||
|
# display.write_text(char_row, 0, len(char_row), ORANGE)
|
||||||
|
# display.write_text('Kiel', 0, 7, BLUE)
|
||||||
|
|
||||||
|
|
||||||
# c = 'I'
|
# c = 'I'
|
||||||
@@ -125,3 +125,4 @@ if __name__ == '__main__':
|
|||||||
# weather_check()
|
# weather_check()
|
||||||
# font_5x7_test()
|
# font_5x7_test()
|
||||||
bit_arrays()
|
bit_arrays()
|
||||||
|
show_system_load()
|
||||||
|
|||||||
Reference in New Issue
Block a user