Skip to content

Commit

Permalink
add frequency display to the "o" command
Browse files Browse the repository at this point in the history
closes #438
  • Loading branch information
jcw committed Feb 13, 2014
1 parent 56cb95a commit a718cb9
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion examples/RF12/RF12demo/RF12demo.ino
Expand Up @@ -374,14 +374,34 @@ static void handleInput (char c) {
}
break;

case 'o': // Increment frequency within band
case 'o': { // Increment frequency within band
// Stay within your country's ISM spectrum management guidelines, i.e.
// allowable frequencies and their use when selecting operating frequencies.
if ((value > 95) && (value < 3904)) { // supported by RFM12B
config.frequency_offset = value;
saveConfig();
}
#if !TINY
// display the exact frequency associated with this setting
uint8_t freq = 0, band = config.nodeId >> 6;
switch (band) {
case RF12_433MHZ: freq = 43; break;
case RF12_868MHZ: freq = 86; break;
case RF12_915MHZ: freq = 90; break;
}
uint32_t f1 = freq * 100000L + band * 25L * config.frequency_offset;
Serial.print((word) (f1 / 10000));
printOneChar('.');
uint16_t f2 = f1 % 10000;
// tedious, but this avoids introducing floating point
printOneChar('0' + f2 / 1000);
printOneChar('0' + (f2 / 100) % 10);
printOneChar('0' + (f2 / 10) % 10);
printOneChar('0' + f2 % 10);
Serial.println(" MHz");
#endif
break;
}

case 'g': // set network group
config.group = value;
Expand Down

0 comments on commit a718cb9

Please sign in to comment.