From b4069bcef4c722ec0f3e865e587d5826e6cb7e4a Mon Sep 17 00:00:00 2001 From: Adrian Studer Date: Sun, 27 Oct 2024 17:16:25 -0700 Subject: [PATCH 01/16] add duckGLOW SAO --- i2c-addresses.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i2c-addresses.md b/i2c-addresses.md index 48843f3..44f55e2 100644 --- a/i2c-addresses.md +++ b/i2c-addresses.md @@ -13,4 +13,4 @@ If you have made an SAO that you are bringing, please add it to this list submit | 0x19 | Blinky Loop SAO | Can also use 0x18 | [hackaday.io](https://hackaday.io/project/198163-blinky-loop-sao) | | 0x1A | Hack-Man SAO | See project for commands | [hackaday.io](https://hackaday.io/project/198301-hack-man-sao) | | 0x55 | Badge Tag NFC SAO | Can be changed in a register | [hackaday.io](https://hackaday.io/project/198165-badge-tag-nfc-sao) | - +| 0x6C | duckGLOW SAO | Change to 0x6C-06F w/ solder jumpers | [hackaday.io](https://hackaday.io/project/198918-duckglow-sao) | From 76a197383589faac86eb8780877f5efd92423e50 Mon Sep 17 00:00:00 2001 From: Elliot Williams Date: Sat, 2 Nov 2024 02:15:27 +0100 Subject: [PATCH 02/16] adding ch32v003 flasher --- .gitmodules | 3 +++ i2c_proto_petal_tutorial/pico_ch32v003_prog | 1 + 2 files changed, 4 insertions(+) create mode 160000 i2c_proto_petal_tutorial/pico_ch32v003_prog diff --git a/.gitmodules b/.gitmodules index 605f78b..a184a26 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [submodule "software/libraries/MicroPython-SSD1306"] path = software/libraries/MicroPython-SSD1306 url = https://github.com/TimHanewich/MicroPython-SSD1306 +[submodule "i2c_proto_petal_tutorial/pico_ch32v003_prog"] + path = i2c_proto_petal_tutorial/pico_ch32v003_prog + url = git@github.com:hexagon5un/pico_ch32v003_prog.git diff --git a/i2c_proto_petal_tutorial/pico_ch32v003_prog b/i2c_proto_petal_tutorial/pico_ch32v003_prog new file mode 160000 index 0000000..08759e6 --- /dev/null +++ b/i2c_proto_petal_tutorial/pico_ch32v003_prog @@ -0,0 +1 @@ +Subproject commit 08759e68a57e1254cff1b7bc4cfa2ffb4180f2a3 From dd12b690fefacfc91cb0454df31806404d8d63fa Mon Sep 17 00:00:00 2001 From: Elliot Williams Date: Sat, 2 Nov 2024 02:16:18 +0100 Subject: [PATCH 03/16] adding a couple binaries --- i2c_proto_petal_tutorial/demo_roms/blink.bin | Bin 0 -> 492 bytes i2c_proto_petal_tutorial/demo_roms/blink2.bin | Bin 0 -> 484 bytes software/software/main.py | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) create mode 100755 i2c_proto_petal_tutorial/demo_roms/blink.bin create mode 100755 i2c_proto_petal_tutorial/demo_roms/blink2.bin diff --git a/i2c_proto_petal_tutorial/demo_roms/blink.bin b/i2c_proto_petal_tutorial/demo_roms/blink.bin new file mode 100755 index 0000000000000000000000000000000000000000..d0a9bd70d2410872efd81cc51a2b36019323f74b GIT binary patch literal 492 zcmd02VBlf^0vSdI1}PvW1Yl~AX%L$h8041ej0_5s8yU-l8yOjdSs6Hr1y~Jw-NacL zfV`z&LVJq^LJfdC1!2~spQi)q$*r!R8Qqe@wlWAD6l8tuxAmVe>j624%+inIY(SN4 zY9Et3jxvZiP64Wz$ohEJ(SO^&Gdy5*pK*9H`vHmK3F0Qj3nL3V|(T}TR2^uVa8#{WOJa)h1uBblvji^ daJZXI<#F%qeSD7fpYn=yAm0eiKf0ZP0Ra1lb>IL1 literal 0 HcmV?d00001 diff --git a/i2c_proto_petal_tutorial/demo_roms/blink2.bin b/i2c_proto_petal_tutorial/demo_roms/blink2.bin new file mode 100755 index 0000000000000000000000000000000000000000..da20ceeaa9c72945f0ceb46ee656dcd1e6bd1718 GIT binary patch literal 484 zcmd02Xb@unf+$7?h6o@g1Yl~AX%L$h8041i>P!x-?lTT=7iV%XXXjv4Uc}BI%r4F` zAPw6Xi~yyyS6vokzU zUc=5O%+A1}yy`h$Q$wI2+mTRnux|hD(^weH+0HRcejd&&bAG!xqXYADc86A{$?fb8 zj~R1_l7B<9D9` literal 0 HcmV?d00001 diff --git a/software/software/main.py b/software/software/main.py index 7578c19..c0e61f0 100644 --- a/software/software/main.py +++ b/software/software/main.py @@ -51,7 +51,7 @@ - time.sleep_ms(20) + time.sleep_ms(100) bootLED.off() From f70c795238e56badebc58d42be662b9806756559 Mon Sep 17 00:00:00 2001 From: Elliot Williams Date: Sat, 2 Nov 2024 02:16:39 +0100 Subject: [PATCH 04/16] adding in acouple blinks --- .../{demo_roms => demo_binaries}/blink.bin | Bin .../{demo_roms => demo_binaries}/blink2.bin | Bin 2 files changed, 0 insertions(+), 0 deletions(-) rename i2c_proto_petal_tutorial/{demo_roms => demo_binaries}/blink.bin (100%) rename i2c_proto_petal_tutorial/{demo_roms => demo_binaries}/blink2.bin (100%) diff --git a/i2c_proto_petal_tutorial/demo_roms/blink.bin b/i2c_proto_petal_tutorial/demo_binaries/blink.bin similarity index 100% rename from i2c_proto_petal_tutorial/demo_roms/blink.bin rename to i2c_proto_petal_tutorial/demo_binaries/blink.bin diff --git a/i2c_proto_petal_tutorial/demo_roms/blink2.bin b/i2c_proto_petal_tutorial/demo_binaries/blink2.bin similarity index 100% rename from i2c_proto_petal_tutorial/demo_roms/blink2.bin rename to i2c_proto_petal_tutorial/demo_binaries/blink2.bin From 3ceb82372a88957f16d92e714ea4680ab7d69cc0 Mon Sep 17 00:00:00 2001 From: MakeItHackin Date: Fri, 1 Nov 2024 20:19:18 -0700 Subject: [PATCH 05/16] Update i2c-addresses.md Added new I2C address for Skull of Fate --- i2c-addresses.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i2c-addresses.md b/i2c-addresses.md index 48843f3..28058b3 100644 --- a/i2c-addresses.md +++ b/i2c-addresses.md @@ -13,4 +13,4 @@ If you have made an SAO that you are bringing, please add it to this list submit | 0x19 | Blinky Loop SAO | Can also use 0x18 | [hackaday.io](https://hackaday.io/project/198163-blinky-loop-sao) | | 0x1A | Hack-Man SAO | See project for commands | [hackaday.io](https://hackaday.io/project/198301-hack-man-sao) | | 0x55 | Badge Tag NFC SAO | Can be changed in a register | [hackaday.io](https://hackaday.io/project/198165-badge-tag-nfc-sao) | - +| 0x13 | Skull of Fate SAO | Can be changed. See doc. | [hackaday.io](https://hackaday.io/project/198974-skull-of-fate-sao) | From f9ce9eeee5d00542af1d8b8c354e7d20383f97af Mon Sep 17 00:00:00 2001 From: MakeItHackin Date: Fri, 1 Nov 2024 20:21:24 -0700 Subject: [PATCH 06/16] Update i2c-addresses.md Added new I2C address for Skull of Fate From b2450abc3b94bec904b4f7bc925660db2def90b7 Mon Sep 17 00:00:00 2001 From: Elliot Williams Date: Sat, 2 Nov 2024 02:36:58 +0100 Subject: [PATCH 07/16] charles' cap touch adc demo --- .../demo_binaries/cap_touch_adc.bin | Bin 0 -> 2556 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100755 i2c_proto_petal_tutorial/demo_binaries/cap_touch_adc.bin diff --git a/i2c_proto_petal_tutorial/demo_binaries/cap_touch_adc.bin b/i2c_proto_petal_tutorial/demo_binaries/cap_touch_adc.bin new file mode 100755 index 0000000000000000000000000000000000000000..57bff2712b00bdff9f03f9632e3370fcb504d5bc GIT binary patch literal 2556 zcmcImeQXow8Gr8VyK~XHd|Ze_6eMF4r^=)##NbdyoJ(xqOSOuXmJp!@Y4n<9m5SPq zLO&$5^Tn@CO0$q0#LmXH)Dh5H>crv^3;t*v$FZF(rCAsao7yelkx2WH2Gj{-;OxDG zh)nx~zjo4V-~0T2&&T^dANK2DLO`Cs>jC~s){~x9&f0J7{r|DFSft$yEsZkzDqk2M zYg!-2qV&!XNc&>IvOYHR+E9*iOMe-I?#`x8tT0OUz9RdS@%k#PC^n{FkkAE)Fc*Z8 zsP^eoTI)5bqWBak#eno20|#m~u7+m5$K*7058+%O9Dpqa)&!e2Cx7J)`v-Afl5$Ej zy)fiuoE!Qn=Q*Fv+bc*f>49>YeLJutUK-o~E!x?GD*X`_10_aqLXa9S=%uTA@VFwl z7i{>JAnA3q^rI-Pa{cr`S2m~mvP;r?GhkVMzqKU2H3I`b$>!ohjVt8ZLn(3ur$9Hx zKm;d&VJ-4mI1r@@*em8q>jWLEY?qoD=$OOErt23RG3I?|hZ^MblBONDzaG6&d4i4Tp^cfNo-!pp8{7jsaNKlL7rhI*UG zy{Di(&Vg=}S&qGl_-TXj;ky-3tFt0(vNlI&suhE5c^hj)*!RLEqi|BviIewwQPhPr=v#!Hhs6889;^)*g2>Jim*c2b3XH+gnuNkJ;! z3I@Zcr%Mw%;*_;fR8W+KS+lbcsXkxc$#|#R<_myFY;R-%v#Ot^Y`6j}&;$}QLvoin zHI!3X1nL}n&tmu;#Kp^}ET*fF8S^fDJbbLUJZJTG4A<&l*5l%J&b(VuEst!X%DbsP zL{71C{s09g)pKJz@1cNaz;HO9sqPew43Hg;Hgz7(Z>r{TL$`_>R7#ZgU4;CR0w%Nj zVs3>q<_s{z0v`K~kp&aa`o^T=V^Gv^imkSiQ;OpHWz zsEA|BMW(% zyJvHKaZS&Wz9C9i7r>t8*%<2)r4lj|NOV|a^ct=cZ&N%cuo5%JN^L1JU1Uarg>@=d z%}P%%tlKiZHcD&a(lCjLwkJOsCa2(}b#pY&$(+Q^u{>AJWlHBBI3`uU3%r6OVa4Nh zH&GZ%`~GQ&i#6i*5-Z-=uc3~_=_Jn%-7Cpg?Zt4M^y|m&pW9bBVQk1hwzE(S<7Y|~ zqy(}TRpO~6AB&l9EIjatXC330%4MniD4mir|HQ_D5yRD0VX^A($GaYl=2;r7qe z`3h(m-Gshu{Pl^!EE z-I1fJZ{f#$8?ppHzwSKJb$v8iK?$m#6D;RA+VT-c2T84elXP-ZS1=Vse4C%d6GWR% z99hzKNQ;hW@Ek|FqWeU4iBu`=aqlvW*S+i7WjI#!$<9L$v`*~YiC^u}wg+W&*{ZLgS~urxEkQ=W&`E4;B7qMIqfJjG6{UcFEg=n$u_ z+X8bCO!K|vptCSghit|a@Mv-ALu7lq4I+UQ{Glt-n*>KJGCv27ID=F_Lq&{>r1~Sq zC^(XxsM705(-ZR`KU2%?28IhJ6jT-qp|bQm^j8Fhr%oLCa}SXW63N#t`{Y`tc86=( uH^u+v-*a8={a=kIYfU42;4+y(arDsWNMF3$^8&s1MfV*ty*#8R0R98Z+l(pz literal 0 HcmV?d00001 From 959d946650a36170d1fb57e89d72ce6ce978ead6 Mon Sep 17 00:00:00 2001 From: Elliot Williams Date: Sat, 2 Nov 2024 15:38:19 +0100 Subject: [PATCH 08/16] update pico ch32v003 prog --- .../demo_binaries/cap_touch_adc.bin | Bin 2556 -> 0 bytes i2c_proto_petal_tutorial/pico_ch32v003_prog | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100755 i2c_proto_petal_tutorial/demo_binaries/cap_touch_adc.bin diff --git a/i2c_proto_petal_tutorial/demo_binaries/cap_touch_adc.bin b/i2c_proto_petal_tutorial/demo_binaries/cap_touch_adc.bin deleted file mode 100755 index 57bff2712b00bdff9f03f9632e3370fcb504d5bc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2556 zcmcImeQXow8Gr8VyK~XHd|Ze_6eMF4r^=)##NbdyoJ(xqOSOuXmJp!@Y4n<9m5SPq zLO&$5^Tn@CO0$q0#LmXH)Dh5H>crv^3;t*v$FZF(rCAsao7yelkx2WH2Gj{-;OxDG zh)nx~zjo4V-~0T2&&T^dANK2DLO`Cs>jC~s){~x9&f0J7{r|DFSft$yEsZkzDqk2M zYg!-2qV&!XNc&>IvOYHR+E9*iOMe-I?#`x8tT0OUz9RdS@%k#PC^n{FkkAE)Fc*Z8 zsP^eoTI)5bqWBak#eno20|#m~u7+m5$K*7058+%O9Dpqa)&!e2Cx7J)`v-Afl5$Ej zy)fiuoE!Qn=Q*Fv+bc*f>49>YeLJutUK-o~E!x?GD*X`_10_aqLXa9S=%uTA@VFwl z7i{>JAnA3q^rI-Pa{cr`S2m~mvP;r?GhkVMzqKU2H3I`b$>!ohjVt8ZLn(3ur$9Hx zKm;d&VJ-4mI1r@@*em8q>jWLEY?qoD=$OOErt23RG3I?|hZ^MblBONDzaG6&d4i4Tp^cfNo-!pp8{7jsaNKlL7rhI*UG zy{Di(&Vg=}S&qGl_-TXj;ky-3tFt0(vNlI&suhE5c^hj)*!RLEqi|BviIewwQPhPr=v#!Hhs6889;^)*g2>Jim*c2b3XH+gnuNkJ;! z3I@Zcr%Mw%;*_;fR8W+KS+lbcsXkxc$#|#R<_myFY;R-%v#Ot^Y`6j}&;$}QLvoin zHI!3X1nL}n&tmu;#Kp^}ET*fF8S^fDJbbLUJZJTG4A<&l*5l%J&b(VuEst!X%DbsP zL{71C{s09g)pKJz@1cNaz;HO9sqPew43Hg;Hgz7(Z>r{TL$`_>R7#ZgU4;CR0w%Nj zVs3>q<_s{z0v`K~kp&aa`o^T=V^Gv^imkSiQ;OpHWz zsEA|BMW(% zyJvHKaZS&Wz9C9i7r>t8*%<2)r4lj|NOV|a^ct=cZ&N%cuo5%JN^L1JU1Uarg>@=d z%}P%%tlKiZHcD&a(lCjLwkJOsCa2(}b#pY&$(+Q^u{>AJWlHBBI3`uU3%r6OVa4Nh zH&GZ%`~GQ&i#6i*5-Z-=uc3~_=_Jn%-7Cpg?Zt4M^y|m&pW9bBVQk1hwzE(S<7Y|~ zqy(}TRpO~6AB&l9EIjatXC330%4MniD4mir|HQ_D5yRD0VX^A($GaYl=2;r7qe z`3h(m-Gshu{Pl^!EE z-I1fJZ{f#$8?ppHzwSKJb$v8iK?$m#6D;RA+VT-c2T84elXP-ZS1=Vse4C%d6GWR% z99hzKNQ;hW@Ek|FqWeU4iBu`=aqlvW*S+i7WjI#!$<9L$v`*~YiC^u}wg+W&*{ZLgS~urxEkQ=W&`E4;B7qMIqfJjG6{UcFEg=n$u_ z+X8bCO!K|vptCSghit|a@Mv-ALu7lq4I+UQ{Glt-n*>KJGCv27ID=F_Lq&{>r1~Sq zC^(XxsM705(-ZR`KU2%?28IhJ6jT-qp|bQm^j8Fhr%oLCa}SXW63N#t`{Y`tc86=( uH^u+v-*a8={a=kIYfU42;4+y(arDsWNMF3$^8&s1MfV*ty*#8R0R98Z+l(pz diff --git a/i2c_proto_petal_tutorial/pico_ch32v003_prog b/i2c_proto_petal_tutorial/pico_ch32v003_prog index 08759e6..b27aed7 160000 --- a/i2c_proto_petal_tutorial/pico_ch32v003_prog +++ b/i2c_proto_petal_tutorial/pico_ch32v003_prog @@ -1 +1 @@ -Subproject commit 08759e68a57e1254cff1b7bc4cfa2ffb4180f2a3 +Subproject commit b27aed77272f5a6784cd8eae403d3d86f6571f0e From 661ef3e3539f4f26b5582b0e8031a358ff7ddbf3 Mon Sep 17 00:00:00 2001 From: Elliot Williams Date: Sat, 2 Nov 2024 15:38:56 +0100 Subject: [PATCH 09/16] how the sausage was made --- software/badge_image/flash_badge.sh | 54 +++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 software/badge_image/flash_badge.sh diff --git a/software/badge_image/flash_badge.sh b/software/badge_image/flash_badge.sh new file mode 100755 index 0000000..db51846 --- /dev/null +++ b/software/badge_image/flash_badge.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# Mount Pico and copy firmware file + +FIRMWARE=./supercon_image.uf2 + +# Function to execute on new device +new_device () +{ + # First save the device to variable + DEVICE=$(echo $1 | cut -d'/' -f3) + + # Notify user + #echo "Found Device: $DEVICE" + + # Create mount point if it doesn't exist + mkdir -p /mnt/$DEVICE + + # Mount device + mount /dev/$DEVICE /mnt/$DEVICE + + # Copy firmware + cp $FIRMWARE /mnt/$DEVICE/ + + # Attempt unmount to force write + echo -n "Copying firmware to $DEVICE ..." + umount /mnt/$DEVICE + echo "Done" + + # Delete device node so we don't try to do it again + rm /dev/$DEVICE +} + +# Must have root permission +if [ "$EUID" -ne 0 ] + then echo "Must run as root or via sudo" + exit +fi + +# Start here +systemctl daemon-reload + +echo "Looking for new devices..." +echo "Hold BOOTSEL for 5 seconds while plugging in." + +# Loop through, looking for device files +while true + do + for I in `ls /dev/sd*1 2>/dev/null` + do new_device $I + done + sleep 5 +done + +# EOF From 87b32525f2e19b10c21c900a1e1991ab8069164a Mon Sep 17 00:00:00 2001 From: Tod Kurt Date: Sat, 2 Nov 2024 09:58:10 -0700 Subject: [PATCH 10/16] add touchwheel SAO to i2c address list --- i2c-addresses.md | 1 + 1 file changed, 1 insertion(+) diff --git a/i2c-addresses.md b/i2c-addresses.md index 817d694..676d4c4 100644 --- a/i2c-addresses.md +++ b/i2c-addresses.md @@ -12,6 +12,7 @@ If you have made an SAO that you are bringing, please add it to this list submit | 0x12 | I2C Proto Badge (default) | In firmware, change to whatever | | | 0x19 | Blinky Loop SAO | Can also use 0x18 | [hackaday.io](https://hackaday.io/project/198163-blinky-loop-sao) | | 0x1A | Hack-Man SAO | See project for commands | [hackaday.io](https://hackaday.io/project/198301-hack-man-sao) | +| 0x54 | TouchwheelSAO | Can change addr in Arduino src | [hackaday.io](https://hackaday.io/project/199100-touchwheelsao) | | 0x55 | Badge Tag NFC SAO | Can be changed in a register | [hackaday.io](https://hackaday.io/project/198165-badge-tag-nfc-sao) | | 0x6C | duckGLOW SAO | Change to 0x6C-06F w/ solder jumpers | [hackaday.io](https://hackaday.io/project/198918-duckglow-sao) | | 0x13 | Skull of Fate SAO | Can be changed. See doc. | [hackaday.io](https://hackaday.io/project/198974-skull-of-fate-sao) | From 2265114ba247a1938c9a1fe921e46448fb12e35a Mon Sep 17 00:00:00 2001 From: Alan Copeland Date: Sat, 2 Nov 2024 21:17:18 -0700 Subject: [PATCH 11/16] Add 'alpha_petal' to libraries. --- software/libraries/Alpha_Petal/README.md | 15 + software/libraries/Alpha_Petal/alpha_petal.py | 355 ++++++++++++++++++ 2 files changed, 370 insertions(+) create mode 100644 software/libraries/Alpha_Petal/README.md create mode 100644 software/libraries/Alpha_Petal/alpha_petal.py diff --git a/software/libraries/Alpha_Petal/README.md b/software/libraries/Alpha_Petal/README.md new file mode 100644 index 0000000..ac56789 --- /dev/null +++ b/software/libraries/Alpha_Petal/README.md @@ -0,0 +1,15 @@ +# Alpha Petal + +Displays a string on the SAO petal, one char at a time. the font is hand drawn and hard coded, crafted with love in the alley. The class needs to be initialized then can be passed a string consisting of [a-z] or space. There is no exception handling. + + +# Usage +### Initialization: +Initialize the class: +`ap = alpha_petal(petal_bus, PETAL_ADDRESS, time)` +### Displaying text +The `petal_string` function will not process uppercase. Any string passed will be displayed one letter at a time. spaces wipe and then wait to create temporal distance between words. I recommend ending with a space to delineate between iterations. + + while True: + pt.petal_string('alan supercon ') + diff --git a/software/libraries/Alpha_Petal/alpha_petal.py b/software/libraries/Alpha_Petal/alpha_petal.py new file mode 100644 index 0000000..00d5d1d --- /dev/null +++ b/software/libraries/Alpha_Petal/alpha_petal.py @@ -0,0 +1,355 @@ +class alpha_petal: + """ + Displays a string on the SAO petal, one char at a time. the font is hand drawn + and hard coded. The class needs to be initialized then can be passed a string + consisting of [a-z] or space. There is no exception handling. + """ + + def __init__(self, bus, addr, sleeper): + """ + Initializes the class. + + Args: + bus: which i2c bus the petal is on. shold be passed from the define in main + addr: the address of the petal. can be passed in as 0x00 or as the define from main + sleeper: the time import needs to be passed in for some reason, idk I don't write python + + returns: + none + """ + self.bus = bus + self.addr = addr + self.sleeper = sleeper + + def petal_letter_reset(self): + """ + mostly shamelessly stolen from the startup animation. used to 'wipe' the letters off and + as a break where spaces are + + args: + none + + returns: + none + """ + self.sleeper.sleep_ms(500) + for j in range(8): + which_leds = (1 << (j+1)) - 1 + for i in range(1,9): + #print(which_leds) + self.bus.writeto_mem(self.addr, i, bytes([which_leds])) + self.sleeper.sleep_ms(30) + self.bus.writeto_mem(self.addr, i, bytes([which_leds])) + self.bus.writeto_mem(self.addr, 0x01, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x0])) + + def petal_string(self,disp_str): + """ + This is the meat of the class, a monstrosity of ifs because micropython doesnt + have match. it loops through the string and displays each char, resets the + display and moves on to the next char. there is also some print statements to + help with debug that are vestigial. + + Args: + disp_str: the string you want to display, [a-z] only. spaces are a 2 second + pause. + + returns: + nothing + """ + for chr in disp_str: + if chr == 'a': + print("char was a") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x10])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0xE])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x3])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x5])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x11])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x7F])) + self.petal_letter_reset() + if chr == 'b': + print("char was b") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x1F])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x3])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x9])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x7F])) + self.petal_letter_reset() + if chr == 'c': + print("char was c") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x8])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x10])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x70])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x7C])) + self.petal_letter_reset() + if chr == 'd': + print("char was d") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x1F])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x1])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x1])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x1F])) + self.petal_letter_reset() + if chr == 'e': + print("char was e") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x1C])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x1])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x1])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x1])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x7F])) + self.petal_letter_reset() + if chr == 'f': + print("char was f") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x10])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x1])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x1])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x11])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x7F])) + self.petal_letter_reset() + if chr == 'g': + print("char was g") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x10])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x7F])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x8])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x7E])) + self.petal_letter_reset() + if chr == 'h': + print("char was h") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x10])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0xF])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x10])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0xF])) + self.petal_letter_reset() + if chr == 'i': + print("char was i") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x41])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x18])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x60])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x3])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x31])) + self.petal_letter_reset() + if chr == 'j': + print("char was j") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x41])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x78])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x3])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x71])) + self.petal_letter_reset() + if chr == 'k': + print("char was k") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x3])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x5])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x12])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x3])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x1])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x1F])) + self.petal_letter_reset() + if chr == 'l': + print("char was l") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x1C])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x8])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0xF])) + self.petal_letter_reset() + if chr == 'm': + print("char was m") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x5])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x8])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x40])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x1E])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x7])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x10])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0xF])) + self.petal_letter_reset() + if chr == 'n': + print("char was n") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x10])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0xF])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x3])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x5])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x12])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0xE])) + self.petal_letter_reset() + if chr == 'o': + print("char was o") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x8])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x8])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x8])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x8])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x8])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x8])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x8])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x8])) + self.petal_letter_reset() + if chr == 'p': + print("char was p") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x10])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x1])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x3])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x9])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x7F])) + self.petal_letter_reset() + if chr == 'q': + print("char was q") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x8])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x8])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x8])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0xE])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x68])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x8])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x8])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x8])) + self.petal_letter_reset() + if chr == 'r': + print("char was r") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x11])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x20])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x3])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x9])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x7F])) + self.petal_letter_reset() + if chr == 's': + print("char was s") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x7F])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x10])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x7F])) + self.petal_letter_reset() + if chr == 't': + print("char was t") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x21])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x8])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x40])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x1F])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x8])) + self.petal_letter_reset() + if chr == 'u': + print("char was u") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x10])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x7E])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x10])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0xF])) + self.petal_letter_reset() + if chr == 'v': + print("char was v") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0xF])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x41])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x10])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x0])) + self.petal_letter_reset() + if chr == 'w': + print("char was w") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x1])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0xD])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x22])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0xE])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x10])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x0])) + self.petal_letter_reset() + if chr == 'x': + print("char was x") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x21])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x21])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x21])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x21])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x4])) + self.petal_letter_reset() + if chr == 'y': + print("char was y") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x21])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x2])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x8])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x40])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x3])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x11])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x4])) + self.petal_letter_reset() + if chr == 'z': + print("char was z") + self.bus.writeto_mem(self.addr, 0x01, bytes([0x12])) + self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x03, bytes([0x1C])) + self.bus.writeto_mem(self.addr, 0x04, bytes([0x4])) + self.bus.writeto_mem(self.addr, 0x05, bytes([0x10])) + self.bus.writeto_mem(self.addr, 0x06, bytes([0x3])) + self.bus.writeto_mem(self.addr, 0x07, bytes([0x1C])) + self.bus.writeto_mem(self.addr, 0x08, bytes([0x9])) + self.petal_letter_reset() + if chr == ' ': + self.petal_letter_reset() + self.petal_letter_reset() From cbe09f1a865e5c4815eb34b8f18c792b2dfb02c9 Mon Sep 17 00:00:00 2001 From: Alan Copeland Date: Sun, 3 Nov 2024 01:42:44 -0700 Subject: [PATCH 12/16] add rotation capability and slot selection for supercon 8 badge --- software/libraries/Alpha_Petal/alpha_petal.py | 685 ++++++++++-------- 1 file changed, 380 insertions(+), 305 deletions(-) diff --git a/software/libraries/Alpha_Petal/alpha_petal.py b/software/libraries/Alpha_Petal/alpha_petal.py index 00d5d1d..2a90af1 100644 --- a/software/libraries/Alpha_Petal/alpha_petal.py +++ b/software/libraries/Alpha_Petal/alpha_petal.py @@ -1,10 +1,11 @@ +import time class alpha_petal: """ Displays a string on the SAO petal, one char at a time. the font is hand drawn and hard coded. The class needs to be initialized then can be passed a string consisting of [a-z] or space. There is no exception handling. """ - + def __init__(self, bus, addr, sleeper): """ Initializes the class. @@ -19,8 +20,80 @@ def __init__(self, bus, addr, sleeper): """ self.bus = bus self.addr = addr + self.memx = [1,2,3,4,5,6,7,8] self.sleeper = sleeper - + self.rot = 0 + + def set_slot(self, slot): + """ + The font is originally designed to be in slot 1. if you're using the SAO in a different slot on the 2024 supercon + badge, you can call this function and you don't have to figure out rotation yourself. if its on a different badge + check out the set_rotation function. + + Args: + slot: int 1-6 + + Returns: + none + """ + if slot == 1: + self.rot = 0 + if slot == 2: + self.rot = 1 + if slot == 3: + self.rot = 2 + if slot == 4: + self.rot = 4 + if slot == 5: + self.rot = 5 + if slot == 6: + self.rot = 6 + self.rot %= 8 + + def set_rotation(self, rot): + """ + sets the rotation of the text displayed on the petal. there are 8 possible orientations 0-7. + each rotation moves 45* anti-clockwise + + + Args: + rot: int [0-7] this will be mod 8, so really any number can be used. + + Returns: + none + """ + self.rot = rot + self.rot %= 8 + + def rotate_string(self, disp_str): + """ + this function takes in a string and rotates 45* after every letter. the rotation is saved across calls and is shared with + the rest of the class, so a call to set_rotation will affect the starting point of this function + + Args: + disp_str: [a-z] and space. string of lowercase letters to display + + Returns: + none + """ + for chr in disp_str: + self.petal_char(chr) + self.rot += 1 + self.rot %= 8 + + def disp_string(self, disp_str): + """ + displays a string one char at a time. spaces are processed as a double reset to delinate words. + + Args: + disp_str: [a-z] and space. string of lowercase letters to display + + Returns: + none + """ + for chr in disp_str: + self.petal_char(chr) + def petal_letter_reset(self): """ mostly shamelessly stolen from the startup animation. used to 'wipe' the letters off and @@ -40,316 +113,318 @@ def petal_letter_reset(self): self.bus.writeto_mem(self.addr, i, bytes([which_leds])) self.sleeper.sleep_ms(30) self.bus.writeto_mem(self.addr, i, bytes([which_leds])) - self.bus.writeto_mem(self.addr, 0x01, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x0])) - def petal_string(self,disp_str): + def petal_char(self, chr): """ This is the meat of the class, a monstrosity of ifs because micropython doesnt - have match. it loops through the string and displays each char, resets the - display and moves on to the next char. there is also some print statements to - help with debug that are vestigial. + have match. it displays a char then resets the display. there is also some print statements to + help with debug that are vestigial. If you want to use this by itself for some reason, be my + guest but it is implimented elsewhere to display strings. Args: - disp_str: the string you want to display, [a-z] only. spaces are a 2 second + chr: the char you want to display, [a-z] only. spaces are a 2 second pause. returns: nothing """ - for chr in disp_str: - if chr == 'a': - print("char was a") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x10])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0xE])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x3])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x5])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x11])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x7F])) - self.petal_letter_reset() - if chr == 'b': - print("char was b") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x1F])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x3])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x9])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x7F])) - self.petal_letter_reset() - if chr == 'c': - print("char was c") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x8])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x10])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x70])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x7C])) - self.petal_letter_reset() - if chr == 'd': - print("char was d") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x1F])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x1])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x1])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x1F])) - self.petal_letter_reset() - if chr == 'e': - print("char was e") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x1C])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x1])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x1])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x1])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x7F])) - self.petal_letter_reset() - if chr == 'f': - print("char was f") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x10])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x1])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x1])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x11])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x7F])) - self.petal_letter_reset() - if chr == 'g': - print("char was g") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x10])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x7F])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x8])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x7E])) - self.petal_letter_reset() - if chr == 'h': - print("char was h") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x10])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0xF])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x10])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0xF])) - self.petal_letter_reset() - if chr == 'i': - print("char was i") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x41])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x18])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x60])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x3])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x31])) - self.petal_letter_reset() - if chr == 'j': - print("char was j") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x41])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x78])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x3])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x71])) - self.petal_letter_reset() - if chr == 'k': - print("char was k") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x3])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x5])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x12])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x3])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x1])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x1F])) - self.petal_letter_reset() - if chr == 'l': - print("char was l") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x1C])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x8])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0xF])) - self.petal_letter_reset() - if chr == 'm': - print("char was m") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x5])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x8])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x40])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x1E])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x7])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x10])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0xF])) - self.petal_letter_reset() - if chr == 'n': - print("char was n") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x10])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0xF])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x3])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x5])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x12])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0xE])) - self.petal_letter_reset() - if chr == 'o': - print("char was o") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x8])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x8])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x8])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x8])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x8])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x8])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x8])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x8])) - self.petal_letter_reset() - if chr == 'p': - print("char was p") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x10])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x1])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x3])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x9])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x7F])) - self.petal_letter_reset() - if chr == 'q': - print("char was q") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x8])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x8])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x8])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0xE])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x68])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x8])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x8])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x8])) - self.petal_letter_reset() - if chr == 'r': - print("char was r") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x11])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x20])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x3])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x9])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x7F])) - self.petal_letter_reset() - if chr == 's': - print("char was s") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x7F])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x10])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x7F])) - self.petal_letter_reset() - if chr == 't': - print("char was t") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x21])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x8])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x40])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x1F])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x8])) - self.petal_letter_reset() - if chr == 'u': - print("char was u") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x10])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x7E])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x10])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0xF])) - self.petal_letter_reset() - if chr == 'v': - print("char was v") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0xF])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x41])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x10])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x0])) - self.petal_letter_reset() - if chr == 'w': - print("char was w") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x1])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0xD])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x22])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0xE])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x10])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x0])) - self.petal_letter_reset() - if chr == 'x': - print("char was x") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x21])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x21])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x21])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x21])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x4])) - self.petal_letter_reset() - if chr == 'y': - print("char was y") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x21])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x2])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x8])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x40])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x0])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x3])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x11])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x4])) - self.petal_letter_reset() - if chr == 'z': - print("char was z") - self.bus.writeto_mem(self.addr, 0x01, bytes([0x12])) - self.bus.writeto_mem(self.addr, 0x02, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x03, bytes([0x1C])) - self.bus.writeto_mem(self.addr, 0x04, bytes([0x4])) - self.bus.writeto_mem(self.addr, 0x05, bytes([0x10])) - self.bus.writeto_mem(self.addr, 0x06, bytes([0x3])) - self.bus.writeto_mem(self.addr, 0x07, bytes([0x1C])) - self.bus.writeto_mem(self.addr, 0x08, bytes([0x9])) - self.petal_letter_reset() - if chr == ' ': - self.petal_letter_reset() - self.petal_letter_reset() + self.memx = [1,2,3,4,5,6,7,8] + self.rot %= 8 + self.memx[:] = self.memx[-self.rot:] + self.memx[:-self.rot] + if chr == 'a': + print("char was a") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x10])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0xE])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x3])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x5])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x11])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x7F])) + self.petal_letter_reset() + if chr == 'b': + print("char was b") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x1F])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x3])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x9])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x7F])) + self.petal_letter_reset() + if chr == 'c': + print("char was c") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x8])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x10])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x70])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x7C])) + self.petal_letter_reset() + if chr == 'd': + print("char was d") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x1F])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x1])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x1])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x1F])) + self.petal_letter_reset() + if chr == 'e': + print("char was e") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x1C])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x1])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x1])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x1])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x7F])) + self.petal_letter_reset() + if chr == 'f': + print("char was f") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x10])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x1])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x1])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x11])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x7F])) + self.petal_letter_reset() + if chr == 'g': + print("char was g") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x10])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x7F])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x8])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x7E])) + self.petal_letter_reset() + if chr == 'h': + print("char was h") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x10])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0xF])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x10])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0xF])) + self.petal_letter_reset() + if chr == 'i': + print("char was i") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x41])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x18])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x60])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x3])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x31])) + self.petal_letter_reset() + if chr == 'j': + print("char was j") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x41])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x78])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x3])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x71])) + self.petal_letter_reset() + if chr == 'k': + print("char was k") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x3])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x5])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x12])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x3])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x1])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x1F])) + self.petal_letter_reset() + if chr == 'l': + print("char was l") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x1C])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x8])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0xF])) + self.petal_letter_reset() + if chr == 'm': + print("char was m") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x5])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x8])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x40])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x1E])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x7])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x10])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0xF])) + self.petal_letter_reset() + if chr == 'n': + print("char was n") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x10])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0xF])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x3])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x5])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x12])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0xE])) + self.petal_letter_reset() + if chr == 'o': + print("char was o") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x8])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x8])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x8])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x8])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x8])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x8])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x8])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x8])) + self.petal_letter_reset() + if chr == 'p': + print("char was p") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x10])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x1])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x3])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x9])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x7F])) + self.petal_letter_reset() + if chr == 'q': + print("char was q") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x8])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x8])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x8])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0xE])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x68])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x8])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x8])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x8])) + self.petal_letter_reset() + if chr == 'r': + print("char was r") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x11])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x20])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x3])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x9])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x7F])) + self.petal_letter_reset() + if chr == 's': + print("char was s") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x7F])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x10])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x7F])) + self.petal_letter_reset() + if chr == 't': + print("char was t") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x21])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x8])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x40])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x1F])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x8])) + self.petal_letter_reset() + if chr == 'u': + print("char was u") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x10])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x7E])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x10])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0xF])) + self.petal_letter_reset() + if chr == 'v': + print("char was v") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0xF])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x41])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x10])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x0])) + self.petal_letter_reset() + if chr == 'w': + print("char was w") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x1])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0xD])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x22])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0xE])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x10])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x0])) + self.petal_letter_reset() + if chr == 'x': + print("char was x") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x21])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x21])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x21])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x21])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x4])) + self.petal_letter_reset() + if chr == 'y': + print("char was y") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x21])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x2])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x8])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x40])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x0])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x3])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x11])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x4])) + self.petal_letter_reset() + if chr == 'z': + print("char was z") + self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x12])) + self.bus.writeto_mem(self.addr, self.memx[1], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[2], bytes([0x1C])) + self.bus.writeto_mem(self.addr, self.memx[3], bytes([0x4])) + self.bus.writeto_mem(self.addr, self.memx[4], bytes([0x10])) + self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x3])) + self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x1C])) + self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x9])) + self.petal_letter_reset() + if chr == ' ': + self.petal_letter_reset() + self.petal_letter_reset() From 6baa0dc6d816d4c32569122967313f997096859e Mon Sep 17 00:00:00 2001 From: Alan Copeland Date: Sun, 3 Nov 2024 01:56:37 -0700 Subject: [PATCH 13/16] clean up documentation --- software/libraries/Alpha_Petal/README.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/software/libraries/Alpha_Petal/README.md b/software/libraries/Alpha_Petal/README.md index ac56789..94f777e 100644 --- a/software/libraries/Alpha_Petal/README.md +++ b/software/libraries/Alpha_Petal/README.md @@ -7,9 +7,16 @@ Displays a string on the SAO petal, one char at a time. the font is hand drawn a ### Initialization: Initialize the class: `ap = alpha_petal(petal_bus, PETAL_ADDRESS, time)` -### Displaying text -The `petal_string` function will not process uppercase. Any string passed will be displayed one letter at a time. spaces wipe and then wait to create temporal distance between words. I recommend ending with a space to delineate between iterations. - while True: - pt.petal_string('alan supercon ') +### Functions +`set_slot(slot:int[1-6])` This wraps the `set_rotation` function allowing you to specify a slot on the badge. 1,2,5,6 are recommended. +`set_rotation(rotation:int[0-7])` This allows you to natively set the rotation, [0-7], 45* incriments +`rotate_string(string:string)` This displays a string, rotating 45* between each char +`disp_string(string:string)` This displays a string, should be called after `set_rotation` or `set_slot` +`petal_letter_reset()` This is used internally to wipe letters +`petal_char(char:char)` This is used internally to display a single char and then wipe it away +### Usage +To just display text: +`set_rotation(0) #not strictly needed, but it's best to clean up` +`disp_string('your string ') #the trailing space is important to delinate between the trailing 'g' and leading 'y'` \ No newline at end of file From e5c6f92a7d831da1b898198d8eb87f35c18cbca8 Mon Sep 17 00:00:00 2001 From: Alan Copeland Date: Sun, 3 Nov 2024 01:57:24 -0700 Subject: [PATCH 14/16] Move char reset to bottom of petal_char --- software/libraries/Alpha_Petal/alpha_petal.py | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/software/libraries/Alpha_Petal/alpha_petal.py b/software/libraries/Alpha_Petal/alpha_petal.py index 2a90af1..8c3877c 100644 --- a/software/libraries/Alpha_Petal/alpha_petal.py +++ b/software/libraries/Alpha_Petal/alpha_petal.py @@ -149,7 +149,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x5])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x11])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x7F])) - self.petal_letter_reset() + if chr == 'b': print("char was b") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) @@ -160,7 +160,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x3])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x9])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x7F])) - self.petal_letter_reset() + if chr == 'c': print("char was c") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x4])) @@ -171,7 +171,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x0])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x0])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x7C])) - self.petal_letter_reset() + if chr == 'd': print("char was d") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) @@ -182,7 +182,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x2])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x4])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x1F])) - self.petal_letter_reset() + if chr == 'e': print("char was e") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) @@ -193,7 +193,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x1])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x1])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x7F])) - self.petal_letter_reset() + if chr == 'f': print("char was f") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) @@ -204,7 +204,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x1])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x11])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x7F])) - self.petal_letter_reset() + if chr == 'g': print("char was g") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) @@ -215,7 +215,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x0])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x8])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x7E])) - self.petal_letter_reset() + if chr == 'h': print("char was h") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) @@ -226,7 +226,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x4])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x10])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0xF])) - self.petal_letter_reset() + if chr == 'i': print("char was i") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x41])) @@ -237,7 +237,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x0])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x3])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x31])) - self.petal_letter_reset() + if chr == 'j': print("char was j") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x41])) @@ -248,7 +248,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x0])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x3])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x71])) - self.petal_letter_reset() + if chr == 'k': print("char was k") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x3])) @@ -259,7 +259,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x3])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x1])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x1F])) - self.petal_letter_reset() + if chr == 'l': print("char was l") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) @@ -270,7 +270,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x0])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x0])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0xF])) - self.petal_letter_reset() + if chr == 'm': print("char was m") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x5])) @@ -281,7 +281,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x7])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x10])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0xF])) - self.petal_letter_reset() + if chr == 'n': print("char was n") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) @@ -292,7 +292,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x5])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x12])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0xE])) - self.petal_letter_reset() + if chr == 'o': print("char was o") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x8])) @@ -303,7 +303,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x8])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x8])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x8])) - self.petal_letter_reset() + if chr == 'p': print("char was p") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) @@ -314,7 +314,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x3])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x9])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x7F])) - self.petal_letter_reset() + if chr == 'q': print("char was q") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x8])) @@ -325,7 +325,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x8])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x8])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x8])) - self.petal_letter_reset() + if chr == 'r': print("char was r") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) @@ -336,7 +336,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x3])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x9])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x7F])) - self.petal_letter_reset() + if chr == 's': print("char was s") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x0])) @@ -347,7 +347,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x0])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x10])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x7F])) - self.petal_letter_reset() + if chr == 't': print("char was t") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x21])) @@ -358,7 +358,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x0])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x1F])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x8])) - self.petal_letter_reset() + if chr == 'u': print("char was u") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) @@ -369,7 +369,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x4])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x10])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0xF])) - self.petal_letter_reset() + if chr == 'v': print("char was v") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) @@ -380,7 +380,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x4])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x10])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x0])) - self.petal_letter_reset() + if chr == 'w': print("char was w") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x1])) @@ -391,7 +391,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x4])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x10])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x0])) - self.petal_letter_reset() + if chr == 'x': print("char was x") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x21])) @@ -402,7 +402,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x4])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x21])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x4])) - self.petal_letter_reset() + if chr == 'y': print("char was y") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x21])) @@ -413,7 +413,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x3])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x11])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x4])) - self.petal_letter_reset() + if chr == 'z': print("char was z") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x12])) @@ -424,7 +424,7 @@ def petal_char(self, chr): self.bus.writeto_mem(self.addr, self.memx[5], bytes([0x3])) self.bus.writeto_mem(self.addr, self.memx[6], bytes([0x1C])) self.bus.writeto_mem(self.addr, self.memx[7], bytes([0x9])) - self.petal_letter_reset() + if chr == ' ': self.petal_letter_reset() - self.petal_letter_reset() + self.petal_letter_reset() \ No newline at end of file From 87346afb0bd4902c7c93483b7bf06929548e28a4 Mon Sep 17 00:00:00 2001 From: Alan Copeland <85801702+Nutsandbolts800@users.noreply.github.com> Date: Sun, 3 Nov 2024 01:58:57 -0700 Subject: [PATCH 15/16] update readme on alpha_petal --- software/libraries/Alpha_Petal/README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/software/libraries/Alpha_Petal/README.md b/software/libraries/Alpha_Petal/README.md index 94f777e..ecf9227 100644 --- a/software/libraries/Alpha_Petal/README.md +++ b/software/libraries/Alpha_Petal/README.md @@ -10,13 +10,20 @@ Initialize the class: ### Functions `set_slot(slot:int[1-6])` This wraps the `set_rotation` function allowing you to specify a slot on the badge. 1,2,5,6 are recommended. + `set_rotation(rotation:int[0-7])` This allows you to natively set the rotation, [0-7], 45* incriments + `rotate_string(string:string)` This displays a string, rotating 45* between each char + `disp_string(string:string)` This displays a string, should be called after `set_rotation` or `set_slot` + `petal_letter_reset()` This is used internally to wipe letters + `petal_char(char:char)` This is used internally to display a single char and then wipe it away ### Usage To just display text: + `set_rotation(0) #not strictly needed, but it's best to clean up` -`disp_string('your string ') #the trailing space is important to delinate between the trailing 'g' and leading 'y'` \ No newline at end of file + +`disp_string('your string ') #the trailing space is important to delinate between the trailing 'g' and leading 'y'` From 0296acdbf95665d0abf98d14cc41224fa7c128d2 Mon Sep 17 00:00:00 2001 From: Alan Copeland Date: Sun, 3 Nov 2024 11:14:46 -0800 Subject: [PATCH 16/16] Add touchwheel support to alpha_petal. add documentation for touchwheel-alpha_petal integration. --- software/libraries/Alpha_Petal/README.md | 10 +++++- software/libraries/Alpha_Petal/alpha_petal.py | 33 ++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/software/libraries/Alpha_Petal/README.md b/software/libraries/Alpha_Petal/README.md index ecf9227..02c9f17 100644 --- a/software/libraries/Alpha_Petal/README.md +++ b/software/libraries/Alpha_Petal/README.md @@ -21,9 +21,17 @@ Initialize the class: `petal_char(char:char)` This is used internally to display a single char and then wipe it away +`touchwheel_string(disp_str:string, touchwheel_bus:bus)` This displays a string which can be rotated with the touchwheel. + ### Usage -To just display text: +#### To just display text: `set_rotation(0) #not strictly needed, but it's best to clean up` `disp_string('your string ') #the trailing space is important to delinate between the trailing 'g' and leading 'y'` + +#### Display text that rotates: + +Automatically: `rotate_string('your string ')` + +Based on touchwheel: `touchwheel_string('your string ', touchwheel_bus)` \ No newline at end of file diff --git a/software/libraries/Alpha_Petal/alpha_petal.py b/software/libraries/Alpha_Petal/alpha_petal.py index 8c3877c..a8daf63 100644 --- a/software/libraries/Alpha_Petal/alpha_petal.py +++ b/software/libraries/Alpha_Petal/alpha_petal.py @@ -23,6 +23,18 @@ def __init__(self, bus, addr, sleeper): self.memx = [1,2,3,4,5,6,7,8] self.sleeper = sleeper self.rot = 0 + + def touchwheel_read(self, bus): + """Returns 0 for no touch, 1-255 clockwise around the circle from the south + + Args: + bus: this is passed in from the calling function and shold be the i2c bus the touch wheel is on + + Returns: + none + + """ + return(bus.readfrom_mem(84, 0, 1)[0]) def set_slot(self, slot): """ @@ -93,6 +105,23 @@ def disp_string(self, disp_str): """ for chr in disp_str: self.petal_char(chr) + + def touchwheel_string(self, disp_str, touchwheel_bus): + """ + displays a string one char at a time but each char is rotated based on the touch of the touchwheel. + + Args: + string: [a-z] and space. string of lowercase letters to display + touchwheel_bus: pass this in from main + Returns: + none + """ + for chr in disp_str: + tw = self.touchwheel_read(touchwheel_bus) #0 for no touch; 1-255 for touch + if tw != 0: + self.rot = tw/32 + self.rot %= 8 + self.petal_char(chr) def petal_letter_reset(self): """ @@ -138,7 +167,9 @@ def petal_char(self, chr): """ self.memx = [1,2,3,4,5,6,7,8] self.rot %= 8 + self.rot = int(self.rot) self.memx[:] = self.memx[-self.rot:] + self.memx[:-self.rot] + print(f'rotation after converstion to int... {self.rot}') if chr == 'a': print("char was a") self.bus.writeto_mem(self.addr, self.memx[0], bytes([0x2])) @@ -427,4 +458,4 @@ def petal_char(self, chr): if chr == ' ': self.petal_letter_reset() - self.petal_letter_reset() \ No newline at end of file + self.petal_letter_reset()