Skip to content

Commit

Permalink
v2.7.0
Browse files Browse the repository at this point in the history
v2.7.0
  • Loading branch information
StefanCostea authored Jun 17, 2023
2 parents 5030467 + fbaef3a commit 7e06aa1
Show file tree
Hide file tree
Showing 25 changed files with 615 additions and 67 deletions.
6 changes: 6 additions & 0 deletions Inc/HALAL/Models/Concepts/Concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,9 @@ struct total_sizeof<>{
public:
static constexpr size_t value = 0;
};

template<class Type>
concept Array = std::is_array<Type>::value;

template<class Type>
concept NotArray = not Array<Type>;
7 changes: 3 additions & 4 deletions Inc/HALAL/Models/Packets/PacketValue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class PacketValue<string> : public PacketValue<>{
}
};

template<class Type,size_t N>
template<class Type,size_t N>
class PacketValue<Type(&)[N]>: public PacketValue<> {
public:
using value_type = Type;
Expand All @@ -140,12 +140,11 @@ class PacketValue<Type(&)[N]>: public PacketValue<> {
};

#if __cpp_deduction_guides >= 201606
template<class Type,size_t N>
template<class Type,size_t N>
PacketValue(Type(*)[N])->PacketValue<Type(&)[N]>;
#endif


template<class Type,size_t N>
template<class Type,size_t N>
class PacketValue<Type*(&)[N]>: public PacketValue<> {
public:
using value_type = Type*;
Expand Down
5 changes: 3 additions & 2 deletions Inc/HALAL/Models/TimerPeripheral/TimerPeripheral.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,17 @@ class TimerPeripheral {
struct InitData {
private:
InitData() = default;

public:
uint32_t prescaler;
uint32_t period;
uint32_t deadtime;
uint32_t polarity;
uint32_t negated_polarity;
TIM_TYPE type;
vector<PWMData> pwm_channels = {};
vector<pair<uint32_t, uint32_t>> input_capture_channels = {};
InitData(TIM_TYPE type, uint32_t prescaler = 5,
uint32_t period = 55000, uint32_t deadtime = 0);
uint32_t period = 55000, uint32_t deadtime = 0, uint32_t polarity = TIM_OCPOLARITY_HIGH, uint32_t negated_polarity = TIM_OCPOLARITY_HIGH);
};

TIM_HandleTypeDef* handle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class ServerSocket : public OrderProtocol{

void send();

bool is_connected();

private:

static err_t accept_callback(void* arg, struct tcp_pcb* incomming_control_block, err_t error);
Expand Down
2 changes: 2 additions & 0 deletions Inc/HALAL/Services/Communication/Ethernet/TCP/Socket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class Socket : public OrderProtocol{

void process_data();

bool is_connected();

static err_t connect_callback(void* arg, struct tcp_pcb* client_control_block, err_t error);
static err_t receive_callback(void* arg, struct tcp_pcb* client_control_block, struct pbuf* packet_buffer, err_t error);
static err_t poll_callback(void* arg, struct tcp_pcb* client_control_block);
Expand Down
4 changes: 4 additions & 0 deletions Inc/HALAL/Services/PWM/DualPWM/DualPWM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ class DualPWM : virtual public PWM {
DualPWM(Pin& pin, Pin& pin_negated);

void turn_on();
void turn_on_positive();
void turn_on_negated();
void turn_off();
void turn_off_positive();
void turn_off_negated();

friend class DualPhasedPWM;
};
2 changes: 1 addition & 1 deletion Inc/ST-LIB_HIGH/Control/Blocks/Derivator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class SimpleDerivator : public ControlBlock<double,double>{
double buffer[N] = {0.0};
int index = 0;
public:
SimpleDerivator(double period): ControlBlock<double,double>(0.0), period(period){}
SimpleDerivator(double period): ControlBlock<double,double>(0.0), period(period){ output_value = 0.0;}
void execute()override{
buffer[index] = input_value;
output_value = (buffer[index] - buffer[((index-1)%(N) + (N))%(N)])/period;
Expand Down
4 changes: 2 additions & 2 deletions Inc/ST-LIB_HIGH/Control/Blocks/Integrator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Integrator<IntegratorType::Trapezoidal> : public ControlBlock<double,doubl
double ki;
bool first_execution = true;
public:
Integrator(double period, double ki):ControlBlock<double,double>(0.0), period(period), ki(ki){}
Integrator(double period, double ki):ControlBlock<double,double>(0.0), period(period), ki(ki){output_value = 0.0;}
void execute() override {
buffer[index] = input_value;
if(first_execution){
Expand Down Expand Up @@ -98,7 +98,7 @@ class Integrator<IntegratorType::BackwardEuler>: public ControlBlock<double,doub
double ki;
bool first_execution = true;
public:
Integrator(double period, double ki):ControlBlock<double,double>(0.0), period(period), ki(ki) {}
Integrator(double period, double ki):ControlBlock<double,double>(0.0), period(period), ki(ki) {output_value = 0.0;}
void execute() override {
buffer[index] = input_value;
if(first_execution){
Expand Down
2 changes: 0 additions & 2 deletions Inc/ST-LIB_HIGH/Control/Blocks/MovingAverage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include "stdio.h"
#include "../ControlSystem.hpp"

double computeMA(double input_value);

template<size_t N>
class MovingAverage : public ControlBlock<double,double> {
private:
Expand Down
2 changes: 1 addition & 1 deletion Inc/ST-LIB_HIGH/Protections/ProtectionManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ProtectionManager {
static constexpr uint16_t fault_id = 2;
static char* message;
static size_t message_size;
static constexpr const char* format = "{\"boardId\": %s, \"timestamp\":{%s}, %s}";
static constexpr const char* format = "{\"boardId\": %s, \"timestamp\":{%s}, %s}\0";

static Boards::ID board_id;
static vector<Protection> low_frequency_protections;
Expand Down
5 changes: 3 additions & 2 deletions Inc/ST-LIB_LOW/HalfBridge/HalfBridge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ class HalfBridge {
void set_phase(float phase);
float get_phase();

DualPhasedPWM positive_pwm;
DualPhasedPWM negative_pwm;
private:
bool is_dual;

DualPhasedPWM positive_pwm;
DualPhasedPWM negative_pwm;

uint8_t enable;
};
1 change: 1 addition & 0 deletions Inc/ST-LIB_LOW/ST-LIB_LOW.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "Sensors/LinearSensor/LinearSensor.hpp"
#include "Sensors/LookupSensor/LookupSensor.hpp"
#include "Sensors/EncoderSensor/EncoderSensor.hpp"
#include "Sensors/NTC/NTC.hpp"

class STLIB_LOW {
public:
Expand Down
20 changes: 11 additions & 9 deletions Inc/ST-LIB_LOW/Sensors/Common/PT100.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@
#include "Control/ControlBlock.hpp"
#include "Control/Blocks/MovingAverage.hpp"


template<size_t N>
class PT100{
public:
static constexpr float k = 841.836735;
static constexpr float offset = -492.204082;
MovingAverage<N>* filter = nullptr;

ControlBlock<float,float>* filter = nullptr;

template<size_t N>
PT100(Pin& pin, float* value, MovingAverage<N>& filter);
PT100(Pin& pin, float* value);

template<size_t N>
PT100(Pin& pin, float& value, MovingAverage<N>& filter);
PT100(Pin& pin, float& value);

Expand All @@ -27,28 +26,31 @@ class PT100{
};

template<size_t N>
PT100::PT100(Pin& pin, float* value, MovingAverage<N>& filter) : value(value), filter(&filter){
PT100<N>::PT100(Pin& pin, float* value, MovingAverage<N>& filter) : value(value), filter(&filter){
id = ADC::inscribe(pin);
Sensor::adc_id_list.push_back(id);
}

template<size_t N>
PT100::PT100(Pin& pin, float& value, MovingAverage<N>& filter) : value(&value), filter(&filter){
PT100<N>::PT100(Pin& pin, float& value, MovingAverage<N>& filter) : value(&value), filter(&filter){
id = ADC::inscribe(pin);
Sensor::adc_id_list.push_back(id);
}

PT100::PT100(Pin& pin, float* value) : value(value){
template<size_t N>
PT100<N>::PT100(Pin& pin, float* value) : value(value){
id = ADC::inscribe(pin);
Sensor::adc_id_list.push_back(id);
}

PT100::PT100(Pin& pin, float& value) : value(&value){
template<size_t N>
PT100<N>::PT100(Pin& pin, float& value) : value(&value){
id = ADC::inscribe(pin);
Sensor::adc_id_list.push_back(id);
}

void PT100::read(){
template<size_t N>
void PT100<N>::read(){
float val = ADC::get_value(id);
if(filter != nullptr){
filter->input(k/val + offset);
Expand Down
Loading

0 comments on commit 7e06aa1

Please sign in to comment.