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"));
EEPROM.put(CW_SIDETONE, sideTone);
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;
@ -484,7 +484,8 @@ void WriteEEPRom_FT817(byte fromType)
printLineF2(F("Sidetone set! CAT"));
EEPROM.put(CW_SIDETONE, sideTone);
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;
@ -504,7 +505,7 @@ void WriteEEPRom_FT817(byte fromType)
printLineF2(F("CW Speed set!"));
EEPROM.put(CW_DELAY, cwDelayTime);
delay(300);
printLine2("");
clearLine2();
break;
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)
@ -513,7 +514,7 @@ void WriteEEPRom_FT817(byte fromType)
printLineF2(F("CW Speed set!"));
EEPROM.put(CW_SPEED, cwSpeed);
delay(300);
printLine2("");
clearLine2();
break;
/*

View File

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

View File

@ -84,6 +84,7 @@
#define PTT (A3)
#define ANALOG_KEYER (A6)
#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:
@ -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_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_KEY_TYPE 358
#define DISPLAY_OPTION1 361 //Display Option1
#define DISPLAY_OPTION2 362 //Display Option2
//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.
@ -258,6 +263,9 @@ 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
byte displayOption1 = 0;
byte displayOption2 = 0;
//CW ADC Range
int cwAdcSTFrom = 0;
int cwAdcSTTo = 0;
@ -267,6 +275,10 @@ int cwAdcDashFrom = 0;
int cwAdcDashTo = 0;
int cwAdcBothFrom = 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
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
boolean modeCalibrate = false;//this mode of menus shows extended menus to calibrate the oscillators and choose the proper
//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
* you start hacking around
@ -756,6 +772,24 @@ void initSettings(){
//CW interval between TX and CW Start
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
if (EEPROM.read(USER_CALLSIGN_KEY) == 0x59)
@ -923,6 +957,7 @@ void initPorts(){
pinMode(PTT, INPUT_PULLUP);
pinMode(ANALOG_KEYER, INPUT_PULLUP);
pinMode(ANALOG_SMETER, INPUT); //by KD8CEC
pinMode(CW_TONE, OUTPUT);
digitalWrite(CW_TONE, 0);
@ -958,7 +993,7 @@ void setup()
//Serial.begin(9600);
lcd.begin(16, 2);
printLineF(1, F("CECBT v0.30"));
printLineF(1, F("CECBT v0.31"));
Init_Cat(38400, SERIAL_8N1);
initMeter(); //not used in this build
@ -972,7 +1007,7 @@ void setup()
else {
printLineF(0, F("uBITX v0.20"));
delay(500);
printLine2("");
clearLine2();
}
initPorts();
@ -1046,7 +1081,12 @@ void loop(){
doRIT();
else
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
Check_Cat(inTx? 1 : 0);

View File

@ -14,6 +14,7 @@ void btnWaitForClick(){
void factory_alignment(){
factoryCalibration(1);
line2DisplayStatus = 1;
if (calibration == 0){
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
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. do not delete lines
@ -101,17 +99,17 @@ char update_PaddleLatch(byte isUpdateKeyState) {
unsigned char tmpKeyerControl;
int paddle = analogRead(ANALOG_KEYER);
if (paddle > cwAdcDashFrom && paddle < cwAdcDashTo)
if (paddle >= cwAdcDashFrom && paddle <= cwAdcDashTo)
tmpKeyerControl |= DAH_L;
else if (paddle > cwAdcDotFrom && paddle < cwAdcDotTo)
else if (paddle >= cwAdcDotFrom && paddle <= cwAdcDotTo)
tmpKeyerControl |= DIT_L;
else if (paddle > cwAdcBothFrom && paddle < cwAdcBothTo)
else if (paddle >= cwAdcBothFrom && paddle <= cwAdcBothTo)
tmpKeyerControl |= (DAH_L | DIT_L) ;
else
{
if (Iambic_Key)
tmpKeyerControl = 0 ;
else if (paddle > cwAdcSTFrom && paddle < cwAdcSTTo)
else if (paddle >= cwAdcSTFrom && paddle <= cwAdcSTTo)
tmpKeyerControl = DIT_L ;
else
tmpKeyerControl = 0 ;

View File

@ -235,6 +235,7 @@ void menuSidebandToggle(int btn){
}
}
/*
//Select CW Key Type by KD8CEC
void menuSetupKeyType(int btn){
if (!btn && digitalRead(PTT) == HIGH){
@ -269,6 +270,71 @@ void menuSetupKeyType(int btn){
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.
//by KD8CEC
@ -734,7 +800,6 @@ void menuSetupCalibration(int btn){
menuOn = 0;
}
void printCarrierFreq(unsigned long freq){
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
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
lcd.setCursor(0, linenmbr); // place the cursor at the beginning of the selected line
lcd.print(c);
@ -145,6 +148,9 @@ void printLineF(char linenmbr, const __FlashStringHelper *c)
#define LCD_MAX_COLUMN 16
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);
for (byte i = eepromStartIndex; i <= eepromEndIndex; i++)
@ -168,6 +174,12 @@ void printLine2(const char *c){
printLine(0,c);
}
void clearLine2()
{
printLine2("");
line2DisplayStatus = 0;
}
// short cut to print to the first line
void printLine1Clear(){
printLine(1,"");
@ -179,6 +191,7 @@ void printLine2Clear(){
void printLine2ClearAndUpdate(){
printLine(0, "");
line2DisplayStatus = 0;
updateDisplay();
}
@ -251,18 +264,22 @@ void updateDisplay() {
// strcat(c, " TX");
printLine(1, c);
byte diplayVFOLine = 1;
if ((displayOption1 & 0x01) == 0x01)
diplayVFOLine = 0;
if ((vfoActive == VFO_A && ((isDialLock & 0x01) == 0x01)) ||
(vfoActive == VFO_B && ((isDialLock & 0x02) == 0x02))) {
lcd.setCursor(5,1);
lcd.setCursor(5,diplayVFOLine);
lcd.write((uint8_t)0);
}
else if (isCWAutoMode == 2){
lcd.setCursor(5,1);
lcd.setCursor(5,diplayVFOLine);
lcd.write(0x7E);
}
else
{
lcd.setCursor(5,1);
lcd.setCursor(5,diplayVFOLine);
lcd.write(":");
}