Ke Ao Teensy Flight Software
The software on the Teensy in the Ke Ao cubesat.
Loading...
Searching...
No Matches
artemis_devices.h
Go to the documentation of this file.
1
6#ifndef _ARTEMIS_DEVICES_H
7#define _ARTEMIS_DEVICES_H
8
9#include "artemisbeacons.h"
10#include "config/artemis_defs.h"
11#include <Adafruit_GPS.h>
12#include <Adafruit_INA219.h>
13#include <Adafruit_LIS3MDL.h>
14#include <Adafruit_LSM6DSOX.h>
15#include <Adafruit_Sensor.h>
16#include <support/configCosmosKernel.h>
17
18namespace Artemis {
20 namespace Devices {
29 public:
39 struct __attribute__((packed)) magbeacon {
46 BeaconType type = BeaconType::MagnetometerBeacon;
53 uint32_t deci = 0;
55 float magx = 0;
57 float magy = 0;
59 float magz = 0;
60 };
71 Adafruit_LIS3MDL *magnetometer = new Adafruit_LIS3MDL();
72
73 int32_t setup(void);
74 int32_t read(uint32_t uptime);
75
76 private:
77 bool magnetometerSetup;
78 };
79
87 class IMU {
88 public:
100 struct __attribute__((packed)) imubeacon {
106 BeaconType type = BeaconType::IMUBeacon;
112 uint32_t deci = 0;
114 float accelx = 0;
116 float accely = 0;
118 float accelz = 0;
120 float gyrox = 0;
122 float gyroy = 0;
124 float gyroz = 0;
126 float imutemp = 0;
127 };
142 Adafruit_LSM6DSOX *imu = new Adafruit_LSM6DSOX();
143
144 int32_t setup(void);
145 int32_t read(uint32_t uptime);
146
147 private:
148 bool imuSetup;
149 };
150
157 class GPS {
158 public:
170 struct __attribute__((packed)) gpsbeacon {
176 BeaconType type = BeaconType::GPSBeacon;
182 uint32_t deci = 0;
184 float latitude = 0;
186 float longitude = 0;
188 float speed = 0;
190 float angle = 0;
192 float altitude = 0;
194 uint8_t satellites = 0;
196 bool fix = false;
198 uint8_t fixquality = 0;
200 uint8_t year = 0;
202 uint8_t month = 0;
204 uint8_t day = 0;
206 uint8_t hour = 0;
208 uint8_t minute = 0;
210 uint8_t second = 0;
212 uint16_t millisecond = 0;
213 };
232 Adafruit_GPS *gps = new Adafruit_GPS(&Serial7);
233
234 int32_t setup(void);
235 int32_t update(void);
236 int32_t read(uint32_t uptime);
237
238 private:
239 bool gpsSetup;
240 };
241
244 public:
254 struct __attribute__((packed)) currentbeacon1 {
260 BeaconType type = BeaconType::CurrentBeacon1;
267 uint32_t deci = 0;
286 };
307 struct __attribute__((packed)) currentbeacon2 {
313 BeaconType type = BeaconType::CurrentBeacon2;
320 uint32_t deci = 0;
343 };
370 std::map<std::string, Adafruit_INA219 *> current_sensors = {
371 {"solar_panel_1", new Adafruit_INA219(0x40)},
372 {"solar_panel_2", new Adafruit_INA219(0x41)},
373 {"solar_panel_3", new Adafruit_INA219(0x42)},
374 {"solar_panel_4", new Adafruit_INA219(0x43)},
375 {"battery_board", new Adafruit_INA219(0x44)},
376 };
377
378 int32_t setup(void);
379 int32_t read(uint32_t uptime);
380
381 private:
382 bool currentSetup;
383 };
384
387 public:
398 struct __attribute__((packed)) temperaturebeacon {
404 BeaconType type = BeaconType::TemperatureBeacon;
411 uint32_t deci = 0;
419 float tmp36_temperatureC[ARTEMIS_TEMP_SENSOR_COUNT];
421 float teensy_temperatureC = 0;
422 };
450 std::map<std::string, int> temp_sensors = {
451 { "obc", A0},
452 { "pdu", A1},
453 {"battery_board", A6},
454 {"solar_panel_1", A7},
455 {"solar_panel_2", A8},
456 {"solar_panel_3", A9},
457 {"solar_panel_4", A17},
458 };
459
460 int32_t setup(void);
461 int32_t read(uint32_t uptime);
462
463 private:
464 bool temperatureSetup;
465 };
466
468 class Switches {
469 public:
479 struct __attribute__((packed)) switchbeacon {
484 BeaconType type = BeaconType::SwitchBeacon;
490 uint32_t deci = 0;
496 uint8_t switches[13];
497 };
498 };
499 } // namespace Devices
500} // namespace Artemis
501
502#endif //_ARTEMIS_DEVICES_H
The Artemis definitions header file.
#define ARTEMIS_CURRENT_SENSOR_COUNT
The number of current sensors in the satellite.
Definition artemis_defs.h:18
#define ARTEMIS_TEMP_SENSOR_COUNT
The number of temperature sensors in the satellite.
Definition artemis_defs.h:20
#define ARTEMIS_CURRENT_BEACON_1_COUNT
The number of readings that can fit in the first beacon.
Definition artemis_defs.h:16
Definitions of Artemis Beacons.
The current sensors on the satellite.
Definition artemis_devices.h:243
int32_t read(uint32_t uptime)
Reads current sensors and generates two packets on both RFM23 and Astrodev queues.
Definition artemis_devices.cpp:294
std::map< std::string, Adafruit_INA219 * > current_sensors
Mapping between current sensor string names and current sensor objects.
Definition artemis_devices.h:370
int32_t setup(void)
Sets up I2C connection to current sensors.
Definition artemis_devices.cpp:271
The satellite's Global Positioning System (GPS).
Definition artemis_devices.h:157
int32_t read(uint32_t uptime)
Reads GPS sensor and generates a packet on both RFM23 and Astrodev queues.
Definition artemis_devices.cpp:598
int32_t update(void)
Called to update the GPS.
Definition artemis_devices.cpp:554
int32_t setup(void)
Sets up serial connection to GPS sensor.
Definition artemis_devices.cpp:471
The satellite's Inertial Measurement Unit (IMU).
Definition artemis_devices.h:87
int32_t read(uint32_t uptime)
Reads IMU and generates a packet on both RFM23 and Astrodev queues.
Definition artemis_devices.cpp:206
int32_t setup(void)
Sets up I2C connection to IMU.
Definition artemis_devices.cpp:144
The satellite's magnetometer.
Definition artemis_devices.h:28
int32_t setup(void)
Sets up I2C connection to magnetometer.
Definition artemis_devices.cpp:15
int32_t read(uint32_t uptime)
Reads magnetometer and generates a packet on both RFM23 and Astrodev queues.
Definition artemis_devices.cpp:85
The switches on the PDU of the satellite.
Definition artemis_devices.h:468
The temperature sensors on the satellite.
Definition artemis_devices.h:386
int32_t setup(void)
Sets up analog connection to temperature sensors.
Definition artemis_devices.cpp:389
std::map< std::string, int > temp_sensors
Mapping between temperature sensor string names and their analog pins.
Definition artemis_devices.h:450
int32_t read(uint32_t uptime)
Reads temperature sensors and generates a packet on both RFM23 and Astrodev queues.
Definition artemis_devices.cpp:409
BeaconType
Enumeration of beacon type.
Definition artemisbeacons.h:30
The first current beacon structure.
Definition artemis_devices.h:254
The second current beacon structure.
Definition artemis_devices.h:307
The GPS beacon structure.
Definition artemis_devices.h:170
The IMU beacon structure.
Definition artemis_devices.h:100
The magnetometer beacon structure.
Definition artemis_devices.h:39
The switches beacon structure.
Definition artemis_devices.h:479
The temperature beacon structure.
Definition artemis_devices.h:398