#pragma once #include #include "json.hpp" #include "Motordef.h" using json= nlohmann::json; #ifndef WIN32 #define MT_DRV888_CUO_PATH "/mnt/flash-disk/huago/drv888_cuo.json" #define MT_DRV888_ZOU_PATH "/mnt/flash-disk/huago/drv888_zou.json" #define MT_TMC216_CUO_PATH "/mnt/flash-disk/huago/tmc216_cuo.json" #define MT_TMC216_ZOU_PATH "/mnt/flash-disk/huago/tmc216_zou.json" #else #define MT_DRV888_CUO_PATH "drv888_cuo.json" #define MT_DRV888_ZOU_PATH "drv888_zou.json" #define MT_TMC216_CUO_PATH "tmc216_cuo.json" #define MT_TMC216_ZOU_PATH "tmc216_zou.json" #endif class MotorConfig { private: const std::vector m_jsonpaths={ MT_DRV888_CUO_PATH, MT_DRV888_ZOU_PATH, MT_TMC216_CUO_PATH, MT_TMC216_ZOU_PATH }; public: enum class MTBDType { MT_TMC, MT_DRV }; public: MotorConfig(/* args */); ~MotorConfig(); std::string GetParams(bool bzouzhi,MTBDType mttype); void SetParams(bool bzouzhi,MTBDType mttype,MotorSpeedParamEx& param); std::vector GetMotorSpeedParams(bool bzouzhi,MTBDType mttype); std::vector GetMotorSpeedParams(const std::string& json_str); MotorSpeedParamEx GetMotorSpeedParam(bool bzouzhi,MTBDType mttype,int speed,int colormmode,int dpi); private: void initconfigfile(); void to_json(MotorSpeedParamEx& param,json& j); void from_json(json& j,MotorSpeedParamEx& param); };