// morse_beacon_cheaty.ino
// #include <Arduino.h> // optional

// USE HEADPHONES - makes sounds

// They are beeps and they are noisy


#include "hidden.h"
#include "buzzer.h"

extern void buzz_setup();

void _preamble() {
    wsp wsp wsp wsp

    dot dot dot dash    wspace
    dot dot dot dash    wspace
    dot dot dot dash    wspace

    wsp wsp
}


void _cq() {
    // CQ:
    dash dot dash dot wspace dash dash dot dash wspace
    wsp
}


void _de() {
    // DE:
    dash dot dot wspace dot wsp cr cr wsp
}

void _wa1xyz() {
    // WA1XYZ
    dot dash dash wspace
    dot dash wspace
    dot dash dash dash dash wspace
    dash dot dot dash wspace
    dash dot dash dash wspace
    dash dash dot dot wspace
    wsp
}

void _hello() {
    // HELLO  sp   
    dot dot dot dot wspace
    dot wspace
    dot dash dot dot wspace
    dot dash dot dot wspace
    dash dash dash wspace
    wsp
}

void _longPause() {
    for (int count = 7; count > 0; count--) {
        wsp  //  non-printing
    }
}

void _ksign() {
    wsp cr wsp wsp // wspace wspace wspace do not print the spaces
    dash dot dash wspace
    wsp wsp wsp
    wsp wsp wsp // simulate pause of other operator
}

void _rsign() {
    dot dash dot wspace
    wsp
}

void _btsign() {
    dash dot dot dot   dash wspace
    wsp
}

void serial_setup() {
    Serial.begin(9600);
}

void print_signons() {
    wspace wspace wspace cr
    Serial.println("Pushbutton and LEDs mostly ignored - reused diagram/schematic ;)");
    Serial.println("Morse Trainer - cheaty cpp macro version");
    Serial.print(" speed: ");
    Serial.println(speed);
    wsp wsp
}

void _mark() {
    Serial.print(" mark ");
}

void _stn_reply_a() {
    cr rsign rsign cr
    wsp wsp
    hello wsp wsp
    wsp wsp wsp
    // longPause
    cr
    btsign
    wsp wsp wsp wsp
    cr mark cr
}


void _call_up() {
    preamble
    cr
    wsp wsp wsp

    cr cr

    cq de wsp

    wa1xyz cr cr wsp
    wa1xyz cr cr wsp

    wa1xyz cr cr wspace mark

    ksign
    wsp wsp wsp
}

#define ASPAN 3 // attention span ;)

void morse_message() {
    for (int iterations = ASPAN ; iterations > 0; iterations--) {
        callup
        stn_reply_a
        wsp wsp wsp wsp wsp wsp wsp wsp
    }
}

void done_deal() {
    wsp wsp wsp wsp wsp
    dot dot wspace
    dot dot wspace wsp wsp
    cr
    Serial.println("setup() is done.  Pushbutton active now.");
}

void setup() {
    delay(100); // have some delay
    serial_setup();
    buzz_setup();
    print_signons();
    morse_message();
    // stn_reply_a // test only - omit
    cr
    done_deal();
}

extern void buzz_loop();
void loop() {
    buzz_loop();
}

// Saved: Sun 29 Oct 21:42:55 UTC 2022
// END.