Push button to send beacon immediately.

pull/174/head
FUJIURA Toyonori 2022-03-27 09:02:14 +09:00
rodzic c52c39efea
commit fba322a0d5
5 zmienionych plików z 38 dodań i 12 usunięć

Wyświetl plik

@ -4,8 +4,8 @@
#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, bool needcheckpowerchip, bool powercheckstatus)
: 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), needCheckPowerChip(needcheckpowerchip), powerCheckStatus(powercheckstatus) {
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)
: 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) {
}
BoardFinder::BoardFinder(const std::list<BoardConfig const *> &boardConfigs) : _boardConfigs(boardConfigs) {
@ -130,12 +130,12 @@ bool BoardFinder::checkPowerConfig(BoardConfig const *boardConfig, logging::Logg
}
// 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);
BoardConfig TTGO_LORA32_V2 ("TTGO_LORA32_V2", eTTGO_LORA32_V2, 21, 22, 0x3C, 0, 5, 19, 27, 18, 14, 26, 0, 0, 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, 15, 12, 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, true, true);
BoardConfig ETH_BOARD ("ETH_BOARD", eETH_BOARD, 33, 32, 0x3C, 0, 14, 2, 15, 12, 4, 36, 0, 0);
BoardConfig TRACKERD ("TRACKERD", eTRACKERD, 5, 4, 0x3C, 0, 18, 19, 23, 16, 14, 26, 0, 0);
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);
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);
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_V2 ("TTGO_LORA32_V2", eTTGO_LORA32_V2, 21, 22, 0x3C, 0, 5, 19, 27, 18, 14, 26, 0, 0, 0, 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, 15, 12, 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 ETH_BOARD ("ETH_BOARD", eETH_BOARD, 33, 32, 0x3C, 0, 14, 2, 15, 12, 4, 36, 0, 0, 0);
BoardConfig TRACKERD ("TRACKERD", eTRACKERD, 5, 4, 0x3C, 0, 18, 19, 23, 16, 14, 26, 0, 0, 0);
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 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);
// clang-format on

Wyświetl plik

@ -24,7 +24,7 @@ enum BoardType
class BoardConfig {
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, bool needcheckpowerchip = false, bool powercheckstatus = false);
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);
String Name;
BoardType Type;
@ -42,6 +42,7 @@ public:
uint8_t LoraIRQ;
uint8_t GpsRx;
uint8_t GpsTx;
uint8_t Button;
bool needCheckPowerChip;
bool powerCheckStatus;

Wyświetl plik

@ -15,6 +15,7 @@ lib_deps =
peterus/ESP-FTP-Server-Lib @ 0.9.5
knolleary/PubSubClient@^2.8
mikalhart/TinyGPSPlus @ 1.0.2
shaggydog/OneButton @ 1.5.0
check_tool = cppcheck
check_flags =
cppcheck: --suppress=*:*.pio\* --inline-suppr -DCPPCHECK --force lib -ilib/TimeLib -ilib/LoRa -ilib/NTPClient

Wyświetl plik

@ -1,5 +1,6 @@
#include <logger.h>
#include <OneButton.h>
#include <TimeLib.h>
#include "Task.h"
@ -12,7 +13,21 @@ BeaconTask::BeaconTask(TaskQueue<std::shared_ptr<APRSMessage>> &toModem, TaskQue
BeaconTask::~BeaconTask() {
}
OneButton BeaconTask::_userButton;
bool BeaconTask::_send_update;
uint BeaconTask::_instances;
void BeaconTask::pushButton() {
_send_update = true;
}
bool BeaconTask::setup(System &system) {
if (_instances++ == 0 && system.getBoardConfig()->Button > 0) {
_userButton = OneButton(system.getBoardConfig()->Button, true, true);
_userButton.attachClick(pushButton);
_send_update = false;
}
_useGps = system.getUserConfig()->beacon.use_gps;
if (_useGps) {
@ -41,9 +56,12 @@ bool BeaconTask::loop(System &system) {
}
}
_userButton.tick();
// check for beacon
if (_beacon_timer.check()) {
if (_beacon_timer.check() || _send_update) {
if (sendBeacon(system)) {
_send_update = false;
_beacon_timer.start();
}
}

Wyświetl plik

@ -1,6 +1,7 @@
#ifndef TASK_BEACON_H_
#define TASK_BEACON_H_
#include <OneButton.h>
#include <TinyGPS++.h>
#include <APRSMessage.h>
@ -26,6 +27,11 @@ private:
HardwareSerial _ss;
TinyGPSPlus _gps;
bool _useGps;
static uint _instances;
static OneButton _userButton;
static bool _send_update;
static void pushButton();
};
#endif