Public Access
GNSS App: a Compass, with Places to be led back to and a level
Tab goes on from the Sky to a third view (issue #16): a rose that turns with the device, the heading, where north came from and how long ago, the sun on the rose, and a level. m marks where you stand as a Place, t picks one as the target: an arrowhead on the rose, its distance and bearing. The sensor's directions were checked by hand on the device. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0162FokPdvY2KsS4NBfwyWPk
This commit is contained in:
+45
-6
@@ -1,35 +1,74 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "app.h"
|
||||
#include "compass.h"
|
||||
#include "dialog_model.h"
|
||||
#include "line_editor.h"
|
||||
#include "list_model.h"
|
||||
#include "places.h"
|
||||
#include "services/gnss_service.h"
|
||||
#include "services/storage_service.h"
|
||||
#include "settings.h"
|
||||
|
||||
namespace roro {
|
||||
|
||||
// GNSS (see docs/milestones/M2.md, Q59): the Position view, and the Sky view with every satellite
|
||||
// in view placed by direction and elevation. Tab switches between them.
|
||||
// GNSS (see docs/milestones/M2.md, Q59): the Position view, the Sky view with every satellite in
|
||||
// view placed by direction and elevation, and the Compass (issue #16, docs/milestones/H1.md): a
|
||||
// rose that turns with the device, and the way to a Place the user marked. Tab goes round them.
|
||||
class GnssApp : public App {
|
||||
public:
|
||||
GnssApp(GnssService& gnss, const Settings& settings) : gnss_(gnss), settings_(settings) {}
|
||||
void onEnter() override { requestRedraw(); }
|
||||
GnssApp(GnssService& gnss, const Settings& settings, StorageService& storage)
|
||||
: gnss_(gnss), settings_(settings), storage_(storage) {}
|
||||
void onEnter() override;
|
||||
bool onKey(const KeyEvent& e) override;
|
||||
bool textEntryActive() const override { return mode_ == Mode::Name; }
|
||||
void update(uint32_t nowMs) override;
|
||||
void draw(Canvas& c) override;
|
||||
void help(std::vector<KeyHelp>& out) const override;
|
||||
const char* helpTitle() const override;
|
||||
bool badge() const override { return gnss_.tracking(); }
|
||||
|
||||
private:
|
||||
enum class View { Position, Sky, Compass };
|
||||
// Over the Compass: the list of Places, and the name of a new one.
|
||||
enum class Mode { View, Places, Name };
|
||||
|
||||
void drawPosition(Canvas& c);
|
||||
void drawSky(Canvas& c);
|
||||
void drawCompass(Canvas& c);
|
||||
void drawPlaces(Canvas& c);
|
||||
bool compassKey(const KeyEvent& e);
|
||||
bool placesKey(const KeyEvent& e);
|
||||
void readImu();
|
||||
void loadPlaces();
|
||||
void savePlaces();
|
||||
void mark();
|
||||
void aimAtSun();
|
||||
void say(const std::string& text);
|
||||
|
||||
GnssService& gnss_;
|
||||
const Settings& settings_;
|
||||
bool sky_ = false;
|
||||
StorageService& storage_;
|
||||
View view_ = View::Position;
|
||||
Mode mode_ = Mode::View;
|
||||
uint32_t lastDrawMs_ = 0;
|
||||
std::string refusal_; // why a Track couldn't start, shown for a few seconds
|
||||
std::string refusal_; // why something couldn't be done, or that it was: shown for a few seconds
|
||||
uint32_t refusalMs_ = 0;
|
||||
|
||||
gnss::HeadingFilter heading_;
|
||||
uint32_t imuUs_ = 0, imuMs_ = 0;
|
||||
int courseSecond_ = -1; // the Fix whose course was last given to the filter
|
||||
float shownHeading_ = -1, shownTiltX_ = 0, shownTiltY_ = 0;
|
||||
std::vector<gnss::Place> places_;
|
||||
bool placesLoaded_ = false;
|
||||
int target_ = -1; // in places_; -1: none
|
||||
ListModel list_{6};
|
||||
LineEditor name_{gnss::kPlaceNameBytes};
|
||||
std::unique_ptr<DialogModel> dialog_;
|
||||
};
|
||||
|
||||
} // namespace roro
|
||||
|
||||
Reference in New Issue
Block a user