saved work
This commit is contained in:
@@ -1,38 +0,0 @@
|
|||||||
/**** 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 ****/
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
#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_ */
|
|
||||||
40
firmware/src/hw/cv_driver.cpp
Normal file
40
firmware/src/hw/cv_driver.cpp
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/**** Includes ****/
|
||||||
|
#include "../utils/utils.h"
|
||||||
|
#include "cv_driver.h"
|
||||||
|
|
||||||
|
using namespace hw;
|
||||||
|
|
||||||
|
/**** Private definitions ****/
|
||||||
|
/**** Private constants ****/
|
||||||
|
/**** Private variables ****/
|
||||||
|
/**** Private function declarations ****/
|
||||||
|
|
||||||
|
/**** Public function definitions ****/
|
||||||
|
hw::CVdriver::CVdriver(board::AnalogIn* sup_voltage, board::AnalogIn* out_voltage, board::Hafbridge* hbridge)
|
||||||
|
{
|
||||||
|
this->sup_voltage = sup_voltage;
|
||||||
|
this->hbridge = hbridge;
|
||||||
|
this->target = 0;
|
||||||
|
this->off = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
hw::CVdriver::~CVdriver(void)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void hw::CVdriver::update(void)
|
||||||
|
{
|
||||||
|
// Update all inputs
|
||||||
|
this->sup_voltage->read();
|
||||||
|
|
||||||
|
// Calculate ratio
|
||||||
|
uint16_t ratio = util::sat_ratio(this->target, this->sup_voltage->last_read);
|
||||||
|
|
||||||
|
// Set output
|
||||||
|
this->hbridge->write(ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**** Private function definitions ****/
|
||||||
37
firmware/src/hw/cv_driver.h
Normal file
37
firmware/src/hw/cv_driver.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#ifndef CONST_VOLTAGE_DRIVER_H_
|
||||||
|
#define CONST_VOLTAGE_DRIVER_H_
|
||||||
|
|
||||||
|
/**** Includes ****/
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "../board/ain.h"
|
||||||
|
#include "../board/halfbridge.h"
|
||||||
|
|
||||||
|
namespace hw {
|
||||||
|
|
||||||
|
/**** Public definitions ****/
|
||||||
|
|
||||||
|
class CVdriver
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
board::AnalogIn* sup_voltage;
|
||||||
|
|
||||||
|
board::Hafbridge* hbridge;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CVdriver(board::AnalogIn* sup_voltage, board::Hafbridge* hbridge);
|
||||||
|
~CVdriver(void);
|
||||||
|
|
||||||
|
uint16_t target = 0;
|
||||||
|
uint8_t off = 0;
|
||||||
|
|
||||||
|
void process(void);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**** Public function declarations ****/
|
||||||
|
|
||||||
|
#ifdef TESTING
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} //namespace
|
||||||
|
|
||||||
|
#endif /* CONST_VOLTAGE_DRIVER_H_ */
|
||||||
@@ -204,10 +204,10 @@
|
|||||||
<Compile Include="hw\button.h">
|
<Compile Include="hw\button.h">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="hw\cc_driver.cpp">
|
<Compile Include="hw\cv_driver.cpp">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="hw\cc_driver.h">
|
<Compile Include="hw\cv_driver.h">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="hw\display_led.cpp">
|
<Compile Include="hw\display_led.cpp">
|
||||||
|
|||||||
Reference in New Issue
Block a user