kopia lustrzana https://github.com/pimoroni/pimoroni-pico
Badger2040W: Add thickness back. Better error backdrop.
rodzic
3f0efa9765
commit
0410b7c775
|
@ -119,6 +119,7 @@ def draw_badge():
|
||||||
display = badger2040w.Badger2040W()
|
display = badger2040w.Badger2040W()
|
||||||
display.led(128)
|
display.led(128)
|
||||||
display.set_update_speed(badger2040w.UPDATE_NORMAL)
|
display.set_update_speed(badger2040w.UPDATE_NORMAL)
|
||||||
|
display.set_thickness(2)
|
||||||
|
|
||||||
jpeg = jpegdec.JPEG(display.display)
|
jpeg = jpegdec.JPEG(display.display)
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ TEXT_PADDING = 4
|
||||||
TEXT_WIDTH = WIDTH - TEXT_PADDING - TEXT_PADDING - ARROW_WIDTH
|
TEXT_WIDTH = WIDTH - TEXT_PADDING - TEXT_PADDING - ARROW_WIDTH
|
||||||
|
|
||||||
FONTS = ["sans", "gothic", "cursive", "serif"]
|
FONTS = ["sans", "gothic", "cursive", "serif"]
|
||||||
|
THICKNESSES = [2, 1, 1, 2]
|
||||||
# ------------------------------
|
# ------------------------------
|
||||||
# Drawing functions
|
# Drawing functions
|
||||||
# ------------------------------
|
# ------------------------------
|
||||||
|
@ -91,6 +92,7 @@ def render_page():
|
||||||
next_pos = pos
|
next_pos = pos
|
||||||
add_newline = False
|
add_newline = False
|
||||||
display.set_font(FONTS[state["font_idx"]])
|
display.set_font(FONTS[state["font_idx"]])
|
||||||
|
display.set_thickness(THICKNESSES[state["font_idx"]])
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
# Read a full line and split it into words
|
# Read a full line and split it into words
|
||||||
|
|
|
@ -6,6 +6,7 @@ LINE_HEIGHT = 20
|
||||||
|
|
||||||
display = badger2040w.Badger2040W()
|
display = badger2040w.Badger2040W()
|
||||||
display.led(128)
|
display.led(128)
|
||||||
|
display.set_thickness(2)
|
||||||
|
|
||||||
# Clear to white
|
# Clear to white
|
||||||
display.set_pen(15)
|
display.set_pen(15)
|
||||||
|
|
|
@ -181,6 +181,7 @@ items_per_page = 0
|
||||||
display = badger2040w.Badger2040W()
|
display = badger2040w.Badger2040W()
|
||||||
display.led(128)
|
display.led(128)
|
||||||
display.set_font("sans")
|
display.set_font("sans")
|
||||||
|
display.set_thickness(2)
|
||||||
if changed:
|
if changed:
|
||||||
display.set_update_speed(badger2040w.UPDATE_FAST)
|
display.set_update_speed(badger2040w.UPDATE_FAST)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -145,7 +145,7 @@ def launch(file):
|
||||||
|
|
||||||
|
|
||||||
# Draw an overlay box with a given message within it
|
# Draw an overlay box with a given message within it
|
||||||
def warning(display, message, width=badger2040.WIDTH - 40, height=badger2040.HEIGHT - 40, line_spacing=20, text_size=0.6):
|
def warning(display, message, width=badger2040.WIDTH - 20, height=badger2040.HEIGHT - 20, line_spacing=20, text_size=0.6):
|
||||||
print(message)
|
print(message)
|
||||||
|
|
||||||
if display is None:
|
if display is None:
|
||||||
|
@ -156,6 +156,12 @@ def warning(display, message, width=badger2040.WIDTH - 40, height=badger2040.HEI
|
||||||
display.set_pen(12)
|
display.set_pen(12)
|
||||||
display.rectangle((badger2040.WIDTH - width) // 2, (badger2040.HEIGHT - height) // 2, width, height)
|
display.rectangle((badger2040.WIDTH - width) // 2, (badger2040.HEIGHT - height) // 2, width, height)
|
||||||
|
|
||||||
|
width -= 20
|
||||||
|
height -= 20
|
||||||
|
|
||||||
|
display.set_pen(15)
|
||||||
|
display.rectangle((badger2040.WIDTH - width) // 2, (badger2040.HEIGHT - height) // 2, width, height)
|
||||||
|
|
||||||
# Take the provided message and split it up into
|
# Take the provided message and split it up into
|
||||||
# lines that fit within the specified width
|
# lines that fit within the specified width
|
||||||
words = message.split(" ")
|
words = message.split(" ")
|
||||||
|
|
Ładowanie…
Reference in New Issue