a simple app made for text to morse conversion
Available on Play Store soon!
Morse is made to convert any given Text into Morse.
The user is able to decide using checkboxes on which way he wants to send the morse:
- Tone: A nice 440 Hz Sinewave gets faded in and out (if timewise possible)
- Flash: The device camera flash is used to morse slow but bright and visible
- Background: The app's background is also able to flash in the faster speeds
Morse is compliant with all 4 standarized speeds:
- 60 ms
- 120 ms
- 240 ms
- 1200 ms
(ms per dit)
The whole International Morse Alphabet is supported, every unsupported letter gets treated as a space.
(as listed in this german Wikipedia entry: Morse Tabelle)
Morse features a rather simplistic user interface.
- an input field for typing cleartext which will be converted
- 2 text fields showing status, current letter and the according morse code
- a progress bar showing the progress of ongoing morse
- a button to start and stop the morsing process
- 3 checkboxes for selecting outputs:
- Flash
- Background
- Sound
- a slider for selecting the speed
- and a small text field below the slider for displaying the currently selected speed in ms
Morse also adapts if the soft keyboard is invoked, although this will be adjusted, because on some devices with big UI elements or a small screen this results in overlapping components.
Most of the work is done within the MainActivity, but several tasks such as creating the sound are beeing managed by different classes.
Morse uses 2 different sound libraries at the moment, because of each others better performance in different speeds.
- perfectTune by karlotoy is better in high speeds
- an own version combinated from perfectTune and some stackoverflow code features an fading in and fading out effect but crackles a lot in high speeds.
- a third generator from stackoverflow just kept as a source for the own version, but currently unused
- String TAG: used for debugging and logging purposes
- Int speedbar: current speed selected by user
- Boolean active: if a morsing process is currently active
- Thread worker: second Thread for morsing to not lock up the UI
- Boolean flashavailable: gets set in onCreate(), defines if device has a flash available
- Boolean boxflash: If the Checkbox for the flash is checked
- Boolean boxtone: If the Checkbox for the tone is checked
- Boolean boxbackground: If the Checkbox for the background is checked
- ConstraintLayout constrainlayout: static reference to the constraintlayout for managing it from second Thread
- Context context: static reference to the MainActivity context
- Boolean flash: Variable defining if the flash should be on, used during morsing, processed by a third Thread
- Int PERMISSION_REQUEST_CAMERA: static int for identifying during the permission request procedure
- onCreate: sets up first time stuff
- encodebuttonclick: starts the whole morsing process including a second Thread or stops it if there is one running
- morse: general function for managing whole morsing process, returns true if morse finished and false if morse has been cancelled
- updateinfo: simple function beeing called mostly from morsing process to update the UI
The whole Morse Code is saved within a big Map. This makes it easier to manage and also enables requesting the morse code for a letter by using morse.get(Character)
starts the whole morsing process including a second Thread or stops it if there is one running
This function has an program structure plan available! Download PAP or Download/View PDF
The function morse does everything interesting and is pretty important, so it gets its own description
- The Thread camworker is beeing created, which will manage turning on flash later on, because turning flash on and off apparently takes quite some time and would mess up the precise timing of the morse.
- First for loop generally looping thourgh every character of the input text
- If statement checking whether the next character needs special threatment like spaces or not
- If not it starts a small for loop collecting the morse symbols for display
- Second for loop loops through every morsing segment of the character
- depending on selected output types, the outputs get activated
- either the tone gets played for a defined time or if tone output is deactivated the exact same length is beeing waited
- selected outputs get turned off again
- the empty dit between morsing signals is beeing waited
- The time between letters is beeing waited
- If statement checking whether the next character needs special threatment like spaces or not
This function has an program structure plan available! Download PAP or Download/View PDF
Morse only needs permission to camera for activating the flash, but it of course works fine without flash if it hasn't got the permission yet. The camera permission is requested upon start of the app. The selection box for flash greys out if the permission is missing or if the device lacks a flash.
- strings.xml: the default message text and the sound frequency in Hz is defined here
- colors.xml: the standard colors and the colors for inverting background and text are defined here
- activity_main.xml: standard layout file for the main activity