Artemis Teensy Flight Software
The software on the Teensy in the Artemis cubesat.
artemis_devices.h
Go to the documentation of this file.
1 
8 #ifndef _ARTEMIS_DEVICES_H
9 #define _ARTEMIS_DEVICES_H
10 
11 #include "artemisbeacons.h"
12 #include "config/artemis_defs.h"
13 #include "helpers.h"
14 #include "pdu.h"
15 #include <Adafruit_GPS.h>
16 #include <Adafruit_INA219.h>
17 #include <Adafruit_LIS3MDL.h>
18 #include <Adafruit_LSM6DSOX.h>
19 #include <Adafruit_Sensor.h>
20 #include <InternalTemperature.h>
21 #include <SD.h>
23 
24 namespace Artemis {
26 namespace Devices {
28  class Magnetometer {
29  public:
31  struct __attribute__((packed)) magbeacon {
33  BeaconType type = BeaconType::MagnetometerBeacon;
35  uint32_t deci = 0;
37  float magx = 0;
39  float magy = 0;
41  float magz = 0;
42  };
60  Adafruit_LIS3MDL *magnetometer = new Adafruit_LIS3MDL();
61 
62  bool setup(void);
63  bool read(uint32_t uptime);
64 
65  private:
67  bool magnetometerSetup;
68  };
69 
71  class IMU {
72  public:
74  struct __attribute__((packed)) imubeacon {
76  BeaconType type = BeaconType::IMUBeacon;
78  uint32_t deci = 0;
80  float accelx = 0;
82  float accely = 0;
84  float accelz = 0;
86  float gyrox = 0;
88  float gyroy = 0;
90  float gyroz = 0;
92  float imutemp = 0;
93  };
115  Adafruit_LSM6DSOX *imu = new Adafruit_LSM6DSOX();
116 
117  bool setup(void);
118  bool read(uint32_t uptime);
119 
120  private:
122  bool imuSetup;
123  };
124 
127  public:
129  struct __attribute__((packed)) currentbeacon1 {
131  BeaconType type = BeaconType::CurrentBeacon1;
133  uint32_t deci = 0;
138  };
151  struct __attribute__((packed)) currentbeacon2 {
153  BeaconType type = BeaconType::CurrentBeacon2;
155  uint32_t deci = 0;
157  float busvoltage[ARTEMIS_CURRENT_SENSOR_COUNT -
162  };
182  std::map<std::string, Adafruit_INA219 *> current_sensors = {
183  {"solar_panel_1", new Adafruit_INA219(0x40)},
184  {"solar_panel_2", new Adafruit_INA219(0x41)},
185  {"solar_panel_3", new Adafruit_INA219(0x42)},
186  {"solar_panel_4", new Adafruit_INA219(0x43)},
187  {"battery_board", new Adafruit_INA219(0x44)},
188  };
189 
190  bool setup(void);
191  void read(uint32_t uptime);
192 
193  private:
199  bool currentSetup;
200  };
201 
204  public:
206  struct __attribute__((packed)) temperaturebeacon {
208  BeaconType type = BeaconType::TemperatureBeacon;
210  uint32_t deci = 0;
212  float tmp36_tempC[ARTEMIS_TEMP_SENSOR_COUNT];
215  };
228  std::map<std::string, int> temp_sensors = {
229  { "obc", A0},
230  { "pdu", A1},
231  {"battery_board", A6},
232  {"solar_panel_1", A7},
233  {"solar_panel_2", A8},
234  {"solar_panel_3", A9},
235  {"solar_panel_4", A17},
236  };
237 
238  void setup(void);
239  void read(uint32_t uptime);
240  };
241 
243  class GPS {
244  public:
246  struct __attribute__((packed)) gpsbeacon {
248  BeaconType type = BeaconType::GPSBeacon;
250  uint32_t deci = 0;
252  float latitude = 0;
254  float longitude = 0;
256  float speed = 0;
258  float angle = 0;
260  float altitude = 0;
262  uint8_t satellites = 0;
263  };
280  Adafruit_GPS *gps = new Adafruit_GPS(&Serial7);
281 
282  bool setup(void);
283  void update(void);
284  void read(uint32_t uptime);
285 
286  private:
288  bool gpsSetup;
289  };
290 
292  class Switches {
293  public:
297  struct __attribute__((packed)) switchbeacon {
299  BeaconType type = BeaconType::SwitchBeacon;
301  uint32_t deci = 0;
303  uint8_t sw[NUMBER_OF_SWITCHES + 1];
304  };
315  };
316 } // namespace Devices
317 } // namespace Artemis
318 
319 #endif //_ARTEMIS_DEVICES_H
The Artemis definitions.
#define ARTEMIS_CURRENT_SENSOR_COUNT
The number of current sensors in the satellite.
Definition: artemis_defs.h:17
#define ARTEMIS_TEMP_SENSOR_COUNT
The number of temperature sensors in the satellite.
Definition: artemis_defs.h:20
#define ARTEMIS_CURRENT_BEACON_1_COUNT
Definition: artemis_defs.h:15
Definition of Artemis beacon types.
The current sensors on the satellite.
Definition: artemis_devices.h:126
std::map< std::string, Adafruit_INA219 * > current_sensors
Instantiation and mapping of core sensor objects.
Definition: artemis_devices.h:182
bool setup(void)
Sets up the satellite's current sensors.
Definition: current_sensors.cpp:25
void read(uint32_t uptime)
Reads the satellite's current sensors.
Definition: current_sensors.cpp:46
The satellite's Global Positioning System (GPS).
Definition: artemis_devices.h:243
void read(uint32_t uptime)
Reads the satellite's GPS data.
Definition: gps.cpp:65
void update(void)
Update the satellite's GPS.
Definition: gps.cpp:38
bool setup(void)
Sets up the satellite's GPS.
Definition: gps.cpp:21
Adafruit_GPS * gps
The core sensor object.
Definition: artemis_devices.h:280
The satellite's Inertial Measurement Unit (IMU).
Definition: artemis_devices.h:71
Adafruit_LSM6DSOX * imu
The core sensor object.
Definition: artemis_devices.h:115
bool setup(void)
Sets up the satellite's IMU.
Definition: imu.cpp:21
bool read(uint32_t uptime)
Reads the satellite's IMU.
Definition: imu.cpp:43
The satellite's magnetometer.
Definition: artemis_devices.h:28
Adafruit_LIS3MDL * magnetometer
The core sensor object.
Definition: artemis_devices.h:60
bool setup(void)
Sets up the satellite's magnetometer.
Definition: magnetometer.cpp:21
bool read(uint32_t uptime)
Reads the satellite's magnetometer.
Definition: magnetometer.cpp:43
The switches on the PDU of the satellite.
Definition: artemis_devices.h:292
The temperature sensors on the satellite.
Definition: artemis_devices.h:203
void read(uint32_t uptime)
Reads the satellite's temperature sensors.
Definition: temperature_sensors.cpp:38
std::map< std::string, int > temp_sensors
Mapping of temperature sensor names and analog pins.
Definition: artemis_devices.h:228
void setup(void)
Sets up the satellite's temperature sensors.
Definition: temperature_sensors.cpp:18
Headers and definitions common to all COSMOS Kernel.
The header file for helper functions.
elapsedMillis uptime
The time in milliseconds since the channel was started.
Definition: pdu_channel.cpp:25
BeaconType
Enumeration of beacon types.
Definition: artemisbeacons.h:16
The header file for the PDU class.
#define NUMBER_OF_SWITCHES
The number of switches on the PDU.
Definition: pdu.h:19
The first current beacon structure.
Definition: artemis_devices.h:129
The second current beacon structure.
Definition: artemis_devices.h:151
The GPS beacon structure.
Definition: artemis_devices.h:246
The structure of an IMU beacon.
Definition: artemis_devices.h:74
The structure of a magnetometer beacon.
Definition: artemis_devices.h:31
The PDU switches beacon structure.
Definition: artemis_devices.h:297
The temperature beacon structure.
Definition: artemis_devices.h:206
float teensy_tempC
The temperature of the Teensy's processor.
Definition: artemis_devices.h:214