Skip to content

Commit

Permalink
增加3 ,9 调节bfo
Browse files Browse the repository at this point in the history
  • Loading branch information
losehu committed Sep 22, 2024
1 parent 4bddc2a commit 4344a0e
Showing 1 changed file with 52 additions and 25 deletions.
77 changes: 52 additions & 25 deletions app/si.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ uint32_t light_time;
bool INPUT_STATE = false;

static void light_open() {
if(gEeprom.BACKLIGHT_TIME) {
light_time = (BACKLIGHT_MAP[gEeprom.BACKLIGHT_TIME-1]-1>=0?BACKLIGHT_MAP[gEeprom.BACKLIGHT_TIME-1]-1:0)*500;
if (gEeprom.BACKLIGHT_TIME) {
light_time = (BACKLIGHT_MAP[gEeprom.BACKLIGHT_TIME - 1] - 1 >= 0 ? BACKLIGHT_MAP[gEeprom.BACKLIGHT_TIME - 1] - 1
: 0) * 500;
BACKLIGHT_TurnOn();
}
}
Expand Down Expand Up @@ -378,15 +379,15 @@ void HandleUserInput() {
light_open();
display_flag = 1;
}
SI_key(kbds.current, KEY_TYPE1, KEY_TYPE2, KEY_TYPE3, kbds.prev);
SI_key(kbds.current, KEY_TYPE1, KEY_TYPE2, KEY_TYPE3, kbds.prev);

}

void SI_key(KEY_Code_t key, bool KEY_TYPE1, bool KEY_TYPE2, bool KEY_TYPE3, KEY_Code_t key_prev) {
// up-down keys
if (INPUT_STATE && KEY_TYPE3) {
OnKeyDownFreqInput(key_prev);
return ;
return;
}
if (KEY_TYPE1 || KEY_TYPE3) {
if (KEY_TYPE3)key = key_prev;
Expand All @@ -395,17 +396,43 @@ void SI_key(KEY_Code_t key, bool KEY_TYPE1, bool KEY_TYPE2, bool KEY_TYPE3, KEY_
case KEY_DOWN:
tune((siCurrentFreq + (key == KEY_UP ? step : -step)) * divider);
resetBFO();
return ;
return;
#ifdef ENABLE_4732SSB
case KEY_SIDE1:
case KEY_SIDE2:
if (SI47XX_IsSSB()) {
if (key == KEY_UP ? (bfo < INT16_MAX - 10) : (bfo > INT16_MIN + 10)) {
bfo = bfo + (key == KEY_UP ? 10 : -10);
}
SI47XX_SetBFO(bfo);
case KEY_3:
if (SI47XX_IsSSB()) {
if (bfo < INT16_MAX - 10) {
bfo += 10;
}
SI47XX_SetBFO(bfo);
if(key==KEY_SIDE1) return;

}
break;
case KEY_SIDE2:
case KEY_9:

if (SI47XX_IsSSB()) {
if (bfo > INT16_MIN + 10) {
bfo -= 10;
}
return ;
SI47XX_SetBFO(bfo);
if(key==KEY_SIDE2) return;

}

break;


// case KEY_SIDE1:
// case KEY_SIDE2:
// if (SI47XX_IsSSB()) {
// if (key == KEY_UP ? (bfo < INT16_MAX - 10) : (bfo > INT16_MIN + 10)) {
// bfo = bfo + (key == KEY_UP ? 10 : -10);
// }
// SI47XX_SetBFO(bfo);
// }
// return ;

#endif
case KEY_2:
Expand All @@ -414,7 +441,7 @@ void SI_key(KEY_Code_t key, bool KEY_TYPE1, bool KEY_TYPE2, bool KEY_TYPE3, KEY_
key == KEY_2 ? att++ : att--;
SI47XX_SetAutomaticGainControl(key == KEY_2 ? 1 : att > 0, att);
}
return ;
return;

default:
break;
Expand All @@ -427,27 +454,27 @@ void SI_key(KEY_Code_t key, bool KEY_TYPE1, bool KEY_TYPE2, bool KEY_TYPE3, KEY_
switch (key_prev) {
case KEY_4:
SNR_flag = !SNR_flag;
return ;
return;
case KEY_1:
if (step < 1000) {
if (step == 1 || step == 10 || step == 100 ) {
if (step == 1 || step == 10 || step == 100) {
step *= 5;
} else {
step *= 2;
}
}
return ;
return;


case KEY_7:
if (step > 1) {
if ( step == 10 || step == 100 || step == 1000) {
if (step == 10 || step == 100 || step == 1000) {
step /= 2;
} else {
step /= 5;
}
}
return ;
return;

case KEY_6:
#ifdef ENABLE_4732SSB
Expand All @@ -472,12 +499,12 @@ void SI_key(KEY_Code_t key, bool KEY_TYPE1, bool KEY_TYPE2, bool KEY_TYPE3, KEY_
}
#endif

return ;
return;

case KEY_5:
INPUT_STATE = 1;
FreqInput();
return ;
return;
case KEY_0:
divider = 100;
WaitDisplay();
Expand Down Expand Up @@ -507,7 +534,7 @@ void SI_key(KEY_Code_t key, bool KEY_TYPE1, bool KEY_TYPE2, bool KEY_TYPE3, KEY_
}
tune(Read_FreqSaved());
resetBFO();
return ;
return;
#ifdef ENABLE_4732SSB

case KEY_F:
Expand All @@ -525,7 +552,7 @@ void SI_key(KEY_Code_t key, bool KEY_TYPE1, bool KEY_TYPE2, bool KEY_TYPE3, KEY_
SI47XX_PowerUp();
seeking = false;
} else SI_run = false;
return ;
return;
case KEY_3:
case KEY_9:
#ifdef ENABLE_4732SSB
Expand All @@ -546,12 +573,12 @@ void SI_key(KEY_Code_t key, bool KEY_TYPE1, bool KEY_TYPE2, bool KEY_TYPE3, KEY_


seeking = true;
return ;
return;
default:
break;
}
}
return ;
return;
}


Expand Down Expand Up @@ -584,7 +611,7 @@ void SI4732_Main() {
}

if (cnt % 25 == 0) {
HandleUserInput();
HandleUserInput();
}

if (seeking && cnt % 100 == 0) {
Expand Down

0 comments on commit 4344a0e

Please sign in to comment.