Merge pull request #15 from phdlee/version0.31

Fixed Bug CW Key Range
Append Feature : Display Line Toggle, (Between line1 and line2)
 Append function : for other users / using s.meter, p.meter ... (when idle time execute function)
This commit is contained in:
phdlee 2018-01-29 18:44:05 +09:00 committed by GitHub
commit 04699ba074
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 174 additions and 18 deletions

View File

@ -472,7 +472,7 @@ void WriteEEPRom_FT817(byte fromType)
printLineF2(F("Sidetone set! CAT")); printLineF2(F("Sidetone set! CAT"));
EEPROM.put(CW_SIDETONE, sideTone); EEPROM.put(CW_SIDETONE, sideTone);
delay(300); //If timeout errors occur in the calling software, remove them delay(300); //If timeout errors occur in the calling software, remove them
printLine2(""); //Ham radio deluxe is the only one that supports this feature yet. and ham radio deluxe has wait time as greater than 500ms clearLine2();
} }
break; break;
@ -484,7 +484,8 @@ void WriteEEPRom_FT817(byte fromType)
printLineF2(F("Sidetone set! CAT")); printLineF2(F("Sidetone set! CAT"));
EEPROM.put(CW_SIDETONE, sideTone); EEPROM.put(CW_SIDETONE, sideTone);
delay(300); //If timeout errors occur in the calling software, remove them delay(300); //If timeout errors occur in the calling software, remove them
printLine2(""); //Ham radio deluxe is the only one that supports this feature yet. and ham radio deluxe has wait time as greater than 500ms clearLine2();
line2DisplayStatus = 0;
} }
break; break;
@ -504,7 +505,7 @@ void WriteEEPRom_FT817(byte fromType)
printLineF2(F("CW Speed set!")); printLineF2(F("CW Speed set!"));
EEPROM.put(CW_DELAY, cwDelayTime); EEPROM.put(CW_DELAY, cwDelayTime);
delay(300); delay(300);
printLine2(""); clearLine2();
break; break;
case 0x62 : // case 0x62 : //
//5-0 CW Speed (4-60 WPM) (#21) From 0 to 38 (HEX) with 0 = 4 WPM and 38 = 60 WPM (1 WPM steps) //5-0 CW Speed (4-60 WPM) (#21) From 0 to 38 (HEX) with 0 = 4 WPM and 38 = 60 WPM (1 WPM steps)
@ -513,7 +514,7 @@ void WriteEEPRom_FT817(byte fromType)
printLineF2(F("CW Speed set!")); printLineF2(F("CW Speed set!"));
EEPROM.put(CW_SPEED, cwSpeed); EEPROM.put(CW_SPEED, cwSpeed);
delay(300); delay(300);
printLine2(""); clearLine2();
break; break;
/* /*

View File

@ -299,7 +299,11 @@ void controlAutoCW(){
printLineFromEEPRom(0, 2, cwStartIndex + displayScrolStep + CW_DATA_OFSTADJ, cwEndIndex + CW_DATA_OFSTADJ); printLineFromEEPRom(0, 2, cwStartIndex + displayScrolStep + CW_DATA_OFSTADJ, cwEndIndex + CW_DATA_OFSTADJ);
lcd.setCursor(0,0); byte diplayAutoCWLine = 0;
if ((displayOption1 & 0x01) == 0x01)
diplayAutoCWLine = 1;
lcd.setCursor(0, diplayAutoCWLine);
lcd.write(byteToChar(selectedCWTextIndex)); lcd.write(byteToChar(selectedCWTextIndex));
lcd.write(':'); lcd.write(':');
isNeedScroll = (cwEndIndex - cwStartIndex) > 14 ? 1 : 0; isNeedScroll = (cwEndIndex - cwStartIndex) > 14 ? 1 : 0;

View File

@ -84,6 +84,7 @@
#define PTT (A3) #define PTT (A3)
#define ANALOG_KEYER (A6) #define ANALOG_KEYER (A6)
#define ANALOG_SPARE (A7) #define ANALOG_SPARE (A7)
#define ANALOG_SMETER (A7) //by KD8CEC
/** /**
* The Raduino board is the size of a standard 16x2 LCD panel. It has three connectors: * The Raduino board is the size of a standard 16x2 LCD panel. It has three connectors:
@ -172,6 +173,10 @@ int count = 0; //to generally count ticks, loops, etc
#define CW_ADC_DASH_TO 355 //CW ADC Range DASH to (Lower 8 bit) #define CW_ADC_DASH_TO 355 //CW ADC Range DASH to (Lower 8 bit)
#define CW_ADC_BOTH_FROM 356 //CW ADC Range BOTH from (Lower 8 bit) #define CW_ADC_BOTH_FROM 356 //CW ADC Range BOTH from (Lower 8 bit)
#define CW_ADC_BOTH_TO 357 //CW ADC Range BOTH to (Lower 8 bit) #define CW_ADC_BOTH_TO 357 //CW ADC Range BOTH to (Lower 8 bit)
#define CW_KEY_TYPE 358
#define DISPLAY_OPTION1 361 //Display Option1
#define DISPLAY_OPTION2 362 //Display Option2
//Check Firmware type and version //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 FIRMWAR_ID_ADDR 776 //776 : 0x59, 777 :0x58, 778 : 0x68 : Id Number, if not found id, erase eeprom(32~1023) for prevent system error.
@ -258,6 +263,9 @@ byte isTxType = 0; //000000[0 - isSplit] [0 - isTXStop]
byte arTuneStep[5]; byte arTuneStep[5];
byte tuneStepIndex; //default Value 0, start Offset is 0 because of check new user byte tuneStepIndex; //default Value 0, start Offset is 0 because of check new user
byte displayOption1 = 0;
byte displayOption2 = 0;
//CW ADC Range //CW ADC Range
int cwAdcSTFrom = 0; int cwAdcSTFrom = 0;
int cwAdcSTTo = 0; int cwAdcSTTo = 0;
@ -267,6 +275,10 @@ int cwAdcDashFrom = 0;
int cwAdcDashTo = 0; int cwAdcDashTo = 0;
int cwAdcBothFrom = 0; int cwAdcBothFrom = 0;
int cwAdcBothTo = 0; int cwAdcBothTo = 0;
byte cwKeyType = 0; //0: straight, 1 : iambica, 2: iambicb
bool Iambic_Key = true;
#define IAMBICB 0x10 // 0 for Iambic A, 1 for Iambic B
unsigned char keyerControl = IAMBICB;
//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
@ -296,6 +308,10 @@ unsigned long dbgCount = 0; //not used now
unsigned char txFilter = 0; //which of the four transmit filters are in use unsigned char txFilter = 0; //which of the four transmit filters are in use
boolean modeCalibrate = false;//this mode of menus shows extended menus to calibrate the oscillators and choose the proper boolean modeCalibrate = false;//this mode of menus shows extended menus to calibrate the oscillators and choose the proper
//beat frequency //beat frequency
unsigned long beforeIdle_ProcessTime = 0; //for check Idle time
byte line2DisplayStatus = 0; //0:Clear, 1 : menu, 1: DisplayFrom Idle,
/** /**
* Below are the basic functions that control the uBitx. Understanding the functions before * Below are the basic functions that control the uBitx. Understanding the functions before
* you start hacking around * you start hacking around
@ -756,6 +772,24 @@ void initSettings(){
//CW interval between TX and CW Start //CW interval between TX and CW Start
EEPROM.get(CW_START, delayBeforeCWStartTime); EEPROM.get(CW_START, delayBeforeCWStartTime);
EEPROM.get(CW_KEY_TYPE, cwKeyType);
if (cwKeyType > 2)
cwKeyType = 0;
if (cwKeyType == 0)
Iambic_Key = false;
else
{
Iambic_Key = true;
if (cwKeyType = 1)
keyerControl &= ~IAMBICB;
else
keyerControl |= IAMBICB;
}
EEPROM.get(DISPLAY_OPTION1, displayOption1);
EEPROM.get(DISPLAY_OPTION2, displayOption2);
//User callsign information //User callsign information
if (EEPROM.read(USER_CALLSIGN_KEY) == 0x59) if (EEPROM.read(USER_CALLSIGN_KEY) == 0x59)
@ -923,6 +957,7 @@ void initPorts(){
pinMode(PTT, INPUT_PULLUP); pinMode(PTT, INPUT_PULLUP);
pinMode(ANALOG_KEYER, INPUT_PULLUP); pinMode(ANALOG_KEYER, INPUT_PULLUP);
pinMode(ANALOG_SMETER, INPUT); //by KD8CEC
pinMode(CW_TONE, OUTPUT); pinMode(CW_TONE, OUTPUT);
digitalWrite(CW_TONE, 0); digitalWrite(CW_TONE, 0);
@ -958,7 +993,7 @@ void setup()
//Serial.begin(9600); //Serial.begin(9600);
lcd.begin(16, 2); lcd.begin(16, 2);
printLineF(1, F("CECBT v0.30")); printLineF(1, F("CECBT v0.31"));
Init_Cat(38400, SERIAL_8N1); Init_Cat(38400, SERIAL_8N1);
initMeter(); //not used in this build initMeter(); //not used in this build
@ -972,7 +1007,7 @@ void setup()
else { else {
printLineF(0, F("uBITX v0.20")); printLineF(0, F("uBITX v0.20"));
delay(500); delay(500);
printLine2(""); clearLine2();
} }
initPorts(); initPorts();
@ -1046,7 +1081,12 @@ void loop(){
doRIT(); doRIT();
else else
doTuningWithThresHold(); doTuningWithThresHold();
}
if (isCWAutoMode == 0 && beforeIdle_ProcessTime < millis() - 200) {
idle_process();
beforeIdle_ProcessTime = millis();
}
} //end of check TX Status
//we check CAT after the encoder as it might put the radio into TX //we check CAT after the encoder as it might put the radio into TX
Check_Cat(inTx? 1 : 0); Check_Cat(inTx? 1 : 0);

View File

@ -14,6 +14,7 @@ void btnWaitForClick(){
void factory_alignment(){ void factory_alignment(){
factoryCalibration(1); factoryCalibration(1);
line2DisplayStatus = 1;
if (calibration == 0){ if (calibration == 0){
printLine2("Setup Aborted"); printLine2("Setup Aborted");

30
ubitx_20/ubitx_idle.ino Normal file
View File

@ -0,0 +1,30 @@
/*************************************************************************
KD8CEC's uBITX Idle time Processing
Functions that run at times that do not affect TX, CW, and CAT
It is called in 1/10 time unit.
-----------------------------------------------------------------------------
This program 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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
void idle_process()
{
//space for user graphic display
if (menuOn == 0)
{
//if line2DisplayStatus == 0 <-- this condition is clear Line, you can display any message
}
}

View File

@ -91,8 +91,6 @@ void cwKeyUp(){
#define IAMBICB 0x10 // 0 for Iambic A, 1 for Iambic B #define IAMBICB 0x10 // 0 for Iambic A, 1 for Iambic B
enum KSTYPE {IDLE, CHK_DIT, CHK_DAH, KEYED_PREP, KEYED, INTER_ELEMENT }; enum KSTYPE {IDLE, CHK_DIT, CHK_DAH, KEYED_PREP, KEYED, INTER_ELEMENT };
static long ktimer; static long ktimer;
bool Iambic_Key = true;
unsigned char keyerControl = IAMBICB;
unsigned char keyerState = IDLE; unsigned char keyerState = IDLE;
//Below is a test to reduce the keying error. do not delete lines //Below is a test to reduce the keying error. do not delete lines
@ -101,17 +99,17 @@ char update_PaddleLatch(byte isUpdateKeyState) {
unsigned char tmpKeyerControl; unsigned char tmpKeyerControl;
int paddle = analogRead(ANALOG_KEYER); int paddle = analogRead(ANALOG_KEYER);
if (paddle > cwAdcDashFrom && paddle < cwAdcDashTo) if (paddle >= cwAdcDashFrom && paddle <= cwAdcDashTo)
tmpKeyerControl |= DAH_L; tmpKeyerControl |= DAH_L;
else if (paddle > cwAdcDotFrom && paddle < cwAdcDotTo) else if (paddle >= cwAdcDotFrom && paddle <= cwAdcDotTo)
tmpKeyerControl |= DIT_L; tmpKeyerControl |= DIT_L;
else if (paddle > cwAdcBothFrom && paddle < cwAdcBothTo) else if (paddle >= cwAdcBothFrom && paddle <= cwAdcBothTo)
tmpKeyerControl |= (DAH_L | DIT_L) ; tmpKeyerControl |= (DAH_L | DIT_L) ;
else else
{ {
if (Iambic_Key) if (Iambic_Key)
tmpKeyerControl = 0 ; tmpKeyerControl = 0 ;
else if (paddle > cwAdcSTFrom && paddle < cwAdcSTTo) else if (paddle >= cwAdcSTFrom && paddle <= cwAdcSTTo)
tmpKeyerControl = DIT_L ; tmpKeyerControl = DIT_L ;
else else
tmpKeyerControl = 0 ; tmpKeyerControl = 0 ;

View File

@ -235,6 +235,7 @@ void menuSidebandToggle(int btn){
} }
} }
/*
//Select CW Key Type by KD8CEC //Select CW Key Type by KD8CEC
void menuSetupKeyType(int btn){ void menuSetupKeyType(int btn){
if (!btn && digitalRead(PTT) == HIGH){ if (!btn && digitalRead(PTT) == HIGH){
@ -269,6 +270,71 @@ void menuSetupKeyType(int btn){
menuOn = 0; menuOn = 0;
} }
} }
*/
//Select CW Key Type by KD8CEC
void menuSetupKeyType(int btn){
int knob = 0;
int selectedKeyType = 0;
int moveStep = 0;
if (!btn && digitalRead(PTT) == HIGH){
printLineF2(F("Change Key Type?"));
}
else {
printLineF2(F("Press PTT to set"));
delay_background(500, 0);
selectedKeyType = cwKeyType;
while(!btnDown() && digitalRead(PTT) == HIGH){
//Display Key Type
if (selectedKeyType == 0)
printLineF1(F("Straight"));
else if (selectedKeyType == 1)
printLineF1(F("IAMBICA"));
else if (selectedKeyType == 2)
printLineF1(F("IAMBICB"));
knob = enc_read();
if (knob != 0)
{
moveStep += (knob > 0 ? 1 : -1);
if (selectedKeyType > 0 && moveStep < -3) {
selectedKeyType--;
moveStep = 0;
}
else if (selectedKeyType < 2 && moveStep > 3) {
selectedKeyType++;
moveStep = 0;
}
}
Check_Cat(0); //To prevent disconnections
}
//save the setting
if (digitalRead(PTT) == LOW){
printLineF2(F("CW Key Type set!"));
cwKeyType = selectedKeyType;
EEPROM.put(CW_KEY_TYPE, cwKeyType);
if (cwKeyType == 0)
Iambic_Key = false;
else
{
Iambic_Key = true;
if (cwKeyType = 1)
keyerControl &= ~IAMBICB;
else
keyerControl |= IAMBICB;
}
delay_background(2000, 0);
}
printLine2ClearAndUpdate();
menuOn = 0;
}
}
//Analog pin monitoring with CW Key and function keys connected. //Analog pin monitoring with CW Key and function keys connected.
//by KD8CEC //by KD8CEC
@ -734,7 +800,6 @@ void menuSetupCalibration(int btn){
menuOn = 0; menuOn = 0;
} }
void printCarrierFreq(unsigned long freq){ void printCarrierFreq(unsigned long freq){
memset(c, 0, sizeof(c)); memset(c, 0, sizeof(c));

View File

@ -116,6 +116,9 @@ 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(unsigned char linenmbr, const char *c) { void printLine(unsigned char linenmbr, const char *c) {
if ((displayOption1 & 0x01) == 0x01)
linenmbr = (linenmbr == 0 ? 1 : 0); //Line Toggle
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);
@ -145,6 +148,9 @@ void printLineF(char linenmbr, const __FlashStringHelper *c)
#define LCD_MAX_COLUMN 16 #define LCD_MAX_COLUMN 16
void printLineFromEEPRom(char linenmbr, char lcdColumn, byte eepromStartIndex, byte eepromEndIndex) { void printLineFromEEPRom(char linenmbr, char lcdColumn, byte eepromStartIndex, byte eepromEndIndex) {
if ((displayOption1 & 0x01) == 0x01)
linenmbr = (linenmbr == 0 ? 1 : 0); //Line Toggle
lcd.setCursor(lcdColumn, linenmbr); lcd.setCursor(lcdColumn, linenmbr);
for (byte i = eepromStartIndex; i <= eepromEndIndex; i++) for (byte i = eepromStartIndex; i <= eepromEndIndex; i++)
@ -168,6 +174,12 @@ void printLine2(const char *c){
printLine(0,c); printLine(0,c);
} }
void clearLine2()
{
printLine2("");
line2DisplayStatus = 0;
}
// short cut to print to the first line // short cut to print to the first line
void printLine1Clear(){ void printLine1Clear(){
printLine(1,""); printLine(1,"");
@ -179,6 +191,7 @@ void printLine2Clear(){
void printLine2ClearAndUpdate(){ void printLine2ClearAndUpdate(){
printLine(0, ""); printLine(0, "");
line2DisplayStatus = 0;
updateDisplay(); updateDisplay();
} }
@ -251,18 +264,22 @@ void updateDisplay() {
// strcat(c, " TX"); // strcat(c, " TX");
printLine(1, c); printLine(1, c);
byte diplayVFOLine = 1;
if ((displayOption1 & 0x01) == 0x01)
diplayVFOLine = 0;
if ((vfoActive == VFO_A && ((isDialLock & 0x01) == 0x01)) || if ((vfoActive == VFO_A && ((isDialLock & 0x01) == 0x01)) ||
(vfoActive == VFO_B && ((isDialLock & 0x02) == 0x02))) { (vfoActive == VFO_B && ((isDialLock & 0x02) == 0x02))) {
lcd.setCursor(5,1); lcd.setCursor(5,diplayVFOLine);
lcd.write((uint8_t)0); lcd.write((uint8_t)0);
} }
else if (isCWAutoMode == 2){ else if (isCWAutoMode == 2){
lcd.setCursor(5,1); lcd.setCursor(5,diplayVFOLine);
lcd.write(0x7E); lcd.write(0x7E);
} }
else else
{ {
lcd.setCursor(5,1); lcd.setCursor(5,diplayVFOLine);
lcd.write(":"); lcd.write(":");
} }