first test!
This commit is contained in:
parent
c507dbf4e7
commit
d591974b95
|
|
@ -1,61 +1,34 @@
|
|||
{
|
||||
"beacons": [
|
||||
{
|
||||
"callsign": "NOCALL-7",
|
||||
"callsign": "CA2RXU-6",
|
||||
"gpsEcoMode": false,
|
||||
"symbol": "[",
|
||||
"overlay": "/",
|
||||
"micE": "",
|
||||
"comment": "",
|
||||
"smartBeacon": {
|
||||
"active": true,
|
||||
"slowRate": 120,
|
||||
"slowSpeed": 3,
|
||||
"fastRate": 60,
|
||||
"fastSpeed": 15,
|
||||
"minTxDist": 50,
|
||||
"minDeltaBeacon": 20,
|
||||
"turnMinDeg": 12,
|
||||
"turnSlope": 60
|
||||
}
|
||||
"smartBeaconActive": true,
|
||||
"smartBeaconSetting": 0
|
||||
},
|
||||
{
|
||||
"callsign": "NOCALL-7",
|
||||
"callsign": "CA2RXU-6",
|
||||
"gpsEcoMode": false,
|
||||
"symbol": ">",
|
||||
"overlay": "/",
|
||||
"micE": "",
|
||||
"comment": "",
|
||||
"smartBeacon": {
|
||||
"active": true,
|
||||
"slowRate": 120,
|
||||
"slowSpeed": 10,
|
||||
"fastRate": 60,
|
||||
"fastSpeed": 70,
|
||||
"minTxDist": 100,
|
||||
"minDeltaBeacon": 12,
|
||||
"turnMinDeg": 10,
|
||||
"turnSlope": 80
|
||||
}
|
||||
"smartBeaconActive": true,
|
||||
"smartBeaconSetting": 2
|
||||
},
|
||||
{
|
||||
"callsign": "NOCALL-7",
|
||||
"callsign": "CA2RXU-6",
|
||||
"gpsEcoMode": false,
|
||||
"symbol": "b",
|
||||
"overlay": "/",
|
||||
"micE": "",
|
||||
"comment": "",
|
||||
"smartBeacon": {
|
||||
"active": true,
|
||||
"slowRate": 120,
|
||||
"slowSpeed": 5,
|
||||
"fastRate": 60,
|
||||
"fastSpeed": 40,
|
||||
"minTxDist": 100,
|
||||
"minDeltaBeacon": 12,
|
||||
"turnMinDeg": 12,
|
||||
"turnSlope": 60
|
||||
}
|
||||
"smartBeaconActive": true,
|
||||
"smartBeaconSetting": 1
|
||||
}
|
||||
],
|
||||
"display": {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ ________________________________________________________________________________
|
|||
#include <logger.h>
|
||||
#include <WiFi.h>
|
||||
#include "APRSPacketLib.h"
|
||||
#include "smartbeacon_utils.h"
|
||||
#include "bluetooth_utils.h"
|
||||
#include "keyboard_utils.h"
|
||||
#include "configuration.h"
|
||||
|
|
@ -46,7 +47,7 @@ TinyGPSPlus gps;
|
|||
OneButton userButton = OneButton(BUTTON_PIN, true, true);
|
||||
#endif
|
||||
|
||||
String versionDate = "2024.08.21";
|
||||
String versionDate = "2024.08.26";
|
||||
|
||||
uint8_t myBeaconsIndex = 0;
|
||||
int myBeaconsSize = Config.beacons.size();
|
||||
|
|
@ -84,7 +85,7 @@ bool sosActive = false;
|
|||
|
||||
bool miceActive = false;
|
||||
|
||||
bool smartBeaconValue = true;
|
||||
bool smartBeaconActive = true;
|
||||
|
||||
int ackRequestNumber;
|
||||
|
||||
|
|
@ -158,8 +159,9 @@ void loop() {
|
|||
miceActive = Config.validateMicE(currentBeacon->micE);
|
||||
}
|
||||
POWER_Utils::batteryManager();
|
||||
|
||||
STATION_Utils::checkSmartBeaconValue();
|
||||
|
||||
SMARTBEACON_Utils::checkValues(myBeaconsIndex);
|
||||
SMARTBEACON_Utils::checkState();
|
||||
|
||||
if (!Config.simplifiedTrackerMode) {
|
||||
#ifdef BUTTON_PIN
|
||||
|
|
@ -200,16 +202,16 @@ void loop() {
|
|||
Utils::checkStatus();
|
||||
STATION_Utils::checkTelemetryTx();
|
||||
}
|
||||
if (!sendUpdate && gps_loc_update && smartBeaconValue) {
|
||||
if (!sendUpdate && gps_loc_update && smartBeaconActive) {
|
||||
GPS_Utils::calculateDistanceTraveled();
|
||||
if (!sendUpdate) {
|
||||
GPS_Utils::calculateHeadingDelta(currentSpeed);
|
||||
}
|
||||
STATION_Utils::checkStandingUpdateTime();
|
||||
}
|
||||
STATION_Utils::checkSmartBeaconState();
|
||||
SMARTBEACON_Utils::checkFixedBeaconTime();
|
||||
if (sendUpdate && gps_loc_update) STATION_Utils::sendBeacon(0);
|
||||
if (gps_time_update) STATION_Utils::checkSmartBeaconInterval(currentSpeed);
|
||||
if (gps_time_update) SMARTBEACON_Utils::checkInterval(currentSpeed);
|
||||
|
||||
if (millis() - refreshDisplayTime >= 1000 || gps_time_update) {
|
||||
GPS_Utils::checkStartUpFrames();
|
||||
|
|
|
|||
|
|
@ -29,20 +29,13 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) {
|
|||
|
||||
bcn.callsign = BeaconsArray[i]["callsign"] | "NOCALL-7";
|
||||
bcn.callsign.toUpperCase();
|
||||
bcn.gpsEcoMode = BeaconsArray[i]["gpsEcoMode"] | false;
|
||||
bcn.symbol = BeaconsArray[i]["symbol"] | ">";
|
||||
bcn.overlay = BeaconsArray[i]["overlay"] | "/";
|
||||
bcn.micE = BeaconsArray[i]["micE"] | "";
|
||||
bcn.comment = BeaconsArray[i]["comment"] | "";
|
||||
bcn.smartBeaconState = BeaconsArray[i]["smartBeacon"]["active"] | true;
|
||||
bcn.slowRate = BeaconsArray[i]["smartBeacon"]["slowRate"] | 120;
|
||||
bcn.slowSpeed = BeaconsArray[i]["smartBeacon"]["slowSpeed"] | 10;
|
||||
bcn.fastRate = BeaconsArray[i]["smartBeacon"]["fastRate"] | 60;
|
||||
bcn.fastSpeed = BeaconsArray[i]["smartBeacon"]["fastSpeed"]| 70;
|
||||
bcn.minTxDist = BeaconsArray[i]["smartBeacon"]["minTxDist"] | 100;
|
||||
bcn.minDeltaBeacon = BeaconsArray[i]["smartBeacon"]["minDeltaBeacon"] | 12;
|
||||
bcn.turnMinDeg = BeaconsArray[i]["smartBeacon"]["turnMinDeg"] | 10;
|
||||
bcn.turnSlope = BeaconsArray[i]["smartBeacon"]["turnSlope"] | 80;
|
||||
bcn.smartBeaconActive = BeaconsArray[i]["smartBeaconActive"] | true;
|
||||
bcn.smartBeaconSetting = BeaconsArray[i]["smartBeaconSetting"] | 0;
|
||||
bcn.micE = BeaconsArray[i]["micE"] | "";
|
||||
bcn.gpsEcoMode = BeaconsArray[i]["gpsEcoMode"] | false;
|
||||
|
||||
beacons.push_back(bcn);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,20 +8,13 @@
|
|||
class Beacon {
|
||||
public:
|
||||
String callsign;
|
||||
bool gpsEcoMode;
|
||||
String symbol;
|
||||
String overlay;
|
||||
String micE;
|
||||
String comment;
|
||||
bool smartBeaconState;
|
||||
int slowRate;
|
||||
int slowSpeed;
|
||||
int fastRate;
|
||||
int fastSpeed;
|
||||
int minTxDist;
|
||||
int minDeltaBeacon;
|
||||
int turnMinDeg;
|
||||
int turnSlope;
|
||||
bool smartBeaconActive;
|
||||
byte smartBeaconSetting;
|
||||
String micE;
|
||||
bool gpsEcoMode;
|
||||
};
|
||||
|
||||
class Display {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <TinyGPS++.h>
|
||||
#include "TimeLib.h"
|
||||
#include "smartbeacon_utils.h"
|
||||
#include "configuration.h"
|
||||
#include "station_utils.h"
|
||||
#include "boards_pinout.h"
|
||||
|
|
@ -17,22 +18,23 @@
|
|||
#define GPS_BAUD 9600
|
||||
#endif
|
||||
|
||||
extern Configuration Config;
|
||||
extern HardwareSerial neo6m_gps; // cambiar a gpsSerial
|
||||
extern TinyGPSPlus gps;
|
||||
extern Beacon *currentBeacon;
|
||||
extern logging::Logger logger;
|
||||
extern bool sendUpdate;
|
||||
extern bool sendStandingUpdate;
|
||||
extern Configuration Config;
|
||||
extern HardwareSerial neo6m_gps; // cambiar a gpsSerial
|
||||
extern TinyGPSPlus gps;
|
||||
extern Beacon *currentBeacon;
|
||||
extern logging::Logger logger;
|
||||
extern bool sendUpdate;
|
||||
extern bool sendStandingUpdate;
|
||||
|
||||
extern uint32_t lastTxTime;
|
||||
extern uint32_t txInterval;
|
||||
extern double lastTxLat;
|
||||
extern double lastTxLng;
|
||||
extern double lastTxDistance;
|
||||
extern uint32_t lastTx;
|
||||
extern bool disableGPS;
|
||||
extern bool gpsShouldSleep;
|
||||
extern uint32_t lastTxTime;
|
||||
extern uint32_t txInterval;
|
||||
extern double lastTxLat;
|
||||
extern double lastTxLng;
|
||||
extern double lastTxDistance;
|
||||
extern uint32_t lastTx;
|
||||
extern bool disableGPS;
|
||||
extern bool gpsShouldSleep;
|
||||
extern SmartBeaconValues currentSmartBeaconValues;
|
||||
|
||||
double currentHeading = 0;
|
||||
double previousHeading = 0;
|
||||
|
|
@ -73,7 +75,7 @@ namespace GPS_Utils {
|
|||
currentHeading = gps.course.deg();
|
||||
lastTxDistance = TinyGPSPlus::distanceBetween(gps.location.lat(), gps.location.lng(), lastTxLat, lastTxLng);
|
||||
if (lastTx >= txInterval) {
|
||||
if (lastTxDistance > currentBeacon->minTxDist) {
|
||||
if (lastTxDistance > currentSmartBeaconValues.minTxDist) {
|
||||
sendUpdate = true;
|
||||
sendStandingUpdate = false;
|
||||
} else {
|
||||
|
|
@ -91,13 +93,13 @@ namespace GPS_Utils {
|
|||
void calculateHeadingDelta(int speed) {
|
||||
uint8_t TurnMinAngle;
|
||||
double headingDelta = abs(previousHeading - currentHeading);
|
||||
if (lastTx > currentBeacon->minDeltaBeacon * 1000) {
|
||||
if (lastTx > currentSmartBeaconValues.minDeltaBeacon * 1000) {
|
||||
if (speed == 0) {
|
||||
TurnMinAngle = currentBeacon->turnMinDeg + (currentBeacon->turnSlope/(speed + 1));
|
||||
TurnMinAngle = currentSmartBeaconValues.turnMinDeg + (currentSmartBeaconValues.turnSlope/(speed + 1));
|
||||
} else {
|
||||
TurnMinAngle = currentBeacon->turnMinDeg + (currentBeacon->turnSlope/speed);
|
||||
TurnMinAngle = currentSmartBeaconValues.turnMinDeg + (currentSmartBeaconValues.turnSlope/speed);
|
||||
}
|
||||
if (headingDelta > TurnMinAngle && lastTxDistance > currentBeacon->minTxDist) {
|
||||
if (headingDelta > TurnMinAngle && lastTxDistance > currentSmartBeaconValues.minTxDist) {
|
||||
sendUpdate = true;
|
||||
sendStandingUpdate = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -322,10 +322,10 @@ namespace KEYBOARD_Utils {
|
|||
menuDisplay = 63;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void rightArrow() {
|
||||
if (menuDisplay == 0 || menuDisplay == 200) {
|
||||
if(myBeaconsIndex >= (myBeaconsSize-1)) {
|
||||
if(myBeaconsIndex >= (myBeaconsSize - 1)) {
|
||||
myBeaconsIndex = 0;
|
||||
} else {
|
||||
myBeaconsIndex++;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
#include "smartbeacon_utils.h"
|
||||
#include "configuration.h"
|
||||
#include "winlink_utils.h"
|
||||
|
||||
extern Configuration Config;
|
||||
extern Beacon *currentBeacon;
|
||||
extern bool smartBeaconActive;
|
||||
extern uint32_t txInterval;
|
||||
extern uint32_t lastTxTime;
|
||||
extern bool sendUpdate;
|
||||
extern uint8_t winlinkStatus;
|
||||
|
||||
|
||||
SmartBeaconValues currentSmartBeaconValues;
|
||||
byte lastSmartBeaconIndex = 10;
|
||||
bool wxRequestStatus = false;
|
||||
uint32_t wxRequestTime = 0;
|
||||
|
||||
|
||||
SmartBeaconValues smartBeaconSettings[3] = {
|
||||
{120, 3, 60, 15, 50, 20, 12, 60}, // Runner settings = SLOW
|
||||
{120, 5, 60, 40, 100, 12, 12, 60}, // Bike settings = MEDIUM
|
||||
{120, 10, 60, 70, 100, 12, 10, 80} // Car settings = FAST
|
||||
};
|
||||
|
||||
|
||||
namespace SMARTBEACON_Utils {
|
||||
|
||||
void checkValues(byte index) {
|
||||
if (lastSmartBeaconIndex != index) {
|
||||
currentSmartBeaconValues = smartBeaconSettings[index];
|
||||
lastSmartBeaconIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
void checkInterval(int speed) {
|
||||
if (smartBeaconActive) {
|
||||
if (speed < currentSmartBeaconValues.slowSpeed) {
|
||||
txInterval = currentSmartBeaconValues.slowRate * 1000;
|
||||
} else if (speed > currentSmartBeaconValues.fastSpeed) {
|
||||
txInterval = currentSmartBeaconValues.fastRate * 1000;
|
||||
} else {
|
||||
txInterval = min(currentSmartBeaconValues.slowRate, currentSmartBeaconValues.fastSpeed * currentSmartBeaconValues.fastRate / speed) * 1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void checkFixedBeaconTime() {
|
||||
if (!smartBeaconActive) {
|
||||
uint32_t lastTxSmartBeacon = millis() - lastTxTime;
|
||||
if (lastTxSmartBeacon >= Config.nonSmartBeaconRate * 60 * 1000) {
|
||||
sendUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void checkState() {
|
||||
if (wxRequestStatus && (millis() - wxRequestTime) > 20000) {
|
||||
wxRequestStatus = false;
|
||||
}
|
||||
if(winlinkStatus == 0 && !wxRequestStatus) {
|
||||
smartBeaconActive = currentBeacon->smartBeaconActive;
|
||||
} else {
|
||||
smartBeaconActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
#ifndef SMARTBEACON_UTILS_H_
|
||||
#define SMARTBEACON_UTILS_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
struct SmartBeaconValues {
|
||||
int slowRate;
|
||||
int slowSpeed;
|
||||
int fastRate;
|
||||
int fastSpeed;
|
||||
int minTxDist;
|
||||
int minDeltaBeacon;
|
||||
int turnMinDeg;
|
||||
int turnSlope;
|
||||
};
|
||||
|
||||
|
||||
namespace SMARTBEACON_Utils {
|
||||
|
||||
void checkValues(byte index);
|
||||
void checkInterval(int speed);
|
||||
void checkFixedBeaconTime();
|
||||
void checkState();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -23,8 +23,6 @@ extern uint32_t lastTxTime;
|
|||
|
||||
extern bool sendUpdate;
|
||||
|
||||
extern uint32_t txInterval;
|
||||
|
||||
extern double currentHeading;
|
||||
extern double previousHeading;
|
||||
|
||||
|
|
@ -33,18 +31,18 @@ extern double lastTxLng;
|
|||
extern double lastTxDistance;
|
||||
|
||||
extern bool miceActive;
|
||||
extern bool smartBeaconValue;
|
||||
extern uint8_t winlinkStatus;
|
||||
extern bool smartBeaconActive;
|
||||
extern bool winlinkCommentState;
|
||||
|
||||
extern int wxModuleType;
|
||||
extern bool gpsIsActive;
|
||||
extern bool gpsShouldSleep;
|
||||
|
||||
|
||||
bool sendStandingUpdate = false;
|
||||
uint8_t updateCounter = Config.sendCommentAfterXBeacons;
|
||||
bool wxRequestStatus = false;
|
||||
uint32_t wxRequestTime = 0;
|
||||
|
||||
|
||||
|
||||
uint32_t lastTelemetryTx = 0;
|
||||
uint32_t telemetryTx = millis();
|
||||
|
|
@ -167,18 +165,6 @@ namespace STATION_Utils {
|
|||
}
|
||||
}
|
||||
|
||||
void checkSmartBeaconInterval(int speed) {
|
||||
if (smartBeaconValue) {
|
||||
if (speed < currentBeacon->slowSpeed) {
|
||||
txInterval = currentBeacon->slowRate * 1000;
|
||||
} else if (speed > currentBeacon->fastSpeed) {
|
||||
txInterval = currentBeacon->fastRate * 1000;
|
||||
} else {
|
||||
txInterval = min(currentBeacon->slowRate, currentBeacon->fastSpeed * currentBeacon->fastRate / speed) * 1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void checkStandingUpdateTime() {
|
||||
if (!sendUpdate && lastTx >= Config.standingUpdateTime * 60 * 1000) {
|
||||
sendUpdate = true;
|
||||
|
|
@ -189,26 +175,6 @@ namespace STATION_Utils {
|
|||
}
|
||||
}
|
||||
|
||||
void checkSmartBeaconValue() {
|
||||
if (wxRequestStatus && (millis() - wxRequestTime) > 20000) {
|
||||
wxRequestStatus = false;
|
||||
}
|
||||
if(winlinkStatus == 0 && !wxRequestStatus) {
|
||||
smartBeaconValue = currentBeacon->smartBeaconState;
|
||||
} else {
|
||||
smartBeaconValue = false;
|
||||
}
|
||||
}
|
||||
|
||||
void checkSmartBeaconState() {
|
||||
if (!smartBeaconValue) {
|
||||
uint32_t lastTxSmartBeacon = millis() - lastTxTime;
|
||||
if (lastTxSmartBeacon >= Config.nonSmartBeaconRate * 60 * 1000) {
|
||||
sendUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sendBeacon(uint8_t type) {
|
||||
String packet;
|
||||
if (Config.bme.sendTelemetry && type == 1) { // WX
|
||||
|
|
@ -275,7 +241,7 @@ namespace STATION_Utils {
|
|||
displayShow("<<< TX >>>", "", packet,100);
|
||||
LoRa_Utils::sendNewPacket(packet);
|
||||
|
||||
if (smartBeaconValue) {
|
||||
if (smartBeaconActive) {
|
||||
lastTxLat = gps.location.lat();
|
||||
lastTxLng = gps.location.lng();
|
||||
previousHeading = currentHeading;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,7 @@ namespace STATION_Utils {
|
|||
void deleteListenedTrackersbyTime();
|
||||
void checkListenedTrackersByTimeAndDelete();
|
||||
void orderListenedTrackersByDistance(const String& callsign, float distance, float course);
|
||||
void checkSmartBeaconInterval(int speed);
|
||||
void checkStandingUpdateTime();
|
||||
void checkSmartBeaconValue();
|
||||
void checkSmartBeaconState();
|
||||
void sendBeacon(uint8_t type);
|
||||
void checkTelemetryTx();
|
||||
void saveIndex(uint8_t type, uint8_t index);
|
||||
|
|
|
|||
|
|
@ -4,20 +4,20 @@
|
|||
#include "display.h"
|
||||
#include "utils.h"
|
||||
|
||||
extern Beacon *currentBeacon;
|
||||
extern Configuration Config;
|
||||
extern Beacon *currentBeacon;
|
||||
extern Configuration Config;
|
||||
|
||||
extern uint32_t lastTx;
|
||||
extern uint32_t lastTxTime;
|
||||
extern uint32_t lastTx;
|
||||
extern uint32_t lastTxTime;
|
||||
|
||||
extern bool displayEcoMode;
|
||||
extern uint32_t displayTime;
|
||||
extern bool displayState;
|
||||
extern int menuDisplay;
|
||||
extern String versionDate;
|
||||
extern bool flashlight;
|
||||
extern bool displayEcoMode;
|
||||
extern uint32_t displayTime;
|
||||
extern bool displayState;
|
||||
extern int menuDisplay;
|
||||
extern String versionDate;
|
||||
extern bool flashlight;
|
||||
|
||||
extern bool statusState;
|
||||
extern bool statusState;
|
||||
|
||||
uint32_t statusTime = millis();
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ namespace Utils {
|
|||
}
|
||||
|
||||
String getSmartBeaconState() {
|
||||
if (currentBeacon->smartBeaconState) return "On";
|
||||
if (currentBeacon->smartBeaconActive) return "On";
|
||||
return "Off";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue