ubitx-v5d-xcvr/ubitx_20/ubitx_idle.ino

255 lines
6.3 KiB
Arduino
Raw Normal View History

2018-01-29 04:38:48 -05:00
/*************************************************************************
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/>.
**************************************************************************/
2018-02-03 02:35:27 -05:00
char line2Buffer[16];
2018-01-29 08:49:30 -05:00
//KD8CEC 200Hz ST
//L14.150 200Hz ST
//U14.150 +150khz
2018-01-29 10:00:43 -05:00
int freqScrollPosition = 0;
2018-01-29 08:49:30 -05:00
//Example Line2 Optinal Display
//immediate execution, not call by scheulder
void updateLine2Buffer(char isDirectCall)
2018-01-29 08:49:30 -05:00
{
unsigned long tmpFreq = 0;
if (isDirectCall == 0)
2018-01-29 08:49:30 -05:00
{
if (ritOn)
{
2018-03-04 22:51:14 -05:00
strcpy(line2Buffer, "RitTX:");
//display frequency
tmpFreq = ritTxFrequency;
for (int i = 15; i >= 6; i--) {
if (tmpFreq > 0) {
if (i == 12 || i == 8) line2Buffer[i] = '.';
else {
line2Buffer[i] = tmpFreq % 10 + 0x30;
tmpFreq /= 10;
}
}
else
line2Buffer[i] = ' ';
}
return;
2018-02-03 02:35:27 -05:00
} //end of ritOn display
//======================================================
//other VFO display
//======================================================
if (vfoActive == VFO_B)
{
tmpFreq = vfoA;
}
else
{
tmpFreq = vfoB;
}
// EXAMPLE 1 & 2
//U14.150.100
2018-01-29 08:49:30 -05:00
//display frequency
for (int i = 9; i >= 0; i--) {
2018-01-29 08:49:30 -05:00
if (tmpFreq > 0) {
if (i == 2 || i == 6) line2Buffer[i] = '.';
2018-01-29 08:49:30 -05:00
else {
line2Buffer[i] = tmpFreq % 10 + 0x30;
tmpFreq /= 10;
}
}
else
line2Buffer[i] = ' ';
}
//EXAMPLE #1
2018-02-03 02:35:27 -05:00
if ((displayOption1 & 0x04) == 0x00) //none scroll display
2018-01-29 10:00:43 -05:00
line2Buffer[6] = 'k';
else
{
//example #2
2018-02-03 02:35:27 -05:00
if (freqScrollPosition++ > 18) //none scroll display time
2018-01-29 10:00:43 -05:00
{
line2Buffer[6] = 'k';
if (freqScrollPosition > 25)
freqScrollPosition = -1;
2018-01-29 10:00:43 -05:00
}
2018-02-03 02:35:27 -05:00
else //scroll frequency
2018-01-29 10:00:43 -05:00
{
line2Buffer[10] = 'H';
line2Buffer[11] = 'z';
2018-02-03 02:35:27 -05:00
if (freqScrollPosition < 7)
{
for (int i = 11; i >= 0; i--)
if (i - (7 - freqScrollPosition) >= 0)
line2Buffer[i] = line2Buffer[i - (7 - freqScrollPosition)];
else
line2Buffer[i] = ' ';
}
else
{
for (int i = 0; i < 11; i++)
if (i + (freqScrollPosition - 7) <= 11)
line2Buffer[i] = line2Buffer[i + (freqScrollPosition - 7)];
else
line2Buffer[i] = ' ';
}
2018-01-29 10:00:43 -05:00
}
2018-02-03 02:35:27 -05:00
} //scroll
line2Buffer[7] = ' ';
} //check direct call by encoder
if (isIFShift)
2018-01-29 08:49:30 -05:00
{
2018-01-30 04:43:08 -05:00
if (isDirectCall == 1)
for (int i = 0; i < 16; i++)
line2Buffer[i] = ' ';
//IFShift Offset Value
line2Buffer[8] = 'I';
line2Buffer[9] = 'F';
2018-03-04 22:51:14 -05:00
//if (ifShiftValue == 0)
//{
/*
2018-01-30 04:43:08 -05:00
line2Buffer[10] = 'S';
line2Buffer[11] = ':';
line2Buffer[12] = 'O';
line2Buffer[13] = 'F';
line2Buffer[14] = 'F';
2018-03-04 22:51:14 -05:00
*/
//}
//else
//{
2018-01-30 04:43:08 -05:00
line2Buffer[10] = ifShiftValue >= 0 ? '+' : 0;
line2Buffer[11] = 0;
line2Buffer[12] = ' ';
//11, 12, 13, 14, 15
memset(b, 0, sizeof(b));
ltoa(ifShiftValue, b, DEC);
strncat(line2Buffer, b, 5);
2018-03-04 22:51:14 -05:00
//}
2018-01-30 04:43:08 -05:00
if (isDirectCall == 1) //if call by encoder (not scheduler), immediate print value
printLine2(line2Buffer);
2018-02-03 02:35:27 -05:00
} // end of display IF
else // step display
2018-01-29 08:49:30 -05:00
{
if (isDirectCall != 0)
return;
2018-02-03 02:35:27 -05:00
memset(&line2Buffer[8], ' ', 8);
//Step
2018-02-03 02:35:27 -05:00
long tmpStep = arTuneStep[tuneStepIndex -1];
byte isStepKhz = 0;
if (tmpStep >= 1000)
{
isStepKhz = 2;
}
for (int i = 10; i >= 8 - isStepKhz; i--) {
if (tmpStep > 0) {
2018-02-03 02:35:27 -05:00
line2Buffer[i + isStepKhz] = tmpStep % 10 + 0x30;
tmpStep /= 10;
}
else
2018-02-03 02:35:27 -05:00
line2Buffer[i +isStepKhz] = ' ';
}
//if (isStepKhz == 1)
// line2Buffer[10] = 'k';
if (isStepKhz == 0)
{
line2Buffer[11] = 'H';
line2Buffer[12] = 'z';
}
line2Buffer[13] = ' ';
//if (
//Check CW Key cwKeyType = 0; //0: straight, 1 : iambica, 2: iambicb
if (cwKeyType == 0)
{
line2Buffer[14] = 'S';
line2Buffer[15] = 'T';
}
else if (cwKeyType == 1)
{
line2Buffer[14] = 'I';
line2Buffer[15] = 'A';
}
else
{
line2Buffer[14] = 'I';
line2Buffer[15] = 'B';
}
2018-01-29 08:49:30 -05:00
}
}
//meterType : 0 = S.Meter, 1 : P.Meter
void DisplayMeter(byte meterType, byte meterValue, char drawPosition)
{
2018-02-06 02:13:05 -05:00
if (meterType == 0 || meterType == 1 || meterType == 2)
{
drawMeter(meterValue); //call original source code
int lineNumber = 0;
if ((displayOption1 & 0x01) == 0x01)
lineNumber = 1;
lcd.setCursor(drawPosition, lineNumber);
2018-02-06 02:13:05 -05:00
for (int i = 0; i < 6; i++) //meter 5 + +db 1 = 6
lcd.write(lcdMeter[i]);
}
2018-01-29 08:49:30 -05:00
}
2018-01-29 04:38:48 -05:00
byte testValue = 0;
char checkCount = 0;
2018-01-29 04:38:48 -05:00
void idle_process()
{
//space for user graphic display
if (menuOn == 0)
{
2018-02-03 02:35:27 -05:00
if ((displayOption1 & 0x10) == 0x10) //always empty topline
return;
2018-01-29 04:38:48 -05:00
//if line2DisplayStatus == 0 <-- this condition is clear Line, you can display any message
2018-01-29 10:00:43 -05:00
if (line2DisplayStatus == 0 || (((displayOption1 & 0x04) == 0x04) && line2DisplayStatus == 2)) {
if (checkCount++ > 1)
{
updateLine2Buffer(0); //call by scheduler
printLine2(line2Buffer);
line2DisplayStatus = 2;
checkCount = 0;
}
//EX for Meters
/*
DisplayMeter(0, testValue++, 7);
if (testValue > 30)
testValue = 0;
*/
2018-01-29 09:02:46 -05:00
}
2018-01-29 04:38:48 -05:00
}
}