UKHAS Wiki

UK High Altitude Society

User Tools

Site Tools


projects:firefly:morselib1.py
#morselib1.py
#Pass coordinate string to splitter() and it'll toggle a GPIO in mc- code
import GPIO
import MOD
import debug
 
def radio_on_off(on_off):
    if (on_off == 'on'):
        debug.msg('Radio on')
        GPIO.setIOvalue(7, 0) 
    elif (on_off == 'off'):
        debug.msg('Radio off')
        GPIO.setIOvalue(7, 1)
 
def dit():
    MOD.sleep(2)
    GPIO.setIOvalue(3, 1)
    MOD.sleep(1)
    GPIO.setIOvalue(3,0)
 
def dash():
    MOD.sleep(2)
    GPIO.setIOvalue(3, 1)
    MOD.sleep(2)
    GPIO.setIOvalue(3,0)
 
def code(number):
    MOD.sleep(3)
    if (number == '.'):
        debug.msg('Dot')
    elif (number == 'N'):
        debug.msg('N')
    elif (number == 'S'):
        debug.msg('S')
    elif (number == 'E'):
        debug.msg('E')
    elif (number == 'W'):
        debug.msg('W')
    elif (number == '-'):
        debug.msg('-')
        dit()
        dash()
        dit()
    else:
        int_number = int(number)
        debug.msg('%d' % int_number)
        if (int_number == 0):
            dash()
            dash()
        elif (int_number == 1):
            dit()
        elif (int_number == 2):
            dit()
            dit()
        elif (int_number == 3):
            dit()
            dit()
            dit()
        elif (int_number == 4):
            dit()
            dit()
            dit()
            dit()
        elif (int_number == 5):
            dash()
        elif (int_number == 6):
            dash()
            dit()
        elif (int_number == 7):
            dash()
            dit()
            dit()
        elif (int_number == 8):
            dash()
            dit()
            dit()
            dit()
        elif (int_number == 9):
            dash()
            dit()
            dit()
            dit()
            dit()
        else:
            debug.msg('Not between 0 and 9')
 
def splitter(coord):
    debug.msg(coord)
    j = 0
    while j < len(coord):
        code(coord[j])
        j = j + 1
projects/firefly/morselib1.py.txt ยท Last modified: 2008/07/19 23:33 (external edit)