mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-21 18:22:32 +00:00
Initial support for RadioMaster Bandit. (#4523)
* Initial support for RadioMaster Bandit. * Different lighting can be made for Button 1 & 2 on the Bandit. Changes to AmbientLighting will turn off af shutdown(). * Trunk * Trunk again.
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
// In theory up to 27 dBm is possible, but the modules installed in most radios can cope with a max of 20. So BIG WARNING
|
||||
// if you set power to something higher than 17 or 20 you might fry your board.
|
||||
|
||||
#ifdef RADIOMASTER_900_BANDIT_NANO
|
||||
#if defined(RADIOMASTER_900_BANDIT_NANO) || defined(RADIOMASTER_900_BANDIT)
|
||||
// Structure to hold DAC and DB values
|
||||
typedef struct {
|
||||
uint8_t dac;
|
||||
@@ -40,12 +40,23 @@ DACDB getDACandDB(uint8_t dbm)
|
||||
static const struct {
|
||||
uint8_t dbm;
|
||||
DACDB values;
|
||||
} dbmToDACDB[] = {
|
||||
}
|
||||
#ifdef RADIOMASTER_900_BANDIT_NANO
|
||||
dbmToDACDB[] = {
|
||||
{20, {168, 2}}, // 100mW
|
||||
{24, {148, 6}}, // 250mW
|
||||
{27, {128, 9}}, // 500mW
|
||||
{30, {90, 12}} // 1000mW
|
||||
};
|
||||
#endif
|
||||
#ifdef RADIOMASTER_900_BANDIT
|
||||
dbmToDACDB[] = {
|
||||
{20, {165, 2}}, // 100mW
|
||||
{24, {155, 6}}, // 250mW
|
||||
{27, {142, 9}}, // 500mW
|
||||
{30, {110, 10}} // 1000mW
|
||||
};
|
||||
#endif
|
||||
const int numValues = sizeof(dbmToDACDB) / sizeof(dbmToDACDB[0]);
|
||||
|
||||
// Find the interval dbm falls within and interpolate
|
||||
@@ -56,7 +67,12 @@ DACDB getDACandDB(uint8_t dbm)
|
||||
}
|
||||
|
||||
// Return a default value if no match is found and default to 100mW
|
||||
#ifdef RADIOMASTER_900_BANDIT_NANO
|
||||
DACDB defaultValue = {168, 2};
|
||||
#endif
|
||||
#ifdef RADIOMASTER_900_BANDIT
|
||||
DACDB defaultValue = {165, 2};
|
||||
#endif
|
||||
return defaultValue;
|
||||
}
|
||||
#endif
|
||||
@@ -95,7 +111,7 @@ bool RF95Interface::init()
|
||||
{
|
||||
RadioLibInterface::init();
|
||||
|
||||
#ifdef RADIOMASTER_900_BANDIT_NANO
|
||||
#if defined(RADIOMASTER_900_BANDIT_NANO) || defined(RADIOMASTER_900_BANDIT)
|
||||
// DAC and DB values based on dBm using interpolation
|
||||
DACDB dacDbValues = getDACandDB(power);
|
||||
int8_t powerDAC = dacDbValues.dac;
|
||||
@@ -117,7 +133,7 @@ bool RF95Interface::init()
|
||||
// enable PA
|
||||
#ifdef RF95_PA_EN
|
||||
#if defined(RF95_PA_DAC_EN)
|
||||
#ifdef RADIOMASTER_900_BANDIT_NANO
|
||||
#if defined(RADIOMASTER_900_BANDIT_NANO) || defined(RADIOMASTER_900_BANDIT)
|
||||
// Use calculated DAC value
|
||||
dacWrite(RF95_PA_EN, powerDAC);
|
||||
#else
|
||||
@@ -163,7 +179,7 @@ bool RF95Interface::init()
|
||||
LOG_INFO("Frequency set to %f\n", getFreq());
|
||||
LOG_INFO("Bandwidth set to %f\n", bw);
|
||||
LOG_INFO("Power output set to %d\n", power);
|
||||
#ifdef RADIOMASTER_900_BANDIT_NANO
|
||||
#if defined(RADIOMASTER_900_BANDIT_NANO) || defined(RADIOMASTER_900_BANDIT)
|
||||
LOG_INFO("DAC output set to %d\n", powerDAC);
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user