// 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.
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
bz1:1
bz1:2
r1:1
r1:2
r2:1
r2:2
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r
btn2:1.l
btn2:2.l
btn2:1.r
btn2:2.r
led2:A
led2:C
led1:A
led1:C
r3:1
r3:2
r4:1
r4:2