diff --git a/.DS_Store b/.DS_Store index 3943f0b..f1bd07b 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/examples/.DS_Store b/examples/.DS_Store new file mode 100644 index 0000000..92ad0ba Binary files /dev/null and b/examples/.DS_Store differ diff --git a/examples/91-pico_inky/main.py b/examples/91-pico_inky/main.py index b0248ea..f2ec59b 100644 --- a/examples/91-pico_inky/main.py +++ b/examples/91-pico_inky/main.py @@ -4,12 +4,11 @@ # # 1. Download latest release of Pimoroni Pico Libraries # (such as pico-v1.23.0-1-pimoroni-micropython.uf2): -# https://github.com/pimoroni/pimoroni-pico/releases -# -# 2. Install the release # -# 3. Connect the Pico Display, here `Pico Inky Pack` +# https://github.com/pimoroni/pimoroni-pico/releases # +# 2. Connect the Pico Display, here `Pico Inky Pack` +# 3. Install the release # 4. Program the example # # See also: @@ -18,103 +17,123 @@ # https://www.youtube.com/watch?v=ytnBCw5TO9s&ab_channel=MakingStuffwithChrisDeHut # https://shkspr.mobi/blog/2024/06/displaying-a-qr-code-in-micropython-on-the-tildagon-badge/ # https://realpython.com/python-generate-qr-code/ +# https://learn.pimoroni.com/article/getting-started-with-badger-2040 -import time -from pimoroni import Button from picographics import PicoGraphics from picographics import DISPLAY_INKY_PACK # 296x128 mono e-ink from picographics import PEN_1BIT - -def clear(): - display.set_pen(WHITE) - display.clear() - display.update() - - -# Create a display object from the class and configure -display = PicoGraphics( +badge = PicoGraphics( display=DISPLAY_INKY_PACK, pen_type=PEN_1BIT, rotate=0) -# display.set_backlight(0.5) -display.set_font("bitmap8") # bitmap6, bitmap8, bitmap14_outline - -# button_a = Button(12) -# button_b = Button(13) -# button_c = Button(14) - -WHITE = 15 -BLACK = 0 +badge.set_pen(15) # white +badge.clear() -clear() +badge.set_pen(0) # black +badge.set_font("bitmap8") # bitmap6, bitmap8, bitmap14_outline +badge.text("Tomas", 3, 3, scale=7) +# badge.text('Fryza', 150, 70, scale=2) +badge.text("Brno University of Technology", 32, 94, scale=1) -display.set_pen(BLACK) -# text, x, y, wordwrap, scale -display.text("Tomas", 3, 3, 240, 8) -display.text('Fryza', 150, 67, 100, 2) -display.text("Brno University of Technology", 2, 94, 200, 1) -# display.line(10, 100, 286, 100) -display.set_font("bitmap6") -display.text("Czechia", 2, 102, 100, 4) -# display.text("Czechoslovakia", 2, 102, 296, 4) +badge.line(20, 75, 185, 75) +badge.set_font("bitmap6") +badge.text("Czechia", 33, 102, scale=4) +# badge.text("Czechoslovakia", 2, 102, scale=4) -# QR code data +# QR code data (GitHub) +# https://github.com/tomas-fryza/ qr_code = [ [1,1,1,1,1,1,1,0,1,1,1,0,0,0,1,0,0,0,1,1,1,1,1,1,1], [1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,1,0,0,0,0,0,1], - [], - [], - [], - [], - [], - [], - [], - [], - [], - [], - [], - [], - [], - [], - [], - [], - [], - [], - [], - [], - []] - -# Size of each QR code pixel on the canvas -pixel_size = 5 - -# Offset size in pixels -offset_size = 46 - -# Calculate the offset to start drawing the QR code (centre it within the available space) -offset = 50 + offset_size + [1,0,1,1,1,0,1,0,0,1,0,0,1,1,0,0,0,0,1,0,1,1,1,0,1], + [1,0,1,1,1,0,1,0,0,0,0,1,1,1,0,1,0,0,1,0,1,1,1,0,1], + [1,0,1,1,1,0,1,0,1,1,1,0,0,0,1,0,0,0,1,0,1,1,1,0,1], + [1,0,0,0,0,0,1,0,1,0,0,0,1,1,1,0,1,0,1,0,0,0,0,0,1], + [1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1], + [0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0], + [1,1,1,0,0,1,1,0,1,1,1,0,0,0,0,1,1,1,1,1,1,0,0,1,1], + [0,1,0,1,1,1,0,1,1,1,0,1,1,0,1,1,1,0,1,1,0,1,0,1,1], + [1,0,1,1,0,0,1,0,0,0,0,1,1,1,0,1,1,1,0,0,0,1,1,0,1], + [0,0,0,0,0,0,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,0,0,1,0,0,1,0,0,1,1,0,0,0,1,0,1,1,1], + [1,1,1,1,1,1,1,0,1,1,0,0,1,0,1,0,1,1,0,0,1,0,1,0,1,0,0,1,0], + [1,0,0,0,0,0,1,0,0,1,1,0,0,1,1,1,1,0,1,0,1,0,0,0,1,1,1,0,0], + [1,0,1,1,1,0,1,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,1,1,1,0,0,0,1], + [1,0,1,1,1,0,1,0,1,1,0,0,0,0,1,0,0,1,1,1,0,0,1,0,1,1,1,0,0], + [1,0,1,1,1,0,1,0,0,1,1,1,1,0,0,0,0,1,0,1,0,0,0,0,1,1,1,0,1], + [1,0,0,0,0,0,1,0,1,1,1,1,0,1,0,0,1,1,0,1,1,1,1,0,1,0,0,1,0], + [1,1,1,1,1,1,1,0,1,0,0,0,0,0,1,1,0,1,0,0,1,1,1,1,1,0,0,1,0]] + +pixel_size = 3 +offset_x = 200 +offset_y = 23 # Loop through the array -for row in range(9): - for col in range(9): +for row in range(len(qr_code)): + for col in range(len(qr_code[0])): if qr_code[row][col] == 1: - x = (col * pixel_size) + offset - y = (row * pixel_size) + offset - display.rectangle(x, y, pixel_size, pixel_size) - print(x, y) + x = (col * pixel_size) + offset_x + y = (row * pixel_size) + offset_y + badge.rectangle(x, y, pixel_size, pixel_size) -display.update() +badge.update() + +# import time +# from pimoroni import Button + +# button_a = Button(12) +# button_b = Button(13) +# button_c = Button(14) # while True: # if button_a.read(): -# display.line(10,50,286,50) -# display.update() +# badge.line(10,50,286,50) +# badge.update() # elif button_b.read(): -# display.text("IEEE", 10, 70, 240, 4) -# display.update() +# badge.text("IEEE", 10, 70, 240, 4) +# badge.update() # elif button_c.read(): -# display.text("Brno University of Technology", 10, 118, 240, 1) -# display.update() +# badge.text("Brno University of Technology", 10, 118, 240, 1) +# badge.update() # # time.sleep(0.1) # this number is how frequently the Pico checks for button presses diff --git a/examples/91-pico_inky/qrcode.png b/examples/91-pico_inky/qrcode.png new file mode 100644 index 0000000..6c27faa Binary files /dev/null and b/examples/91-pico_inky/qrcode.png differ diff --git a/examples/91-pico_inky/qrcode.py b/examples/91-pico_inky/qrcode.py new file mode 100644 index 0000000..9c01b01 --- /dev/null +++ b/examples/91-pico_inky/qrcode.py @@ -0,0 +1,20 @@ +# qrcode.py + +import segno + +qrcode = segno.make_qr("https://www.linkedin.com/in/tomas-fryza-0b008753/") +qrcode.save( + "qrcode.png", + scale=1, + border=0 +) + +from PIL import Image +im = Image.open('qrcode.png', 'r') +width, height = im.size +pixel_values = list(im.getdata()) +print(pixel_values) + +output_list = [1 if x == 0 else 0 for x in pixel_values] +print(output_list) +print(len(output_list))