Skip to content

Commit

Permalink
Improve toggle scanlist
Browse files Browse the repository at this point in the history
  • Loading branch information
armel committed Jun 26, 2024
1 parent b5d8a07 commit 30e2dc8
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,13 @@ static void toggle_chan_scanlist(void)
}
*/

if(gTxVfo->SCANLIST1_PARTICIPATION == 1)
{
gTxVfo->SCANLIST1_PARTICIPATION = 0;
gTxVfo->SCANLIST2_PARTICIPATION = 1;
gTxVfo->SCANLIST3_PARTICIPATION = 0;
}
else if(gTxVfo->SCANLIST2_PARTICIPATION == 1)
{
gTxVfo->SCANLIST1_PARTICIPATION = 0;
gTxVfo->SCANLIST2_PARTICIPATION = 0;
gTxVfo->SCANLIST3_PARTICIPATION = 1;
}
else if(gTxVfo->SCANLIST3_PARTICIPATION == 1)
{
gTxVfo->SCANLIST1_PARTICIPATION = 1;
gTxVfo->SCANLIST2_PARTICIPATION = 0;
gTxVfo->SCANLIST3_PARTICIPATION = 0;
}
uint8_t scanTmp = (gTxVfo->SCANLIST1_PARTICIPATION << 2) | (gTxVfo->SCANLIST2_PARTICIPATION << 1) | gTxVfo->SCANLIST3_PARTICIPATION;

This comment has been minimized.

Copy link
@prokrypt

prokrypt Jun 26, 2024

currently goes through scanlists like:

0
1
1 3
 23
  3
 2
12
123

should probably be uint8_t scanTmp = gTxVfo->SCANLIST1_PARTICIPATION | (gTxVfo->SCANLIST2_PARTICIPATION << 1) | (gTxVfo->SCANLIST3_PARTICIPATION << 2);

so it'll go through the lists a little more logically like:

0
1
 2
12
  3
1 3
 23
123

scanTmp = (scanTmp++ < 7) ? scanTmp: 0;

gTxVfo->SCANLIST1_PARTICIPATION = (scanTmp >> 0) & 0x01;
gTxVfo->SCANLIST2_PARTICIPATION = (scanTmp >> 1) & 0x01;
gTxVfo->SCANLIST3_PARTICIPATION = (scanTmp >> 2) & 0x01;

SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true, true, true);

Expand Down

1 comment on commit 30e2dc8

@armel
Copy link
Owner Author

@armel armel commented on 30e2dc8 Jun 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right 👍🏼

Please sign in to comment.