kopia lustrzana https://github.com/lora-aprs/LoRa_APRS_iGate
first rework
rodzic
ee329f8ddf
commit
a3c25dff0a
|
@ -1,8 +1,11 @@
|
||||||
{
|
{
|
||||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||||
// for the documentation about the extensions.json format
|
// for the documentation about the extensions.json format
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
"platformio.platformio-ide",
|
"platformio.platformio-ide",
|
||||||
"xaver.clang-format"
|
"xaver.clang-format"
|
||||||
]
|
],
|
||||||
}
|
"unwantedRecommendations": [
|
||||||
|
"ms-vscode.cpptools-extension-pack"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
|
@ -4,8 +4,22 @@
|
||||||
|
|
||||||
#define MODULE_NAME "BoardFinder"
|
#define MODULE_NAME "BoardFinder"
|
||||||
|
|
||||||
BoardConfig::BoardConfig(String name, BoardType type, uint8_t oledsda, uint8_t oledscl, uint8_t oledaddr, uint8_t oledreset, uint8_t lorasck, uint8_t loramiso, uint8_t loramosi, uint8_t loracs, uint8_t lorareset, uint8_t lorairq, uint8_t gpsrx, uint8_t gpstx, uint8_t button, bool needcheckpowerchip, bool powercheckstatus)
|
OledPins::OledPins(int8_t sda, int8_t scl, int8_t reset, int8_t addr) : Sda(sda), Scl(scl), Reset(reset), Addr(addr) {
|
||||||
: Name(name), Type(type), OledSda(oledsda), OledScl(oledscl), OledAddr(oledaddr), OledReset(oledreset), LoraSck(lorasck), LoraMiso(loramiso), LoraMosi(loramosi), LoraCS(loracs), LoraReset(lorareset), LoraIRQ(lorairq), GpsRx(gpsrx), GpsTx(gpstx), Button(button), needCheckPowerChip(needcheckpowerchip), powerCheckStatus(powercheckstatus) {
|
}
|
||||||
|
|
||||||
|
LoraPins::LoraPins(int8_t sck, int8_t miso, int8_t mosi, int8_t cs, int8_t reset, int8_t irq) : Sck(sck), Miso(miso), Mosi(mosi), CS(cs), Reset(reset), IRQ(irq) {
|
||||||
|
}
|
||||||
|
|
||||||
|
GpsPins::GpsPins(int8_t rx, int8_t tx) : Rx(rx), Tx(tx) {
|
||||||
|
}
|
||||||
|
|
||||||
|
EthernetPins::EthernetPins(int8_t mdc, int8_t mdio, int8_t nreset, int8_t addr, int8_t power, eth_clock_mode_t clk, eth_phy_type_t type) : MDC(mdc), MDIO(mdio), nReset(nreset), Addr(addr), Power(power), CLK(clk), Type(type) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ButtonPins::ButtonPins(int8_t pin) : Pin(pin) {
|
||||||
|
}
|
||||||
|
|
||||||
|
BoardConfig::BoardConfig(String name, BoardType type, OledPins oled, LoraPins lora, GpsPins gps, EthernetPins ethernet, ButtonPins button, bool needcheckpowerchip, bool powercheckstatus) : Name(name), Type(type), Oled(oled), Lora(lora), Gps(gps), Ethernet(ethernet), Button(button), needCheckPowerChip(needcheckpowerchip), powerCheckStatus(powercheckstatus) {
|
||||||
}
|
}
|
||||||
|
|
||||||
BoardFinder::BoardFinder(const std::list<BoardConfig const *> &boardConfigs) : _boardConfigs(boardConfigs) {
|
BoardFinder::BoardFinder(const std::list<BoardConfig const *> &boardConfigs) : _boardConfigs(boardConfigs) {
|
||||||
|
@ -18,7 +32,7 @@ BoardConfig const *BoardFinder::searchBoardConfig(logging::Logger &logger) {
|
||||||
for (BoardConfig const *boardconf : _boardConfigs) {
|
for (BoardConfig const *boardconf : _boardConfigs) {
|
||||||
if (boardconf->needCheckPowerChip && checkPowerConfig(boardconf, logger) == boardconf->powerCheckStatus) {
|
if (boardconf->needCheckPowerChip && checkPowerConfig(boardconf, logger) == boardconf->powerCheckStatus) {
|
||||||
PowerManagement powerManagement;
|
PowerManagement powerManagement;
|
||||||
Wire.begin(boardconf->OledSda, boardconf->OledScl);
|
Wire.begin(boardconf->Oled.Sda, boardconf->Oled.Scl);
|
||||||
powerManagement.begin(Wire);
|
powerManagement.begin(Wire);
|
||||||
powerManagement.activateOLED();
|
powerManagement.activateOLED();
|
||||||
Wire.end();
|
Wire.end();
|
||||||
|
@ -36,7 +50,7 @@ BoardConfig const *BoardFinder::searchBoardConfig(logging::Logger &logger) {
|
||||||
for (BoardConfig const *boardconf : _boardConfigs) {
|
for (BoardConfig const *boardconf : _boardConfigs) {
|
||||||
if (boardconf->needCheckPowerChip && checkPowerConfig(boardconf, logger) == boardconf->powerCheckStatus) {
|
if (boardconf->needCheckPowerChip && checkPowerConfig(boardconf, logger) == boardconf->powerCheckStatus) {
|
||||||
PowerManagement powerManagement;
|
PowerManagement powerManagement;
|
||||||
Wire.begin(boardconf->OledSda, boardconf->OledScl);
|
Wire.begin(boardconf->Oled.Sda, boardconf->Oled.Scl);
|
||||||
powerManagement.begin(Wire);
|
powerManagement.begin(Wire);
|
||||||
powerManagement.activateLoRa();
|
powerManagement.activateLoRa();
|
||||||
Wire.end();
|
Wire.end();
|
||||||
|
@ -63,19 +77,19 @@ BoardConfig const *BoardFinder::getBoardConfig(String name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BoardFinder::checkOledConfig(BoardConfig const *boardConfig, logging::Logger &logger) {
|
bool BoardFinder::checkOledConfig(BoardConfig const *boardConfig, logging::Logger &logger) {
|
||||||
if (boardConfig->OledReset > 0) {
|
if (boardConfig->Oled.Reset != -1) {
|
||||||
pinMode(boardConfig->OledReset, OUTPUT);
|
pinMode(boardConfig->Oled.Reset, OUTPUT);
|
||||||
digitalWrite(boardConfig->OledReset, HIGH);
|
digitalWrite(boardConfig->Oled.Reset, HIGH);
|
||||||
delay(1);
|
delay(1);
|
||||||
digitalWrite(boardConfig->OledReset, LOW);
|
digitalWrite(boardConfig->Oled.Reset, LOW);
|
||||||
delay(10);
|
delay(10);
|
||||||
digitalWrite(boardConfig->OledReset, HIGH);
|
digitalWrite(boardConfig->Oled.Reset, HIGH);
|
||||||
}
|
}
|
||||||
if (!Wire.begin(boardConfig->OledSda, boardConfig->OledScl)) {
|
if (!Wire.begin(boardConfig->Oled.Sda, boardConfig->Oled.Scl)) {
|
||||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_WARN, MODULE_NAME, "issue with wire");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_WARN, MODULE_NAME, "issue with wire");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Wire.beginTransmission(boardConfig->OledAddr);
|
Wire.beginTransmission(boardConfig->Oled.Addr);
|
||||||
if (!Wire.endTransmission()) {
|
if (!Wire.endTransmission()) {
|
||||||
Wire.end();
|
Wire.end();
|
||||||
return true;
|
return true;
|
||||||
|
@ -85,24 +99,24 @@ bool BoardFinder::checkOledConfig(BoardConfig const *boardConfig, logging::Logge
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BoardFinder::checkModemConfig(BoardConfig const *boardConfig) {
|
bool BoardFinder::checkModemConfig(BoardConfig const *boardConfig) {
|
||||||
pinMode(boardConfig->LoraReset, OUTPUT);
|
pinMode(boardConfig->Lora.Reset, OUTPUT);
|
||||||
digitalWrite(boardConfig->LoraReset, LOW);
|
digitalWrite(boardConfig->Lora.Reset, LOW);
|
||||||
delay(10);
|
delay(10);
|
||||||
digitalWrite(boardConfig->LoraReset, HIGH);
|
digitalWrite(boardConfig->Lora.Reset, HIGH);
|
||||||
delay(10);
|
delay(10);
|
||||||
|
|
||||||
pinMode(boardConfig->LoraCS, OUTPUT);
|
pinMode(boardConfig->Lora.CS, OUTPUT);
|
||||||
digitalWrite(boardConfig->LoraCS, HIGH);
|
digitalWrite(boardConfig->Lora.CS, HIGH);
|
||||||
|
|
||||||
SPI.begin(boardConfig->LoraSck, boardConfig->LoraMiso, boardConfig->LoraMosi, boardConfig->LoraCS);
|
SPI.begin(boardConfig->Lora.Sck, boardConfig->Lora.Miso, boardConfig->Lora.Mosi, boardConfig->Lora.CS);
|
||||||
|
|
||||||
digitalWrite(boardConfig->LoraCS, LOW);
|
digitalWrite(boardConfig->Lora.CS, LOW);
|
||||||
|
|
||||||
SPI.beginTransaction(SPISettings(8E6, MSBFIRST, SPI_MODE0));
|
SPI.beginTransaction(SPISettings(8E6, MSBFIRST, SPI_MODE0));
|
||||||
SPI.transfer(0x42);
|
SPI.transfer(0x42);
|
||||||
uint8_t response = SPI.transfer(0x00);
|
uint8_t response = SPI.transfer(0x00);
|
||||||
SPI.endTransaction();
|
SPI.endTransaction();
|
||||||
digitalWrite(boardConfig->LoraCS, HIGH);
|
digitalWrite(boardConfig->Lora.CS, HIGH);
|
||||||
SPI.end();
|
SPI.end();
|
||||||
if (response == 0x12) {
|
if (response == 0x12) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -111,7 +125,7 @@ bool BoardFinder::checkModemConfig(BoardConfig const *boardConfig) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BoardFinder::checkPowerConfig(BoardConfig const *boardConfig, logging::Logger &logger) {
|
bool BoardFinder::checkPowerConfig(BoardConfig const *boardConfig, logging::Logger &logger) {
|
||||||
if (!Wire.begin(boardConfig->OledSda, boardConfig->OledScl)) {
|
if (!Wire.begin(boardConfig->Oled.Sda, boardConfig->Oled.Scl)) {
|
||||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_WARN, MODULE_NAME, "issue with wire");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_WARN, MODULE_NAME, "issue with wire");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -134,14 +148,15 @@ bool BoardFinder::checkPowerConfig(BoardConfig const *boardConfig, logging::Logg
|
||||||
}
|
}
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
BoardConfig TTGO_LORA32_V1 ("TTGO_LORA32_V1", eTTGO_LORA32_V1, 4, 15, 0x3C, 0, 5, 19, 27, 18, 14, 26, 0, 0, 0);
|
BoardConfig TTGO_LORA32_V1 ("TTGO_LORA32_V1", eTTGO_LORA32_V1, OledPins( 4, 15), LoraPins( 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, 0, 0, 0);
|
BoardConfig TTGO_LORA32_V2 ("TTGO_LORA32_V2", eTTGO_LORA32_V2, OledPins(21, 22), LoraPins( 5, 19, 27, 18, 14, 26));
|
||||||
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, 15, 12, 38, true);
|
BoardConfig TTGO_T_Beam_V0_7 ("TTGO_T_Beam_V0_7", eTTGO_T_Beam_V0_7, OledPins(21, 22), LoraPins( 5, 19, 27, 18, 14, 26), GpsPins(15, 12), EthernetPins(), ButtonPins(38), 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, 12, 34, 38, true, true);
|
BoardConfig TTGO_T_Beam_V1_0 ("TTGO_T_Beam_V1_0", eTTGO_T_Beam_V1_0, OledPins(21, 22), LoraPins( 5, 19, 27, 18, 14, 26), GpsPins(12, 34), EthernetPins(), ButtonPins(38), true, true);
|
||||||
BoardConfig ETH_BOARD ("ETH_BOARD", eETH_BOARD, 33, 32, 0x3C, 0, 14, 2, 15, 12, 4, 36, 0, 0, 0);
|
BoardConfig LILYGO_POE_ETH_BOARD ("LILYGO_POE_ETH_BOARD", eLILYGO_POE_ETH_BOARD, OledPins(33, 32), LoraPins(14, 2, 15, 12, 4, 36), GpsPins(), EthernetPins(23, 18, 5, 0, -1, ETH_CLOCK_GPIO17_OUT, ETH_PHY_LAN8720));
|
||||||
BoardConfig TRACKERD ("TRACKERD", eTRACKERD, 5, 4, 0x3C, 0, 18, 19, 23, 16, 14, 26, 0, 0, 0);
|
BoardConfig WT32_ETH_BOARD ("WT32_ETH_BOARD", eWT32_ETH_BOARD, OledPins(17, 5), LoraPins(14, 2, 15, 12, 4, 36), GpsPins(), EthernetPins(23, 18, -1, 1, 16, ETH_CLOCK_GPIO0_IN, ETH_PHY_LAN8720));
|
||||||
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, 0, 0, 0);
|
BoardConfig TRACKERD ("TRACKERD", eTRACKERD, OledPins( 5, 4), LoraPins(18, 19, 23, 16, 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, 0, 0, 0);
|
BoardConfig HELTEC_WIFI_LORA_32_V1 ("HELTEC_WIFI_LORA_32_V1", eHELTEC_WIFI_LORA_32_V1, OledPins( 4, 15, 16), LoraPins( 5, 19, 27, 18, 14, 26));
|
||||||
BoardConfig GUALTHERIUS_LORAHAM_v100("GUALTHERIUS_LORAHAM_v100", eGUALTHERIUS_LORAHAM_v100, 17, 16, 0x3C, 0, 18, 19, 23, 5, 13, 35, 0, 0, 0);
|
BoardConfig HELTEC_WIFI_LORA_32_V2 ("HELTEC_WIFI_LORA_32_V2", eHELTEC_WIFI_LORA_32_V2, OledPins( 4, 15, 16), LoraPins( 5, 19, 27, 18, 14, 26));
|
||||||
BoardConfig GUALTHERIUS_LORAHAM_v106("GUALTHERIUS_LORAHAM_v106", eGUALTHERIUS_LORAHAM_v106, 17, 16, 0x3C, 0, 18, 19, 23, 2, 13, 35, 0, 0, 0);
|
BoardConfig GUALTHERIUS_LORAHAM_v100("GUALTHERIUS_LORAHAM_v100", eGUALTHERIUS_LORAHAM_v100, OledPins(17, 16), LoraPins(18, 19, 23, 5, 13, 35));
|
||||||
|
BoardConfig GUALTHERIUS_LORAHAM_v106("GUALTHERIUS_LORAHAM_v106", eGUALTHERIUS_LORAHAM_v106, OledPins(17, 16), LoraPins(18, 19, 23, 2, 13, 35));
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
|
@ -5,46 +5,94 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <ETH.h>
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
|
||||||
#include <logger.h>
|
#include <logger.h>
|
||||||
|
|
||||||
enum BoardType
|
enum BoardType {
|
||||||
{
|
|
||||||
eHELTEC_WIFI_LORA_32_V1,
|
eHELTEC_WIFI_LORA_32_V1,
|
||||||
eHELTEC_WIFI_LORA_32_V2,
|
eHELTEC_WIFI_LORA_32_V2,
|
||||||
eTTGO_LORA32_V1,
|
eTTGO_LORA32_V1,
|
||||||
eTTGO_LORA32_V2,
|
eTTGO_LORA32_V2,
|
||||||
eTTGO_T_Beam_V0_7,
|
eTTGO_T_Beam_V0_7,
|
||||||
eTTGO_T_Beam_V1_0,
|
eTTGO_T_Beam_V1_0,
|
||||||
eETH_BOARD,
|
eLILYGO_POE_ETH_BOARD,
|
||||||
|
eWT32_ETH_BOARD,
|
||||||
eTRACKERD,
|
eTRACKERD,
|
||||||
eGUALTHERIUS_LORAHAM_v100,
|
eGUALTHERIUS_LORAHAM_v100,
|
||||||
eGUALTHERIUS_LORAHAM_v106
|
eGUALTHERIUS_LORAHAM_v106
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class OledPins {
|
||||||
|
public:
|
||||||
|
explicit OledPins(int8_t sda, int8_t scl, int8_t reset = -1, int8_t addr = 0x3C);
|
||||||
|
|
||||||
|
int8_t Sda;
|
||||||
|
int8_t Scl;
|
||||||
|
int8_t Reset;
|
||||||
|
int8_t Addr;
|
||||||
|
};
|
||||||
|
|
||||||
|
class LoraPins {
|
||||||
|
public:
|
||||||
|
explicit LoraPins(int8_t sck, int8_t miso, int8_t mosi, int8_t cs, int8_t reset, int8_t irq);
|
||||||
|
|
||||||
|
int8_t Sck;
|
||||||
|
int8_t Miso;
|
||||||
|
int8_t Mosi;
|
||||||
|
int8_t CS;
|
||||||
|
int8_t Reset;
|
||||||
|
int8_t IRQ;
|
||||||
|
};
|
||||||
|
|
||||||
|
class GpsPins {
|
||||||
|
public:
|
||||||
|
explicit GpsPins(int8_t rx = -1, int8_t tx = -1);
|
||||||
|
|
||||||
|
int8_t Rx;
|
||||||
|
int8_t Tx;
|
||||||
|
};
|
||||||
|
|
||||||
|
class EthernetPins {
|
||||||
|
public:
|
||||||
|
explicit EthernetPins(int8_t mdc = -1, int8_t mdio = -1, int8_t nreset = -1, int8_t addr = 0, int8_t power = -1, eth_clock_mode_t clk = ETH_CLOCK_GPIO17_OUT, eth_phy_type_t type = ETH_PHY_LAN8720);
|
||||||
|
|
||||||
|
int8_t MDC;
|
||||||
|
int8_t MDIO;
|
||||||
|
int8_t nReset;
|
||||||
|
int8_t Addr;
|
||||||
|
int8_t Power;
|
||||||
|
|
||||||
|
eth_clock_mode_t CLK;
|
||||||
|
eth_phy_type_t Type;
|
||||||
|
|
||||||
|
bool isEthernetBoard() const {
|
||||||
|
return MDC != -1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class ButtonPins {
|
||||||
|
public:
|
||||||
|
explicit ButtonPins(int8_t pin = -1);
|
||||||
|
|
||||||
|
int8_t Pin;
|
||||||
|
};
|
||||||
|
|
||||||
class BoardConfig {
|
class BoardConfig {
|
||||||
public:
|
public:
|
||||||
explicit BoardConfig(String name, BoardType type, uint8_t oledsda, uint8_t oledscl, uint8_t oledaddr, uint8_t oledreset, uint8_t lorasck, uint8_t loramiso, uint8_t loramosi, uint8_t loracs, uint8_t lorareset, uint8_t lorairq, uint8_t gpsrx, uint8_t gpstx, uint8_t button, bool needcheckpowerchip = false, bool powercheckstatus = false);
|
explicit BoardConfig(String name, BoardType type, OledPins oled, LoraPins lora, GpsPins gps = GpsPins(), EthernetPins ethernet = EthernetPins(), ButtonPins button = ButtonPins(), bool needcheckpowerchip = false, bool powercheckstatus = false);
|
||||||
|
|
||||||
String Name;
|
String Name;
|
||||||
BoardType Type;
|
BoardType Type;
|
||||||
|
|
||||||
uint8_t OledSda;
|
OledPins Oled;
|
||||||
uint8_t OledScl;
|
LoraPins Lora;
|
||||||
uint8_t OledAddr;
|
GpsPins Gps;
|
||||||
uint8_t OledReset;
|
EthernetPins Ethernet;
|
||||||
|
|
||||||
uint8_t LoraSck;
|
ButtonPins Button;
|
||||||
uint8_t LoraMiso;
|
|
||||||
uint8_t LoraMosi;
|
|
||||||
uint8_t LoraCS;
|
|
||||||
uint8_t LoraReset;
|
|
||||||
uint8_t LoraIRQ;
|
|
||||||
uint8_t GpsRx;
|
|
||||||
uint8_t GpsTx;
|
|
||||||
uint8_t Button;
|
|
||||||
|
|
||||||
bool needCheckPowerChip;
|
bool needCheckPowerChip;
|
||||||
bool powerCheckStatus;
|
bool powerCheckStatus;
|
||||||
|
@ -70,7 +118,8 @@ extern BoardConfig TTGO_LORA32_V1;
|
||||||
extern BoardConfig TTGO_LORA32_V2;
|
extern BoardConfig TTGO_LORA32_V2;
|
||||||
extern BoardConfig TTGO_T_Beam_V0_7;
|
extern BoardConfig TTGO_T_Beam_V0_7;
|
||||||
extern BoardConfig TTGO_T_Beam_V1_0;
|
extern BoardConfig TTGO_T_Beam_V1_0;
|
||||||
extern BoardConfig ETH_BOARD;
|
extern BoardConfig LILYGO_POE_ETH_BOARD;
|
||||||
|
extern BoardConfig WT32_ETH_BOARD;
|
||||||
extern BoardConfig TRACKERD;
|
extern BoardConfig TRACKERD;
|
||||||
extern BoardConfig HELTEC_WIFI_LORA_32_V1;
|
extern BoardConfig HELTEC_WIFI_LORA_32_V1;
|
||||||
extern BoardConfig HELTEC_WIFI_LORA_32_V2;
|
extern BoardConfig HELTEC_WIFI_LORA_32_V2;
|
||||||
|
|
|
@ -9,16 +9,16 @@ Display::~Display() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Display::setup(BoardConfig const *const boardConfig) {
|
void Display::setup(BoardConfig const *const boardConfig) {
|
||||||
if (boardConfig->OledReset != 0) {
|
if (boardConfig->Oled.Reset != -1) {
|
||||||
pinMode(boardConfig->OledReset, OUTPUT);
|
pinMode(boardConfig->Oled.Reset, OUTPUT);
|
||||||
digitalWrite(boardConfig->OledReset, HIGH);
|
digitalWrite(boardConfig->Oled.Reset, HIGH);
|
||||||
delay(1);
|
delay(1);
|
||||||
digitalWrite(boardConfig->OledReset, LOW);
|
digitalWrite(boardConfig->Oled.Reset, LOW);
|
||||||
delay(10);
|
delay(10);
|
||||||
digitalWrite(boardConfig->OledReset, HIGH);
|
digitalWrite(boardConfig->Oled.Reset, HIGH);
|
||||||
}
|
}
|
||||||
Wire.begin(boardConfig->OledSda, boardConfig->OledScl);
|
Wire.begin(boardConfig->Oled.Sda, boardConfig->Oled.Scl);
|
||||||
_disp = new SSD1306(&Wire, boardConfig->OledAddr);
|
_disp = new SSD1306(&Wire, boardConfig->Oled.Addr);
|
||||||
|
|
||||||
Bitmap bitmap(_disp->getWidth(), _disp->getHeight());
|
Bitmap bitmap(_disp->getWidth(), _disp->getHeight());
|
||||||
_disp->display(&bitmap);
|
_disp->display(&bitmap);
|
||||||
|
@ -42,8 +42,7 @@ void Display::setDisplaySaveTimeout(uint32_t timeout) {
|
||||||
_displaySaveModeTimer.setTimeout(timeout * 1000);
|
_displaySaveModeTimer.setTimeout(timeout * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Display::activateDistplay()
|
void Display::activateDistplay() {
|
||||||
{
|
|
||||||
_disp->displayOn();
|
_disp->displayOn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,8 @@ void setup() {
|
||||||
boardConfigs.push_back(&TTGO_LORA32_V2);
|
boardConfigs.push_back(&TTGO_LORA32_V2);
|
||||||
boardConfigs.push_back(&TTGO_T_Beam_V0_7);
|
boardConfigs.push_back(&TTGO_T_Beam_V0_7);
|
||||||
boardConfigs.push_back(&TTGO_T_Beam_V1_0);
|
boardConfigs.push_back(&TTGO_T_Beam_V1_0);
|
||||||
boardConfigs.push_back(Ð_BOARD);
|
boardConfigs.push_back(&LILYGO_POE_ETH_BOARD);
|
||||||
|
boardConfigs.push_back(&WT32_ETH_BOARD);
|
||||||
boardConfigs.push_back(&TRACKERD);
|
boardConfigs.push_back(&TRACKERD);
|
||||||
boardConfigs.push_back(&HELTEC_WIFI_LORA_32_V1);
|
boardConfigs.push_back(&HELTEC_WIFI_LORA_32_V1);
|
||||||
boardConfigs.push_back(&HELTEC_WIFI_LORA_32_V2);
|
boardConfigs.push_back(&HELTEC_WIFI_LORA_32_V2);
|
||||||
|
@ -99,7 +100,7 @@ void setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boardConfig->Type == eTTGO_T_Beam_V1_0) {
|
if (boardConfig->Type == eTTGO_T_Beam_V1_0) {
|
||||||
Wire.begin(boardConfig->OledSda, boardConfig->OledScl);
|
Wire.begin(boardConfig->Oled.Sda, boardConfig->Oled.Scl);
|
||||||
PowerManagement powerManagement;
|
PowerManagement powerManagement;
|
||||||
if (!powerManagement.begin(Wire)) {
|
if (!powerManagement.begin(Wire)) {
|
||||||
LoRaSystem.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "AXP192 init done!");
|
LoRaSystem.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "AXP192 init done!");
|
||||||
|
@ -128,7 +129,7 @@ void setup() {
|
||||||
LoRaSystem.getTaskManager().addAlwaysRunTask(&wifiTask);
|
LoRaSystem.getTaskManager().addAlwaysRunTask(&wifiTask);
|
||||||
tcpip = true;
|
tcpip = true;
|
||||||
}
|
}
|
||||||
if (boardConfig->Type == eETH_BOARD) {
|
if (boardConfig->Ethernet.isEthernetBoard()) {
|
||||||
LoRaSystem.getTaskManager().addAlwaysRunTask(ðTask);
|
LoRaSystem.getTaskManager().addAlwaysRunTask(ðTask);
|
||||||
tcpip = true;
|
tcpip = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@ void BeaconTask::pushButton() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BeaconTask::setup(System &system) {
|
bool BeaconTask::setup(System &system) {
|
||||||
if (_instances++ == 0 && system.getBoardConfig()->Button > 0) {
|
if (_instances++ == 0 && system.getBoardConfig()->Button.Pin != -1) {
|
||||||
_userButton = OneButton(system.getBoardConfig()->Button, true, true);
|
_userButton = OneButton(system.getBoardConfig()->Button.Pin, true, true);
|
||||||
_userButton.attachClick(pushButton);
|
_userButton.attachClick(pushButton);
|
||||||
_send_update = false;
|
_send_update = false;
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,8 @@ bool BeaconTask::setup(System &system) {
|
||||||
_useGps = system.getUserConfig()->beacon.use_gps;
|
_useGps = system.getUserConfig()->beacon.use_gps;
|
||||||
|
|
||||||
if (_useGps) {
|
if (_useGps) {
|
||||||
if (system.getBoardConfig()->GpsRx != 0) {
|
if (system.getBoardConfig()->Gps.Rx != -1) {
|
||||||
_ss.begin(9600, SERIAL_8N1, system.getBoardConfig()->GpsTx, system.getBoardConfig()->GpsRx);
|
_ss.begin(9600, SERIAL_8N1, system.getBoardConfig()->Gps.Tx, system.getBoardConfig()->Gps.Rx);
|
||||||
} else {
|
} else {
|
||||||
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "NO GPS found.");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "NO GPS found.");
|
||||||
_useGps = false;
|
_useGps = false;
|
||||||
|
|
|
@ -78,34 +78,18 @@ EthTask::~EthTask() {
|
||||||
bool EthTask::setup(System &system) {
|
bool EthTask::setup(System &system) {
|
||||||
WiFi.onEvent(WiFiEvent);
|
WiFi.onEvent(WiFiEvent);
|
||||||
|
|
||||||
constexpr uint8_t ETH_NRST = 5;
|
if (system.getBoardConfig()->Ethernet.nReset != -1) {
|
||||||
constexpr uint8_t ETH_ADDR = 0;
|
pinMode(system.getBoardConfig()->Ethernet.nReset, OUTPUT);
|
||||||
constexpr int ETH_POWER_PIN = -1;
|
digitalWrite(system.getBoardConfig()->Ethernet.nReset, 0);
|
||||||
constexpr int ETH_MDC_PIN = 23;
|
delay(200);
|
||||||
constexpr int ETH_MDIO_PIN = 18;
|
digitalWrite(system.getBoardConfig()->Ethernet.nReset, 1);
|
||||||
constexpr eth_phy_type_t ETH_TYPE = ETH_PHY_LAN8720;
|
delay(200);
|
||||||
constexpr eth_clock_mode_t ETH_CLK = ETH_CLOCK_GPIO17_OUT; // TTGO PoE V1.0
|
digitalWrite(system.getBoardConfig()->Ethernet.nReset, 0);
|
||||||
// constexpr eth_clock_mode_t ETH_CLK = ETH_CLOCK_GPIO0_OUT; // TTGO PoE V1.2
|
delay(200);
|
||||||
|
digitalWrite(system.getBoardConfig()->Ethernet.nReset, 1);
|
||||||
|
}
|
||||||
|
|
||||||
// config for WT32-ETH01 - comment out upper values, proper board support will come later
|
ETH.begin(system.getBoardConfig()->Ethernet.Addr, system.getBoardConfig()->Ethernet.Power, system.getBoardConfig()->Ethernet.MDC, system.getBoardConfig()->Ethernet.MDIO, system.getBoardConfig()->Ethernet.Type, system.getBoardConfig()->Ethernet.CLK);
|
||||||
// constexpr uint8_t ETH_NRST = 5;
|
|
||||||
// constexpr uint8_t ETH_ADDR = 1;
|
|
||||||
// constexpr int ETH_POWER_PIN = 16;
|
|
||||||
// constexpr int ETH_MDC_PIN = 23;
|
|
||||||
// constexpr int ETH_MDIO_PIN = 18;
|
|
||||||
// constexpr eth_phy_type_t ETH_TYPE = ETH_PHY_LAN8720;
|
|
||||||
// constexpr eth_clock_mode_t ETH_CLK = ETH_CLOCK_GPIO0_IN;
|
|
||||||
|
|
||||||
pinMode(ETH_NRST, OUTPUT);
|
|
||||||
digitalWrite(ETH_NRST, 0);
|
|
||||||
delay(200);
|
|
||||||
digitalWrite(ETH_NRST, 1);
|
|
||||||
delay(200);
|
|
||||||
digitalWrite(ETH_NRST, 0);
|
|
||||||
delay(200);
|
|
||||||
digitalWrite(ETH_NRST, 1);
|
|
||||||
|
|
||||||
ETH.begin(ETH_ADDR, ETH_POWER_PIN, ETH_MDC_PIN, ETH_MDIO_PIN, ETH_TYPE, ETH_CLK);
|
|
||||||
|
|
||||||
if (!system.getUserConfig()->network.DHCP) {
|
if (!system.getUserConfig()->network.DHCP) {
|
||||||
ETH.config(system.getUserConfig()->network.static_.ip, system.getUserConfig()->network.static_.gateway, system.getUserConfig()->network.static_.subnet, system.getUserConfig()->network.static_.dns1, system.getUserConfig()->network.static_.dns2);
|
ETH.config(system.getUserConfig()->network.static_.ip, system.getUserConfig()->network.static_.gateway, system.getUserConfig()->network.static_.subnet, system.getUserConfig()->network.static_.dns1, system.getUserConfig()->network.static_.dns2);
|
||||||
|
|
|
@ -23,8 +23,8 @@ void RadiolibTask::setFlag(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RadiolibTask::setup(System &system) {
|
bool RadiolibTask::setup(System &system) {
|
||||||
SPI.begin(system.getBoardConfig()->LoraSck, system.getBoardConfig()->LoraMiso, system.getBoardConfig()->LoraMosi, system.getBoardConfig()->LoraCS);
|
SPI.begin(system.getBoardConfig()->Lora.Sck, system.getBoardConfig()->Lora.Miso, system.getBoardConfig()->Lora.Mosi, system.getBoardConfig()->Lora.CS);
|
||||||
module = new Module(system.getBoardConfig()->LoraCS, system.getBoardConfig()->LoraIRQ, system.getBoardConfig()->LoraReset);
|
module = new Module(system.getBoardConfig()->Lora.CS, system.getBoardConfig()->Lora.IRQ, system.getBoardConfig()->Lora.Reset);
|
||||||
radio = new SX1278(module);
|
radio = new SX1278(module);
|
||||||
|
|
||||||
config = system.getUserConfig()->lora;
|
config = system.getUserConfig()->lora;
|
||||||
|
|
Ładowanie…
Reference in New Issue