Skip to content

Commit

Permalink
adding stuff in
Browse files Browse the repository at this point in the history
  • Loading branch information
RCMast3r committed Apr 29, 2024
1 parent f36ebda commit e84c294
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
56 changes: 56 additions & 0 deletions lib/systems/include/ParameterSystem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#pragma once
#include <unordered_map>

namespace Parameters {

class FloatParameter {
public:
virtual float get() const = 0;
virtual void set(float value) = 0;
virtual ~FloatParameter() {}
};

class BoolParameter {
public:
virtual bool get() const = 0;
virtual void set(bool value) = 0;
virtual ~BoolParameter() {}
};

class MaxSpeed : public FloatParameter {
float value;
public:
MaxSpeed() : value(120.0) {}
float get() const override { return value; }
void set(float v) override { value = v; }
};

class Threshold : public FloatParameter {
float value;
public:
Threshold() : value(0.75) {}
float get() const override { return value; }
void set(float v) override { value = v; }
};

class IsActive : public BoolParameter {
bool value;
public:
IsActive() : value(false) {}
bool get() const override { return value; }
void set(bool v) override { value = v; }
};

MaxSpeed MaxSpeedInstance;
Threshold ThresholdInstance;
std::unordered_map<const char *, Parameters::FloatParameter*> floatLookupMap = {
{"b1fc2577", &MaxSpeedInstance},
{"0da627ad", &ThresholdInstance},
};

IsActive IsActiveInstance;
std::unordered_map<const char *, Parameters::BoolParameter*> boolLookupMap = {
{"57401e59", &IsActiveInstance},
};

}
3 changes: 1 addition & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Include files */
/* System Includes*/
#include <Arduino.h>

#include "ParameterSystem.h"
/* Libraries */
#include "FlexCAN_T4.h"
#include "HyTech_CAN.h"
Expand Down Expand Up @@ -282,7 +282,6 @@ void setup()
/*
Init Systems
*/

safety_system.init();

// Drivetrain set all inverters disabled
Expand Down

0 comments on commit e84c294

Please sign in to comment.