kopia lustrzana https://github.com/lora-aprs/LoRa_APRS_iGate
remove smart pointer of board config
rodzic
c5fd0cc46c
commit
16fea99b9b
|
@ -6,14 +6,14 @@ BoardConfig::BoardConfig(String name, BoardType type, uint8_t oledsda, uint8_t o
|
|||
: Name(name), Type(type), OledSda(oledsda), OledScl(oledscl), OledAddr(oledaddr), OledReset(oledreset), LoraSck(lorasck), LoraMiso(loramiso), LoraMosi(loramosi), LoraCS(loracs), LoraReset(lorareset), LoraIRQ(lorairq), needCheckPowerChip(needcheckpowerchip), powerCheckStatus(powercheckstatus) {
|
||||
}
|
||||
|
||||
BoardFinder::BoardFinder(std::list<std::shared_ptr<BoardConfig>> &boardConfigs) : _boardConfigs(boardConfigs) {
|
||||
BoardFinder::BoardFinder(std::list<BoardConfig const *> boardConfigs) : _boardConfigs(boardConfigs) {
|
||||
}
|
||||
|
||||
std::shared_ptr<BoardConfig> BoardFinder::searchBoardConfig() {
|
||||
BoardConfig const *BoardFinder::searchBoardConfig() {
|
||||
logPrintlnI("looking for a board config.");
|
||||
logPrintlnI("searching for OLED...");
|
||||
|
||||
for (std::shared_ptr<BoardConfig> boardconf : _boardConfigs) {
|
||||
for (BoardConfig const *boardconf : _boardConfigs) {
|
||||
if (boardconf->needCheckPowerChip && checkPowerConfig(boardconf) == boardconf->powerCheckStatus) {
|
||||
PowerManagement powerManagement;
|
||||
Wire.begin(boardconf->OledSda, boardconf->OledScl);
|
||||
|
@ -31,7 +31,7 @@ std::shared_ptr<BoardConfig> BoardFinder::searchBoardConfig() {
|
|||
|
||||
logPrintlnI("could not find OLED, will search for the modem now...");
|
||||
|
||||
for (std::shared_ptr<BoardConfig> boardconf : _boardConfigs) {
|
||||
for (BoardConfig const *boardconf : _boardConfigs) {
|
||||
if (boardconf->needCheckPowerChip && checkPowerConfig(boardconf) == boardconf->powerCheckStatus) {
|
||||
PowerManagement powerManagement;
|
||||
Wire.begin(boardconf->OledSda, boardconf->OledScl);
|
||||
|
@ -50,8 +50,8 @@ std::shared_ptr<BoardConfig> BoardFinder::searchBoardConfig() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
std::shared_ptr<BoardConfig> BoardFinder::getBoardConfig(String name) {
|
||||
std::_List_iterator<std::shared_ptr<BoardConfig>> elem = std::find_if(_boardConfigs.begin(), _boardConfigs.end(), [&](std::shared_ptr<BoardConfig> conf) {
|
||||
BoardConfig const *BoardFinder::getBoardConfig(String name) {
|
||||
std::_List_iterator<BoardConfig const *> elem = std::find_if(_boardConfigs.begin(), _boardConfigs.end(), [&](BoardConfig const *conf) {
|
||||
return conf->Name == name;
|
||||
});
|
||||
if (elem == _boardConfigs.end()) {
|
||||
|
@ -60,7 +60,7 @@ std::shared_ptr<BoardConfig> BoardFinder::getBoardConfig(String name) {
|
|||
return *elem;
|
||||
}
|
||||
|
||||
bool BoardFinder::checkOledConfig(std::shared_ptr<BoardConfig> boardConfig) {
|
||||
bool BoardFinder::checkOledConfig(BoardConfig const *boardConfig) {
|
||||
if (boardConfig->OledReset > 0) {
|
||||
pinMode(boardConfig->OledReset, OUTPUT);
|
||||
digitalWrite(boardConfig->OledReset, HIGH);
|
||||
|
@ -80,7 +80,7 @@ bool BoardFinder::checkOledConfig(std::shared_ptr<BoardConfig> boardConfig) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool BoardFinder::checkModemConfig(std::shared_ptr<BoardConfig> boardConfig) {
|
||||
bool BoardFinder::checkModemConfig(BoardConfig const *boardConfig) {
|
||||
pinMode(boardConfig->LoraReset, OUTPUT);
|
||||
digitalWrite(boardConfig->LoraReset, LOW);
|
||||
delay(10);
|
||||
|
@ -107,7 +107,7 @@ bool BoardFinder::checkModemConfig(std::shared_ptr<BoardConfig> boardConfig) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool BoardFinder::checkPowerConfig(std::shared_ptr<BoardConfig> boardConfig) {
|
||||
bool BoardFinder::checkPowerConfig(BoardConfig const *boardConfig) {
|
||||
if (!Wire.begin(boardConfig->OledSda, boardConfig->OledScl)) {
|
||||
logPrintlnW("issue with wire");
|
||||
return false;
|
||||
|
@ -128,3 +128,14 @@ bool BoardFinder::checkPowerConfig(std::shared_ptr<BoardConfig> boardConfig) {
|
|||
logPrintlnD("power chip NOT found");
|
||||
return false;
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
BoardConfig TTGO_LORA32_V1 ("TTGO_LORA32_V1", eTTGO_LORA32_V1, 4, 15, 0x3C, 0, 5, 19, 27, 18, 14, 26);
|
||||
BoardConfig TTGO_LORA32_V2 ("TTGO_LORA32_V2", eTTGO_LORA32_V2, 21, 22, 0x3C, 0, 5, 19, 27, 18, 14, 26, true);
|
||||
BoardConfig TTGO_T_Beam_V0_7 ("TTGO_T_Beam_V0_7", eTTGO_T_Beam_V0_7, 21, 22, 0x3C, 0, 5, 19, 27, 18, 14, 26, true);
|
||||
BoardConfig TTGO_T_Beam_V1_0 ("TTGO_T_Beam_V1_0", eTTGO_T_Beam_V1_0, 21, 22, 0x3C, 0, 5, 19, 27, 18, 14, 26, true, true);
|
||||
BoardConfig ETH_BOARD ("ETH_BOARD", eETH_BOARD, 33, 32, 0x3C, 0, 14, 2, 15, 12, 4, 36);
|
||||
BoardConfig TRACKERD ("TRACKERD", eTRACKERD, 5, 4, 0x3C, 0, 18, 19, 23, 16, 14, 26);
|
||||
BoardConfig HELTEC_WIFI_LORA_32_V1("HELTEC_WIFI_LORA_32_V1", eHELTEC_WIFI_LORA_32_V1, 4, 15, 0x3C, 16, 5, 19, 27, 18, 14, 26);
|
||||
BoardConfig HELTEC_WIFI_LORA_32_V2("HELTEC_WIFI_LORA_32_V2", eHELTEC_WIFI_LORA_32_V2, 4, 15, 0x3C, 16, 5, 19, 27, 18, 14, 26);
|
||||
// clang-format on
|
||||
|
|
|
@ -45,18 +45,27 @@ public:
|
|||
|
||||
class BoardFinder {
|
||||
public:
|
||||
explicit BoardFinder(std::list<std::shared_ptr<BoardConfig>> &boardConfigs);
|
||||
explicit BoardFinder(std::list<BoardConfig const *> boardConfigs);
|
||||
|
||||
std::shared_ptr<BoardConfig> searchBoardConfig();
|
||||
BoardConfig const *searchBoardConfig();
|
||||
|
||||
std::shared_ptr<BoardConfig> getBoardConfig(String name);
|
||||
BoardConfig const *getBoardConfig(String name);
|
||||
|
||||
private:
|
||||
std::list<std::shared_ptr<BoardConfig>> _boardConfigs;
|
||||
std::list<BoardConfig const *> _boardConfigs;
|
||||
|
||||
bool checkOledConfig(std::shared_ptr<BoardConfig> boardConfig);
|
||||
bool checkModemConfig(std::shared_ptr<BoardConfig> boardConfig);
|
||||
bool checkPowerConfig(std::shared_ptr<BoardConfig> boardConfig);
|
||||
bool checkOledConfig(BoardConfig const *boardConfig);
|
||||
bool checkModemConfig(BoardConfig const *boardConfig);
|
||||
bool checkPowerConfig(BoardConfig const *boardConfig);
|
||||
};
|
||||
|
||||
extern BoardConfig TTGO_LORA32_V1;
|
||||
extern BoardConfig TTGO_LORA32_V2;
|
||||
extern BoardConfig TTGO_T_Beam_V0_7;
|
||||
extern BoardConfig TTGO_T_Beam_V1_0;
|
||||
extern BoardConfig ETH_BOARD;
|
||||
extern BoardConfig TRACKERD;
|
||||
extern BoardConfig HELTEC_WIFI_LORA_32_V1;
|
||||
extern BoardConfig HELTEC_WIFI_LORA_32_V2;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,7 +8,7 @@ Display::Display() : _disp(0), _statusFrame(0), _displaySaveMode(false) {
|
|||
Display::~Display() {
|
||||
}
|
||||
|
||||
void Display::setup(std::shared_ptr<BoardConfig> boardConfig) {
|
||||
void Display::setup(BoardConfig const *const boardConfig) {
|
||||
if (boardConfig->OledReset != 0) {
|
||||
pinMode(boardConfig->OledReset, OUTPUT);
|
||||
digitalWrite(boardConfig->OledReset, HIGH);
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
Display();
|
||||
~Display();
|
||||
|
||||
void setup(std::shared_ptr<BoardConfig> boardConfig);
|
||||
void setup(BoardConfig const *const boardConfig);
|
||||
// setup functions
|
||||
void showSpashScreen(String firmwareTitle, String version);
|
||||
void setStatusFrame(std::shared_ptr<StatusFrame> frame);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "LoRa_APRS.h"
|
||||
|
||||
LoRa_APRS::LoRa_APRS(std::shared_ptr<BoardConfig> boardConfig) : _LastReceivedMsg(0), _RxFrequency(LORA_RX_FREQUENCY), _TxFrequency(LORA_TX_FREQUENCY) {
|
||||
LoRa_APRS::LoRa_APRS(BoardConfig const *const boardConfig) : _LastReceivedMsg(0), _RxFrequency(LORA_RX_FREQUENCY), _TxFrequency(LORA_TX_FREQUENCY) {
|
||||
SPI.begin(boardConfig->LoraSck, boardConfig->LoraMiso, boardConfig->LoraMosi, boardConfig->LoraCS);
|
||||
setPins(boardConfig->LoraCS, boardConfig->LoraReset, boardConfig->LoraIRQ);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
class LoRa_APRS : public LoRaClass {
|
||||
public:
|
||||
explicit LoRa_APRS(std::shared_ptr<BoardConfig> boardConfig);
|
||||
explicit LoRa_APRS(BoardConfig const *const boardConfig);
|
||||
|
||||
bool checkMessage();
|
||||
std::shared_ptr<APRSMessage> getMessage();
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
|
||||
#include "System.h"
|
||||
|
||||
System::System(std::shared_ptr<BoardConfig> boardConfig, std::shared_ptr<Configuration> userConfig) : _boardConfig(boardConfig), _userConfig(userConfig), _isWifiEthConnected(false) {
|
||||
System::System(BoardConfig const *const boardConfig, std::shared_ptr<Configuration> userConfig) : _boardConfig(boardConfig), _userConfig(userConfig), _isWifiEthConnected(false) {
|
||||
}
|
||||
|
||||
System::~System() {
|
||||
}
|
||||
|
||||
std::shared_ptr<BoardConfig> System::getBoardConfig() const {
|
||||
BoardConfig const *const System::getBoardConfig() const {
|
||||
return _boardConfig;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
|
||||
class System {
|
||||
public:
|
||||
System(std::shared_ptr<BoardConfig> boardConfig, std::shared_ptr<Configuration> userConfig);
|
||||
System(BoardConfig const *const boardConfig, std::shared_ptr<Configuration> userConfig);
|
||||
~System();
|
||||
|
||||
std::shared_ptr<BoardConfig> getBoardConfig() const;
|
||||
BoardConfig const *const getBoardConfig() const;
|
||||
std::shared_ptr<Configuration> getUserConfig() const;
|
||||
TaskManager & getTaskManager();
|
||||
Display & getDisplay();
|
||||
|
@ -21,7 +21,7 @@ public:
|
|||
void connectedViaWifiEth(bool status);
|
||||
|
||||
private:
|
||||
std::shared_ptr<BoardConfig> _boardConfig;
|
||||
BoardConfig const *const _boardConfig;
|
||||
std::shared_ptr<Configuration> _userConfig;
|
||||
TaskManager _taskManager;
|
||||
Display _display;
|
||||
|
|
|
@ -33,22 +33,20 @@ void setup() {
|
|||
logPrintlnI("LoRa APRS iGate by OE5BPA (Peter Buchegger)");
|
||||
logPrintlnI("Version: " VERSION);
|
||||
|
||||
std::list<std::shared_ptr<BoardConfig>> boardConfigs;
|
||||
// clang-format off
|
||||
boardConfigs.push_back(std::shared_ptr<BoardConfig>(new BoardConfig("TTGO_LORA32_V1", eTTGO_LORA32_V1, 4, 15, 0x3C, 0, 5, 19, 27, 18, 14, 26)));
|
||||
boardConfigs.push_back(std::shared_ptr<BoardConfig>(new BoardConfig("TTGO_LORA32_V2", eTTGO_LORA32_V2, 21, 22, 0x3C, 0, 5, 19, 27, 18, 14, 26, true)));
|
||||
boardConfigs.push_back(std::shared_ptr<BoardConfig>(new BoardConfig("TTGO_T_Beam_V0_7", eTTGO_T_Beam_V0_7, 21, 22, 0x3C, 0, 5, 19, 27, 18, 14, 26, true)));
|
||||
boardConfigs.push_back(std::shared_ptr<BoardConfig>(new BoardConfig("TTGO_T_Beam_V1_0", eTTGO_T_Beam_V1_0, 21, 22, 0x3C, 0, 5, 19, 27, 18, 14, 26, true, true)));
|
||||
boardConfigs.push_back(std::shared_ptr<BoardConfig>(new BoardConfig("ETH_BOARD", eETH_BOARD, 33, 32, 0x3C, 0, 14, 2, 15, 12, 4, 36)));
|
||||
boardConfigs.push_back(std::shared_ptr<BoardConfig>(new BoardConfig("TRACKERD", eTRACKERD, 5, 4, 0x3C, 0, 18, 19, 23, 16, 14, 26)));
|
||||
boardConfigs.push_back(std::shared_ptr<BoardConfig>(new BoardConfig("HELTEC_WIFI_LORA_32_V1", eHELTEC_WIFI_LORA_32_V1, 4, 15, 0x3C, 16, 5, 19, 27, 18, 14, 26)));
|
||||
boardConfigs.push_back(std::shared_ptr<BoardConfig>(new BoardConfig("HELTEC_WIFI_LORA_32_V2", eHELTEC_WIFI_LORA_32_V2, 4, 15, 0x3C, 16, 5, 19, 27, 18, 14, 26)));
|
||||
// clang-format on
|
||||
std::list<BoardConfig const *> boardConfigs;
|
||||
boardConfigs.push_back(&TTGO_LORA32_V1);
|
||||
boardConfigs.push_back(&TTGO_LORA32_V2);
|
||||
boardConfigs.push_back(&TTGO_T_Beam_V0_7);
|
||||
boardConfigs.push_back(&TTGO_T_Beam_V1_0);
|
||||
boardConfigs.push_back(Ð_BOARD);
|
||||
boardConfigs.push_back(&TRACKERD);
|
||||
boardConfigs.push_back(&HELTEC_WIFI_LORA_32_V1);
|
||||
boardConfigs.push_back(&HELTEC_WIFI_LORA_32_V2);
|
||||
|
||||
ProjectConfigurationManagement confmg;
|
||||
std::shared_ptr<Configuration> userConfig = confmg.readConfiguration();
|
||||
BoardFinder finder(boardConfigs);
|
||||
std::shared_ptr<BoardConfig> boardConfig = finder.getBoardConfig(userConfig->board);
|
||||
BoardConfig const * boardConfig = finder.getBoardConfig(userConfig->board);
|
||||
if (boardConfig == 0) {
|
||||
boardConfig = finder.searchBoardConfig();
|
||||
if (boardConfig == 0) {
|
||||
|
|
Ładowanie…
Reference in New Issue