From charlesreid1

Revision as of 20:23, 31 July 2015 by Admin (talk | contribs) (Created page with "michael-morse is yet another Python morse code library. Code is on GitHub here: https://github.com/charlesreid1/michael-morse =Overview= ==How It Works== This library basic...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

michael-morse is yet another Python morse code library. Code is on GitHub here: https://github.com/charlesreid1/michael-morse

Overview

How It Works

This library basically creates a queue of activities. It translates an ascii message into morse code, and morse code into a series of scheduled on/off switches.

These switches are tied to actions that can be either hardware- or software-based.


Details

The Code

You can find the code on GitHub: https://github.com/charlesreid1/michael-morse

Example

There is a simple example included in the GitHub repository: https://github.com/charlesreid1/michael-morse

This example shows you how to control an LED on the Raspberry Pi GPIO by integrating it with the Morse library.

Here's what the final product looks like. This is about as simple as it gets, folks: you turn on some GPIO pins, you redefine the on/off functions, you make a Michael Morse, then you fire off your message.

# Use michael-morse to make an LED blink using Raspberry Pi GPIO.

# -----------------------
# RPi stuff
try:
    import RPi.GPIO as GPIO
except RuntimeError:
    print("Error importing RPi.GPIO! This is probably because you need superuser privileges. You can achieve this by using 'sudo' to run your script")
# get ready to use gpio from pi
GPIO.cleanup()
GPIO.setmode(GPIO.BOARD)
# use channel 15, i.e., P22
channel = 16
# gpio is used for output
GPIO.setup(channel, GPIO.OUT)

def LED_on():
    GPIO.output(channel,GPIO.HIGH)
def LED_off():
    GPIO.output(channel,GPIO.LOW)

# -----------------------

from MichaelMorse import MichaelMorse

m = MichaelMorse(15,on=LED_on,off=LED_off)
m.send("hello world de kc7dbu")


Why michael-morse?

What makes it different? This morse code library is aimed at use with the Raspberry Pi, so applications for using morse code include both circuitry (controlling the GPIO pin voltages) and non-circuitry (performing tasks or subroutines). Most of the other libraries I'd found were aimed at one or the other.

Who's michael-morse?

The name of the library is an homage to Michael Morse, outfielder and designated hitter on the 2014 San Francisco Giants World Series team.