From 2f155d2ebbb5d95cadd219a0cf5782b02453ef25 Mon Sep 17 00:00:00 2001 From: Travis Goodspeed Date: Sun, 19 Nov 2017 14:14:44 -0500 Subject: [PATCH] Beginnings of a Morse application. #44 #46 --- firmware/Makefile | 2 +- firmware/applist.h | 4 ++- firmware/apps/morse.c | 63 +++++++++++++++++++++++++++++++++++++++++++ firmware/apps/morse.h | 11 ++++++++ 4 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 firmware/apps/morse.c create mode 100644 firmware/apps/morse.h diff --git a/firmware/Makefile b/firmware/Makefile index e18fc34..55a4925 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -7,7 +7,7 @@ BSL = ../bin/cc430-bsl.py modules=main.o lcd.o lcdtext.o rtc.o keypad.o apps.o sidebutton.o radio.o power.o \ dmesg.o \ libs/assembler.o -apps= apps/clock.o apps/rpn.o apps/hex.o apps/stopwatch.o +apps= apps/clock.o apps/rpn.o apps/hex.o apps/stopwatch.o apps/morse.c all: goodwatch.hex diff --git a/firmware/applist.h b/firmware/applist.h index 71cc30e..da8cb3c 100644 --- a/firmware/applist.h +++ b/firmware/applist.h @@ -6,7 +6,7 @@ #include "apps/stopwatch.h" #include "apps/rpn.h" #include "apps/hex.h" - +#include "apps/morse.h" /* For each application, the init() function is called at entry. The draw() function is called 4 times per second. The exit() function @@ -23,6 +23,8 @@ static struct app apps[]={ {.name="rpn calc", .init=rpn_init, .draw=rpn_draw, .exit=rpn_exit}, //Hex Viewer. {.name="memory", .init=hex_init, .draw=hex_draw, .exit=hex_exit}, + //Radio Tool + {.name="morse", .init=morse_init, .draw=morse_draw, .exit=morse_exit}, //End on null entry. {.name=0, .init=0, .draw=0, .exit=0} diff --git a/firmware/apps/morse.c b/firmware/apps/morse.c new file mode 100644 index 0000000..c354457 --- /dev/null +++ b/firmware/apps/morse.c @@ -0,0 +1,63 @@ +/*! \file morse.c + \brief Handy morse code tool for 70cm. + + This is a handy little application for playing with the radio. It + will be modified to use radio interrupt callbacks in the future, and + any particularly large or complicated radio tools should go in a + different applet. + +*/ + + +#include "api.h" + + +//! Enter the radio tool. +void morse_init(){ + /* Power management being king, we shouldn't initialize the radio + until we need it, but for now we'll start it at entry to keep + things simple. + */ + radio_init(); +} +//! Exit the radio tool. +int morse_exit(){ + /* Always turn the radio off at exit. + */ + radio_off(); + + //Allow the exit. + return 0; +} +//! Draw the screen and increase the count. +void morse_draw(){ + char ch=getchar(); + + switch(ch){ + case '7': + lcd_string(" 73"); + radio_morse("--... ...-- "); + break; + case '1': + lcd_string(" CQ"); + radio_morse("-.-. --.- "); + break; + case '0': + lcd_string(" K"); + radio_morse("-.- "); + break; + + + case '/': + /* TODO Replace this with a configurable callsign. */ + radio_morse("-.- -.- ....- ...- --.. "); + lcd_string(" KK4VCZ"); + break; + + default: //Show the callsign by default. + lcd_string("RAD TOOL"); + break; + } + +} + diff --git a/firmware/apps/morse.h b/firmware/apps/morse.h new file mode 100644 index 0000000..f237b60 --- /dev/null +++ b/firmware/apps/morse.h @@ -0,0 +1,11 @@ +/*! \file morse.h + \brief Handy morse code tool for 70cm. + +*/ + +//! Enter the radio tool. +void morse_init(); +//! Exit the radio tool. +int morse_exit(); +//! Draw the screen and increase the count. +void morse_draw();