codex init
This commit is contained in:
68
OpticalChannelTester/App.h
Normal file
68
OpticalChannelTester/App.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
#include "Buttons.h"
|
||||
#include "Display.h"
|
||||
#include "Measurement.h"
|
||||
#include "Pwm.h"
|
||||
#include "Radio.h"
|
||||
#include "SettingsStore.h"
|
||||
|
||||
enum class AppState : uint8_t {
|
||||
IDLE, MENU, SOLO_MEASURE, MASTER_DISCOVER, MASTER_WAIT_READY,
|
||||
MASTER_WAIT_RESULT, SLAVE_READY, SLAVE_WAIT_START, SLAVE_MEASURE,
|
||||
SLAVE_WAIT_ACK, FINISHED
|
||||
};
|
||||
|
||||
class App {
|
||||
public:
|
||||
App();
|
||||
void begin();
|
||||
void update();
|
||||
private:
|
||||
void showIdle();
|
||||
void finishInitialization(bool factoryReset);
|
||||
void showMenu();
|
||||
void changeMenu(int direction);
|
||||
void sanitizeRange();
|
||||
void startTest();
|
||||
bool prepareStage();
|
||||
bool startLocalMeasurement(float hz, float duty);
|
||||
void startMasterDiscovery();
|
||||
void handleRadio();
|
||||
void updateMaster();
|
||||
void updateSlave();
|
||||
void stagePassed();
|
||||
void finish(bool pass, FailReason reason);
|
||||
void abortTest();
|
||||
void sendAbort();
|
||||
void printConfiguration();
|
||||
void printStageStats(const StageStats &s, uint32_t hz);
|
||||
uint64_t actualNominalTotalUs();
|
||||
ProtocolPacket makePacket(MessageType type) const;
|
||||
void sendCurrent(MessageType type);
|
||||
bool packetForCurrent(const ProtocolPacket &p) const;
|
||||
|
||||
Button startButton_, modeButton_;
|
||||
Display display_;
|
||||
SettingsStore store_;
|
||||
Settings settings_ = {};
|
||||
TestParams params_ = {};
|
||||
PwmGenerator pwm_;
|
||||
PulseReceiver receiver_;
|
||||
Measurement measurement_;
|
||||
Radio radio_;
|
||||
AppState state_ = AppState::IDLE;
|
||||
uint8_t menuItem_ = 0;
|
||||
uint32_t stageIndex_ = 0, stageCount_ = 0;
|
||||
uint32_t requestedHz_ = 0;
|
||||
ActualPwm actual_ = {};
|
||||
FailReason pendingReason_ = FailReason::NONE;
|
||||
uint32_t session_ = 0;
|
||||
uint16_t sequence_ = 0;
|
||||
uint8_t peer_[6] = {};
|
||||
bool havePeer_ = false;
|
||||
uint32_t deadlineMs_ = 0, lastSendMs_ = 0;
|
||||
uint8_t retries_ = 0;
|
||||
ProtocolPacket pendingPacket_ = {};
|
||||
bool initialized_ = false, bootResetCandidate_ = false;
|
||||
uint32_t bootCheckStartedMs_ = 0;
|
||||
};
|
||||
Reference in New Issue
Block a user