Skip to content

Commit

Permalink
Fixed missing leading digit.
Browse files Browse the repository at this point in the history
  • Loading branch information
hmatuschek committed Jan 22, 2025
1 parent 0d01331 commit 3297a92
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/opengd77base_codeplug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ OpenGD77BaseCodeplug::encodeSelectiveCall(const SelectiveCall &call) {
toneCode = call.mHz()/100;
}

uint16_t bcd = (((toneCode/100) % 10 ) << 8) |
uint16_t bcd = (((toneCode/1000) % 10 ) << 12) |
(((toneCode/100) % 10 ) << 8) |
(((toneCode/10) % 10 ) << 4) |
(((toneCode/1) % 10 ) << 0);
return (dcs<<15) | (inverted << 14) | (bcd & 0x3fff);
Expand All @@ -55,7 +56,10 @@ OpenGD77BaseCodeplug::decodeSelectiveCall(uint16_t code) {
inverted = ((code >> 14) & 1);

uint16_t bcd = (code & 0x3fff);
code = 100 * ((bcd >> 8) & 0xf) + 10 * ((bcd >> 4) & 0xf) + 1 * ((bcd >> 0) & 0xf);
code = 1000 * ((bcd >> 12) & 0xf)
+ 100 * ((bcd >> 8) & 0xf)
+ 10 * ((bcd >> 4) & 0xf)
+ 1 * ((bcd >> 0) & 0xf);

if (! dcs)
return SelectiveCall(double(code)/10);
Expand Down

0 comments on commit 3297a92

Please sign in to comment.