diff --git a/arduino/msaqsg/ch04/Telegraph/Makefile b/arduino/msaqsg/ch04/Telegraph/Makefile new file mode 120000 index 0000000..bf3dbf5 --- /dev/null +++ b/arduino/msaqsg/ch04/Telegraph/Makefile @@ -0,0 +1 @@ +../../../arduino.mk \ No newline at end of file diff --git a/arduino/msaqsg/ch04/Telegraph/Telegraph.ino b/arduino/msaqsg/ch04/Telegraph/Telegraph.ino new file mode 100644 index 0000000..6133ba2 --- /dev/null +++ b/arduino/msaqsg/ch04/Telegraph/Telegraph.ino @@ -0,0 +1,5 @@ +void setup() { +} + +void loop() { +} diff --git a/arduino/msaqsg/ch04/Telegraph/telegraph.cpp b/arduino/msaqsg/ch04/Telegraph/telegraph.cpp new file mode 100644 index 0000000..a5fd161 --- /dev/null +++ b/arduino/msaqsg/ch04/Telegraph/telegraph.cpp @@ -0,0 +1,46 @@ +// vim:filetype=arduino +#include +#include +#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 +}; diff --git a/arduino/msaqsg/ch04/Telegraph/telegraph.h b/arduino/msaqsg/ch04/Telegraph/telegraph.h new file mode 100644 index 0000000..437d99d --- /dev/null +++ b/arduino/msaqsg/ch04/Telegraph/telegraph.h @@ -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