Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 1:6f09c27a966f, committed 2014-09-19
- Comitter:
- boltonja
- Date:
- Fri Sep 19 17:10:23 2014 +0000
- Parent:
- 0:c1bb102a0fe2
- Commit message:
- Final-ish version of the Yarrduino, for TLAPD 2014.
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun May 04 19:25:42 2014 +0000
+++ b/main.cpp Fri Sep 19 17:10:23 2014 +0000
@@ -1,3 +1,7 @@
+// Yarrduino
+// Copyright 2013, 2014, J. Bolton
+// This program is redistributable under the GNU General Public License, version 3.
+
#include "mbed.h"
// For Freescale FRDM-KL25Z target.
@@ -15,7 +19,13 @@
#define LED_ON 0
DigitalOut myled(LED1);
#endif
-int color = 0;
+enum char_class {
+ LETTER = 0,
+ NUMBER = 1,
+ PUNCTUATION = 2
+};
+
+enum char_class color = LETTER;
void led_off(void)
{
@@ -31,11 +41,11 @@
void led_on(void)
{
#ifdef USE_RGB
- if (color == 1) {
+ if (color == NUMBER) {
r = 0;
g = 1.0;
b = 1.0;
- } else if (color == 2){
+ } else if (color == PUNCTUATION){
r = 1.0;
g = 1.0;
b = 0;
@@ -127,22 +137,22 @@
char i;
if (c <= 'z' && c >='a') {
- color = 0;
+ color = LETTER;
return letters[c-'a'].morse;
}
if (c <= 'Z' && c >= 'A') {
- color = 0;
+ color = LETTER;
return letters[c-'A'].morse;
}
if (c <= '9' && c >= '0') {
- color = 1;
+ color = NUMBER;
return letters[c-'0'].morse;
}
for (i=0; puncs[i].ascii; i++) {
- color = 2;
+ color = PUNCTUATION;
if (puncs[i].ascii == c) {
return puncs[i].morse;
}
@@ -230,11 +240,9 @@
int main()
{
led_off();
- bufindex = 0;
- //strcpy(buffer, "yarr, matey!");
- strcpy(buffer, "012abc!!!");
- bufindex = 9;
+ strcpy(buffer, "yarr, matey!");
+ bufindex = 12;
while(1) {
loop();