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-addresses.md b/i2c-addresses.md index 48843f3..676d4c4 100644 --- a/i2c-addresses.md +++ b/i2c-addresses.md @@ -12,5 +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) | diff --git a/i2c_proto_petal_tutorial/demo_binaries/blink.bin b/i2c_proto_petal_tutorial/demo_binaries/blink.bin new file mode 100755 index 0000000..d0a9bd7 Binary files /dev/null and b/i2c_proto_petal_tutorial/demo_binaries/blink.bin differ diff --git a/i2c_proto_petal_tutorial/demo_binaries/blink2.bin b/i2c_proto_petal_tutorial/demo_binaries/blink2.bin new file mode 100755 index 0000000..da20cee Binary files /dev/null and b/i2c_proto_petal_tutorial/demo_binaries/blink2.bin differ diff --git a/i2c_proto_petal_tutorial/pico_ch32v003_prog b/i2c_proto_petal_tutorial/pico_ch32v003_prog new file mode 160000 index 0000000..b27aed7 --- /dev/null +++ b/i2c_proto_petal_tutorial/pico_ch32v003_prog @@ -0,0 +1 @@ +Subproject commit b27aed77272f5a6784cd8eae403d3d86f6571f0e 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 diff --git a/software/libraries/Alpha_Petal/README.md b/software/libraries/Alpha_Petal/README.md new file mode 100644 index 0000000..02c9f17 --- /dev/null +++ b/software/libraries/Alpha_Petal/README.md @@ -0,0 +1,37 @@ +# 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)` + +### 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 + +`touchwheel_string(disp_str:string, touchwheel_bus:bus)` This displays a string which can be rotated with the touchwheel. + +### 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'` + +#### 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 new file mode 100644 index 0000000..a8daf63 --- /dev/null +++ b/software/libraries/Alpha_Petal/alpha_petal.py @@ -0,0 +1,461 @@ +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. + + 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.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): + """ + 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 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): + """ + 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, 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_char(self, chr): + """ + This is the meat of the class, a monstrosity of ifs because micropython doesnt + 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: + chr: the char you want to display, [a-z] only. spaces are a 2 second + pause. + + returns: + nothing + """ + 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])) + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + 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])) + + if chr == ' ': + self.petal_letter_reset() + self.petal_letter_reset() diff --git a/software/software/main.py b/software/software/main.py index b147ad5..8ab9f78 100644 --- a/software/software/main.py +++ b/software/software/main.py @@ -55,8 +55,14 @@ # Write updated values to board. for i in range(1,9): - petal_bus.writeto_mem(PETAL_ADDRESS, i, bytes([led_state[i]])) - - time.sleep_ms(20) + + if i == petal: + petal_bus.writeto_mem(0, i, bytes([0x7F])) + else: + petal_bus.writeto_mem(0, i, bytes([0x00])) + + + + time.sleep_ms(100) bootLED.off()