Refactoring, housekeeping, documentation
Add a class diagram. Still needs some details. Refactor to better respect SOLID principles. Housekeeping, move and rename classes/files.
This commit is contained in:
40
app/include/pwm/PWMControl.h
Normal file
40
app/include/pwm/PWMControl.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef PWMCONTROL_H_
|
||||
#define PWMCONTROL_H_
|
||||
|
||||
#include <boost/json/object.hpp>
|
||||
#include <string>
|
||||
|
||||
#include <Printable.h>
|
||||
#include <Serializable.h>
|
||||
|
||||
enum class PWM_CONTROL_PROPERTY { CONTROL, ENABLE, MODE };
|
||||
enum class PWM_ENABLE { FULL_SPEED = 0, MANUAL_CONTROL };
|
||||
enum class PWM_MODE { DC = 0, PWM };
|
||||
|
||||
class PWMControl : public Printable, public Serializable {
|
||||
public:
|
||||
PWMControl(std::string controlPath);
|
||||
~PWMControl();
|
||||
|
||||
void pwm(int percent);
|
||||
int pwm();
|
||||
|
||||
void EnableManualControl();
|
||||
void Reset();
|
||||
|
||||
const std::string toString() const override;
|
||||
|
||||
json toJson() const override;
|
||||
|
||||
private:
|
||||
int readValue(std::string path);
|
||||
|
||||
std::string mControlPath;
|
||||
std::string mEnablePath;
|
||||
std::string mModePath;
|
||||
|
||||
std::string mInitialEnable;
|
||||
std::string mInitialMode;
|
||||
};
|
||||
|
||||
#endif // PWMCONTROL_H_
|
||||
18
app/include/pwm/PWMControlFacade.h
Normal file
18
app/include/pwm/PWMControlFacade.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef PWMCONTROLFACADE_H_
|
||||
#define PWMCONTROLFACADE_H_
|
||||
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <regex>
|
||||
#include <vector>
|
||||
|
||||
#include <pwm/PWMControl.h>
|
||||
|
||||
#define HWMON_BASE_PATH "/sys/class/hwmon"
|
||||
|
||||
class PWMControlFacade {
|
||||
public:
|
||||
std::vector<std::shared_ptr<PWMControl>> PWMControls();
|
||||
};
|
||||
|
||||
#endif // PWMCONTROLFACADE_H_
|
||||
Reference in New Issue
Block a user