Time to test on the Pi!

This commit is contained in:
Paul Warren 2017-02-11 13:56:56 +11:00
parent 4d420e8dee
commit 16106dbc87
1 changed files with 113 additions and 105 deletions

View File

@ -8,6 +8,9 @@
################################################## ##################################################
import time import time
import string
import random
from Adafruit_DRV2605 import * from Adafruit_DRV2605 import *
drv = Adafruit_DRV2605(busnum=0) drv = Adafruit_DRV2605(busnum=0)
@ -16,194 +19,199 @@ drv = Adafruit_DRV2605(busnum=0)
drv.begin() drv.begin()
# I2C trigger by sending 'go' command # I2C trigger by sending 'go' command
drv.setMode(DRV2605_MODE_INTTRIG) # default, internal trigger when sending GO command drv.setMode(DRV2605_MODE_INTTRIG)
drv.selectLibrary(1) drv.selectLibrary(1)
def dah():
drv.setWaveform(0, 14)
drv.setWaveform(1, 0)
drv.go()
time.sleep(0.32)
##################################################
# Dahs and Dits arrived at by trial and error
# Feel free to find one that works for you!
# see http://www.ti.com/lit/ds/symlink/drv2605.pdf for more info!
##################################################
def dah():
drv.setWaveform(0, 14)
drv.setWaveform(1, 0)
drv.go()
time.sleep(0.32)
def dit(): def dit():
drv.setWaveform(0, 1) drv.setWaveform(0, 1)
drv.setWaveform(1, 0) drv.setWaveform(1, 0)
drv.go() drv.go()
time.sleep(0.18) time.sleep(0.18)
def wait_letter(): def wait_letter():
time.sleep(0.33) time.sleep(0.33)
def wait_word(): def wait_word():
time.sleep(0.33) time.sleep(0.45)
def a(): def a():
dit(); dah(); dit(); dah();
wait_letter()
def b(): def b():
dah(); dit(); dit(); dit(); dah(); dit(); dit(); dit();
wait_letter()
def c(): def c():
dah(); dit(); dah(); dit() dah(); dit(); dah(); dit()
wait_letter()
def d(): def d():
dah(); dit(); dit(); dah(); dit(); dit();
wait_letter()
def e(): def e():
dit(); dit();
wait_letter()
def f(): def f():
dit(); dit(); dah(); dit(); dit(); dit(); dah(); dit();
wait_letter()
def g(): def g():
dah(); dah(); dit(); dah(); dah(); dit();
wait_letter()
def h(): def h():
dit(); dit(); dit(); dit(); dit(); dit(); dit(); dit();
wait_letter()
def i(): def i():
dit(); dit(); dit(); dit();
wait_letter()
def j(): def j():
dit(); dah(); dah(); dah(); dit(); dah(); dah(); dah();
wait_letter()
def k(): def k():
dah(); dit(); dah(); dah(); dit(); dah();
wait_letter()
def l(): def l():
dit(); dah(); dit(); dit(); dit(); dah(); dit(); dit();
wait_letter()
def m(): def m():
dah(); dah(); dah(); dah();
wait_letter()
def n(): def n():
dah(); dit(); dah(); dit();
wait_letter()
def O(): def O():
dah(); dah(); dah(); dah(); dah(); dah();
wait_letter()
def p(): def p():
dit(); dah(); dah(); dit(); dit(); dah(); dah(); dit();
wait_letter()
def q(): def q():
dah(); dah(); dit(); dah(); dah(); dah(); dit(); dah();
wait_letter()
def r(): def r():
dit(); dah(); dit(); dit(); dah(); dit();
wait_letter()
def s(): def s():
dit(); dit(); dit(); dit(); dit(); dit();
wait_letter()
def t(): def t():
dah(); dah();
wait_letter()
def u(): def u():
dit(); dit(); dah(); dit(); dit(); dah();
wait_letter()
def v(): def v():
dit(); dit(); dit(); dah(); dit(); dit(); dit(); dah();
wait_letter()
def w(): def w():
dit(); dah(); dah(); dit(); dah(); dah();
wait_letter()
def x(): def x():
dah(); dit(); dit(); dah(); dah(); dit(); dit(); dah();
wait_letter()
def y(): def y():
dah(); dit(); dah(); dah(); dah(); dit(); dah(); dah();
wait_letter()
def z(): def z():
dah(); dah(); dit(); dit(); dah(); dah(); dit(); dit();
wait_letter()
def m1(): def m1():
dit(); dah(); dah(); dah(); dah(); dit(); dah(); dah(); dah(); dah();
wait_letter()
def m2(): def m2():
dit(); dit(); dah(); dah(); dah(); dit(); dit(); dah(); dah(); dah();
wait_letter()
def m3(): def m3():
dit(); dit(); dit(); dah(); dah(); dit(); dit(); dit(); dah(); dah();
wait_letter()
def m4(): def m4():
dit(); dit(); dit(); dit(); dah(); dit(); dit(); dit(); dit(); dah();
wait_letter()
def m5(): def m5():
dit(); dit(); dit(); dit(); dit(); dit(); dit(); dit(); dit(); dit();
wait_letter()
def m6(): def m6():
dah(); dit(); dit(); dit(); dit(); dah(); dit(); dit(); dit(); dit();
wait_letter()
def m7(): def m7():
dah(); dah(); dit(); dit(); dit(); dah(); dah(); dit(); dit(); dit();
wait_letter()
def m8(): def m8():
dah(); dah(); dah(); dit(); dit(); dah(); dah(); dah(); dit(); dit();
wait_letter()
def m9(): def m9():
dah(); dah(); dah(); dah(); dit(); dah(); dah(); dah(); dah(); dit();
wait_letter()
def m0(): def m0():
dah(); dah(); dah(); dah(); dah(); dah(); dah(); dah(); dah(); dah();
wait_letter()
print "A" def play_morse(alphanum):
a() gettatr(self, alphanum)()
print "B" wait_letter()
b()
print "C" def generateSequence(size, chars=string.ascii_lowercase + string.digits):
c() return random.sample(chars, size)
print "Q"
q()
def main(args, kwargs):
while(1):
# generate sequence
sequence = generateSequence(64)
# play sequence!
for item in sequence:
print item
print "V"
v()
print "K"
k()
print "1"
m1()
print "A"
a()
print "T"
t()
print "P"
p()