ubitx-v5x/TeensyDSP/Keyer.h

82 lines
2.0 KiB
C++

//**********************************************************************
//
// Keyer, a part of nanoIO
//
// nanoIO paddle keyer (c) 2018, David Freese, W1HKJ
//
// based on code from Iambic Keyer Code Keyer Sketch
// Copyright (c) 2009 Steven T. Elliott
//
// nanoIO is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// nanoIO is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with fldigi. If not, see <http://www.gnu.org/licenses/>.
//
//Revisions:
//
//1.0.0: Initial release
//
//**********************************************************************
#ifndef __Keyer_h__
#define __Keyer_h__
#define IAMBICA 0
#define IAMBICB 1
#define STRAIGHT 2
#define KEYER_LEFT_PADDLE_PIN 17
#define KEYER_RIGHT_PADDLE_PIN 16
class UBitxKeyer
{
public:
UBitxKeyer(int wpm, float weight);
//void cw_pin(int pin);
//void ptt_pin(int pin);
void setWPM(int wpm);
inline int getWPM() { return speed; }
void setWeight(float weight);
inline float getWeight() { return symWeight; }
inline void setMode(int mode) { keyMode = mode; }
inline int getMode() { return keyMode; }
inline bool isDown() { return keyDown; }
bool doPaddles();
private:
void calcRatio();
void updatePaddleLatch();
bool keyDown;
long ktimer;
int speed;
int dashLen; // Length of dash
int dotLen; // Length of dot
int spaceLen; // Length of space
float symWeight;
char keyerControl;
char keyerState;
int keyMode;
};
extern UBitxKeyer& Keyer;
#endif
//======================================================================
// EOF
//======================================================================