Morsecode Library
morsecode
Circuitpython library to crete Morse code
Author(s): Jose David M.
Implementation Notes
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
- class morsecode.Emitter(pin)
Creates a Receiver object ex: sreceptor = Emmiter(‘D13’)
Quickstart: Importing and using the Emitter
Here is an example of using the
Emitter
class. First you will need to import the libraries to use itfrom mc_emitter import Emitter import board
Once this is done you can define your morse code Emitter
internal_led = Emitter(board.D13)
Now you could send phrases to the emitter like so:
internal_led.outmorse("Hugo AKA the Architect")
- convertbpm(bpm)
Converts beats per minute in light output
- Parameters:
bpm (int) – Beats per minute
- Returns:
None
- convertphrase(phrase: str) List[str]
Convert a phrase to a list of words converted to morse code. We use a list to allow the library do some threading methods
- Parameters:
phrase – string to be converted to morse code
- Returns:
list of words converted to morse code
- convertword(word: str) str
Convert a word to its representation in morse code
- Parameters:
word – word string
- Returns:
string of morse code
- static convletter(letter: str, final: str) str
Converts a letter to its representation in morse code
- pattern(patternl: List[int]) None
Converts a list of values [0 or 1] to an output in the Emitter
- Parameters:
patternl (list) – list of [0-1] values
- Returns:
None
led = Emitter('D2') codigo = [1,1,0,1,0,0,1,1,1,0,0,1,1,1,1,1,0,0,0,1] led.pattern(codigo)
- randomblink(iterl: int) None
Emits a random output to the Emitter
- Parameters:
iterl (int) – number of values to be randomly generated
- Returns:
None