@@ -148,8 +148,12 @@ int count = 0; //to generally count ticks, loops, etc
148
148
#define VFO_B_MODE 257
149
149
#define CW_DELAY 258
150
150
#define CW_START 259
151
+ #define HAM_BAND_COUNT 260 //
152
+ #define TX_TUNE_TYPE 261 //
153
+ #define HAM_BAND_RANGE 262 // FROM (2BYTE) TO (2BYTE) * 10 = 40byte
154
+ #define HAM_BAND_FREQS 302 // 40, 1 BAND = 4Byte most bit is mode
151
155
152
- //
156
+ // Check Firmware type and version
153
157
#define VERSION_ADDRESS 779 // check Firmware version
154
158
// USER INFORMATION
155
159
#define USER_CALLSIGN_KEY 780 // 0x59
@@ -228,7 +232,7 @@ byte sideTonePitch=0;
228
232
byte sideToneSub = 0 ;
229
233
230
234
// DialLock
231
- byte isDialLock = 0 ;
235
+ byte isDialLock = 0 ; // 000000[0]vfoB [0]vfoA 0Bit : A, 1Bit : B
232
236
byte isTxOff = 0 ;
233
237
234
238
// Variables for auto cw mode
@@ -264,6 +268,69 @@ boolean modeCalibrate = false;//this mode of menus shows extended menus to calib
264
268
* you start hacking around
265
269
*/
266
270
271
+ // Ham Band
272
+ #define MAX_LIMIT_RANGE 10 // because limited eeprom size
273
+ byte useHamBandCount = 0 ; // 0 use full range frequency
274
+ 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
275
+ // 100 : use full range but not TX on general band, 101 : just change dial speed but.. 2 : jut... but.. 3 : only ham band
276
+ unsigned int hamBandRange[MAX_LIMIT_RANGE][2 ]; // = //Khz because reduce use memory
277
+
278
+ // -1 : not found, 0 ~ 9 : Hamband index
279
+ char getIndexHambanBbyFreq (unsigned long f)
280
+ {
281
+ f = f / 1000 ;
282
+ for (byte i = 0 ; i < useHamBandCount; i++)
283
+ if (hamBandRange[i][0 ] <= f && f < hamBandRange[i][1 ])
284
+ return i;
285
+
286
+ return -1 ;
287
+ }
288
+
289
+ // when Band change step = just hamband
290
+ // moveDirection : 1 = next, -1 : prior
291
+ void setNextHamBandFreq (unsigned long f, char moveDirection)
292
+ {
293
+ unsigned long resultFreq = 0 ;
294
+ byte loadMode = 0 ;
295
+ char findedIndex = getIndexHambanBbyFreq (f);
296
+
297
+ if (findedIndex == -1 ) { // out of hamband
298
+ f = f / 1000 ;
299
+ for (byte i = 0 ; i < useHamBandCount -1 ; i++) {
300
+ if (hamBandRange[i][1 ] <= f && f < hamBandRange[i + 1 ][0 ]) {
301
+ findedIndex = i + moveDirection;
302
+ // return (unsigned long)(hamBandRange[i + 1][0]) * 1000;
303
+ }
304
+ } // end of for
305
+ }
306
+ else if (((moveDirection == 1 ) && (findedIndex < useHamBandCount -1 )) || // Next
307
+ ((moveDirection == -1 ) && (findedIndex > 0 )) ) { // Prior
308
+ findedIndex += moveDirection;
309
+ }
310
+ else
311
+ findedIndex = -1 ;
312
+
313
+ if (findedIndex == -1 )
314
+ findedIndex = (moveDirection == 1 ? 0 : useHamBandCount -1 );
315
+
316
+ EEPROM.get (HAM_BAND_FREQS + 4 * findedIndex, resultFreq);
317
+
318
+ loadMode = (byte)(resultFreq >> 30 );
319
+ resultFreq = resultFreq & 0x3FFFFFFF ;
320
+
321
+ if ((resultFreq / 1000 ) < hamBandRange[findedIndex][0 ] || (resultFreq / 1000 ) > hamBandRange[findedIndex][1 ])
322
+ resultFreq = (unsigned long )(hamBandRange[findedIndex][0 ]) * 1000 ;
323
+
324
+ setFrequency (resultFreq);
325
+ byteWithFreqToMode (loadMode);
326
+ }
327
+
328
+ void saveBandFreqByIndex (unsigned long f, unsigned long mode, byte bandIndex) {
329
+ if (bandIndex >= 0 )
330
+ EEPROM.put (HAM_BAND_FREQS + 4 * bandIndex, (f & 0x3FFFFFFF ) | (mode << 30 ) );
331
+ }
332
+
333
+
267
334
/*
268
335
KD8CEC
269
336
When using the basic delay of the Arduino, the program freezes.
@@ -381,6 +448,12 @@ void setFrequency(unsigned long f){
381
448
void startTx (byte txMode, byte isDisplayUpdate){
382
449
unsigned long tx_freq = 0 ;
383
450
451
+ // Check Hamband only TX //Not found Hamband index by now frequency
452
+ if (tuneTXType >= 100 && getIndexHambanBbyFreq (ritOn ? ritTxFrequency : frequency) == -1 ) {
453
+ // no message
454
+ return ;
455
+ }
456
+
384
457
if (isTxOff != 1 )
385
458
digitalWrite (TX_RX, 1 );
386
459
@@ -502,7 +575,8 @@ void doTuning(){
502
575
unsigned long prev_freq;
503
576
int incdecValue = 0 ;
504
577
505
- if (isDialLock == 1 )
578
+ if ((vfoActive == VFO_A && ((isDialLock & 0x01 ) == 0x01 )) ||
579
+ (vfoActive == VFO_B && ((isDialLock & 0x02 ) == 0x02 )))
506
580
return ;
507
581
508
582
if (isCWAutoMode == 0 || cwAutoDialType == 1 )
@@ -636,6 +710,23 @@ void initSettings(){
636
710
// Version Write for Memory Management Software
637
711
if (EEPROM.read (VERSION_ADDRESS) != VERSION_NUM)
638
712
EEPROM.write (VERSION_ADDRESS, VERSION_NUM);
713
+
714
+ // Ham Band Count
715
+ EEPROM.get (HAM_BAND_COUNT, useHamBandCount);
716
+ EEPROM.get (TX_TUNE_TYPE, tuneTXType);
717
+
718
+
719
+ if ((3 < tuneTXType && 100 < tuneTXType) || 103 < tuneTXType || useHamBandCount < 1 )
720
+ tuneTXType = 0 ;
721
+
722
+ // Read band Information
723
+ for (byte i = 0 ; i < useHamBandCount; i++) {
724
+ unsigned int tmpReadValue = 0 ;
725
+ EEPROM.get (HAM_BAND_RANGE + 4 * i, tmpReadValue);
726
+ hamBandRange[i][0 ] = tmpReadValue;
727
+ EEPROM.get (HAM_BAND_RANGE + 4 * i + 2 , tmpReadValue);
728
+ hamBandRange[i][1 ] = tmpReadValue;
729
+ }
639
730
640
731
if (cwDelayTime < 1 || cwDelayTime > 250 )
641
732
cwDelayTime = 60 ;
@@ -715,14 +806,17 @@ void initPorts(){
715
806
716
807
void setup ()
717
808
{
718
- // Init EEProm for Fault EEProm TEST and Factory Reset
719
809
/*
720
- for (int i = 0; i < 1024; i++)
810
+ //Init EEProm for Fault EEProm TEST and Factory Reset
811
+ //for (int i = 0; i < 1024; i++)
812
+ for (int i = 16; i < 1024; i++) //protect Master_cal, usb_cal
721
813
EEPROM.write(i, 0);
722
814
*/
723
815
// Serial.begin(9600);
724
816
lcd.begin (16 , 2 );
725
817
818
+ // remark for John test
819
+ /*
726
820
Init_Cat(38400, SERIAL_8N1);
727
821
initMeter(); //not used in this build
728
822
initSettings();
@@ -736,9 +830,20 @@ void setup()
736
830
else
737
831
{
738
832
printLineF(0, F("uBITX v0.20"));
739
- delay_background (500 , 0 );
833
+ delay(500); //< -- replace from delay_background(500, 0) //johns bug report / on raspberry
740
834
printLine2("");
741
835
}
836
+ */
837
+ // replace above to below (before initSettings(); position)
838
+
839
+ printLine2 (" CECBT v0.27" );
840
+ printLine1 (" uBITX v0.20" );
841
+ delay (500 );
842
+ printLine2 (" " );
843
+
844
+ Init_Cat (9600 , SERIAL_8N1);
845
+ initMeter (); // not used in this build
846
+ initSettings ();
742
847
743
848
initPorts ();
744
849
initOscillators ();
@@ -751,95 +856,6 @@ void setup()
751
856
752
857
if (btnDown ())
753
858
factory_alignment ();
754
-
755
- /*
756
- //This is for auto key test
757
- EEPROM.put(CW_AUTO_MAGIC_KEY, 0x73); //MAGIC KEY
758
- EEPROM.put(CW_AUTO_COUNT, 3); //WORD COUNT
759
- EEPROM.put(CW_AUTO_DATA + 0, 6); // 0 word begin postion / CQCQ TEST K
760
- EEPROM.put(CW_AUTO_DATA + 1, 33); // 0 word end postion / CQCQ TEST K
761
- EEPROM.put(CW_AUTO_DATA + 2, 34); //1 word begin position / LOL LOL
762
- EEPROM.put(CW_AUTO_DATA + 3, 40); //1 word end position / LOL LOL
763
- EEPROM.put(CW_AUTO_DATA + 4, 41); //2 word begin position / /?![]789
764
- EEPROM.put(CW_AUTO_DATA + 5, 48); //2 word end position / /?![]789
765
-
766
- EEPROM.put(CW_AUTO_DATA + 6, 'C'); //
767
- EEPROM.put(CW_AUTO_DATA + 7, 'Q'); //
768
- EEPROM.put(CW_AUTO_DATA + 8, 'C'); //
769
- EEPROM.put(CW_AUTO_DATA + 9, 'Q'); //
770
- EEPROM.put(CW_AUTO_DATA + 10, ' '); //
771
- EEPROM.put(CW_AUTO_DATA + 11, 'D'); //
772
- EEPROM.put(CW_AUTO_DATA + 12, 'E'); //
773
- EEPROM.put(CW_AUTO_DATA + 13, ' '); //
774
- EEPROM.put(CW_AUTO_DATA + 14, 'K'); //
775
- EEPROM.put(CW_AUTO_DATA + 15, 'D'); //
776
- EEPROM.put(CW_AUTO_DATA + 16, '8'); //
777
- EEPROM.put(CW_AUTO_DATA + 17, 'C'); //
778
- EEPROM.put(CW_AUTO_DATA + 18, 'E'); //
779
- EEPROM.put(CW_AUTO_DATA + 19, 'C'); //
780
- EEPROM.put(CW_AUTO_DATA + 20, ' '); //
781
- EEPROM.put(CW_AUTO_DATA + 21, 'E'); //
782
- EEPROM.put(CW_AUTO_DATA + 22, 'M'); //
783
- EEPROM.put(CW_AUTO_DATA + 23, '3'); //
784
- EEPROM.put(CW_AUTO_DATA + 24, '7'); //
785
- EEPROM.put(CW_AUTO_DATA + 25, ' '); //
786
- EEPROM.put(CW_AUTO_DATA + 26, 'D'); //
787
- EEPROM.put(CW_AUTO_DATA + 27, 'E'); //
788
- EEPROM.put(CW_AUTO_DATA + 28, ' '); //
789
- EEPROM.put(CW_AUTO_DATA + 29, 'C'); //
790
- EEPROM.put(CW_AUTO_DATA + 30, 'E'); //
791
- EEPROM.put(CW_AUTO_DATA + 31, 'C'); //
792
- EEPROM.put(CW_AUTO_DATA + 32, ' '); //
793
- EEPROM.put(CW_AUTO_DATA + 33, 'K'); //
794
- */
795
-
796
- /*
797
- EEPROM.put(CW_AUTO_DATA + 34, '<'); //
798
- EEPROM.put(CW_AUTO_DATA + 35, ' '); //
799
- EEPROM.put(CW_AUTO_DATA + 36, '>'); //
800
- EEPROM.put(CW_AUTO_DATA + 37, ' '); //
801
- EEPROM.put(CW_AUTO_DATA + 38, '7'); //
802
- EEPROM.put(CW_AUTO_DATA + 39, '3'); //
803
- EEPROM.put(CW_AUTO_DATA + 40, 'K'); //
804
-
805
- EEPROM.put(CW_AUTO_DATA + 41, 'C'); //
806
- EEPROM.put(CW_AUTO_DATA + 42, 'Q'); //
807
- EEPROM.put(CW_AUTO_DATA + 43, ' '); //
808
- EEPROM.put(CW_AUTO_DATA + 44, '>'); // start "
809
- EEPROM.put(CW_AUTO_DATA + 45, ' '); // end "
810
- EEPROM.put(CW_AUTO_DATA + 46, '>'); //
811
- EEPROM.put(CW_AUTO_DATA + 47, ' '); //
812
- EEPROM.put(CW_AUTO_DATA + 48, 'K'); //
813
- */
814
-
815
- /*
816
- //This is for auto key test2
817
- //USER CALL SIGN
818
- EEPROM.put(USER_CALLSIGN_KEY, 0x59); //MAGIC KEY
819
- //EEPROM.put(USER_CALLSIGN_LEN, 10); //WORD COUNT
820
- EEPROM.put(USER_CALLSIGN_LEN, 10 + 0x80); //WORD COUNT
821
-
822
- EEPROM.put(USER_CALLSIGN_DAT + 1, 'K'); //
823
- EEPROM.put(USER_CALLSIGN_DAT + 2, 'D'); //
824
- EEPROM.put(USER_CALLSIGN_DAT + 3, '8'); //
825
- EEPROM.put(USER_CALLSIGN_DAT + 4, 'C'); //
826
- EEPROM.put(USER_CALLSIGN_DAT + 5, 'E'); //
827
- EEPROM.put(USER_CALLSIGN_DAT + 6, 'C'); //
828
- EEPROM.put(USER_CALLSIGN_DAT + 7, '/'); //
829
- EEPROM.put(USER_CALLSIGN_DAT + 8, 'A'); //
830
- EEPROM.put(USER_CALLSIGN_DAT + 9, 'B'); //
831
- EEPROM.put(USER_CALLSIGN_DAT + 10, 'C'); //
832
-
833
- //CW QSO CALLSIGN
834
- EEPROM.put(CW_STATION_LEN, 6); //
835
- EEPROM.put(CW_STATION_LEN - 6 + 0 , 'A'); //
836
- EEPROM.put(CW_STATION_LEN - 6 + 1 , 'B'); //
837
- EEPROM.put(CW_STATION_LEN - 6 + 2 , '1'); //
838
- EEPROM.put(CW_STATION_LEN - 6 + 3 , 'C'); //
839
- EEPROM.put(CW_STATION_LEN - 6 + 4 , 'D'); //
840
- EEPROM.put(CW_STATION_LEN - 6 + 5 , 'E'); //
841
- */
842
-
843
859
}
844
860
845
861
0 commit comments