format code
This commit is contained in:
parent
da54029403
commit
3311e7d790
2 changed files with 115 additions and 111 deletions
|
@ -1,5 +1,5 @@
|
||||||
#include <cstring>
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include "pico/stdio.h"
|
#include "pico/stdio.h"
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@
|
||||||
|
|
||||||
MorseCode::MorseCode() { buildMap(); }
|
MorseCode::MorseCode() { buildMap(); }
|
||||||
|
|
||||||
bool MorseCode::charToMorse(const unsigned char ch, char *morseSymbols) {
|
bool MorseCode::charToMorse(const unsigned char ch, char *morseSymbols)
|
||||||
|
{
|
||||||
size_t index {0};
|
size_t index {0};
|
||||||
|
|
||||||
if (ch != ' ' && morseMap[ch] == nullptr) {
|
if (ch != ' ' && morseMap[ch] == nullptr) {
|
||||||
|
@ -35,7 +36,8 @@ bool MorseCode::charToMorse(const unsigned char ch, char *morseSymbols) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MorseCode::sendCharacter(const char ch) {
|
void MorseCode::sendCharacter(const char ch)
|
||||||
|
{
|
||||||
char morseSymbols[32] {0};
|
char morseSymbols[32] {0};
|
||||||
|
|
||||||
if (!charToMorse(ch, morseSymbols)) {
|
if (!charToMorse(ch, morseSymbols)) {
|
||||||
|
@ -47,7 +49,8 @@ void MorseCode::sendCharacter(const char ch) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MorseCode::buildMap() {
|
void MorseCode::buildMap()
|
||||||
|
{
|
||||||
for (size_t i = 0; i < 256; i++) {
|
for (size_t i = 0; i < 256; i++) {
|
||||||
if (i == '\"')
|
if (i == '\"')
|
||||||
morseMap[i] = morseTable[0];
|
morseMap[i] = morseTable[0];
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class MorseCode final {
|
class MorseCode final
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
MorseCode();
|
MorseCode();
|
||||||
void sendCharacter(const char ch);
|
void sendCharacter(const char ch);
|
||||||
|
|
Loading…
Reference in a new issue