Starting to fill in the Telegraph/Morse project
This commit is contained in:
parent
b8a4054e6f
commit
3f19dbf392
1
arduino/msaqsg/ch04/Telegraph/Makefile
Symbolic link
1
arduino/msaqsg/ch04/Telegraph/Makefile
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../arduino.mk
|
5
arduino/msaqsg/ch04/Telegraph/Telegraph.ino
Normal file
5
arduino/msaqsg/ch04/Telegraph/Telegraph.ino
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
void setup() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
}
|
46
arduino/msaqsg/ch04/Telegraph/telegraph.cpp
Normal file
46
arduino/msaqsg/ch04/Telegraph/telegraph.cpp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// vim:filetype=arduino
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include "telegraph.h"
|
||||||
|
|
||||||
|
const char* LETTERS[] = {
|
||||||
|
".-", // A
|
||||||
|
"-...", // B
|
||||||
|
"-.-.", // C
|
||||||
|
"-..", // D
|
||||||
|
".", // E
|
||||||
|
"..-.", // F
|
||||||
|
"--.", // G
|
||||||
|
"....", // H
|
||||||
|
"..", // I
|
||||||
|
".---", // J
|
||||||
|
"-.-", // K
|
||||||
|
".-..", // L
|
||||||
|
"--", // M
|
||||||
|
"-.", // N
|
||||||
|
"---", // O
|
||||||
|
".--.", // P
|
||||||
|
"--.-", // Q
|
||||||
|
".-.", // R
|
||||||
|
"...", // S
|
||||||
|
"-", // T
|
||||||
|
"..-", // U
|
||||||
|
"...-", // V
|
||||||
|
".--", // W
|
||||||
|
"-..-", // X
|
||||||
|
"-.--", // Y
|
||||||
|
"--.." // Z
|
||||||
|
};
|
||||||
|
|
||||||
|
const char* DIGITS[] = {
|
||||||
|
"-----", // 0
|
||||||
|
".----", // 1
|
||||||
|
"..---", // 2
|
||||||
|
"...--", // 3
|
||||||
|
"....-", // 4
|
||||||
|
".....", // 5
|
||||||
|
"-....", // 6
|
||||||
|
"--...", // 7
|
||||||
|
"---..", // 8
|
||||||
|
"----.", // 9
|
||||||
|
};
|
18
arduino/msaqsg/ch04/Telegraph/telegraph.h
Normal file
18
arduino/msaqsg/ch04/Telegraph/telegraph.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef __TELEGRAPH_H__
|
||||||
|
#define __TELEGRAPH_H__
|
||||||
|
|
||||||
|
class Telegraph {
|
||||||
|
public:
|
||||||
|
Telegraph(const int output_pin, const int dit_length);
|
||||||
|
void send_message(const char* message);
|
||||||
|
private:
|
||||||
|
void dit();
|
||||||
|
void dah();
|
||||||
|
void output_code(const char* code);
|
||||||
|
void output_symbol(const int length);
|
||||||
|
|
||||||
|
int _output_pin;
|
||||||
|
int _dit_length;
|
||||||
|
int _dah_length;
|
||||||
|
};
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user