MarlinUI for Ender 3 v2 DWIN LCD (#22594)

Co-Authored-By: Taylor Talkington <taylor.talkington@gmail.com>
This commit is contained in:
Scott Lahteine
2021-08-22 05:25:07 -05:00
committed by Scott Lahteine
parent d51e70083d
commit 73ef26a106
35 changed files with 56500 additions and 41 deletions

View File

@@ -0,0 +1,64 @@
# Generate a 'HZK' font file for the T5UIC1 DWIN LCD
# from multiple bdf font files.
# Note: the 16x16 glyphs are not produced
# Author: Taylor Talkington
# License: GPL
import bdflib.reader
import math
def glyph_bits(size_x, size_y, font, glyph_ord):
asc = font[b'FONT_ASCENT']
desc = font[b'FONT_DESCENT']
bits = [0 for y in range(size_y)]
glyph_bytes = math.ceil(size_x / 8)
try:
glyph = font[glyph_ord]
for y, row in enumerate(glyph.data):
v = row
rpad = size_x - glyph.bbW
if rpad < 0: rpad = 0
if glyph.bbW > size_x: v = v >> (glyph.bbW - size_x) # some glyphs are actually too wide to fit!
v = v << (glyph_bytes * 8) - size_x + rpad
v = v >> glyph.bbX
bits[y + desc + glyph.bbY] |= v
except KeyError:
pass
bits.reverse()
return bits
def marlin_font_hzk():
fonts = [
[6,12,'marlin-6x12-3.bdf'],
[8,16,'marlin-8x16.bdf'],
[10,20,'marlin-10x20.bdf'],
[12,24,'marlin-12x24.bdf'],
[14,28,'marlin-14x28.bdf'],
[16,32,'marlin-16x32.bdf'],
[20,40,'marlin-20x40.bdf'],
[24,48,'marlin-24x48.bdf'],
[28,56,'marlin-28x56.bdf'],
[32,64,'marlin-32x64.bdf']
]
with open('marlin_fixed.hzk','wb') as output:
for f in fonts:
with open(f[2], 'rb') as file:
print(f'{f[0]}x{f[1]}')
font = bdflib.reader.read_bdf(file)
for glyph in range(128):
bits = glyph_bits(f[0], f[1], font, glyph)
glyph_bytes = math.ceil(f[0]/8)
for b in bits:
try:
z = b.to_bytes(glyph_bytes, 'big')
output.write(z)
except OverflowError:
print('Overflow')
print(f'{glyph}')
print(font[glyph])
for b in bits: print(f'{b:0{f[0]}b}')
return

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -13,11 +13,9 @@ use_example_configs "Creality/Ender-3 V2/CrealityUI"
opt_enable MARLIN_DEV_MODE BUFFER_MONITORING
exec_test $1 $2 "Ender 3 v2 with CrealityUI" "$3"
use_example_configs "Creality/Ender-3 V2/CrealityUI"
opt_disable CLASSIC_JERK
use_example_configs "Creality/Ender-3 V2/MarlinUI"
opt_add SDCARD_EEPROM_EMULATION
opt_set TEMP_SENSOR_BED 0
exec_test $1 $2 "Ender 3 v2, SD EEPROM, no CLASSIC_JERK, no Bed" "$3"
exec_test $1 $2 "Ender 3 v2 with MarlinUI" "$3"
restore_configs
opt_set MOTHERBOARD BOARD_CREALITY_V452 SERIAL_PORT 1