1.2
This commit is contained in:
parent
58284e3d28
commit
106def74e0
|
|
@ -45,6 +45,10 @@ build_flags = -Werror -Wall -DTTGO_T_Beam_V0_7
|
|||
board = ttgo-t-beam
|
||||
build_flags = -Werror -Wall -DTTGO_T_Beam_V1_0
|
||||
|
||||
[env:ttgo-t-beam-v1_SX1268]
|
||||
board = ttgo-t-beam
|
||||
build_flags = -Werror -Wall -DTTGO_T_Beam_V1_0_SX1268
|
||||
|
||||
[env:ttgo-t-beam-v1_2]
|
||||
board = ttgo-t-beam
|
||||
build_flags = -Werror -Wall -DTTGO_T_Beam_V1_2
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include <RadioLib.h>
|
||||
#include <logger.h>
|
||||
#include <LoRa.h>
|
||||
#include <SPI.h>
|
||||
#include "configuration.h"
|
||||
#include "msg_utils.h"
|
||||
#include "display.h"
|
||||
|
|
@ -7,7 +9,7 @@
|
|||
extern logging::Logger logger;
|
||||
extern Configuration Config;
|
||||
|
||||
#include <RadioLib.h>
|
||||
|
||||
|
||||
#define RADIO_SCLK_PIN 5
|
||||
#define RADIO_MISO_PIN 19
|
||||
|
|
@ -25,16 +27,18 @@ SX1268 radio = new Module(RADIO_CS_PIN, RADIO_DIO1_PIN, RADIO_RST_PIN, RADIO_BUS
|
|||
namespace LoRa_Utils {
|
||||
|
||||
void setup() {
|
||||
#if defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "Set SPI pins!");
|
||||
SPI.begin(RADIO_SCLK_PIN, RADIO_MISO_PIN, RADIO_MOSI_PIN);
|
||||
|
||||
Serial.print(F("[SX1268] Initializing ... "));
|
||||
int state = radio.begin(BAND);
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "frequency: %d", BAND);
|
||||
if (state == RADIOLIB_ERR_NONE)
|
||||
{
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, "LoRa", "Starting LoRa failed!");
|
||||
while (true);
|
||||
}
|
||||
radio.setSpreadingFactor(12); // ranges from 6-12,default 7 see API docs
|
||||
|
|
@ -43,16 +47,14 @@ namespace LoRa_Utils {
|
|||
state = radio.setOutputPower(20);
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "LoRa init done!");
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, "LoRa", "Starting LoRa failed!");
|
||||
while (true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "Set SPI pins!");
|
||||
#endif
|
||||
#if defined(TTGO_T_Beam_V1_0)
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "Set SPI pins!");
|
||||
SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS);
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "Set LoRa pins!");
|
||||
LoRa.setPins(LORA_CS, LORA_RST, LORA_IRQ);
|
||||
|
|
@ -72,7 +74,8 @@ namespace LoRa_Utils {
|
|||
LoRa.enableCrc();
|
||||
|
||||
LoRa.setTxPower(Config.loramodule.power);
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "LoRa init done!");*/
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "LoRa init done!");
|
||||
#endif
|
||||
}
|
||||
|
||||
void sendNewPacket(const String &newPacket) {
|
||||
|
|
@ -80,6 +83,7 @@ namespace LoRa_Utils {
|
|||
digitalWrite(Config.ptt.io_pin, Config.ptt.reverse ? LOW : HIGH);
|
||||
delay(Config.ptt.preDelay);
|
||||
}
|
||||
#if defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
Serial.println("Transmiting...");
|
||||
int state = radio.transmit("\x3c\xff\x01" + newPacket);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
|
|
@ -104,14 +108,15 @@ namespace LoRa_Utils {
|
|||
Serial.print(F("failed, code "));
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
|
||||
/*LoRa.beginPacket();
|
||||
#endif
|
||||
#if defined(TTGO_T_Beam_V1_0)
|
||||
LoRa.beginPacket();
|
||||
LoRa.write('<');
|
||||
LoRa.write(0xFF);
|
||||
LoRa.write(0x01);
|
||||
LoRa.write((const uint8_t *)newPacket.c_str(), newPacket.length());
|
||||
LoRa.endPacket();*/
|
||||
LoRa.endPacket();
|
||||
#endif
|
||||
if (Config.ptt.active) {
|
||||
delay(Config.ptt.postDelay);
|
||||
digitalWrite(Config.ptt.io_pin, Config.ptt.reverse ? HIGH : LOW);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#define OLED_SCL 22
|
||||
#define OLED_RST 16
|
||||
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
#define GPS_RX 12
|
||||
#define GPS_TX 34
|
||||
#define BUTTON_PIN 38 // The middle button GPIO on the T-Beam
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ extern logging::Logger logger;
|
|||
|
||||
// cppcheck-suppress unusedFunction
|
||||
bool PowerManagement::begin(TwoWire &port) {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
bool result = axp.begin(port, AXP192_SLAVE_ADDRESS);
|
||||
if (!result) {
|
||||
axp.setDCDC1Voltage(3300);
|
||||
|
|
@ -40,7 +40,7 @@ bool PowerManagement::begin(TwoWire &port) {
|
|||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::activateLoRa() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
axp.setPowerOutPut(AXP192_LDO2, AXP202_ON);
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
|
|
@ -51,7 +51,7 @@ void PowerManagement::activateLoRa() {
|
|||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::deactivateLoRa() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
axp.setPowerOutPut(AXP192_LDO2, AXP202_OFF);
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
|
|
@ -61,7 +61,7 @@ void PowerManagement::deactivateLoRa() {
|
|||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::activateGPS() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
axp.setPowerOutPut(AXP192_LDO3, AXP202_ON);
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
|
|
@ -72,7 +72,7 @@ void PowerManagement::activateGPS() {
|
|||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::deactivateGPS() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
axp.setPowerOutPut(AXP192_LDO3, AXP202_OFF);
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
|
|
@ -82,35 +82,35 @@ void PowerManagement::deactivateGPS() {
|
|||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::activateOLED() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON);
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::decativateOLED() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
axp.setPowerOutPut(AXP192_DCDC1, AXP202_OFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::disableChgLed() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
axp.setChgLEDMode(AXP20X_LED_OFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::enableChgLed() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
axp.setChgLEDMode(AXP20X_LED_LOW_LEVEL);
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::activateMeasurement() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
axp.adc1Enable(AXP202_BATT_CUR_ADC1 | AXP202_BATT_VOL_ADC1, true);
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
|
|
@ -124,14 +124,14 @@ void PowerManagement::activateMeasurement() {
|
|||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::deactivateMeasurement() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
axp.adc1Enable(AXP202_BATT_CUR_ADC1 | AXP202_BATT_VOL_ADC1, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
double PowerManagement::getBatteryVoltage() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
return axp.getBattVoltage() / 1000.0;
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
|
|
@ -141,7 +141,7 @@ double PowerManagement::getBatteryVoltage() {
|
|||
|
||||
// cppcheck-suppress unusedFunction
|
||||
double PowerManagement::getBatteryChargeDischargeCurrent() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
if (axp.isChargeing()) {
|
||||
return axp.getBattChargeCurrent();
|
||||
}
|
||||
|
|
@ -153,7 +153,7 @@ double PowerManagement::getBatteryChargeDischargeCurrent() {
|
|||
}
|
||||
|
||||
bool PowerManagement::isBatteryConnected() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
return axp.isBatteryConnect();
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
|
|
@ -162,7 +162,7 @@ bool PowerManagement::isBatteryConnected() {
|
|||
}
|
||||
|
||||
bool PowerManagement::isChargeing() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
return axp.isChargeing();
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
|
|
@ -171,7 +171,7 @@ bool PowerManagement::isChargeing() {
|
|||
}
|
||||
|
||||
void PowerManagement::setup() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
Wire.begin(SDA, SCL);
|
||||
if (!begin(Wire)) {
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "AXP192", "init done!");
|
||||
|
|
@ -209,7 +209,7 @@ void PowerManagement::setup() {
|
|||
}
|
||||
|
||||
void PowerManagement::lowerCpuFrequency() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_LORA_V2_1)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
if (setCpuFrequencyMhz(80)) {
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "CPU frequency set to 80MHz");
|
||||
} else {
|
||||
|
|
@ -231,7 +231,7 @@ void PowerManagement::obtainBatteryInfo() {
|
|||
if (!(rate_limit_check_battery++ % 60))
|
||||
BatteryIsConnected = isBatteryConnected();
|
||||
if (BatteryIsConnected) {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
batteryVoltage = String(getBatteryVoltage(), 2);
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
|
|
@ -254,7 +254,7 @@ bool PowerManagement::getBatteryInfoIsConnected() {
|
|||
}
|
||||
|
||||
void PowerManagement::batteryManager() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_LORA_V2_1)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
obtainBatteryInfo();
|
||||
handleChargingLed();
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define POWER_UTILS_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
#include <axp20x.h>
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
|
|
@ -49,7 +49,7 @@ private:
|
|||
|
||||
bool isBatteryConnected();
|
||||
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
AXP20X_Class axp;
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
|
|
|
|||
Loading…
Reference in New Issue