Skip to content

Commit

Permalink
Merge pull request #7 from hytech-racing/ThermistorCAN
Browse files Browse the repository at this point in the history
Added thermistors
  • Loading branch information
BANANAPEEL202 authored Dec 28, 2023
2 parents 4fc4668 + c22979f commit 2459416
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Libraries/HyTech_CAN/MCU_thermistors.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#include <string.h>
#include <stdint.h>

#pragma pack(push,1)

// @Parseclass
class MCU_thermistors {
public:
MCU_thermistors() = default;
MCU_thermistors(const uint8_t buf[8]) { load(buf); }

inline void load(const uint8_t buf[]) { memcpy(this, buf, sizeof(*this)); }
inline void write(uint8_t buf[]) const { memcpy(buf, this, sizeof(*this)); }

// Getters
inline uint16_t get_thermistor1() const { return thermistor1; }
inline uint16_t get_thermistor2() const { return thermistor2; }

// Setters
inline void set_thermistor1(const uint16_t value) { this->thermistor1 = value; }
inline void set_thermistor2(const uint16_t value) { this->thermistor2 = value; }

private:
uint16_t thermistor1; //front left thermistor
uint16_t thermistor2; //front right thermistor
};

#pragma pack(pop)
37 changes: 37 additions & 0 deletions Libraries/HyTech_CAN/SAB_thermistors_1.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#pragma once

#include <string.h>
#include <stdint.h>

#pragma pack(push,1)

// @Parseclass
class SAB_thermistors_1 {
public:
SAB_thermistors_1() = default;
SAB_thermistors_1(const uint8_t buf[8]) { load(buf); }

inline void load(const uint8_t buf[]) { memcpy(this, buf, sizeof(*this)); }
inline void write(uint8_t buf[]) const { memcpy(buf, this, sizeof(*this)); }

// Getters
inline uint16_t get_thermistor3() const { return thermistor3; }
inline uint16_t get_thermistor4() const { return thermistor4; }
inline uint16_t get_thermistor5() const { return thermistor5; }
inline uint16_t get_thermistor6() const { return thermistor6; }

// Setters
inline void set_thermistor3(const uint16_t value) { this->thermistor3 = value; }
inline void set_thermistor4(const uint16_t value) { this->thermistor4 = value; }
inline void set_thermistor5(const uint16_t value) { this->thermistor5 = value; }
inline void set_thermistor6(const uint16_t value) { this->thermistor6 = value; }

private:
//no free bytes
uint16_t thermistor3; //center front left thermistor
uint16_t thermistor4; //center front right thermistor
uint16_t thermistor5; //center rear left thermistor
uint16_t thermistor6; //center rear right thermistor
};

#pragma pack(pop)
34 changes: 34 additions & 0 deletions Libraries/HyTech_CAN/SAB_thermistors_2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once

#include <string.h>
#include <stdint.h>

#pragma pack(push,1)

// @Parseclass
class SAB_thermistors_2 {
public:
SAB_thermistors_2() = default;
SAB_thermistors_2(const uint8_t buf[8]) { load(buf); }

inline void load(const uint8_t buf[]) { memcpy(this, buf, sizeof(*this)); }
inline void write(uint8_t buf[]) const { memcpy(buf, this, sizeof(*this)); }

// Getters
inline uint16_t get_thermistor7() const { return thermistor7; }
inline uint16_t get_thermistor8() const { return thermistor8; }
inline uint16_t get_thermistor9() const { return thermistor9; }

// Setters
inline void set_thermistor7(const uint16_t value) { this->thermistor7 = value; }
inline void set_thermistor8(const uint16_t value) { this->thermistor8 = value; }
inline void set_thermistor9(const uint16_t value) { this->thermistor9 = value; }

private:
//no free bytes
uint16_t thermistor7; //rear forward thermistor (on left side)
uint16_t thermistor8; //rear left thermistor
uint16_t thermistor9; //rear right thermistor
};

#pragma pack(pop)

0 comments on commit 2459416

Please sign in to comment.