mirror of
https://github.com/meshtastic/firmware.git
synced 2026-09-21 05:45:27 -04:00
* Implement GeofenceModule for waypoint crossing notifications and integrate with existing modules * Waypoint Applet Initial Support on InkHUD * undo tile change * Update screen when Waypoint shows or dissapears * Merge branch 'develop' into waypoint-geofence * Geofence on InkHUD * Update MapTile.h * Update WaypointStore.cpp * Notifications * remove GF from waypoint screen * Prevent Focus from closing the notifiaction banner * Trunk fix * cleanup * undo merge conflix mistake * Waypoint screen on BaseUI * Focus preserve fix * UI bugs * Allow Inkhud to remove waypoint * Respect Locked Waypoints * Trunk fix * Update WaypointStore.cpp * Use 8-digit hex formatting for waypoint IDs. 0x%x was inconsistent with the repo's own convention (0x%08x for 32-bit IDs, used elsewhere in this file). Fixed here and in two other spots I found with the same issue (WaypointModule.cpp, GeofenceModule.cpp). * Update ExternalNotificationModule.cpp * Reject invalid surrogate codepoints in waypoint icon rendering * Update WaypointModule.cpp * Update WaypointStore.cpp * Update WaypointStore.cpp * Update WaypointStore.cpp * trunk fix * fix warnings * power.h rename to Power.h * Update Power.h * Fix executable bit on bin/lint-ifdef-complexity.sh Lost during a prior merge from develop (Windows checkout doesn't preserve file mode), causing "execve failed: Permission denied" in the Trunk Check Runner CI job. develop has this file at 100755; restoring that here. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Update README.md * Clean up waypoint and geofence integration * Minimize waypoint and geofence implementation * removed unnecessary gating * Geofence alert * trunk fix * Update test_main.cpp * Update WaypointStore.cpp --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
76 lines
2.2 KiB
C++
76 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include "configuration.h"
|
|
|
|
#if !MESHTASTIC_EXCLUDE_WAYPOINT
|
|
|
|
#ifndef ENABLE_WAYPOINT_PERSISTENCE
|
|
#define ENABLE_WAYPOINT_PERSISTENCE 1
|
|
#endif
|
|
|
|
#ifndef WAYPOINT_HISTORY_LIMIT
|
|
#define WAYPOINT_HISTORY_LIMIT 10
|
|
#endif
|
|
|
|
#include "Observer.h"
|
|
#include "mesh/MeshTypes.h"
|
|
#include "mesh/generated/meshtastic/mesh.pb.h"
|
|
#include <cstdint>
|
|
#include <deque>
|
|
|
|
enum WaypointNotificationPreference : uint8_t {
|
|
WAYPOINT_NOTIFY_ENTER = 1 << 0,
|
|
WAYPOINT_NOTIFY_EXIT = 1 << 1,
|
|
WAYPOINT_NOTIFY_FAVORITES_ONLY = 1 << 2,
|
|
};
|
|
|
|
struct StoredWaypoint {
|
|
meshtastic_Waypoint waypoint = meshtastic_Waypoint_init_zero;
|
|
uint32_t receivedTime = 0;
|
|
NodeNum creatorNodeNum = 0;
|
|
uint8_t notificationPreferences = 0;
|
|
|
|
bool notificationEnabled(WaypointNotificationPreference preference) const
|
|
{
|
|
return (notificationPreferences & preference) != 0;
|
|
}
|
|
};
|
|
|
|
class WaypointStore : public Observable<const WaypointStore *>
|
|
{
|
|
public:
|
|
bool addFromPacket(const meshtastic_MeshPacket &packet, bool locallyAuthored, StoredWaypoint *stored = nullptr);
|
|
bool purgeExpired(uint32_t now = 0);
|
|
bool removeWaypoint(uint32_t id);
|
|
bool setNotificationPreference(uint32_t id, WaypointNotificationPreference preference, bool enabled);
|
|
|
|
const std::deque<StoredWaypoint> &getWaypoints() const { return waypoints; }
|
|
const StoredWaypoint *findWaypoint(uint32_t id) const;
|
|
|
|
void saveToFlash();
|
|
void loadFromFlash();
|
|
void clearAllWaypoints();
|
|
|
|
static bool isExpired(const meshtastic_Waypoint &wp, uint32_t now = 0);
|
|
static bool isExpired(const StoredWaypoint &entry, uint32_t now = 0);
|
|
static uint8_t notificationPreferencesFromWaypoint(const meshtastic_Waypoint &wp);
|
|
static uint8_t mergeNotificationPreferences(bool locallyAuthored, bool hasExisting, uint8_t existingPreferences,
|
|
const meshtastic_Waypoint &incoming);
|
|
static void clearWireNotificationPreferences(meshtastic_Waypoint &wp);
|
|
|
|
private:
|
|
void addStoredWaypoint(const StoredWaypoint &entry);
|
|
bool removeWaypointById(uint32_t id);
|
|
void notifyChanged();
|
|
|
|
std::deque<StoredWaypoint> waypoints;
|
|
};
|
|
|
|
#if ENABLE_WAYPOINT_PERSISTENCE
|
|
void waypointStoreAutosaveTick();
|
|
#endif
|
|
|
|
extern WaypointStore waypointStore;
|
|
|
|
#endif
|