Compare commits
33 Commits
v0.25
...
version0.2
Author | SHA1 | Date | |
---|---|---|---|
|
b153a305d6 | ||
|
c7be3dcd39 | ||
|
bbb23bf817 | ||
|
4d61cf4de9 | ||
|
e61e45d3dd | ||
|
a1f941f965 | ||
|
d1e72b3bd5 | ||
|
032e7f919f | ||
|
b6bc264332 | ||
|
b1cc5eb98a | ||
|
2fa8247501 | ||
|
2fe1662d67 | ||
|
ebbc5aae5e | ||
|
209cd3a49c | ||
|
587d4854c3 | ||
|
95e5c1dfe5 | ||
|
45a8479061 | ||
|
a6ad381c24 | ||
|
bcf80f851d | ||
|
16304efacd | ||
|
968024ab73 | ||
|
3e60728727 | ||
|
924db221f4 | ||
|
b9b8f4b46f | ||
|
9781ef086b | ||
|
f27f504ea4 | ||
|
b2d3e3a6f8 | ||
|
2b08a76fbf | ||
|
f9050ebb11 | ||
|
90655e03b8 | ||
|
8551ff1b68 | ||
|
5ce94e8e49 | ||
|
7ef9c29fa8 |
74
README.md
74
README.md
@@ -1,11 +1,85 @@
|
|||||||
|
#IMPORTANT INFORMATION
|
||||||
|
----------------------------------------------------------------------------
|
||||||
|
-Working on version 0.29 now. Download the source from the release section rather than the master branch version.
|
||||||
|
Master version is working now.
|
||||||
|
|
||||||
|
- Beta 0.26 and Beta 0.261, Beta 0.262,0.27 is complete test, 0.28 is tested.
|
||||||
|
- You can download and use it (Release section).
|
||||||
|
|
||||||
|
# Current work list (for Version 0.29)
|
||||||
|
1 Testing CAT Control with Software using hamlib on Linux
|
||||||
|
2 BFO setting based on current value - complete
|
||||||
|
3 Select Tune Step - Testing
|
||||||
|
4 Change Tune control type, Do not keep the original source - Complete
|
||||||
|
- Coded differently after clearing the original source
|
||||||
|
- Prevent malfunction by applying threshold
|
||||||
|
5 stabilize and remove many warning messages - by Pullrequest and merge
|
||||||
|
6 Study on improvement method for cw keying - need idea
|
||||||
|
- set ADC Range value
|
||||||
|
|
||||||
|
#NOTICE
|
||||||
|
----------------------------------------------------------------------------
|
||||||
|
I received uBITX a month ago and found that many features are required, and began coding with the idea of implementing minimal functionality as a general hf transceiver rather than an experimental device.
|
||||||
|
|
||||||
|
- fixed bugs...
|
||||||
|
- Diallock for uBITX's sensitive encoders
|
||||||
|
- built in softare Memory keyer and cw options control for CW communication
|
||||||
|
- Implementation of CAT communication protocol for Digital Communication (as FT8, JT65, etc)
|
||||||
|
- Delay Options for external Linear.
|
||||||
|
- and more...
|
||||||
|
|
||||||
|
Most of the basic functions of the HF transceiver I thought were implemented.
|
||||||
|
The minimum basic specification for uBITX to operate as a radio, I think it is finished.
|
||||||
|
So I will release the 0.27 version and if I do not see the bug anymore, I will try to change the version name to 1.0.
|
||||||
|
Now uBITX is an HF radio and will be able to join you in your happy hams life.
|
||||||
|
Based on this source, you can use it by adding functions.
|
||||||
|
|
||||||
|
I am going to do a new project based on this source, linking with WSPR, WSJT-X and so on.
|
||||||
|
Of course, this repository is still running. If you have any bugs or ideas, please feel free to email me.
|
||||||
|
|
||||||
|
http://www.hamskey.com
|
||||||
|
|
||||||
|
DE KD8CEC
|
||||||
|
kd8cec@gmail.com
|
||||||
|
|
||||||
#uBITX
|
#uBITX
|
||||||
uBITX firmware, written for the Raduino/Arduino control of uBITX transceivers
|
uBITX firmware, written for the Raduino/Arduino control of uBITX transceivers
|
||||||
This project is based on https://github.com/afarhan/ubitx and all copyright is inherited.
|
This project is based on https://github.com/afarhan/ubitx and all copyright is inherited.
|
||||||
The copyright information of the original is below.
|
The copyright information of the original is below.
|
||||||
|
|
||||||
KD8CEC
|
KD8CEC
|
||||||
|
----------------------------------------------------------------------------
|
||||||
|
Prepared or finished tasks for the next version
|
||||||
|
- Most of them are implemented and included in version 0.27.
|
||||||
|
- User Interface on LCD -> Option by user (not need)
|
||||||
|
- Include WSPR Beacone function - (implement other new repository)
|
||||||
|
complete experiment
|
||||||
|
need solve : Big code size (over 100%, then remove some functions for experment)
|
||||||
|
need replace Si5351 Library (increase risk and need more beta tester)
|
||||||
|
W3PM sent me his wonderful source - using BITX, GPS
|
||||||
|
|
||||||
----------------------------------------------------------------------------
|
----------------------------------------------------------------------------
|
||||||
## REVISION RECORD
|
## REVISION RECORD
|
||||||
|
0.28
|
||||||
|
- Fixed CAT problem with hamlib on Linux
|
||||||
|
- restore Protocol autorecovery logic
|
||||||
|
|
||||||
|
0.27
|
||||||
|
(First alpha test version, This will be renamed to the major version 1.0)
|
||||||
|
- Dual VFO Dial Lock (vfoA Dial lock)
|
||||||
|
- Support Ham band on uBITX
|
||||||
|
default Hamband is regeion1 but customize by uBITX Manager Software
|
||||||
|
- Advanced ham band options (Tx control) for use in all countries. You can adjust it yourself.
|
||||||
|
- Convenience of band movement
|
||||||
|
|
||||||
|
0.26
|
||||||
|
- only Beta tester released & source code share
|
||||||
|
- find a bug on none initial eeprom uBITX - Fixed (Check -> initialized & compatible original source code)
|
||||||
|
- change the version number 0.26 -> 0.27
|
||||||
|
- Prevent overflow bugs
|
||||||
|
- bug with linux based Hamlib (raspberry pi), It was perfect for the 0.224 version, but there was a problem for the 0.25 version.
|
||||||
|
On Windows, ham deluxe, wsjt-x, jt65-hf, and fldigi were successfully run. Problem with Raspberry pi.
|
||||||
|
|
||||||
0.25
|
0.25
|
||||||
- Beta Version Released
|
- Beta Version Released
|
||||||
http://www.hamskey.com/2018/01/release-beta-version-of-cat-support.html
|
http://www.hamskey.com/2018/01/release-beta-version-of-cat-support.html
|
||||||
|
@@ -181,7 +181,7 @@ void CatSetPTT(boolean isPTTOn, byte fromType)
|
|||||||
void CatVFOToggle(boolean isSendACK, byte fromType)
|
void CatVFOToggle(boolean isSendACK, byte fromType)
|
||||||
{
|
{
|
||||||
if (fromType != 2 && fromType != 3) {
|
if (fromType != 2 && fromType != 3) {
|
||||||
menuVfoToggle(1);
|
menuVfoToggle(1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSendACK)
|
if (isSendACK)
|
||||||
@@ -398,7 +398,7 @@ void ReadEEPRom_FT817(byte fromType)
|
|||||||
|
|
||||||
void WriteEEPRom_FT817(byte fromType)
|
void WriteEEPRom_FT817(byte fromType)
|
||||||
{
|
{
|
||||||
byte temp0 = CAT_BUFF[0];
|
//byte temp0 = CAT_BUFF[0];
|
||||||
byte temp1 = CAT_BUFF[1];
|
byte temp1 = CAT_BUFF[1];
|
||||||
|
|
||||||
CAT_BUFF[0] = 0;
|
CAT_BUFF[0] = 0;
|
||||||
@@ -470,8 +470,8 @@ void WriteEEPRom_FT817(byte fromType)
|
|||||||
sideTone = (sideTonePitch * 50 + 300) + sideToneSub;
|
sideTone = (sideTonePitch * 50 + 300) + sideToneSub;
|
||||||
printLineF2(F("Sidetone set! CAT"));
|
printLineF2(F("Sidetone set! CAT"));
|
||||||
EEPROM.put(CW_SIDETONE, sideTone);
|
EEPROM.put(CW_SIDETONE, sideTone);
|
||||||
delay(500);
|
delay(300); //If timeout errors occur in the calling software, remove them
|
||||||
printLine2("");
|
printLine2(""); //Ham radio deluxe is the only one that supports this feature yet. and ham radio deluxe has wait time as greater than 500ms
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -482,8 +482,8 @@ void WriteEEPRom_FT817(byte fromType)
|
|||||||
sideTone = (sideTonePitch * 50 + 300) + sideToneSub;
|
sideTone = (sideTonePitch * 50 + 300) + sideToneSub;
|
||||||
printLineF2(F("Sidetone set! CAT"));
|
printLineF2(F("Sidetone set! CAT"));
|
||||||
EEPROM.put(CW_SIDETONE, sideTone);
|
EEPROM.put(CW_SIDETONE, sideTone);
|
||||||
delay(500);
|
delay(300); //If timeout errors occur in the calling software, remove them
|
||||||
printLine2("");
|
printLine2(""); //Ham radio deluxe is the only one that supports this feature yet. and ham radio deluxe has wait time as greater than 500ms
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -502,7 +502,7 @@ void WriteEEPRom_FT817(byte fromType)
|
|||||||
cwDelayTime = CAT_BUFF[2];
|
cwDelayTime = CAT_BUFF[2];
|
||||||
printLineF2(F("CW Speed set!"));
|
printLineF2(F("CW Speed set!"));
|
||||||
EEPROM.put(CW_DELAY, cwDelayTime);
|
EEPROM.put(CW_DELAY, cwDelayTime);
|
||||||
delay(500);
|
delay(300);
|
||||||
printLine2("");
|
printLine2("");
|
||||||
break;
|
break;
|
||||||
case 0x62 : //
|
case 0x62 : //
|
||||||
@@ -511,7 +511,7 @@ void WriteEEPRom_FT817(byte fromType)
|
|||||||
cwSpeed = 1200 / ((CAT_BUFF[2] & 0x3F) + 4);
|
cwSpeed = 1200 / ((CAT_BUFF[2] & 0x3F) + 4);
|
||||||
printLineF2(F("CW Speed set!"));
|
printLineF2(F("CW Speed set!"));
|
||||||
EEPROM.put(CW_SPEED, cwSpeed);
|
EEPROM.put(CW_SPEED, cwSpeed);
|
||||||
delay(500);
|
delay(300);
|
||||||
printLine2("");
|
printLine2("");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -648,7 +648,6 @@ void Check_Cat(byte fromType)
|
|||||||
rxBufferCheckCount = Serial.available();
|
rxBufferCheckCount = Serial.available();
|
||||||
rxBufferArriveTime = millis() + CAT_RECEIVE_TIMEOUT; //Set time for timeout
|
rxBufferArriveTime = millis() + CAT_RECEIVE_TIMEOUT; //Set time for timeout
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -208,10 +208,14 @@ void sendCWChar(char cwKeyChar)
|
|||||||
charLength = ((tmpChar >> 6) & 0x03) + 3;
|
charLength = ((tmpChar >> 6) & 0x03) + 3;
|
||||||
|
|
||||||
for (j = 0; j < charLength; j++)
|
for (j = 0; j < charLength; j++)
|
||||||
sendBuff[j] = (tmpChar << j + 2) & 0x80;
|
sendBuff[j] = (tmpChar << (j + 2)) & 0x80;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
charLength = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,7 +261,7 @@ unsigned long scrollDispayTime = 0;
|
|||||||
#define scrollSpeed 500
|
#define scrollSpeed 500
|
||||||
byte displayScrolStep = 0;
|
byte displayScrolStep = 0;
|
||||||
|
|
||||||
int controlAutoCW(){
|
void controlAutoCW(){
|
||||||
int knob = 0;
|
int knob = 0;
|
||||||
byte i;
|
byte i;
|
||||||
|
|
||||||
|
@@ -148,8 +148,14 @@ int count = 0; //to generally count ticks, loops, etc
|
|||||||
#define VFO_B_MODE 257
|
#define VFO_B_MODE 257
|
||||||
#define CW_DELAY 258
|
#define CW_DELAY 258
|
||||||
#define CW_START 259
|
#define CW_START 259
|
||||||
|
#define HAM_BAND_COUNT 260 //
|
||||||
|
#define TX_TUNE_TYPE 261 //
|
||||||
|
#define HAM_BAND_RANGE 262 //FROM (2BYTE) TO (2BYTE) * 10 = 40byte
|
||||||
|
#define HAM_BAND_FREQS 302 //40, 1 BAND = 4Byte most bit is mode
|
||||||
|
#define TUNING_STEP 342 //TUNING STEP * 6 (index 1 + STEPS 5)
|
||||||
|
|
||||||
//
|
//Check Firmware type and version
|
||||||
|
#define FIRMWAR_ID_ADDR 776 //776 : 0x59, 777 :0x58, 778 : 0x68 : Id Number, if not found id, erase eeprom(32~1023) for prevent system error.
|
||||||
#define VERSION_ADDRESS 779 //check Firmware version
|
#define VERSION_ADDRESS 779 //check Firmware version
|
||||||
//USER INFORMATION
|
//USER INFORMATION
|
||||||
#define USER_CALLSIGN_KEY 780 //0x59
|
#define USER_CALLSIGN_KEY 780 //0x59
|
||||||
@@ -206,7 +212,7 @@ unsigned long vfoA=7150000L, vfoB=14200000L, sideTone=800, usbCarrier;
|
|||||||
unsigned long vfoA_eeprom, vfoB_eeprom; //for protect eeprom life
|
unsigned long vfoA_eeprom, vfoB_eeprom; //for protect eeprom life
|
||||||
unsigned long frequency, ritRxFrequency, ritTxFrequency; //frequency is the current frequency on the dial
|
unsigned long frequency, ritRxFrequency, ritTxFrequency; //frequency is the current frequency on the dial
|
||||||
|
|
||||||
int cwSpeed = 100; //this is actuall the dot period in milliseconds
|
unsigned int cwSpeed = 100; //this is actuall the dot period in milliseconds
|
||||||
extern int32_t calibration;
|
extern int32_t calibration;
|
||||||
|
|
||||||
//for store the mode in eeprom
|
//for store the mode in eeprom
|
||||||
@@ -228,8 +234,10 @@ byte sideTonePitch=0;
|
|||||||
byte sideToneSub = 0;
|
byte sideToneSub = 0;
|
||||||
|
|
||||||
//DialLock
|
//DialLock
|
||||||
byte isDialLock = 0;
|
byte isDialLock = 0; //000000[0]vfoB [0]vfoA 0Bit : A, 1Bit : B
|
||||||
byte isTxOff = 0;
|
byte isTxType = 0; //000000[0 - isSplit] [0 - isTXStop]
|
||||||
|
byte arTuneStep[5];
|
||||||
|
byte tuneStepIndex; //default Value 0, start Offset is 0 because of check new user
|
||||||
|
|
||||||
//Variables for auto cw mode
|
//Variables for auto cw mode
|
||||||
byte isCWAutoMode = 0; //0 : none, 1 : CW_AutoMode_Menu_Selection, 2 : CW_AutoMode Sending
|
byte isCWAutoMode = 0; //0 : none, 1 : CW_AutoMode_Menu_Selection, 2 : CW_AutoMode Sending
|
||||||
@@ -264,6 +272,69 @@ boolean modeCalibrate = false;//this mode of menus shows extended menus to calib
|
|||||||
* you start hacking around
|
* you start hacking around
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//Ham Band
|
||||||
|
#define MAX_LIMIT_RANGE 10 //because limited eeprom size
|
||||||
|
byte useHamBandCount = 0; //0 use full range frequency
|
||||||
|
byte tuneTXType = 0; //0 : use full range, 1 : just Change Dial speed, 2 : just ham band change, but can general band by tune, 3 : only ham band (just support 0, 2 (0.26 version))
|
||||||
|
//100 : use full range but not TX on general band, 101 : just change dial speed but.. 2 : jut... but.. 3 : only ham band (just support 100, 102 (0.26 version))
|
||||||
|
unsigned int hamBandRange[MAX_LIMIT_RANGE][2]; // = //Khz because reduce use memory
|
||||||
|
|
||||||
|
//-1 : not found, 0 ~ 9 : Hamband index
|
||||||
|
char getIndexHambanBbyFreq(unsigned long f)
|
||||||
|
{
|
||||||
|
f = f / 1000;
|
||||||
|
for (byte i = 0; i < useHamBandCount; i++)
|
||||||
|
if (hamBandRange[i][0] <= f && f < hamBandRange[i][1])
|
||||||
|
return i;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//when Band change step = just hamband
|
||||||
|
//moveDirection : 1 = next, -1 : prior
|
||||||
|
void setNextHamBandFreq(unsigned long f, char moveDirection)
|
||||||
|
{
|
||||||
|
unsigned long resultFreq = 0;
|
||||||
|
byte loadMode = 0;
|
||||||
|
char findedIndex = getIndexHambanBbyFreq(f);
|
||||||
|
|
||||||
|
if (findedIndex == -1) { //out of hamband
|
||||||
|
f = f / 1000;
|
||||||
|
for (byte i = 0; i < useHamBandCount -1; i++) {
|
||||||
|
if (hamBandRange[i][1] <= f && f < hamBandRange[i + 1][0]) {
|
||||||
|
findedIndex = i + moveDirection;
|
||||||
|
//return (unsigned long)(hamBandRange[i + 1][0]) * 1000;
|
||||||
|
}
|
||||||
|
} //end of for
|
||||||
|
}
|
||||||
|
else if (((moveDirection == 1) && (findedIndex < useHamBandCount -1)) || //Next
|
||||||
|
((moveDirection == -1) && (findedIndex > 0)) ) { //Prior
|
||||||
|
findedIndex += moveDirection;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
findedIndex = -1;
|
||||||
|
|
||||||
|
if (findedIndex == -1)
|
||||||
|
findedIndex = (moveDirection == 1 ? 0 : useHamBandCount -1);
|
||||||
|
|
||||||
|
EEPROM.get(HAM_BAND_FREQS + 4 * findedIndex, resultFreq);
|
||||||
|
|
||||||
|
loadMode = (byte)(resultFreq >> 30);
|
||||||
|
resultFreq = resultFreq & 0x3FFFFFFF;
|
||||||
|
|
||||||
|
if ((resultFreq / 1000) < hamBandRange[(unsigned char)findedIndex][0] || (resultFreq / 1000) > hamBandRange[(unsigned char)findedIndex][1])
|
||||||
|
resultFreq = (unsigned long)(hamBandRange[(unsigned char)findedIndex][0]) * 1000;
|
||||||
|
|
||||||
|
setFrequency(resultFreq);
|
||||||
|
byteWithFreqToMode(loadMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void saveBandFreqByIndex(unsigned long f, unsigned long mode, char bandIndex) {
|
||||||
|
if (bandIndex >= 0)
|
||||||
|
EEPROM.put(HAM_BAND_FREQS + 4 * bandIndex, (f & 0x3FFFFFFF) | (mode << 30) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
KD8CEC
|
KD8CEC
|
||||||
When using the basic delay of the Arduino, the program freezes.
|
When using the basic delay of the Arduino, the program freezes.
|
||||||
@@ -275,7 +346,7 @@ unsigned long delayBeforeTime = 0;
|
|||||||
byte delay_background(unsigned delayTime, byte fromType){ //fromType : 4 autoCWKey -> Check Paddle
|
byte delay_background(unsigned delayTime, byte fromType){ //fromType : 4 autoCWKey -> Check Paddle
|
||||||
delayBeforeTime = millis();
|
delayBeforeTime = millis();
|
||||||
|
|
||||||
while (millis() <= delayBeforeTime + delayTime) {
|
while (millis() - delayBeforeTime <= delayTime) {
|
||||||
|
|
||||||
if (fromType == 4)
|
if (fromType == 4)
|
||||||
{
|
{
|
||||||
@@ -353,10 +424,7 @@ void setTXFilters(unsigned long freq){
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void setFrequency(unsigned long f){
|
void setFrequency(unsigned long f){
|
||||||
uint64_t osc_f;
|
f = (f / arTuneStep[tuneStepIndex -1]) * arTuneStep[tuneStepIndex -1];
|
||||||
|
|
||||||
//1 digits discarded
|
|
||||||
f = (f / 50) * 50;
|
|
||||||
|
|
||||||
setTXFilters(f);
|
setTXFilters(f);
|
||||||
|
|
||||||
@@ -379,9 +447,13 @@ void setFrequency(unsigned long f){
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void startTx(byte txMode, byte isDisplayUpdate){
|
void startTx(byte txMode, byte isDisplayUpdate){
|
||||||
unsigned long tx_freq = 0;
|
//Check Hamband only TX //Not found Hamband index by now frequency
|
||||||
|
if (tuneTXType >= 100 && getIndexHambanBbyFreq(ritOn ? ritTxFrequency : frequency) == -1) {
|
||||||
|
//no message
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isTxOff != 1)
|
if ((isTxType & 0x01) != 0x01)
|
||||||
digitalWrite(TX_RX, 1);
|
digitalWrite(TX_RX, 1);
|
||||||
|
|
||||||
inTx = 1;
|
inTx = 1;
|
||||||
@@ -470,8 +542,6 @@ void checkPTT(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void checkButton(){
|
void checkButton(){
|
||||||
int i, t1, t2, knob, new_knob;
|
|
||||||
|
|
||||||
//only if the button is pressed
|
//only if the button is pressed
|
||||||
if (!btnDown())
|
if (!btnDown())
|
||||||
return;
|
return;
|
||||||
@@ -490,72 +560,64 @@ void checkButton(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/************************************
|
||||||
* The tuning jumps by 50 Hz on each step when you tune slowly
|
Replace function by KD8CEC
|
||||||
* As you spin the encoder faster, the jump size also increases
|
prevent error controls
|
||||||
* This way, you can quickly move to another band by just spinning the
|
applied Threshold for reduct errors, dial Lock, dynamic Step
|
||||||
* tuning knob
|
*************************************/
|
||||||
*/
|
byte threshold = 2; //noe action for count
|
||||||
|
unsigned long lastEncInputtime = 0;
|
||||||
|
int encodedSumValue = 0;
|
||||||
|
#define encodeTimeOut 1000
|
||||||
void doTuning(){
|
void doTuning(){
|
||||||
int s = 0;
|
int s = 0;
|
||||||
unsigned long prev_freq;
|
unsigned long prev_freq;
|
||||||
int incdecValue = 0;
|
long incdecValue = 0;
|
||||||
|
|
||||||
if (isDialLock == 1)
|
if ((vfoActive == VFO_A && ((isDialLock & 0x01) == 0x01)) ||
|
||||||
|
(vfoActive == VFO_B && ((isDialLock & 0x02) == 0x02)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (isCWAutoMode == 0 || cwAutoDialType == 1)
|
if (isCWAutoMode == 0 || cwAutoDialType == 1)
|
||||||
s = enc_read();
|
s = enc_read();
|
||||||
|
|
||||||
if (s){
|
//if time is exceeded, it is recognized as an error,
|
||||||
prev_freq = frequency;
|
//ignore exists values, because of errors
|
||||||
|
if (s == 0) {
|
||||||
if (s > 10)
|
if (encodedSumValue != 0 && (millis() - encodeTimeOut) > lastEncInputtime)
|
||||||
incdecValue = 200000l;
|
encodedSumValue = 0;
|
||||||
if (s > 7)
|
return;
|
||||||
incdecValue = 10000l;
|
|
||||||
else if (s > 4)
|
|
||||||
incdecValue = 1000l;
|
|
||||||
else if (s > 2)
|
|
||||||
incdecValue = 500;
|
|
||||||
else if (s > 0)
|
|
||||||
incdecValue = 50l;
|
|
||||||
else if (s > -2)
|
|
||||||
incdecValue = -50l;
|
|
||||||
else if (s > -4)
|
|
||||||
incdecValue = -500l;
|
|
||||||
else if (s > -7)
|
|
||||||
incdecValue = -1000l;
|
|
||||||
else if (s > -9)
|
|
||||||
incdecValue = -10000l;
|
|
||||||
else
|
|
||||||
incdecValue = -200000l;
|
|
||||||
|
|
||||||
if (incdecValue > 0 && frequency + incdecValue > HIGHEST_FREQ_DIAL)
|
|
||||||
frequency = HIGHEST_FREQ_DIAL;
|
|
||||||
else if (incdecValue < 0 && frequency < -incdecValue + LOWEST_FREQ_DIAL) //for compute and compare based integer type.
|
|
||||||
frequency = LOWEST_FREQ_DIAL;
|
|
||||||
else
|
|
||||||
frequency += incdecValue;
|
|
||||||
|
|
||||||
if (prev_freq < 10000000l && frequency > 10000000l)
|
|
||||||
isUSB = true;
|
|
||||||
|
|
||||||
if (prev_freq > 10000000l && frequency < 10000000l)
|
|
||||||
isUSB = false;
|
|
||||||
|
|
||||||
setFrequency(frequency);
|
|
||||||
updateDisplay();
|
|
||||||
}
|
}
|
||||||
|
lastEncInputtime = millis();
|
||||||
|
|
||||||
|
//for check moving direction
|
||||||
|
encodedSumValue += (s > 0 ? 1 : -1);
|
||||||
|
|
||||||
|
//check threshold
|
||||||
|
if ((encodedSumValue * encodedSumValue) <= (threshold * threshold))
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Valid Action without noise
|
||||||
|
encodedSumValue = 0;
|
||||||
|
|
||||||
|
prev_freq = frequency;
|
||||||
|
//incdecValue = tuningStep * s;
|
||||||
|
frequency += (arTuneStep[tuneStepIndex -1] * s);
|
||||||
|
|
||||||
|
if (prev_freq < 10000000l && frequency > 10000000l)
|
||||||
|
isUSB = true;
|
||||||
|
|
||||||
|
if (prev_freq > 10000000l && frequency < 10000000l)
|
||||||
|
isUSB = false;
|
||||||
|
|
||||||
|
setFrequency(frequency);
|
||||||
|
updateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RIT only steps back and forth by 100 hz at a time
|
* RIT only steps back and forth by 100 hz at a time
|
||||||
*/
|
*/
|
||||||
void doRIT(){
|
void doRIT(){
|
||||||
unsigned long newFreq;
|
|
||||||
|
|
||||||
int knob = enc_read();
|
int knob = enc_read();
|
||||||
unsigned long old_freq = frequency;
|
unsigned long old_freq = frequency;
|
||||||
|
|
||||||
@@ -611,6 +673,7 @@ void storeFrequencyAndMode(byte saveType)
|
|||||||
void initSettings(){
|
void initSettings(){
|
||||||
//read the settings from the eeprom and restore them
|
//read the settings from the eeprom and restore them
|
||||||
//if the readings are off, then set defaults
|
//if the readings are off, then set defaults
|
||||||
|
//for original source Section ===========================
|
||||||
EEPROM.get(MASTER_CAL, calibration);
|
EEPROM.get(MASTER_CAL, calibration);
|
||||||
EEPROM.get(USB_CAL, usbCarrier);
|
EEPROM.get(USB_CAL, usbCarrier);
|
||||||
EEPROM.get(VFO_A, vfoA);
|
EEPROM.get(VFO_A, vfoA);
|
||||||
@@ -618,6 +681,30 @@ void initSettings(){
|
|||||||
EEPROM.get(CW_SIDETONE, sideTone);
|
EEPROM.get(CW_SIDETONE, sideTone);
|
||||||
EEPROM.get(CW_SPEED, cwSpeed);
|
EEPROM.get(CW_SPEED, cwSpeed);
|
||||||
|
|
||||||
|
//for custom source Section =============================
|
||||||
|
//ID & Version Check from EEProm
|
||||||
|
//if found different firmware, erase eeprom (32
|
||||||
|
#define FIRMWAR_ID_ADDR 776 //776 : 0x59, 777 :0x58, 778 : 0x68 : Id Number, if not found id, erase eeprom(32~1023) for prevent system error.
|
||||||
|
if (EEPROM.read(FIRMWAR_ID_ADDR) != 0x59 ||
|
||||||
|
EEPROM.read(FIRMWAR_ID_ADDR + 1) != 0x58 ||
|
||||||
|
EEPROM.read(FIRMWAR_ID_ADDR + 2) != 0x68 ) {
|
||||||
|
|
||||||
|
printLineF(1, F("Init EEProm..."));
|
||||||
|
//initial all eeprom
|
||||||
|
for (unsigned int i = 32; i < 1024; i++) //protect Master_cal, usb_cal
|
||||||
|
EEPROM.write(i, 0);
|
||||||
|
|
||||||
|
//Write Firmware ID
|
||||||
|
EEPROM.write(FIRMWAR_ID_ADDR, 0x59);
|
||||||
|
EEPROM.write(FIRMWAR_ID_ADDR + 1, 0x58);
|
||||||
|
EEPROM.write(FIRMWAR_ID_ADDR + 2, 0x68);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Version Write for Memory Management Software
|
||||||
|
if (EEPROM.read(VERSION_ADDRESS) != VERSION_NUM)
|
||||||
|
EEPROM.write(VERSION_ADDRESS, VERSION_NUM);
|
||||||
|
|
||||||
|
|
||||||
//for Save VFO_A_MODE to eeprom
|
//for Save VFO_A_MODE to eeprom
|
||||||
//0: default, 1:not use, 2:LSB, 3:USB, 4:CW, 5:AM, 6:FM
|
//0: default, 1:not use, 2:LSB, 3:USB, 4:CW, 5:AM, 6:FM
|
||||||
EEPROM.get(VFO_A_MODE, vfoA_mode);
|
EEPROM.get(VFO_A_MODE, vfoA_mode);
|
||||||
@@ -633,9 +720,68 @@ void initSettings(){
|
|||||||
if (EEPROM.read(USER_CALLSIGN_KEY) == 0x59)
|
if (EEPROM.read(USER_CALLSIGN_KEY) == 0x59)
|
||||||
userCallsignLength = EEPROM.read(USER_CALLSIGN_LEN); //MAXIMUM 18 LENGTH
|
userCallsignLength = EEPROM.read(USER_CALLSIGN_LEN); //MAXIMUM 18 LENGTH
|
||||||
|
|
||||||
//Version Write for Memory Management Software
|
//Ham Band Count
|
||||||
if (EEPROM.read(VERSION_ADDRESS) != VERSION_NUM)
|
EEPROM.get(HAM_BAND_COUNT, useHamBandCount);
|
||||||
EEPROM.write(VERSION_ADDRESS, VERSION_NUM);
|
EEPROM.get(TX_TUNE_TYPE, tuneTXType);
|
||||||
|
|
||||||
|
byte findedValidValueCount = 0;
|
||||||
|
|
||||||
|
//Read band Information
|
||||||
|
for (byte i = 0; i < useHamBandCount; i++) {
|
||||||
|
unsigned int tmpReadValue = 0;
|
||||||
|
EEPROM.get(HAM_BAND_RANGE + 4 * i, tmpReadValue);
|
||||||
|
hamBandRange[i][0] = tmpReadValue;
|
||||||
|
|
||||||
|
if (tmpReadValue > 1 && tmpReadValue < 55000)
|
||||||
|
findedValidValueCount++;
|
||||||
|
|
||||||
|
EEPROM.get(HAM_BAND_RANGE + 4 * i + 2, tmpReadValue);
|
||||||
|
hamBandRange[i][1] = tmpReadValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check Value Range and default Set for new users
|
||||||
|
if ((3 < tuneTXType && tuneTXType < 100) || 103 < tuneTXType || useHamBandCount < 1 || findedValidValueCount < 5)
|
||||||
|
{
|
||||||
|
tuneTXType = 2;
|
||||||
|
//if empty band Information, auto insert default region 1 frequency range
|
||||||
|
//This part is made temporary for people who have difficulty setting up, so can remove it when you run out of memory.
|
||||||
|
useHamBandCount = 10;
|
||||||
|
hamBandRange[0][0] = 1810; hamBandRange[0][1] = 2000;
|
||||||
|
hamBandRange[1][0] = 3500; hamBandRange[1][1] = 3800;
|
||||||
|
hamBandRange[2][0] = 5351; hamBandRange[2][1] = 5367;
|
||||||
|
hamBandRange[3][0] = 7000; hamBandRange[3][1] = 7200;
|
||||||
|
hamBandRange[4][0] = 10100; hamBandRange[4][1] = 10150;
|
||||||
|
hamBandRange[5][0] = 14000; hamBandRange[5][1] = 14350;
|
||||||
|
hamBandRange[6][0] = 18068; hamBandRange[6][1] = 18168;
|
||||||
|
hamBandRange[7][0] = 21000; hamBandRange[7][1] = 21450;
|
||||||
|
hamBandRange[8][0] = 24890; hamBandRange[8][1] = 24990;
|
||||||
|
hamBandRange[9][0] = 28000; hamBandRange[9][1] = 29700;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Read Tuning Step Index, and steps
|
||||||
|
findedValidValueCount = 0;
|
||||||
|
EEPROM.get(TUNING_STEP, tuneStepIndex);
|
||||||
|
for (byte i = 0; i < 5; i++) {
|
||||||
|
arTuneStep[i] = EEPROM.read(TUNING_STEP + i + 1);
|
||||||
|
if (arTuneStep[i] >= 1 && arTuneStep[i] < 251) //Maximum 250 for check valid Value
|
||||||
|
findedValidValueCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check Value Range and default Set for new users
|
||||||
|
if (findedValidValueCount < 5)
|
||||||
|
{
|
||||||
|
//Default Setting
|
||||||
|
arTuneStep[0] = 10;
|
||||||
|
arTuneStep[1] = 20;
|
||||||
|
arTuneStep[2] = 50;
|
||||||
|
arTuneStep[3] = 100;
|
||||||
|
arTuneStep[4] = 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tuneStepIndex == 0) //New User
|
||||||
|
tuneStepIndex = 3;
|
||||||
|
|
||||||
|
|
||||||
if (cwDelayTime < 1 || cwDelayTime > 250)
|
if (cwDelayTime < 1 || cwDelayTime > 250)
|
||||||
cwDelayTime = 60;
|
cwDelayTime = 60;
|
||||||
@@ -715,28 +861,35 @@ void initPorts(){
|
|||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
//Init EEProm for Fault EEProm TEST and Factory Reset
|
|
||||||
/*
|
/*
|
||||||
for (int i = 0; i < 1024; i++)
|
//Init EEProm for Fault EEProm TEST and Factory Reset
|
||||||
EEPROM.write(i, 0);
|
//please remove remark for others.
|
||||||
|
//for (int i = 0; i < 1024; i++)
|
||||||
|
for (int i = 16; i < 1024; i++) //protect Master_cal, usb_cal
|
||||||
|
EEPROM.write(i, 0xFF);
|
||||||
|
lcd.begin(16, 2);
|
||||||
|
printLineF(1, F("Complete Erase"));
|
||||||
|
sleep(1000);
|
||||||
|
//while(1);
|
||||||
|
//end section of test
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//Serial.begin(9600);
|
//Serial.begin(9600);
|
||||||
lcd.begin(16, 2);
|
lcd.begin(16, 2);
|
||||||
|
printLineF(1, F("CECBT v0.27"));
|
||||||
|
|
||||||
Init_Cat(38400, SERIAL_8N1);
|
Init_Cat(38400, SERIAL_8N1);
|
||||||
initMeter(); //not used in this build
|
initMeter(); //not used in this build
|
||||||
initSettings();
|
initSettings();
|
||||||
|
|
||||||
printLineF(1, F("CECBT v0.25"));
|
if (userCallsignLength > 0 && ((userCallsignLength & 0x80) == 0x80)) {
|
||||||
if (userCallsignLength > 0 && ((userCallsignLength & 0x80) == 0x80))
|
|
||||||
{
|
|
||||||
userCallsignLength = userCallsignLength & 0x7F;
|
userCallsignLength = userCallsignLength & 0x7F;
|
||||||
printLineFromEEPRom(0, 0, 0, userCallsignLength -1); //eeprom to lcd use offset (USER_CALLSIGN_DAT)
|
printLineFromEEPRom(0, 0, 0, userCallsignLength -1); //eeprom to lcd use offset (USER_CALLSIGN_DAT)
|
||||||
|
delay(500);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
printLineF(0, F("uBITX v0.20"));
|
printLineF(0, F("uBITX v0.20"));
|
||||||
delay_background(500, 0);
|
delay(500);
|
||||||
printLine2("");
|
printLine2("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -751,95 +904,6 @@ void setup()
|
|||||||
|
|
||||||
if (btnDown())
|
if (btnDown())
|
||||||
factory_alignment();
|
factory_alignment();
|
||||||
|
|
||||||
/*
|
|
||||||
//This is for auto key test
|
|
||||||
EEPROM.put(CW_AUTO_MAGIC_KEY, 0x73); //MAGIC KEY
|
|
||||||
EEPROM.put(CW_AUTO_COUNT, 3); //WORD COUNT
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 0, 6); // 0 word begin postion / CQCQ TEST K
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 1, 33); // 0 word end postion / CQCQ TEST K
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 2, 34); //1 word begin position / LOL LOL
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 3, 40); //1 word end position / LOL LOL
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 4, 41); //2 word begin position / /?![]789
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 5, 48); //2 word end position / /?![]789
|
|
||||||
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 6, 'C'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 7, 'Q'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 8, 'C'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 9, 'Q'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 10, ' '); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 11, 'D'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 12, 'E'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 13, ' '); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 14, 'K'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 15, 'D'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 16, '8'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 17, 'C'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 18, 'E'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 19, 'C'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 20, ' '); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 21, 'E'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 22, 'M'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 23, '3'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 24, '7'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 25, ' '); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 26, 'D'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 27, 'E'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 28, ' '); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 29, 'C'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 30, 'E'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 31, 'C'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 32, ' '); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 33, 'K'); //
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 34, '<'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 35, ' '); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 36, '>'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 37, ' '); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 38, '7'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 39, '3'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 40, 'K'); //
|
|
||||||
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 41, 'C'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 42, 'Q'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 43, ' '); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 44, '>'); // start "
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 45, ' '); // end "
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 46, '>'); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 47, ' '); //
|
|
||||||
EEPROM.put(CW_AUTO_DATA + 48, 'K'); //
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
//This is for auto key test2
|
|
||||||
//USER CALL SIGN
|
|
||||||
EEPROM.put(USER_CALLSIGN_KEY, 0x59); //MAGIC KEY
|
|
||||||
//EEPROM.put(USER_CALLSIGN_LEN, 10); //WORD COUNT
|
|
||||||
EEPROM.put(USER_CALLSIGN_LEN, 10 + 0x80); //WORD COUNT
|
|
||||||
|
|
||||||
EEPROM.put(USER_CALLSIGN_DAT + 1, 'K'); //
|
|
||||||
EEPROM.put(USER_CALLSIGN_DAT + 2, 'D'); //
|
|
||||||
EEPROM.put(USER_CALLSIGN_DAT + 3, '8'); //
|
|
||||||
EEPROM.put(USER_CALLSIGN_DAT + 4, 'C'); //
|
|
||||||
EEPROM.put(USER_CALLSIGN_DAT + 5, 'E'); //
|
|
||||||
EEPROM.put(USER_CALLSIGN_DAT + 6, 'C'); //
|
|
||||||
EEPROM.put(USER_CALLSIGN_DAT + 7, '/'); //
|
|
||||||
EEPROM.put(USER_CALLSIGN_DAT + 8, 'A'); //
|
|
||||||
EEPROM.put(USER_CALLSIGN_DAT + 9, 'B'); //
|
|
||||||
EEPROM.put(USER_CALLSIGN_DAT + 10, 'C'); //
|
|
||||||
|
|
||||||
//CW QSO CALLSIGN
|
|
||||||
EEPROM.put(CW_STATION_LEN, 6); //
|
|
||||||
EEPROM.put(CW_STATION_LEN - 6 + 0 , 'A'); //
|
|
||||||
EEPROM.put(CW_STATION_LEN - 6 + 1 , 'B'); //
|
|
||||||
EEPROM.put(CW_STATION_LEN - 6 + 2 , '1'); //
|
|
||||||
EEPROM.put(CW_STATION_LEN - 6 + 3 , 'C'); //
|
|
||||||
EEPROM.put(CW_STATION_LEN - 6 + 4 , 'D'); //
|
|
||||||
EEPROM.put(CW_STATION_LEN - 6 + 5 , 'E'); //
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* CW Keyer
|
* CW Keyer
|
||||||
|
* CW Key logic change with ron's code (ubitx_keyer.cpp) <=== **********************************
|
||||||
|
* The file you are working on. The code only applies and is still in testing. <==== ***********
|
||||||
*
|
*
|
||||||
* The CW keyer handles either a straight key or an iambic / paddle key.
|
* The CW keyer handles either a straight key or an iambic / paddle key.
|
||||||
* They all use just one analog input line. This is how it works.
|
* They all use just one analog input line. This is how it works.
|
||||||
@@ -34,7 +36,6 @@
|
|||||||
//when both are simultaneously pressed
|
//when both are simultaneously pressed
|
||||||
char lastPaddle = 0;
|
char lastPaddle = 0;
|
||||||
|
|
||||||
|
|
||||||
//reads the analog keyer pin and reports the paddle
|
//reads the analog keyer pin and reports the paddle
|
||||||
byte getPaddle(){
|
byte getPaddle(){
|
||||||
int paddle = analogRead(ANALOG_KEYER);
|
int paddle = analogRead(ANALOG_KEYER);
|
||||||
@@ -81,13 +82,218 @@ void cwKeyUp(){
|
|||||||
cwTimeout = millis() + cwDelayTime * 10;
|
cwTimeout = millis() + cwDelayTime * 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
// New logic, by RON
|
||||||
|
// modified by KD8CEC
|
||||||
|
******************************************************************************/
|
||||||
|
#define DIT_L 0x01 // DIT latch
|
||||||
|
#define DAH_L 0x02 // DAH latch
|
||||||
|
#define DIT_PROC 0x04 // DIT is being processed
|
||||||
|
#define PDLSWAP 0x08 // 0 for normal, 1 for swap
|
||||||
|
#define IAMBICB 0x10 // 0 for Iambic A, 1 for Iambic B
|
||||||
|
enum KSTYPE {IDLE, CHK_DIT, CHK_DAH, KEYED_PREP, KEYED, INTER_ELEMENT };
|
||||||
|
|
||||||
|
static long ktimer;
|
||||||
|
|
||||||
|
bool Iambic_Key = true;
|
||||||
|
unsigned char keyerControl = IAMBICB;
|
||||||
|
unsigned char keyerState = IDLE;
|
||||||
|
|
||||||
|
//Below is a test to reduce the keying error.
|
||||||
|
/*
|
||||||
|
char update_PaddleLatch(byte isUpdateKeyState) {
|
||||||
|
int paddle = analogRead(ANALOG_KEYER);
|
||||||
|
unsigned char tmpKeyerControl;
|
||||||
|
|
||||||
|
if (paddle > 800) // above 4v is up
|
||||||
|
tmpKeyerControl = 0;
|
||||||
|
//else if (paddle > 600) // 4-3v is DASH
|
||||||
|
else if (paddle > 693 && paddle < 700) // 4-3v is DASH
|
||||||
|
tmpKeyerControl |= DAH_L;
|
||||||
|
//else if (paddle > 300) //1-2v is DOT
|
||||||
|
else if (paddle > 323 && paddle < 328) //1-2v is DOT
|
||||||
|
tmpKeyerControl |= DIT_L;
|
||||||
|
//else if (paddle > 50)
|
||||||
|
else if (paddle > 280 && paddle < 290)
|
||||||
|
tmpKeyerControl |= (DAH_L | DIT_L) ; //both are between 1 and 2v
|
||||||
|
else
|
||||||
|
tmpKeyerControl = 0 ; //STRAIGHT KEY in original code
|
||||||
|
//keyerControl |= (DAH_L | DIT_L) ; //STRAIGHT KEY in original code
|
||||||
|
|
||||||
|
if (isUpdateKeyState == 1) {
|
||||||
|
keyerControl |= tmpKeyerControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte buff[17];
|
||||||
|
sprintf(buff, "Key : %d", paddle);
|
||||||
|
if (tmpKeyerControl > 0)
|
||||||
|
printLine2(buff);
|
||||||
|
|
||||||
|
return tmpKeyerControl;
|
||||||
|
|
||||||
|
//if (analogRead(ANALOG_DOT) < 600 ) keyerControl |= DIT_L;
|
||||||
|
//if (analogRead(ANALOG_DASH) < 600 ) keyerControl |= DAH_L;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//create by KD8CEC for compatible with new CW Logic
|
||||||
|
char update_PaddleLatch(byte isUpdateKeyState) {
|
||||||
|
int paddle = analogRead(ANALOG_KEYER);
|
||||||
|
unsigned char tmpKeyerControl;
|
||||||
|
|
||||||
|
if (paddle > 800) // above 4v is up
|
||||||
|
tmpKeyerControl = 0;
|
||||||
|
else if (paddle > 600) // 4-3v is DASH
|
||||||
|
tmpKeyerControl |= DAH_L;
|
||||||
|
else if (paddle > 300) //1-2v is DOT
|
||||||
|
tmpKeyerControl |= DIT_L;
|
||||||
|
else if (paddle > 50)
|
||||||
|
tmpKeyerControl |= (DAH_L | DIT_L) ; //both are between 1 and 2v
|
||||||
|
else
|
||||||
|
tmpKeyerControl = 0 ; //STRAIGHT KEY in original code
|
||||||
|
//keyerControl |= (DAH_L | DIT_L) ; //STRAIGHT KEY in original code
|
||||||
|
|
||||||
|
if (isUpdateKeyState == 1) {
|
||||||
|
keyerControl |= tmpKeyerControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tmpKeyerControl;
|
||||||
|
//if (analogRead(ANALOG_DOT) < 600 ) keyerControl |= DIT_L;
|
||||||
|
//if (analogRead(ANALOG_DASH) < 600 ) keyerControl |= DAH_L;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cwKeyer(void){
|
||||||
|
byte paddle;
|
||||||
|
lastPaddle = 0;
|
||||||
|
int dot,dash;
|
||||||
|
bool continue_loop = true;
|
||||||
|
unsigned tmpKeyControl = 0;
|
||||||
|
if( Iambic_Key ){
|
||||||
|
|
||||||
|
while(continue_loop){
|
||||||
|
switch (keyerState) {
|
||||||
|
case IDLE:
|
||||||
|
tmpKeyControl = update_PaddleLatch(0);
|
||||||
|
if ( tmpKeyControl == DAH_L || tmpKeyControl == DIT_L ||
|
||||||
|
tmpKeyControl == (DAH_L | DIT_L) || (keyerControl & 0x03)) {
|
||||||
|
//DIT or DASH or current state DIT & DASH
|
||||||
|
//(analogRead(ANALOG_DOT) < 600) || //DIT
|
||||||
|
//(analogRead(ANALOG_DASH) < 600) || //DIT
|
||||||
|
// (keyerControl & 0x03)) {
|
||||||
|
update_PaddleLatch(1);
|
||||||
|
keyerState = CHK_DIT;
|
||||||
|
}else{
|
||||||
|
if (0 < cwTimeout && cwTimeout < millis()){
|
||||||
|
cwTimeout = 0;
|
||||||
|
stopTx();
|
||||||
|
}
|
||||||
|
continue_loop = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CHK_DIT:
|
||||||
|
if (keyerControl & DIT_L) {
|
||||||
|
keyerControl |= DIT_PROC;
|
||||||
|
ktimer = cwSpeed;
|
||||||
|
keyerState = KEYED_PREP;
|
||||||
|
}else{
|
||||||
|
keyerState = CHK_DAH;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CHK_DAH:
|
||||||
|
if (keyerControl & DAH_L) {
|
||||||
|
ktimer = cwSpeed*3;
|
||||||
|
keyerState = KEYED_PREP;
|
||||||
|
}else{
|
||||||
|
keyerState = IDLE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KEYED_PREP:
|
||||||
|
ktimer += millis(); // set ktimer to interval end time
|
||||||
|
keyerControl &= ~(DIT_L + DAH_L); // clear both paddle latch bits
|
||||||
|
keyerState = KEYED; // next state
|
||||||
|
if (!inTx){
|
||||||
|
keyDown = 0;
|
||||||
|
cwTimeout = millis() + cwDelayTime * 10; //+ CW_TIMEOUT;
|
||||||
|
startTx(TX_CW, 0);
|
||||||
|
}
|
||||||
|
cwKeydown();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KEYED:
|
||||||
|
if (millis() > ktimer) { // are we at end of key down ?
|
||||||
|
cwKeyUp();
|
||||||
|
ktimer = millis() + cwSpeed; // inter-element time
|
||||||
|
keyerState = INTER_ELEMENT; // next state
|
||||||
|
}else if (keyerControl & IAMBICB) {
|
||||||
|
update_PaddleLatch(1); // early paddle latch in Iambic B mode
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case INTER_ELEMENT:
|
||||||
|
// Insert time between dits/dahs
|
||||||
|
update_PaddleLatch(1); // latch paddle state
|
||||||
|
if (millis() > ktimer) { // are we at end of inter-space ?
|
||||||
|
if (keyerControl & DIT_PROC) { // was it a dit or dah ?
|
||||||
|
keyerControl &= ~(DIT_L + DIT_PROC); // clear two bits
|
||||||
|
keyerState = CHK_DAH; // dit done, check for dah
|
||||||
|
}else{
|
||||||
|
keyerControl &= ~(DAH_L); // clear dah latch
|
||||||
|
keyerState = IDLE; // go idle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} //end of while
|
||||||
|
|
||||||
|
}else{
|
||||||
|
while(1){
|
||||||
|
//if (analogRead(ANALOG_DOT) < 600){
|
||||||
|
if (update_PaddleLatch(0) == DIT_L) {
|
||||||
|
// if we are here, it is only because the key is pressed
|
||||||
|
if (!inTx){
|
||||||
|
keyDown = 0;
|
||||||
|
cwTimeout = millis() + cwDelayTime * 10; //+ CW_TIMEOUT;
|
||||||
|
startTx(TX_CW, 0);
|
||||||
|
}
|
||||||
|
// start the transmission)
|
||||||
|
cwKeydown();
|
||||||
|
//while ( analogRead(ANALOG_DOT) < 600 ) delay(1);
|
||||||
|
while ( update_PaddleLatch(0) == DIT_L ) delay(1);
|
||||||
|
cwKeyUp();
|
||||||
|
}else{
|
||||||
|
if (0 < cwTimeout && cwTimeout < millis()){
|
||||||
|
cwTimeout = 0;
|
||||||
|
keyDown = 0;
|
||||||
|
stopTx();
|
||||||
|
}
|
||||||
|
if (!cwTimeout)
|
||||||
|
return;
|
||||||
|
// got back to the beginning of the loop, if no further activity happens on straight key
|
||||||
|
// we will time out, and return out of this routine
|
||||||
|
delay(5);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} //end of else
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================================
|
||||||
|
//Before logic
|
||||||
|
//by Farhan and modified by KD8CEC
|
||||||
|
//======================================================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The keyer handles the straight key as well as the iambic key
|
* The keyer handles the straight key as well as the iambic key
|
||||||
* This module keeps looping until the user stops sending cw
|
* This module keeps looping until the user stops sending cw
|
||||||
* if the cwTimeout is set to 0, then it means, we have to exit the keyer loop
|
* if the cwTimeout is set to 0, then it means, we have to exit the keyer loop
|
||||||
* Each time the key is hit the cwTimeout is pushed to a time in the future by cwKeyDown()
|
* Each time the key is hit the cwTimeout is pushed to a time in the future by cwKeyDown()
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
void cwKeyer(){
|
void cwKeyer(){
|
||||||
byte paddle;
|
byte paddle;
|
||||||
lastPaddle = 0;
|
lastPaddle = 0;
|
||||||
@@ -111,17 +317,7 @@ void cwKeyer(){
|
|||||||
if (!cwTimeout)
|
if (!cwTimeout)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//if a paddle was used (not a straight key) we should extend the space to be a full dash
|
Check_Cat(2); //for uBITX on Raspberry pi, when straight keying, disconnect / test complete
|
||||||
//by adding two more dots long space (one has already been added at the end of the dot or dash)
|
|
||||||
/*
|
|
||||||
if (cwTimeout > 0 && lastPaddle != PADDLE_STRAIGHT)
|
|
||||||
delay_background(cwSpeed * 2, 3);
|
|
||||||
//delay(cwSpeed * 2);
|
|
||||||
|
|
||||||
// got back to the begining of the loop, if no further activity happens on the paddle or the straight key
|
|
||||||
// we will time out, and return out of this routine
|
|
||||||
delay(5);
|
|
||||||
*/
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,3 +380,6 @@ void cwKeyer(){
|
|||||||
delay(cwSpeed);
|
delay(cwSpeed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@@ -13,13 +13,10 @@
|
|||||||
#define printLineF1(x) (printLineF(1, x))
|
#define printLineF1(x) (printLineF(1, x))
|
||||||
#define printLineF2(x) (printLineF(0, x))
|
#define printLineF2(x) (printLineF(0, x))
|
||||||
|
|
||||||
int menuBand(int btn){
|
void menuBand(int btn){
|
||||||
int knob = 0;
|
int knob = 0;
|
||||||
int band;
|
int stepChangeCount = 0;
|
||||||
unsigned long offset;
|
byte btnPressCount = 0;
|
||||||
|
|
||||||
// band = frequency/1000000l;
|
|
||||||
// offset = frequency % 1000000l;
|
|
||||||
|
|
||||||
if (!btn){
|
if (!btn){
|
||||||
printLineF2(F("Band Select?"));
|
printLineF2(F("Band Select?"));
|
||||||
@@ -31,6 +28,32 @@ int menuBand(int btn){
|
|||||||
while (btnDown()) {
|
while (btnDown()) {
|
||||||
delay(50);
|
delay(50);
|
||||||
Check_Cat(0); //To prevent disconnections
|
Check_Cat(0); //To prevent disconnections
|
||||||
|
if (btnPressCount++ > 20) {
|
||||||
|
btnPressCount = 0;
|
||||||
|
if (tuneTXType > 0) { //Just toggle 0 <-> 2, if tuneTXType is 100, 100 -> 0 -> 2
|
||||||
|
tuneTXType = 0;
|
||||||
|
printLineF2(F("Full range mode"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tuneTXType = 2;
|
||||||
|
printLineF2(F("Ham band mode"));
|
||||||
|
}
|
||||||
|
delay_background(1000, 0);
|
||||||
|
printLine2ClearAndUpdate();
|
||||||
|
printLineF2(F("Press to confirm"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char currentBandIndex = -1;
|
||||||
|
//Save Band Information
|
||||||
|
if (tuneTXType == 2 || tuneTXType == 3 || tuneTXType == 102 || tuneTXType == 103) { //only ham band move
|
||||||
|
//Get Now Band Index
|
||||||
|
currentBandIndex = getIndexHambanBbyFreq(frequency);
|
||||||
|
|
||||||
|
if (currentBandIndex >= 0) {
|
||||||
|
//Save Frequency to Band Frequncy Record
|
||||||
|
saveBandFreqByIndex(frequency, modeToByte(), currentBandIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delay(50);
|
delay(50);
|
||||||
@@ -50,16 +73,35 @@ int menuBand(int btn){
|
|||||||
else
|
else
|
||||||
isUSB = false;
|
isUSB = false;
|
||||||
setFrequency(((unsigned long)band * 1000000l) + offset); */
|
setFrequency(((unsigned long)band * 1000000l) + offset); */
|
||||||
if (knob < 0 && frequency > 3000000l)
|
if (tuneTXType == 2 || tuneTXType == 3 || tuneTXType == 102 || tuneTXType == 103) { //only ham band move
|
||||||
setFrequency(frequency - 200000l);
|
if (knob < 0) {
|
||||||
if (knob > 0 && frequency < 30000000l)
|
if (stepChangeCount-- < -3) {
|
||||||
setFrequency(frequency + 200000l);
|
setNextHamBandFreq(frequency, -1); //Prior Band
|
||||||
if (frequency > 10000000l)
|
stepChangeCount = 0;
|
||||||
isUSB = true;
|
}
|
||||||
else
|
}
|
||||||
isUSB = false;
|
else if (knob > 0) {
|
||||||
|
if (stepChangeCount++ > 3) {
|
||||||
|
setNextHamBandFreq(frequency, 1); //Next Band
|
||||||
|
stepChangeCount = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else { //original source
|
||||||
|
if (knob < 0 && frequency > 3000000l)
|
||||||
|
setFrequency(frequency - 200000l);
|
||||||
|
if (knob > 0 && frequency < 30000000l)
|
||||||
|
setFrequency(frequency + 200000l);
|
||||||
|
|
||||||
|
if (frequency > 10000000l)
|
||||||
|
isUSB = true;
|
||||||
|
else
|
||||||
|
isUSB = false;
|
||||||
|
}
|
||||||
|
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
delay(20);
|
delay(20);
|
||||||
Check_Cat(0); //To prevent disconnections
|
Check_Cat(0); //To prevent disconnections
|
||||||
}
|
}
|
||||||
@@ -89,8 +131,16 @@ void byteToMode(byte modeValue){
|
|||||||
else
|
else
|
||||||
isUSB = 0;
|
isUSB = 0;
|
||||||
}
|
}
|
||||||
|
void byteWithFreqToMode(byte modeValue){
|
||||||
|
if (modeValue == 3)
|
||||||
|
isUSB = 1;
|
||||||
|
else if (modeValue == 0) //Not Set
|
||||||
|
isUSB = (frequency > 10000000l) ? true : false;
|
||||||
|
else
|
||||||
|
isUSB = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void menuVfoToggle(int btn)
|
void menuVfoToggle(int btn, char isUseDelayTime)
|
||||||
{
|
{
|
||||||
if (!btn){
|
if (!btn){
|
||||||
if (vfoActive == VFO_A)
|
if (vfoActive == VFO_A)
|
||||||
@@ -124,8 +174,9 @@ void menuVfoToggle(int btn)
|
|||||||
|
|
||||||
ritDisable();
|
ritDisable();
|
||||||
|
|
||||||
//updateDisplay();
|
if (isUseDelayTime == 1) //Found Issue in wsjt-x Linux 32bit
|
||||||
delay_background(500, 0);
|
delay_background(500, 0);
|
||||||
|
|
||||||
printLine2ClearAndUpdate();
|
printLine2ClearAndUpdate();
|
||||||
//exit the menu
|
//exit the menu
|
||||||
menuOn = 0;
|
menuOn = 0;
|
||||||
@@ -178,20 +229,20 @@ void menuSidebandToggle(int btn){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void menuTxOnOff(int btn){
|
void menuTxOnOff(int btn, byte optionType){
|
||||||
if (!btn){
|
if (!btn){
|
||||||
if (isTxOff == 0)
|
if ((isTxType & optionType) == 0)
|
||||||
printLineF2(F("TX OFF?"));
|
printLineF2(F("TX OFF?"));
|
||||||
else
|
else
|
||||||
printLineF2(F("TX ON?"));
|
printLineF2(F("TX ON?"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (isTxOff == 0){
|
if ((isTxType & optionType) == 0){
|
||||||
isTxOff = 1;
|
isTxType |= optionType;
|
||||||
printLineF2(F("TX OFF!"));
|
printLineF2(F("TX OFF!"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
isTxOff = 0;
|
isTxType &= ~(optionType);
|
||||||
printLineF2(F("TX ON!"));
|
printLineF2(F("TX ON!"));
|
||||||
}
|
}
|
||||||
delay_background(500, 0);
|
delay_background(500, 0);
|
||||||
@@ -236,7 +287,7 @@ void menuExit(int btn){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int menuCWSpeed(int btn){
|
void menuCWSpeed(int btn){
|
||||||
int knob = 0;
|
int knob = 0;
|
||||||
int wpm;
|
int wpm;
|
||||||
|
|
||||||
@@ -291,7 +342,7 @@ int menuCWSpeed(int btn){
|
|||||||
menuOn = 0;
|
menuOn = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int menuCWAutoKey(int btn){
|
void menuCWAutoKey(int btn){
|
||||||
if (!btn){
|
if (!btn){
|
||||||
printLineF2(F("CW AutoKey Mode?"));
|
printLineF2(F("CW AutoKey Mode?"));
|
||||||
return;
|
return;
|
||||||
@@ -314,7 +365,7 @@ int menuCWAutoKey(int btn){
|
|||||||
menuOn = 0;
|
menuOn = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int menuSetupCwDelay(int btn){
|
void menuSetupCwDelay(int btn){
|
||||||
int knob = 0;
|
int knob = 0;
|
||||||
int tmpCWDelay = cwDelayTime * 10;
|
int tmpCWDelay = cwDelayTime * 10;
|
||||||
|
|
||||||
@@ -362,7 +413,7 @@ int menuSetupCwDelay(int btn){
|
|||||||
menuOn = 0;
|
menuOn = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int menuSetupTXCWInterval(int btn){
|
void menuSetupTXCWInterval(int btn){
|
||||||
int knob = 0;
|
int knob = 0;
|
||||||
int tmpTXCWInterval = delayBeforeCWStartTime * 2;
|
int tmpTXCWInterval = delayBeforeCWStartTime * 2;
|
||||||
|
|
||||||
@@ -425,10 +476,8 @@ int menuSetupTXCWInterval(int btn){
|
|||||||
extern int32_t calibration;
|
extern int32_t calibration;
|
||||||
extern uint32_t si5351bx_vcoa;
|
extern uint32_t si5351bx_vcoa;
|
||||||
|
|
||||||
int factoryCalibration(int btn){
|
void factoryCalibration(int btn){
|
||||||
int knob = 0;
|
int knob = 0;
|
||||||
int32_t prev_calibration;
|
|
||||||
|
|
||||||
|
|
||||||
//keep clear of any previous button press
|
//keep clear of any previous button press
|
||||||
while (btnDown())
|
while (btnDown())
|
||||||
@@ -437,10 +486,9 @@ int factoryCalibration(int btn){
|
|||||||
|
|
||||||
if (!btn){
|
if (!btn){
|
||||||
printLineF2(F("Set Calibration?"));
|
printLineF2(F("Set Calibration?"));
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
prev_calibration = calibration;
|
|
||||||
calibration = 0;
|
calibration = 0;
|
||||||
|
|
||||||
isUSB = true;
|
isUSB = true;
|
||||||
@@ -495,13 +543,13 @@ int factoryCalibration(int btn){
|
|||||||
delay(100);
|
delay(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
int menuSetupCalibration(int btn){
|
void menuSetupCalibration(int btn){
|
||||||
int knob = 0;
|
int knob = 0;
|
||||||
int32_t prev_calibration;
|
int32_t prev_calibration;
|
||||||
|
|
||||||
if (!btn){
|
if (!btn){
|
||||||
printLineF2(F("Set Calibration?"));
|
printLineF2(F("Set Calibration?"));
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printLineF1(F("Set to Zero-beat,"));
|
printLineF1(F("Set to Zero-beat,"));
|
||||||
@@ -590,7 +638,8 @@ void menuSetupCarrier(int btn){
|
|||||||
printLineF1(F("PTT to confirm. "));
|
printLineF1(F("PTT to confirm. "));
|
||||||
delay_background(1000, 0);
|
delay_background(1000, 0);
|
||||||
|
|
||||||
usbCarrier = 11995000l;
|
//usbCarrier = 11995000l; //Remarked by KD8CEC, Suggest from many user, if entry routine factoryrest
|
||||||
|
|
||||||
si5351bx_setfreq(0, usbCarrier);
|
si5351bx_setfreq(0, usbCarrier);
|
||||||
printCarrierFreq(usbCarrier);
|
printCarrierFreq(usbCarrier);
|
||||||
|
|
||||||
@@ -677,11 +726,14 @@ void menuSetupCwTone(int btn){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setDialLock(byte tmpLock, byte fromMode) {
|
void setDialLock(byte tmpLock, byte fromMode) {
|
||||||
isDialLock = tmpLock;
|
if (tmpLock == 1)
|
||||||
|
isDialLock |= (vfoActive == VFO_A ? 0x01 : 0x02);
|
||||||
|
else
|
||||||
|
isDialLock &= ~(vfoActive == VFO_A ? 0x01 : 0x02);
|
||||||
|
|
||||||
if (fromMode == 2 || fromMode == 3) return;
|
if (fromMode == 2 || fromMode == 3) return;
|
||||||
|
|
||||||
if (isDialLock == 1)
|
if (tmpLock == 1)
|
||||||
printLineF2(F("Dial Lock ON"));
|
printLineF2(F("Dial Lock ON"));
|
||||||
else
|
else
|
||||||
printLineF2(F("Dial Lock OFF"));
|
printLineF2(F("Dial Lock OFF"));
|
||||||
@@ -690,28 +742,87 @@ void setDialLock(byte tmpLock, byte fromMode) {
|
|||||||
printLine2ClearAndUpdate();
|
printLine2ClearAndUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
int btnDownTimeCount;
|
unsigned int btnDownTimeCount;
|
||||||
|
|
||||||
|
#define PRESS_ADJUST_TUNE 1000
|
||||||
|
#define PRESS_LOCK_CONTROL 2000
|
||||||
|
|
||||||
void doMenu(){
|
void doMenu(){
|
||||||
int select=0, i,btnState;
|
int select=0, i,btnState;
|
||||||
|
char isNeedDisplay = 0;
|
||||||
|
|
||||||
//for DialLock On/Off function
|
//for DialLock On/Off function
|
||||||
btnDownTimeCount = 0;
|
btnDownTimeCount = 0;
|
||||||
|
|
||||||
//wait for the button to be raised up
|
//wait for the button to be raised up
|
||||||
|
|
||||||
|
//Appened Lines by KD8CEC for Adjust Tune step and Set Dial lock
|
||||||
while(btnDown()){
|
while(btnDown()){
|
||||||
delay(50);
|
delay(50);
|
||||||
Check_Cat(0); //To prevent disconnections
|
Check_Cat(0); //To prevent disconnections
|
||||||
|
|
||||||
//btnDownTimeCount++;
|
if (btnDownTimeCount++ == (PRESS_ADJUST_TUNE / 50)) { //Set Tune Step
|
||||||
//check long time Down Button -> 3 Second
|
printLineF2(F("Set Tune Step?"));
|
||||||
if (btnDownTimeCount++ > (2000 / 50)) {
|
}
|
||||||
setDialLock(isDialLock == 1 ? 0 : 1, 0); //Reverse Dialo lock
|
else if (btnDownTimeCount > (PRESS_LOCK_CONTROL / 50)) { //check long time Down Button -> 2.5 Second => Lock
|
||||||
|
if (vfoActive == VFO_A)
|
||||||
|
setDialLock((isDialLock & 0x01) == 0x01 ? 0 : 1, 0); //Reverse Dial lock
|
||||||
|
else
|
||||||
|
setDialLock((isDialLock & 0x02) == 0x02 ? 0 : 1, 0); //Reverse Dial lock
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delay(50); //debounce
|
delay(50); //debounce
|
||||||
|
|
||||||
|
//ADJUST TUNE STEP
|
||||||
|
if (btnDownTimeCount > (PRESS_ADJUST_TUNE / 50))
|
||||||
|
{
|
||||||
|
printLineF1(F("Press Key to set"));
|
||||||
|
isNeedDisplay = 1; //check to need display for display current value
|
||||||
|
|
||||||
|
while (digitalRead(PTT) == HIGH && !btnDown())
|
||||||
|
{
|
||||||
|
Check_Cat(0); //To prevent disconnections
|
||||||
|
delay(50); //debounce
|
||||||
|
|
||||||
|
if (isNeedDisplay) {
|
||||||
|
strcpy(b, "Tune Step:");
|
||||||
|
itoa(arTuneStep[tuneStepIndex -1], c, 10);
|
||||||
|
strcat(b, c);
|
||||||
|
printLine2(b);
|
||||||
|
isNeedDisplay = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
i = enc_read();
|
||||||
|
|
||||||
|
if (i != 0) {
|
||||||
|
select += (i > 0 ? 1 : -1);
|
||||||
|
|
||||||
|
if (select * select >= 25) { //Threshold 5 * 5 = 25
|
||||||
|
if (select < 0) {
|
||||||
|
if (tuneStepIndex > 1)
|
||||||
|
tuneStepIndex--;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (tuneStepIndex < 5)
|
||||||
|
tuneStepIndex++;
|
||||||
|
}
|
||||||
|
select = 0;
|
||||||
|
isNeedDisplay = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} //end of while
|
||||||
|
|
||||||
|
printLineF2(F("Changed Step!"));
|
||||||
|
//SAVE EEPROM
|
||||||
|
EEPROM.put(TUNING_STEP, tuneStepIndex);
|
||||||
|
delay_background(500, 0);
|
||||||
|
printLine2ClearAndUpdate();
|
||||||
|
return;
|
||||||
|
} //set tune step
|
||||||
|
|
||||||
|
//Below codes are origial code with modified by KD8CEC
|
||||||
|
//Select menu
|
||||||
menuOn = 2;
|
menuOn = 2;
|
||||||
|
|
||||||
while (menuOn){
|
while (menuOn){
|
||||||
@@ -724,15 +835,18 @@ void doMenu(){
|
|||||||
if (!modeCalibrate && select + i < 80)
|
if (!modeCalibrate && select + i < 80)
|
||||||
select += i;
|
select += i;
|
||||||
}
|
}
|
||||||
if (i < 0 && select - i >= 0)
|
//if (i < 0 && select - i >= 0)
|
||||||
|
if (i < 0 && select - i >= -10)
|
||||||
select += i; //caught ya, i is already -ve here, so you add it
|
select += i; //caught ya, i is already -ve here, so you add it
|
||||||
|
|
||||||
if (select < 10)
|
if (select < -5)
|
||||||
|
menuExit(btnState);
|
||||||
|
else if (select < 10)
|
||||||
menuBand(btnState);
|
menuBand(btnState);
|
||||||
else if (select < 20)
|
else if (select < 20)
|
||||||
menuRitToggle(btnState);
|
menuRitToggle(btnState);
|
||||||
else if (select < 30)
|
else if (select < 30)
|
||||||
menuVfoToggle(btnState);
|
menuVfoToggle(btnState, 1);
|
||||||
else if (select < 40)
|
else if (select < 40)
|
||||||
menuSidebandToggle(btnState);
|
menuSidebandToggle(btnState);
|
||||||
else if (select < 50)
|
else if (select < 50)
|
||||||
@@ -754,7 +868,7 @@ void doMenu(){
|
|||||||
else if (select < 130 && modeCalibrate)
|
else if (select < 130 && modeCalibrate)
|
||||||
menuSetupTXCWInterval(btnState);
|
menuSetupTXCWInterval(btnState);
|
||||||
else if (select < 140 && modeCalibrate)
|
else if (select < 140 && modeCalibrate)
|
||||||
menuTxOnOff(btnState);
|
menuTxOnOff(btnState, 0x01); //TX OFF / ON
|
||||||
else if (select < 150 && modeCalibrate)
|
else if (select < 150 && modeCalibrate)
|
||||||
menuExit(btnState);
|
menuExit(btnState);
|
||||||
|
|
||||||
|
@@ -62,7 +62,7 @@ void i2cWriten(uint8_t reg, uint8_t *vals, uint8_t vcnt) { // write array
|
|||||||
|
|
||||||
|
|
||||||
void si5351bx_init() { // Call once at power-up, start PLLA
|
void si5351bx_init() { // Call once at power-up, start PLLA
|
||||||
uint8_t reg; uint32_t msxp1;
|
uint32_t msxp1;
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
i2cWrite(149, 0); // SpreadSpectrum off
|
i2cWrite(149, 0); // SpreadSpectrum off
|
||||||
i2cWrite(3, si5351bx_clken); // Disable all CLK output drivers
|
i2cWrite(3, si5351bx_clken); // Disable all CLK output drivers
|
||||||
|
@@ -115,7 +115,7 @@ void drawMeter(int8_t needle){
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// The generic routine to display one line on the LCD
|
// The generic routine to display one line on the LCD
|
||||||
void printLine(char linenmbr, char *c) {
|
void printLine(unsigned char linenmbr, const char *c) {
|
||||||
if (strcmp(c, printBuff[linenmbr])) { // only refresh the display when there was a change
|
if (strcmp(c, printBuff[linenmbr])) { // only refresh the display when there was a change
|
||||||
lcd.setCursor(0, linenmbr); // place the cursor at the beginning of the selected line
|
lcd.setCursor(0, linenmbr); // place the cursor at the beginning of the selected line
|
||||||
lcd.print(c);
|
lcd.print(c);
|
||||||
@@ -160,11 +160,11 @@ void printLineFromEEPRom(char linenmbr, char lcdColumn, byte eepromStartIndex, b
|
|||||||
}
|
}
|
||||||
|
|
||||||
// short cut to print to the first line
|
// short cut to print to the first line
|
||||||
void printLine1(char *c){
|
void printLine1(const char *c){
|
||||||
printLine(1,c);
|
printLine(1,c);
|
||||||
}
|
}
|
||||||
// short cut to print to the first line
|
// short cut to print to the first line
|
||||||
void printLine2(char *c){
|
void printLine2(const char *c){
|
||||||
printLine(0,c);
|
printLine(0,c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +251,8 @@ void updateDisplay() {
|
|||||||
// strcat(c, " TX");
|
// strcat(c, " TX");
|
||||||
printLine(1, c);
|
printLine(1, c);
|
||||||
|
|
||||||
if (isDialLock == 1) {
|
if ((vfoActive == VFO_A && ((isDialLock & 0x01) == 0x01)) ||
|
||||||
|
(vfoActive == VFO_B && ((isDialLock & 0x02) == 0x02))) {
|
||||||
lcd.setCursor(5,1);
|
lcd.setCursor(5,1);
|
||||||
lcd.write((uint8_t)0);
|
lcd.write((uint8_t)0);
|
||||||
}
|
}
|
||||||
@@ -311,9 +312,9 @@ int enc_read(void) {
|
|||||||
byte newState;
|
byte newState;
|
||||||
int enc_speed = 0;
|
int enc_speed = 0;
|
||||||
|
|
||||||
long stop_by = millis() + 50;
|
unsigned long start_at = millis();
|
||||||
|
|
||||||
while (millis() < stop_by) { // check if the previous state was stable
|
while (millis() - start_at < 50) { // check if the previous state was stable
|
||||||
newState = enc_state(); // Get current state
|
newState = enc_state(); // Get current state
|
||||||
|
|
||||||
if (newState != enc_prev_state)
|
if (newState != enc_prev_state)
|
||||||
|
Reference in New Issue
Block a user