aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2020-06-04 14:02:27 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2020-06-04 14:02:27 +0200
commit3648aed23a548203ed52e71c9fa1fce18e4558e4 (patch)
treef70dab6b3424f5c42fe22e7df5a097e26c2f4302 /src
parent5a8549dc7f93462aafc0248ecded6697523aaa2c (diff)
downloadrenard_hb9hi-3648aed23a548203ed52e71c9fa1fce18e4558e4.tar.gz
renard_hb9hi-3648aed23a548203ed52e71c9fa1fce18e4558e4.tar.bz2
renard_hb9hi-3648aed23a548203ed52e71c9fa1fce18e4558e4.zip
Fix morse code generation
Diffstat (limited to 'src')
-rw-r--r--src/testapp1/main.c8
-rw-r--r--src/testapp1/morse.c11
2 files changed, 13 insertions, 6 deletions
diff --git a/src/testapp1/main.c b/src/testapp1/main.c
index fc165b4..046acaa 100644
--- a/src/testapp1/main.c
+++ b/src/testapp1/main.c
@@ -12,11 +12,11 @@
#define PORTB_LED (1 << 4)
/* Specify ID here */
-static const uint8_t renard_id = 0;
+static const uint8_t renard_id = 1;
static const uint8_t num_renards_cycle = 4;
// colon (:) represents ERROR
-static const char letters[] = "eish:";
+static const char letters[] = "EISH:";
static const char unique_letter = letters[renard_id];
volatile uint8_t reset_time;
@@ -118,8 +118,8 @@ int main(void)
/* initialise timer interrupt */
inittimer();
- static char *morse_string = "MO ";
- morse_string[2] = unique_letter;
+ static char *morse_string = "M O ";
+ morse_string[4] = unique_letter;
const int permanent = (unique_letter == ':');
diff --git a/src/testapp1/morse.c b/src/testapp1/morse.c
index 65b27cd..4ad623f 100644
--- a/src/testapp1/morse.c
+++ b/src/testapp1/morse.c
@@ -6,6 +6,8 @@
#include "delay.h"
#include "morse.h"
+#define WORDSPACE (2*DIT_DURATION)
+
const uint16_t morse_mapping[60] PROGMEM =
{
// Read bits from right to left
@@ -89,14 +91,19 @@ void morse_symbol(uint8_t sym)
p++;
}
- delay_ms(4*DIT_DURATION);
+ delay_ms(WORDSPACE);
}
void morse(char* text)
{
char* sym = text;
do {
- morse_symbol(*sym - '+');
+ if (*sym == ' ') {
+ delay_ms(WORDSPACE);
+ }
+ else {
+ morse_symbol(*sym - '+');
+ }
sym++;
} while (*sym != '\0');
}