51 lines
977 B
C++
51 lines
977 B
C++
#pragma once
|
|
|
|
#include <fmt/ostream.h>
|
|
|
|
#include <optional>
|
|
#include <ostream>
|
|
#include <string>
|
|
|
|
constexpr int I2C_SLAVE_ADDR = 0x20;
|
|
constexpr int I2C_POLL_COMMAND = 0x00;
|
|
|
|
enum class AppView { MISSION_SELECT, AMI, DRIVER, TESTING };
|
|
std::ostream& operator<<(std::ostream& os, AppView view);
|
|
enum class Mission {
|
|
NONE,
|
|
ACCELERATION,
|
|
SKIDPAD,
|
|
AUTOCROSS,
|
|
TRACKDRIVE,
|
|
EBS_TEST,
|
|
INSPECTION,
|
|
MANUAL
|
|
};
|
|
std::ostream& operator<<(std::ostream& os, Mission mission);
|
|
|
|
class AppState {
|
|
public:
|
|
AppState(const std::string& i2c_dev_path);
|
|
~AppState();
|
|
|
|
void poll();
|
|
|
|
AppView get_view() const;
|
|
Mission get_mission() const;
|
|
|
|
private:
|
|
void unmarshal_mission_select(uint8_t* data);
|
|
void unmarshal_ami(uint8_t* data);
|
|
|
|
// This is optional so that we can still run the code on a PC without I2C
|
|
std::optional<int> i2c_dev_file;
|
|
|
|
AppView view;
|
|
Mission mission;
|
|
|
|
#ifndef NDEBUG
|
|
friend class KeyboardHandler;
|
|
#endif // !NDEBUG
|
|
};
|
|
|
|
extern AppState app_state; |