WrathPak
·
2025-08-18
adapter.h
1#pragma once
2
3#include <MIDIUSB.h>
4#include "keyers.h"
5#include "polybuzzer.h"
6#include "config.h" // Include config.h
7
8class VailAdapter: public Transmitter {
9private:
10 unsigned int txNote = DEFAULT_TONE_NOTE;
11 unsigned int ditDuration = DEFAULT_ADAPTER_DIT_DURATION_MS;
12 bool keyboardMode = true;
13 Keyer *keyer = NULL;
14 PolyBuzzer *buzzer = NULL;
15
16 unsigned long keyPressStartTime = 0;
17 bool keyIsPressed = false;
18
19 unsigned long lastDitTime = 0;
20 unsigned int ditPressCount = 0;
21 bool buzzerEnabled = true;
22
23 bool radioModeActive = false;
24 unsigned long lastCapDahTime = 0;
25 unsigned int capDahPressCount = 0;
26 bool radioDitState = false;
27 bool radioDahState = false;
28
29
30 void midiKey(uint8_t key, bool down);
31 void keyboardKey(uint8_t key, bool down);
32
33 void setRadioDit(bool active);
34 void setRadioDah(bool active);
35
36public:
37 VailAdapter(unsigned int PiezoPin);
38 bool KeyboardMode();
39
40 void ProcessPaddleInput(Paddle paddle, bool pressed, bool isCapacitive);
41 void HandleMIDI(midiEventPacket_t event);
42
43 void BeginTx() override;
44 void EndTx() override;
45
46 void Tick(unsigned int millis);
47
48 void ResetDitCounter();
49 void DisableBuzzer();
50 bool isBuzzerEnabled() const;
51
52 void ToggleRadioMode();
53 bool isRadioModeActive() const;
54 void ResetDahCounter();
55
56 uint8_t getCurrentKeyerType() const;
57 uint16_t getDitDuration() const;
58 uint8_t getTxNote() const;
59};