-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
59bd0ec
commit f8ab179
Showing
8 changed files
with
2,392 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import ST7789 | ||
import spidev as SPI | ||
import RPi.GPIO as GPIO | ||
|
||
import time | ||
import subprocess | ||
|
||
from PIL import Image | ||
from PIL import ImageDraw | ||
from PIL import ImageFont | ||
|
||
from embit.bip39 import mnemonic_to_bytes | ||
from embit.bip39 import mnemonic_from_bytes | ||
|
||
#GPIO define | ||
RST_PIN = 25 | ||
CS_PIN = 8 | ||
DC_PIN = 24 | ||
|
||
KEY_UP_PIN = 6 | ||
KEY_DOWN_PIN = 19 | ||
KEY_LEFT_PIN = 5 | ||
KEY_RIGHT_PIN = 26 | ||
KEY_PRESS_PIN = 13 | ||
|
||
KEY1_PIN = 21 | ||
KEY2_PIN = 20 | ||
KEY3_PIN = 16 | ||
|
||
RST = 27 | ||
DC = 25 | ||
BL = 24 | ||
bus = 0 | ||
device = 0 | ||
|
||
#init GPIO | ||
GPIO.setmode(GPIO.BCM) | ||
GPIO.setup(KEY_UP_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up | ||
GPIO.setup(KEY_DOWN_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up | ||
GPIO.setup(KEY_LEFT_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up | ||
GPIO.setup(KEY_RIGHT_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up | ||
GPIO.setup(KEY_PRESS_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up | ||
GPIO.setup(KEY1_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up | ||
GPIO.setup(KEY2_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up | ||
GPIO.setup(KEY3_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up | ||
|
||
#initialize fonts | ||
impact18 = ImageFont.truetype('/usr/share/fonts/truetype/msttcorefonts/Impact.ttf', 18) | ||
impact23 = ImageFont.truetype('/usr/share/fonts/truetype/msttcorefonts/Impact.ttf', 23) | ||
impact50 = ImageFont.truetype('/usr/share/fonts/truetype/msttcorefonts/Impact.ttf', 50) | ||
|
||
# 240x240 display with hardware SPI: | ||
disp = ST7789.ST7789(SPI.SpiDev(bus, device),RST, DC, BL) | ||
disp.Init() | ||
|
||
# Create blank image for drawing. | ||
# Make sure to create image with mode '1' for 1-bit color. | ||
width = 240 | ||
height = 240 | ||
image = Image.new('RGB', (width, height)) | ||
|
||
# Get drawing object to draw on image. | ||
draw = ImageDraw.Draw(image) | ||
|
||
def displayfinalword(word24): | ||
finalwordwidth, finalwordheight = draw.textsize(word24, font=impact50) | ||
|
||
draw.rectangle((0, 0, width, height), outline=0, fill=0) | ||
|
||
draw.text((65, 60), "Word 24 is :", fill="ORANGE", font=impact23) | ||
draw.text(((240-finalwordwidth)/2, 90), word24, fill="ORANGE", font=impact50) | ||
|
||
draw.text((73, 210), "RIGHT to EXIT", fill="ORANGE", font=impact18) | ||
|
||
disp.ShowImage(image, 0, 0) | ||
|
||
def get_word_24(runstate): | ||
localrunstate = runstate | ||
|
||
stringphrase = localrunstate[1] + " abandon" | ||
|
||
bytes = mnemonic_to_bytes(stringphrase, ignore_checksum=True) | ||
|
||
finalseed = mnemonic_from_bytes(bytes) | ||
|
||
splitseed = finalseed.split() | ||
|
||
word24 = splitseed[-1] | ||
|
||
displayword24runstate = 1 | ||
while displayword24runstate == 1: | ||
displayfinalword(word24) | ||
if GPIO.input(KEY_RIGHT_PIN) == GPIO.LOW: # button is released | ||
time.sleep(0.1) | ||
displayword24runstate = 0 | ||
|
||
localrunstate[0] = 0 | ||
localrunstate[1] = "" | ||
return localrunstate |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
import ST7789 | ||
import spidev as SPI | ||
import RPi.GPIO as GPIO | ||
|
||
import time | ||
import subprocess | ||
|
||
from PIL import Image | ||
from PIL import ImageDraw | ||
from PIL import ImageFont | ||
|
||
from imutils.video import VideoStream | ||
from pyzbar import pyzbar | ||
import argparse | ||
import datetime | ||
import imutils | ||
import time | ||
import cv2 | ||
|
||
#GPIO define | ||
RST_PIN = 25 | ||
CS_PIN = 8 | ||
DC_PIN = 24 | ||
|
||
KEY_UP_PIN = 6 | ||
KEY_DOWN_PIN = 19 | ||
KEY_LEFT_PIN = 5 | ||
KEY_RIGHT_PIN = 26 | ||
KEY_PRESS_PIN = 13 | ||
|
||
KEY1_PIN = 21 | ||
KEY2_PIN = 20 | ||
KEY3_PIN = 16 | ||
|
||
RST = 27 | ||
DC = 25 | ||
BL = 24 | ||
bus = 0 | ||
device = 0 | ||
|
||
#init GPIO | ||
GPIO.setmode(GPIO.BCM) | ||
GPIO.setup(KEY_UP_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up | ||
GPIO.setup(KEY_DOWN_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up | ||
GPIO.setup(KEY_LEFT_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up | ||
GPIO.setup(KEY_RIGHT_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up | ||
GPIO.setup(KEY_PRESS_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up | ||
GPIO.setup(KEY1_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up | ||
GPIO.setup(KEY2_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up | ||
GPIO.setup(KEY3_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up | ||
|
||
# 240x240 display with hardware SPI: | ||
disp = ST7789.ST7789(SPI.SpiDev(bus, device),RST, DC, BL) | ||
disp.Init() | ||
|
||
# Create blank image for drawing. | ||
# Make sure to create image with mode '1' for 1-bit color. | ||
width = 240 | ||
height = 240 | ||
image = Image.new('RGB', (width, height)) | ||
|
||
# Get drawing object to draw on image. | ||
draw = ImageDraw.Draw(image) | ||
|
||
impact18 = ImageFont.truetype('/usr/share/fonts/truetype/msttcorefonts/Impact.ttf', 18) | ||
impact22 = ImageFont.truetype('/usr/share/fonts/truetype/msttcorefonts/Impact.ttf', 22) | ||
|
||
def iotestscreen(runstate): | ||
localrunstate = runstate | ||
|
||
draw.rectangle((0,0,width,height), outline=0, fill=0) | ||
draw.text((45, 5), "Input/Output Check:", fill="ORANGE", font=impact18) | ||
draw.polygon([(61, 89), (80, 46), (99, 89)], outline="ORANGE", fill=0) | ||
draw.polygon([(51, 100), (8, 119), (51, 138)], outline="ORANGE", fill=0) | ||
draw.polygon([(109, 100), (152, 119), (109, 138)], outline="ORANGE", fill=0) | ||
draw.polygon([(61, 151), (80, 193), (99, 151)], outline="ORANGE", fill=0) | ||
draw.ellipse([(61, 99), (99, 141)], outline="ORANGE", fill=0) | ||
draw.ellipse([(198, 40), (238, 80)], outline="ORANGE", fill=0) | ||
draw.ellipse([(198, 95), (238, 135)], outline="ORANGE", fill=0) | ||
draw.text((200, 160), "EXIT", fill="ORANGE", font=impact18) | ||
prescantext = "Scan ANY QR Code" | ||
textwidth, textheight = draw.textsize(prescantext, font=impact22) | ||
draw.text(((240 - textwidth) / 2, 205), prescantext, fill="ORANGE", font=impact22) | ||
disp.ShowImage(image, 0, 0) | ||
|
||
running = True | ||
|
||
scannedqrs = 0 | ||
vs = VideoStream(usePiCamera=True).start() # For Pi Camera | ||
time.sleep(2.0) | ||
|
||
while running == True: | ||
frame = vs.read() | ||
frame = imutils.resize(frame, width=400) | ||
barcodes = pyzbar.decode(frame) | ||
for barcode in barcodes: | ||
scannedqrs += 1 | ||
#time.sleep(0.1) | ||
#time.sleep(0.05) | ||
|
||
draw.rectangle((0, 0, width, height), outline=0, fill=0) | ||
draw.text((45, 5), "Input/Output Check:", fill="ORANGE", font=impact18) | ||
|
||
if GPIO.input(KEY_UP_PIN) == GPIO.LOW: # button is released | ||
#time.sleep(0.1) | ||
draw.polygon([(61, 89), (80, 46), (99, 89)], outline="ORANGE", fill="ORANGE") | ||
else: # button is pressed: | ||
draw.polygon([(61, 89), (80, 46), (99, 89)], outline="ORANGE", fill=0) | ||
|
||
if GPIO.input(KEY_LEFT_PIN) == GPIO.LOW: # button is released | ||
#time.sleep(0.1) | ||
draw.polygon([(51, 100), (8, 119), (51, 138)], outline="ORANGE", fill="ORANGE") | ||
else: # button is pressed: | ||
draw.polygon([(51, 100), (8, 119), (51, 138)], outline="ORANGE", fill=0) | ||
|
||
if GPIO.input(KEY_RIGHT_PIN) == GPIO.LOW: # button is released | ||
#time.sleep(0.1) | ||
draw.polygon([(109, 100), (152, 119), (109, 138)], outline="ORANGE", fill="ORANGE") | ||
else: # button is pressed: | ||
draw.polygon([(109, 100), (152, 119), (109, 138)], outline="ORANGE", fill=0) | ||
|
||
if GPIO.input(KEY_DOWN_PIN) == GPIO.LOW: # button is released | ||
#time.sleep(0.1) | ||
draw.polygon([(61, 151), (80, 193), (99, 151)], outline="ORANGE", fill="ORANGE") | ||
else: # button is pressed: | ||
draw.polygon([(61, 151), (80, 193), (99, 151)], outline="ORANGE", fill=0) | ||
|
||
if GPIO.input(KEY_PRESS_PIN) == GPIO.LOW: # button is released | ||
#time.sleep(0.1) | ||
draw.ellipse([(61, 99), (99, 141)], outline="ORANGE", fill="ORANGE") | ||
else: # button is pressed: | ||
draw.ellipse([(61, 99), (99, 141)], outline="ORANGE", fill=0) | ||
|
||
if GPIO.input(KEY1_PIN) == GPIO.LOW: # button is released | ||
#time.sleep(0.1) | ||
draw.ellipse([(198, 40), (238, 80)], outline="ORANGE", fill="ORANGE") | ||
else: # button is pressed: | ||
draw.ellipse([(198, 40), (238, 80)], outline="ORANGE", fill=0) | ||
|
||
if GPIO.input(KEY2_PIN) == GPIO.LOW: # button is released | ||
#time.sleep(0.1) | ||
draw.ellipse([(198, 95), (238, 135)], outline="ORANGE", fill="ORANGE") | ||
else: # button is pressed: | ||
draw.ellipse([(198, 95), (238, 135)], outline="ORANGE", fill=0) | ||
|
||
draw.text((200, 160), "EXIT", fill="ORANGE", font=impact18) | ||
|
||
scansuccesstext = "QR code scanned!" | ||
if scannedqrs == 0: | ||
textwidth, textheight = draw.textsize(prescantext, font=impact22) | ||
draw.text(((240-textwidth)/2, 205), prescantext, fill="ORANGE", font=impact22) | ||
elif scannedqrs % 2 == 1: | ||
textwidth, textheight = draw.textsize(scansuccesstext, font=impact22) | ||
draw.rectangle((30, 205, 210, 235), outline="ORANGE", fill="ORANGE") | ||
draw.text(((240 - textwidth) / 2, 205), scansuccesstext, fill="BLACK", font=impact22) | ||
elif scannedqrs % 2 == 0: | ||
textwidth, textheight = draw.textsize(scansuccesstext, font=impact22) | ||
draw.rectangle((30, 205, 210, 235), outline="ORANGE", fill="BLACK") | ||
draw.text(((240 - textwidth) / 2, 205), scansuccesstext, fill="ORANGE", font=impact22) | ||
|
||
if GPIO.input(KEY3_PIN) == GPIO.LOW: # button is released | ||
time.sleep(0.4) | ||
vs.stop() | ||
running = False | ||
localrunstate[0] = 3 | ||
return localrunstate | ||
|
||
disp.ShowImage(image,0,0) | ||
|
||
print("You exited the i o test module") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import menus | ||
import iotest | ||
import getwords | ||
import getword24 | ||
import dice | ||
import xpubmake | ||
import psbtsign | ||
|
||
runstate = [0, ""] | ||
seedsignerrunning = True | ||
|
||
while seedsignerrunning == True: | ||
if runstate[0] == 0: | ||
menus.main_menu(runstate) | ||
if runstate[0] == 1: | ||
menus.seedgen_menu(runstate) | ||
if runstate[0] == 2: | ||
menus.signing_menu(runstate) | ||
if runstate[0] == 3: | ||
menus.settings_menu(runstate) | ||
if runstate[0] == 50: | ||
iotest.iotestscreen(runstate) | ||
if runstate[0] == 51: | ||
getwords.gather_23_words(runstate) | ||
if runstate[0] == 52: | ||
getword24.get_word_24(runstate) | ||
if runstate[0] == 53: | ||
dice.getseedfromdice(runstate) | ||
if runstate[0] == 54: | ||
xpubmake.make_xpub(runstate) | ||
if runstate[0] == 55: | ||
psbtsign.sign_psbt(runstate) | ||
if runstate[0] == 56: | ||
menus.donate(runstate) | ||
if runstate[0] == 57: | ||
menus.version_info(runstate) |
Oops, something went wrong.