feat-hal-2 #4

Merged
andis merged 35 commits from feat-hal-2 into develop 2024-07-31 16:15:36 +00:00
2 changed files with 71 additions and 0 deletions
Showing only changes of commit 8f7e5036e7 - Show all commits

View File

@@ -0,0 +1,38 @@
/**** Includes ****/
#include "../utils/utils.h"
#include "../utils/interpolate.h"
#include "potentiometer.h"
using namespace hw;
/**** Private definitions ****/
/**** Private constants ****/
/**** Private variables ****/
/**** Private function declarations ****/
/**** Public function definitions ****/
hw::Potentiometer::Potentiometer(board::AnalogIn* ain_ch, uint16_t low_deadzone, uint16_t high_deadzone)
{
this->ain_ch = ain_ch;
this->low_deadzone = low_deadzone;
this->high_deadzone = high_deadzone;
this->percent = 0;
}
hw::Potentiometer::~Potentiometer(void)
{
return;
}
uint8_t hw::Potentiometer::read(void)
{
// Update input
this->ain_ch->read();
// Calculate percent
this->percent = util::interpolate(this->ain_ch->last_read, this->low_deadzone, this->high_deadzone, 0, 100);
return this->percent;
}
/**** Private function definitions ****/

View File

@@ -0,0 +1,33 @@
#ifndef CONST_CURRENT_DRIVER_H_
#define CONST_CURRENT_DRIVER_H_
/**** Includes ****/
#include <stdint.h>
#include "../board/ain.h"
#include "../board/halfbridge.h"
namespace hw {
/**** Public definitions ****/
class CCdriver
{
protected:
board::AnalogIn* sup_voltage;
board::AnalogIn* sup_current;
board::AnalogIn* ain_ch;
board::AnalogIn* ain_ch;
public:
CCdriver(board::AnalogIn* ain_ch);
~CCdriver(void);
};
/**** Public function declarations ****/
#ifdef TESTING
#endif
} //namespace
#endif /* CONST_CURRENT_DRIVER_H_ */