diff --git a/components/date/date_helper.cpp b/components/date/date_helper.cpp deleted file mode 100644 index a8fd6e0..0000000 --- a/components/date/date_helper.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include "date_helper.hpp" - -using namespace iflytop; -using namespace std; - -int DateHelper::getMaxDay(int year, int month) { - int daymax = 0; - switch (month) { - case 1: - daymax = 31; - break; - case 2: - if (year % 4 == 0) { - daymax = 29; - } else { - daymax = 28; - } - break; - case 3: - daymax = 31; - break; - case 4: - daymax = 30; - break; - case 5: - daymax = 31; - break; - case 6: - daymax = 30; - break; - case 7: - daymax = 31; - break; - case 8: - daymax = 31; - break; - case 9: - daymax = 30; - break; - case 10: - daymax = 31; - break; - case 11: - daymax = 30; - break; - case 12: - daymax = 31; - break; - default: - break; - } - return daymax; -} \ No newline at end of file diff --git a/components/date/date_helper.hpp b/components/date/date_helper.hpp deleted file mode 100644 index 35ee7e5..0000000 --- a/components/date/date_helper.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -namespace iflytop { -using namespace std; -class DateHelper { - public: - static int getMaxDay(int year, int month); -}; -} // namespace iflytop \ No newline at end of file diff --git a/components/errorcode/errorcode.hpp b/components/errorcode/errorcode.hpp deleted file mode 100644 index 58abe8a..0000000 --- a/components/errorcode/errorcode.hpp +++ /dev/null @@ -1 +0,0 @@ -#include "a8000_protocol\api\errorcode.hpp" \ No newline at end of file diff --git a/components/flash/znvs_bak.cpp b/components/flash/znvs_bak.cpp deleted file mode 100644 index 8e33044..0000000 --- a/components/flash/znvs_bak.cpp +++ /dev/null @@ -1,167 +0,0 @@ -#if 0 - -#include "znvs.hpp" - -#include - -#include "sdk\components\flash\zsimple_flash.hpp" -#define TAG "config" - -#ifdef IFLYTOP_NVS_CONFIG_MAX_ITEM_NUM - - -using namespace iflytop; -using namespace std; -#define MARK_S 0x123456 -#define MARK_E 0x87654321 - -#define GET_CFG(typename) \ - cfg_t* cfg = get_cfg(key); \ - if (cfg == nullptr || cfg->type != kcfg_type_##typename) { \ - allocate_cfg(key, kcfg_type_##typename, (uint8_t*)&default_val, sizeof(default_val)); \ - cfg = get_cfg(key); \ - } \ - return *(typename*)cfg->val; - -#define SET_CFG(typename) \ - cfg_t* cfg = get_cfg(key); \ - if (cfg == nullptr || cfg->type != kcfg_type_##typename) { \ - allocate_cfg(key, kcfg_type_##typename, (uint8_t*)&val, sizeof(val)); \ - cfg = get_cfg(key); \ - } else { \ - *(typename*)cfg->val = val; \ - flush(); \ - } - -ZNVS& ZNVS::ins() { - static ZNVS instance; - return instance; -} -void ZNVS::initialize() { - zsimple_flash_init(IFLYTOP_NVS_CONFIG_FLASH_SECTOR); - zsimple_flash_read((uint8_t*)&m_cfg, sizeof(m_cfg)); - if (m_cfg.config_start != MARK_S || m_cfg.config_end != MARK_E) { - ZLOGW(TAG, "config uninitialized, initialize it"); - memset(&m_cfg, 0, sizeof(m_cfg)); - m_cfg.config_start = MARK_S; - m_cfg.config_end = MARK_E; - zsimple_flash_write((uint8_t*)&m_cfg, sizeof(m_cfg)); - } else { - ZLOGI(TAG, "config initialized"); - } -} - -void ZNVS::factory_reset() { - memset(&m_cfg, 0, sizeof(m_cfg)); - m_cfg.config_start = MARK_S; - m_cfg.config_end = MARK_E; - zsimple_flash_write((uint8_t*)&m_cfg, sizeof(m_cfg)); -} - -ZNVS::cfg_t* ZNVS::get_cfg(const char* key) { - for (int i = 0; i < IFLYTOP_NVS_CONFIG_MAX_ITEM_NUM; i++) { - if (strcmp(m_cfg.cfgs[i].key, key) == 0) { - return &m_cfg.cfgs[i]; - } - } - return nullptr; -} - -void ZNVS::allocate_cfg(const char* key, type_t type, uint8_t* default_val, uint8_t len) { - cfg_t* cfg = get_cfg(key); - for (int i = 0; i < IFLYTOP_NVS_CONFIG_MAX_ITEM_NUM; i++) { - if (m_cfg.cfgs[i].is_initialed == false) { - cfg = &m_cfg.cfgs[i]; - strcpy(cfg->key, key); - cfg->is_initialed = true; - cfg->type = (uint8_t)type; - memcpy(cfg->val, default_val, len); -#if 0 - /** - * @brief 刷新flash - * - * TODO:优化这里的代码,不要每次都刷新flash - */ - zsimple_flash_write((uint8_t*)&m_cfg, sizeof(m_cfg)); -#endif - break; - } - } -} - -ZNVS::cfg_t* ZNVS::get_and_create_cfg(const char* key, type_t type, uint8_t* default_val, uint8_t len) { - cfg_t* cfg = get_cfg(key); - if (cfg == nullptr) { - allocate_cfg(key, type, default_val, len); - cfg = get_cfg(key); - } - return cfg; -} - -void ZNVS::dumpcfg() { - ZLOGI(TAG, "=================dump nvs config =================="); - ZLOGI(TAG, "="); - for (int i = 0; i < IFLYTOP_NVS_CONFIG_MAX_ITEM_NUM; i++) { - if (m_cfg.cfgs[i].is_initialed) { - dumpcfg(&m_cfg.cfgs[i]); - } - } - ZLOGI(TAG, "============="); -} - -void ZNVS::dumpcfg(cfg_t* cfg) { - if (!cfg->is_initialed) return; - switch (cfg->type) { - case kcfg_type_int8_t: - ZLOGI(TAG, "= %s val:%d", cfg->key, *(int8_t*)cfg->val); - break; - case kcfg_type_int16_t: - ZLOGI(TAG, "= %s val:%d", cfg->key, *(int16_t*)cfg->val); - break; - case kcfg_type_int32_t: - ZLOGI(TAG, "= %s val:%d", cfg->key, *(int32_t*)cfg->val); - break; - - case kcfg_type_uint8_t: - ZLOGI(TAG, "= %s val:%u", cfg->key, *(int8_t*)cfg->val); - break; - case kcfg_type_uint16_t: - ZLOGI(TAG, "= %s val:%u", cfg->key, *(int16_t*)cfg->val); - break; - case kcfg_type_uint32_t: - ZLOGI(TAG, "= %s val:%u", cfg->key, *(int32_t*)cfg->val); - break; - case kcfg_type_float: - ZLOGI(TAG, "= %s val:%f", cfg->key, *(float*)cfg->val); - break; - case kcfg_type_bool: - ZLOGI(TAG, "= %s val:%d", cfg->key, *(bool*)cfg->val); - break; - default: - ZLOGI(TAG, "= %s val:unknow type", cfg->key); - break; - } - return; -} - -int8_t ZNVS::get_config_int8(const char* key, int8_t default_val) { GET_CFG(int8_t); } -void ZNVS::set_config_int8(const char* key, int8_t val) { SET_CFG(int8_t); } -uint8_t ZNVS::get_config_uint8(const char* key, uint8_t default_val) { GET_CFG(uint8_t); } -void ZNVS::set_config_uint8(const char* key, uint8_t val) { SET_CFG(uint8_t); } -int16_t ZNVS::get_config_int16(const char* key, int16_t default_val) { GET_CFG(int16_t); } -void ZNVS::set_config_int16(const char* key, int16_t val) { SET_CFG(int16_t); } -uint16_t ZNVS::get_config_uint16(const char* key, uint16_t default_val) { GET_CFG(uint16_t); } -void ZNVS::set_config_uint16(const char* key, uint16_t val) { SET_CFG(uint16_t); } -int32_t ZNVS::get_config_int32(const char* key, int32_t default_val) { GET_CFG(int32_t); } -void ZNVS::set_config_int32(const char* key, int32_t val) { SET_CFG(int32_t); } -uint32_t ZNVS::get_config_uint32(const char* key, uint32_t default_val) { GET_CFG(uint32_t); } -void ZNVS::set_config_uint32(const char* key, uint32_t val) { SET_CFG(uint32_t); } -float ZNVS::get_config_float(const char* key, float default_val) { GET_CFG(float); } -void ZNVS::set_config_float(const char* key, float val) { SET_CFG(float); } -bool ZNVS::get_config_bool(const char* key, bool default_val) { GET_CFG(bool); } -void ZNVS::set_config_bool(const char* key, bool val) { SET_CFG(bool); } - -void ZNVS::flush() { zsimple_flash_write((uint8_t*)&m_cfg, sizeof(m_cfg)); } - -#endif -#endif \ No newline at end of file diff --git a/components/flash/znvs_bak.hpp b/components/flash/znvs_bak.hpp deleted file mode 100644 index 79f57be..0000000 --- a/components/flash/znvs_bak.hpp +++ /dev/null @@ -1,83 +0,0 @@ -#pragma once -#if 0 -#include "project_configs.h" -#include "sdk/os/zos.hpp" - -#ifdef IFLYTOP_NVS_CONFIG_MAX_ITEM_NUM - -namespace iflytop { -using namespace std; - -class ZNVS { - typedef enum { - kcfg_type_int8_t, - kcfg_type_uint8_t, - kcfg_type_int16_t, - kcfg_type_uint16_t, - kcfg_type_int32_t, - kcfg_type_uint32_t, - kcfg_type_float, - kcfg_type_bool, - } type_t; - -#pragma pack(1) - typedef struct { - char key[64]; - uint8_t val[8]; - uint8_t type; - bool is_initialed; - } cfg_t; - - typedef struct { - uint32_t config_start; - cfg_t cfgs[IFLYTOP_NVS_CONFIG_MAX_ITEM_NUM]; - uint32_t config_end; - } config_t; -#pragma pack() - - config_t m_cfg; - - public: - static ZNVS& ins(); - - void initialize(); - void factory_reset(); - void dumpcfg(); - - void flush(); - - int8_t get_config_int8(const char* key, int8_t default_val); - void set_config_int8(const char* key, int8_t val); - - uint8_t get_config_uint8(const char* key, uint8_t default_val); - void set_config_uint8(const char* key, uint8_t val); - - int16_t get_config_int16(const char* key, int16_t default_val); - void set_config_int16(const char* key, int16_t val); - - uint16_t get_config_uint16(const char* key, uint16_t default_val); - void set_config_uint16(const char* key, uint16_t val); - - int32_t get_config_int32(const char* key, int32_t default_val); - void set_config_int32(const char* key, int32_t val); - - uint32_t get_config_uint32(const char* key, uint32_t default_val); - void set_config_uint32(const char* key, uint32_t val); - - float get_config_float(const char* key, float default_val); - void set_config_float(const char* key, float val); - - bool get_config_bool(const char* key, bool default_val); - void set_config_bool(const char* key, bool val); - - private: - void dumpcfg(cfg_t* cfg); - - cfg_t* get_cfg(const char* key); - void allocate_cfg(const char* key, type_t type, uint8_t* default_val, uint8_t len); - cfg_t* get_and_create_cfg(const char* key, type_t type, uint8_t* default_val, uint8_t len); -}; - -} // namespace iflytop -#endif -#endif \ No newline at end of file diff --git a/components/mini_servo_motor/mini_servo_motor_ctrl_module.cpp b/components/mini_servo_motor/mini_servo_motor_ctrl_module.cpp index e1d5944..66bfbfb 100644 --- a/components/mini_servo_motor/mini_servo_motor_ctrl_module.cpp +++ b/components/mini_servo_motor/mini_servo_motor_ctrl_module.cpp @@ -1,6 +1,6 @@ #include "mini_servo_motor_ctrl_module.hpp" -#include "sdk\components\errorcode\errorcode.hpp" +#include "a8000_protocol\api\errorcode.hpp" using namespace iflytop; using namespace std; #define TAG "MiniRobotCtrlModule" diff --git a/components/mini_servo_motor/scirpt_cmder_mini_servo_motor_ctrl_module.cpp b/components/mini_servo_motor/scirpt_cmder_mini_servo_motor_ctrl_module.cpp deleted file mode 100644 index 2c31844..0000000 --- a/components/mini_servo_motor/scirpt_cmder_mini_servo_motor_ctrl_module.cpp +++ /dev/null @@ -1,7 +0,0 @@ - -#include "scirpt_cmder_mini_servo_motor_ctrl_module.hpp" - -#include -#if 0 - -#endif \ No newline at end of file diff --git a/components/mini_servo_motor/scirpt_cmder_mini_servo_motor_ctrl_module.hpp b/components/mini_servo_motor/scirpt_cmder_mini_servo_motor_ctrl_module.hpp deleted file mode 100644 index 510e690..0000000 --- a/components/mini_servo_motor/scirpt_cmder_mini_servo_motor_ctrl_module.hpp +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once -#include -#if 0 - -#endif \ No newline at end of file diff --git a/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp b/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp index 9a0372d..39b675b 100644 --- a/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp +++ b/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp @@ -3,7 +3,7 @@ #include #include -#include "sdk/components/errorcode/errorcode.hpp" +#include "a8000_protocol\api\errorcode.hpp" #include "sdk\components\flash\znvs.hpp" using namespace iflytop; #define TAG "SMCM" diff --git a/components/algorithm/pid_module.cpp b/components/water_cooling_temperature_control_module/pid_module.cpp similarity index 100% rename from components/algorithm/pid_module.cpp rename to components/water_cooling_temperature_control_module/pid_module.cpp diff --git a/components/algorithm/pid_module.hpp b/components/water_cooling_temperature_control_module/pid_module.hpp similarity index 100% rename from components/algorithm/pid_module.hpp rename to components/water_cooling_temperature_control_module/pid_module.hpp diff --git a/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.hpp b/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.hpp index ba04c34..ddd2639 100644 --- a/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.hpp +++ b/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.hpp @@ -22,7 +22,7 @@ #include "sdk\components\api\zi_pwm_fan_ctrl_module.hpp" #include "sdk\components\api\zi_pwm_pump_ctrl_module.hpp" // -#include "sdk\components\algorithm\pid_module.hpp" +#include "pid_module.hpp" #include "sdk\components\api\zi_temperature_sensor.hpp" #include "sdk\components\ti\drv8710.hpp" #include "a8000_protocol\api\zi_module.hpp" diff --git a/components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp b/components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp index 326cf7a..a8cf034 100644 --- a/components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp +++ b/components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp @@ -2,7 +2,7 @@ #include -#include "sdk/components/errorcode/errorcode.hpp" +#include "a8000_protocol\api\errorcode.hpp" #include "sdk\components\flash\znvs.hpp" using namespace iflytop; using namespace std;