diff --git a/app/display/fonts/font_5x7_opt.py b/app/display/fonts/font_5x7_opt.py index 786549f..4288f5c 100644 --- a/app/display/fonts/font_5x7_opt.py +++ b/app/display/fonts/font_5x7_opt.py @@ -61,8 +61,9 @@ font_5x7 = { 'z': [0x00, 0x00, 0x1F, 0x02, 0x04, 0x08, 0x1F], # Width: 5 # Numbers (0-9) - Optimized for consistent width '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': [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 '3': [0x1F, 0x02, 0x04, 0x02, 0x01, 0x11, 0x0E], # Width: 5 '4': [0x02, 0x06, 0x0A, 0x12, 0x1F, 0x02, 0x02], # Width: 5 diff --git a/app/display/neopixel_64x64.py b/app/display/neopixel_64x64.py index af7a37e..6c15952 100644 --- a/app/display/neopixel_64x64.py +++ b/app/display/neopixel_64x64.py @@ -139,7 +139,7 @@ class NeoPixel_64x64(NeoPixel): print(letter) for row in range(self.font_height): row_data = char_data[row] - print(number_to_bitarray_msb(row_data)) + for col in range(char_width): # Check if pixel should be lit (MSB first) # Only check bits within the actual character width diff --git a/app/utils/utils.py b/app/utils/utils.py index 3194236..a90502a 100644 --- a/app/utils/utils.py +++ b/app/utils/utils.py @@ -1,11 +1,63 @@ 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): """Convert 8-bit number to bit array (MSB first)""" 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'): """ Return date/time as string with different formats diff --git a/main.py b/main.py index f3455d5..ab0e523 100644 --- a/main.py +++ b/main.py @@ -40,8 +40,6 @@ def emoji_test(): display.write() - show_system_load() - def weather_check(): wlan = Wlan('WOKWI-Guest', '12345678') @@ -105,11 +103,13 @@ def bit_arrays(): # c = 'A' # print(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(char_row, 0, len(char_row), ORANGE) - display.write_text('Kiel', 0, 7, BLUE) + utils.is_letter_assigned_right(char_row, font_5x7[char_row]) + + # display.write_text(char_row, 0, len(char_row), ORANGE) + # display.write_text('Kiel', 0, 7, BLUE) # c = 'I' @@ -125,3 +125,4 @@ if __name__ == '__main__': # weather_check() # font_5x7_test() bit_arrays() + show_system_load()