Compare commits

..

13 Commits

Author SHA1 Message Date
phdlee
b153a305d6 Merge branch 'master' into version0.29 2018-01-25 22:25:35 +09:00
phdlee
c7be3dcd39 test for new cw keying logic 2018-01-24 21:41:15 +09:00
phdlee
bbb23bf817 default set for new users 2018-01-22 21:16:29 +09:00
phdlee
4d61cf4de9 freq tunes, and set defualt values 2018-01-22 19:46:50 +09:00
phdlee
e61e45d3dd Update README.md 2018-01-22 18:26:22 +09:00
phdlee
a1f941f965 Update README.md 2018-01-22 18:25:41 +09:00
phdlee
d1e72b3bd5 Update README.md 2018-01-22 18:24:29 +09:00
phdlee
032e7f919f Update README.md 2018-01-22 18:21:55 +09:00
phdlee
b6bc264332 Update README.md 2018-01-22 18:11:15 +09:00
phdlee
b1cc5eb98a Update README.md 2018-01-22 02:11:35 +09:00
phdlee
2fa8247501 v0.29 prepare 2018-01-20 22:05:04 +09:00
phdlee
2fe1662d67 Merge pull request #8 from qiwenmin/master
Fixed most compilation warnings and a delay issue
2018-01-20 21:24:15 +09:00
Qi Wenmin
209cd3a49c Fixed most compilation warnings and a delay issue
* Fixed most compilation warnings (Compiler warning level: All)
* Fixed a delay issue in enc_read function.
2018-01-17 14:42:15 +08:00
8 changed files with 417 additions and 122 deletions

View File

@@ -1,7 +1,21 @@
#IMPORTANT INFORMATION
----------------------------------------------------------------------------
- Beta 0.26 and Beta 0.261, Beta 0.262, Beta 0.27 is complete test
- You can download and use it.
-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
----------------------------------------------------------------------------
@@ -46,6 +60,10 @@ Prepared or finished tasks for the next version
----------------------------------------------------------------------------
## 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)

View File

@@ -398,7 +398,7 @@ void ReadEEPRom_FT817(byte fromType)
void WriteEEPRom_FT817(byte fromType)
{
byte temp0 = CAT_BUFF[0];
//byte temp0 = CAT_BUFF[0];
byte temp1 = CAT_BUFF[1];
CAT_BUFF[0] = 0;

View File

@@ -208,10 +208,14 @@ void sendCWChar(char cwKeyChar)
charLength = ((tmpChar >> 6) & 0x03) + 3;
for (j = 0; j < charLength; j++)
sendBuff[j] = (tmpChar << j + 2) & 0x80;
sendBuff[j] = (tmpChar << (j + 2)) & 0x80;
break;
}
else
{
charLength = 0;
}
}
}
@@ -257,7 +261,7 @@ unsigned long scrollDispayTime = 0;
#define scrollSpeed 500
byte displayScrolStep = 0;
int controlAutoCW(){
void controlAutoCW(){
int knob = 0;
byte i;

View File

@@ -152,6 +152,7 @@ int count = 0; //to generally count ticks, loops, etc
#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.
@@ -211,7 +212,7 @@ unsigned long vfoA=7150000L, vfoB=14200000L, sideTone=800, usbCarrier;
unsigned long vfoA_eeprom, vfoB_eeprom; //for protect eeprom life
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;
//for store the mode in eeprom
@@ -235,7 +236,8 @@ byte sideToneSub = 0;
//DialLock
byte isDialLock = 0; //000000[0]vfoB [0]vfoA 0Bit : A, 1Bit : B
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
byte isCWAutoMode = 0; //0 : none, 1 : CW_AutoMode_Menu_Selection, 2 : CW_AutoMode Sending
@@ -320,8 +322,8 @@ void setNextHamBandFreq(unsigned long f, char moveDirection)
loadMode = (byte)(resultFreq >> 30);
resultFreq = resultFreq & 0x3FFFFFFF;
if ((resultFreq / 1000) < hamBandRange[findedIndex][0] || (resultFreq / 1000) > hamBandRange[findedIndex][1])
resultFreq = (unsigned long)(hamBandRange[findedIndex][0]) * 1000;
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);
@@ -422,10 +424,7 @@ void setTXFilters(unsigned long freq){
*/
void setFrequency(unsigned long f){
uint64_t osc_f;
//1 digits discarded
f = (f / 50) * 50;
f = (f / arTuneStep[tuneStepIndex -1]) * arTuneStep[tuneStepIndex -1];
setTXFilters(f);
@@ -448,8 +447,6 @@ void setFrequency(unsigned long f){
*/
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
@@ -545,8 +542,6 @@ void checkPTT(){
}
void checkButton(){
int i, t1, t2, knob, new_knob;
//only if the button is pressed
if (!btnDown())
return;
@@ -565,17 +560,19 @@ void checkButton(){
}
/**
* The tuning jumps by 50 Hz on each step when you tune slowly
* As you spin the encoder faster, the jump size also increases
* This way, you can quickly move to another band by just spinning the
* tuning knob
*/
/************************************
Replace function by KD8CEC
prevent error controls
applied Threshold for reduct errors, dial Lock, dynamic Step
*************************************/
byte threshold = 2; //noe action for count
unsigned long lastEncInputtime = 0;
int encodedSumValue = 0;
#define encodeTimeOut 1000
void doTuning(){
int s = 0;
unsigned long prev_freq;
int incdecValue = 0;
long incdecValue = 0;
if ((vfoActive == VFO_A && ((isDialLock & 0x01) == 0x01)) ||
(vfoActive == VFO_B && ((isDialLock & 0x02) == 0x02)))
@@ -584,54 +581,43 @@ void doTuning(){
if (isCWAutoMode == 0 || cwAutoDialType == 1)
s = enc_read();
if (s){
prev_freq = frequency;
if (s > 10)
incdecValue = 200000l;
if (s > 7)
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();
//if time is exceeded, it is recognized as an error,
//ignore exists values, because of errors
if (s == 0) {
if (encodedSumValue != 0 && (millis() - encodeTimeOut) > lastEncInputtime)
encodedSumValue = 0;
return;
}
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
*/
void doRIT(){
unsigned long newFreq;
int knob = enc_read();
unsigned long old_freq = frequency;
@@ -738,19 +724,65 @@ void initSettings(){
EEPROM.get(HAM_BAND_COUNT, useHamBandCount);
EEPROM.get(TX_TUNE_TYPE, tuneTXType);
if ((3 < tuneTXType && tuneTXType < 100) || 103 < tuneTXType || useHamBandCount < 1)
tuneTXType = 0;
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)
cwDelayTime = 60;

View File

@@ -1,5 +1,7 @@
/**
* 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.
* They all use just one analog input line. This is how it works.
@@ -34,7 +36,6 @@
//when both are simultaneously pressed
char lastPaddle = 0;
//reads the analog keyer pin and reports the paddle
byte getPaddle(){
int paddle = analogRead(ANALOG_KEYER);
@@ -81,13 +82,218 @@ void cwKeyUp(){
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
* 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
* Each time the key is hit the cwTimeout is pushed to a time in the future by cwKeyDown()
*/
/*
void cwKeyer(){
byte paddle;
lastPaddle = 0;
@@ -111,17 +317,7 @@ void cwKeyer(){
if (!cwTimeout)
return;
//if a paddle was used (not a straight key) we should extend the space to be a full dash
//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);
*/
Check_Cat(2); //for uBITX on Raspberry pi, when straight keying, disconnect / test complete
continue;
}
@@ -184,3 +380,6 @@ void cwKeyer(){
delay(cwSpeed);
}
}
*/

View File

@@ -13,7 +13,7 @@
#define printLineF1(x) (printLineF(1, x))
#define printLineF2(x) (printLineF(0, x))
int menuBand(int btn){
void menuBand(int btn){
int knob = 0;
int stepChangeCount = 0;
byte btnPressCount = 0;
@@ -36,21 +36,6 @@ int menuBand(int btn){
}
else {
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.
if (useHamBandCount < 1) {
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;
}
printLineF2(F("Ham band mode"));
}
delay_background(1000, 0);
@@ -302,7 +287,7 @@ void menuExit(int btn){
}
}
int menuCWSpeed(int btn){
void menuCWSpeed(int btn){
int knob = 0;
int wpm;
@@ -357,7 +342,7 @@ int menuCWSpeed(int btn){
menuOn = 0;
}
int menuCWAutoKey(int btn){
void menuCWAutoKey(int btn){
if (!btn){
printLineF2(F("CW AutoKey Mode?"));
return;
@@ -380,7 +365,7 @@ int menuCWAutoKey(int btn){
menuOn = 0;
}
int menuSetupCwDelay(int btn){
void menuSetupCwDelay(int btn){
int knob = 0;
int tmpCWDelay = cwDelayTime * 10;
@@ -428,7 +413,7 @@ int menuSetupCwDelay(int btn){
menuOn = 0;
}
int menuSetupTXCWInterval(int btn){
void menuSetupTXCWInterval(int btn){
int knob = 0;
int tmpTXCWInterval = delayBeforeCWStartTime * 2;
@@ -491,10 +476,8 @@ int menuSetupTXCWInterval(int btn){
extern int32_t calibration;
extern uint32_t si5351bx_vcoa;
int factoryCalibration(int btn){
void factoryCalibration(int btn){
int knob = 0;
int32_t prev_calibration;
//keep clear of any previous button press
while (btnDown())
@@ -503,10 +486,9 @@ int factoryCalibration(int btn){
if (!btn){
printLineF2(F("Set Calibration?"));
return 0;
return;
}
prev_calibration = calibration;
calibration = 0;
isUSB = true;
@@ -561,13 +543,13 @@ int factoryCalibration(int btn){
delay(100);
}
int menuSetupCalibration(int btn){
void menuSetupCalibration(int btn){
int knob = 0;
int32_t prev_calibration;
if (!btn){
printLineF2(F("Set Calibration?"));
return 0;
return;
}
printLineF1(F("Set to Zero-beat,"));
@@ -656,7 +638,8 @@ void menuSetupCarrier(int btn){
printLineF1(F("PTT to confirm. "));
delay_background(1000, 0);
usbCarrier = 11995000l;
//usbCarrier = 11995000l; //Remarked by KD8CEC, Suggest from many user, if entry routine factoryrest
si5351bx_setfreq(0, usbCarrier);
printCarrierFreq(usbCarrier);
@@ -759,22 +742,29 @@ void setDialLock(byte tmpLock, byte fromMode) {
printLine2ClearAndUpdate();
}
int btnDownTimeCount;
unsigned int btnDownTimeCount;
#define PRESS_ADJUST_TUNE 1000
#define PRESS_LOCK_CONTROL 2000
void doMenu(){
int select=0, i,btnState;
char isNeedDisplay = 0;
//for DialLock On/Off function
btnDownTimeCount = 0;
//wait for the button to be raised up
//Appened Lines by KD8CEC for Adjust Tune step and Set Dial lock
while(btnDown()){
delay(50);
Check_Cat(0); //To prevent disconnections
//btnDownTimeCount++;
//check long time Down Button -> 3 Second
if (btnDownTimeCount++ > (2000 / 50)) {
if (btnDownTimeCount++ == (PRESS_ADJUST_TUNE / 50)) { //Set Tune Step
printLineF2(F("Set Tune Step?"));
}
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
@@ -784,6 +774,55 @@ void doMenu(){
}
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;
while (menuOn){
@@ -796,10 +835,13 @@ void doMenu(){
if (!modeCalibrate && select + i < 80)
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
if (select < 10)
if (select < -5)
menuExit(btnState);
else if (select < 10)
menuBand(btnState);
else if (select < 20)
menuRitToggle(btnState);

View File

@@ -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
uint8_t reg; uint32_t msxp1;
uint32_t msxp1;
Wire.begin();
i2cWrite(149, 0); // SpreadSpectrum off
i2cWrite(3, si5351bx_clken); // Disable all CLK output drivers

View File

@@ -115,7 +115,7 @@ void drawMeter(int8_t needle){
*/
// 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
lcd.setCursor(0, linenmbr); // place the cursor at the beginning of the selected line
lcd.print(c);
@@ -160,11 +160,11 @@ void printLineFromEEPRom(char linenmbr, char lcdColumn, byte eepromStartIndex, b
}
// short cut to print to the first line
void printLine1(char *c){
void printLine1(const char *c){
printLine(1,c);
}
// short cut to print to the first line
void printLine2(char *c){
void printLine2(const char *c){
printLine(0,c);
}
@@ -312,9 +312,9 @@ int enc_read(void) {
byte newState;
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
if (newState != enc_prev_state)