From ba55f5fec8675a24d48bdca03d498ebda68e25df Mon Sep 17 00:00:00 2001 From: tomas-fryza Date: Fri, 24 Jan 2025 21:23:34 +0100 Subject: [PATCH] qr code added --- .DS_Store | Bin 6148 -> 6148 bytes examples/.DS_Store | Bin 0 -> 6148 bytes examples/91-pico_inky/main.py | 175 +++++++++++++++++-------------- examples/91-pico_inky/qrcode.png | Bin 0 -> 210 bytes examples/91-pico_inky/qrcode.py | 20 ++++ 5 files changed, 117 insertions(+), 78 deletions(-) create mode 100644 examples/.DS_Store create mode 100644 examples/91-pico_inky/qrcode.png create mode 100644 examples/91-pico_inky/qrcode.py diff --git a/.DS_Store b/.DS_Store index 3943f0b1f93bb95561e3e8d3eb8647b26f026a56..f1bd07b6fcea793c09b5c7b7ea15657a168e68c3 100644 GIT binary patch delta 142 zcmZoMXfc=|#>B)qu~2NHo}wTN0|Nsi1A_nqLjgk$Ln=e@#Dvw06_^-BK@uE5feMC1 zhFqBBWCg|sc0&sb9R*Xv$;%lXrP1Wef{XHU^7GO`hHmCzWMSRR&cV+Cv~9B>(|6{{ T{34bdK+AxLfnjri$QEV*Acq{} delta 81 zcmZoMXfc=|#>B`mu~2NHo}wTV0|Nsi1A_nqgDyip5Ee{KSUuT5gk>`uGb8I}0haHK go7p+|Ie;2AGqQYVp3E;|$pO>?(!;blKx7Lu0H)9o2LJ#7 diff --git a/examples/.DS_Store b/examples/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..92ad0ba19e8fc5d77432efa807308d2cc9b7d805 GIT binary patch literal 6148 zcmeHK%}N6?5T3Nv?ox#w6g>vKR_q>1D_)khzJM!wP^n#8bm_V&{jo?X>{VaLH}QF# zNm8ZMUOb4D8JK*N$;^g)SuzO#h+y3D0LlR1pc3X>Y<>_LCtZ@9^$-gEjTr7hK?`C? zm!jG69~q#%+k#{8;1K$_Z{PdZgO_MB>_>@;Fy=k#C-HDpt$v7HzOb=bbc#;NxeXuH zBpkIz<6+PqTvP8tsU(`)?dUS@PFm%iQs49C zaF8Y{eZZJ`{ydM78DIvOfwgA99(qn`tyjs5V+NRk-!MSugG43tEoKJw(SZ$JA8EWm zNP;%KB?zTO-(qGEM^J=GMKr0xJ~4zzN58ajzQxR-Ne7{4#_!mfg?*t2Jv;iP4hP{I zT=t1F&fTn>PX5dd5_ym?PP4@r* literal 0 HcmV?d00001 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,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,0,1,0,1,1,1,1,1,0,1,0,0], + [0,0,0,0,0,0,0,0,1,0,0,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 0000000000000000000000000000000000000000..6c27faa027812554918c19a4b8b8845259a1bcb2 GIT binary patch literal 210 zcmeAS@N?(olHy`uVBq!ia0vp^vLMU|BpB*mL@feRGd*1#Ln>}1C(OBW_&~sH@n4Mx zr@DqW9NcLt5#-@7ktY=4jZ6Xh}fCbc)=MP2U3#)V(rFJtG~f4E29z+w(hN5YTz zx$h1f$jF*?Fu+)w%i;uI`h|klvoe#+-b%jfdguWFv_W5^p0xj`ei) Kb6Mw<&;$TcF