diff --git a/SConscript b/SConscript new file mode 100644 index 0000000..e69de29 diff --git a/dwlib/dw.h b/dwlib/dw.h new file mode 100644 index 0000000..e69de29 diff --git a/dwlib/dw_conf.h b/dwlib/dw_conf.h new file mode 100644 index 0000000..e69de29 diff --git a/old/SConscript b/old/SConscript deleted file mode 100644 index 368abad..0000000 --- a/old/SConscript +++ /dev/null @@ -1,43 +0,0 @@ -from building import * - -# get current dir path -cwd = GetCurrentDir() - -# init src and inc vars -src = [] -inc = [] - -# add dwin common include -inc = inc + [cwd + '/dwlib'] - -# add dwin basic code -src = src + ['./dwlib/basic/src/dw_init.c'] -src = src + ['./dwlib/basic/src/dw_space.c'] -inc = inc + [cwd + '/dwlib/basic/inc'] - -#add dwin plugins code - -#add system plugins code -if GetDepend('RT_USING_DW_SYSTEM'): - src = src + ['./dwlib/plugins/system/dw_system.c'] - inc = inc + [cwd + '/dwlib/plugins/system'] - -#add cmd plugins code -if GetDepend('RT_USING_DW_CMD'): - src = src + ['./dwlib/plugins/cmd/dw_cmd.c'] - inc = inc + [cwd + '/dwlib/plugins/cmd'] - -#add login plugins code -if GetDepend('RT_USING_DW_LOGIN'): - src = src + ['./dwlib/plugins/login/dw_login.c'] - inc = inc + [cwd + '/dwlib/plugins/login'] - -#add vicon plugins code -if GetDepend('RT_USING_DW_VICON'): - src = src + ['./dwlib/plugins/vicon/dw_vicon.c'] - inc = inc + [cwd + '/dwlib/plugins/vicon'] - -# add group to IDE project -group = DefineGroup('Dwinlib', src, depend = ['RT_USING_DWIN'], CPPPATH = inc) - -Return('group') diff --git a/old/bugList.md b/old/bugList.md deleted file mode 100644 index 253cd7b..0000000 --- a/old/bugList.md +++ /dev/null @@ -1,6 +0,0 @@ -## BugList ## - -2017-08-31: 使用密码登陆插件时,应用层再次使用读写函数(特别是读取PAGEID),会出现数据解析错误 -~~~ -已经解决,将底层读写寄存器空间和变量空间进行资源锁定,暂时使用禁止OS调度来实现,不好要换成资源锁 -~~~ diff --git a/old/changeLog.md b/old/changeLog.md deleted file mode 100644 index 980e28e..0000000 --- a/old/changeLog.md +++ /dev/null @@ -1,74 +0,0 @@ -## dwlib changeLog ## - -ver 1.3.1 2017-08-31 by liuguang -~~~ -1. 登陆插件添加删除密码功能 -2. 修复使用密码登陆插件时,应用层再次使用读写函数 - (特别是读取PAGEID),会出现数据解析错误,但是暂时 - 使用禁止OS调度来实现,不好实现方式不好要换成资源锁 -~~~ - -ver 1.3.0 2017-08-31 by liuguang -1. 添加cmd对finsh和msh的支持, 且支持rtconfig.h配置功能 - -当前版本支持的命令有以下 -~~~ - 1.01. 获取迪文屏幕固件版本(不是迪文库版本) - 1.02. 获取当前背光亮度 - 1.03. 设置当前背光亮度 - 1.04. 控制蜂鸣 - 1.05. 获取当前页 - 1.06. 跳转到指定页面 - 1.07. 获取当前波特率 - 1.08. 设置屏幕旋转方向 - 1.09. 获取当前屏幕方向 - 1.10. 获取背光是否由触摸控制 - 1.11. 获取是否开启帧CRC功能 - 1.12. 设置是否开启帧CRC功能 - 1.13. 获取触摸数据是否自动上传 - 1.14. 设置触摸数据是否自动上传 - 1.15. 获取数据寄存器上电初始化模式 - 1.16. 设置数据寄存器上电初始化模式 - 1.17. 获取蜂鸣器是否开启 - 1.18. 设置蜂鸣器是否开启 - 1.19. 获取RTC时间 - 1.20. 设置RTC时间 - 1.21. 使用时间戳设置RTC时间 - 1.22. 获取RTC时间戳 - 1.23. 登陆插件的添加用户密码 - 1.24. 变量图标功能插件添加变量图标 - 1.25. 变量图标功能插件图标切换 -~~~ - -rtconfig.h支持库功能宏开关, 方便库的代码大小剪切: -~~~ - 2.01. RT_USING_DWIN 开启迪文库, 方便使用scons工具 - 2.02. RT_USING_DMT48270M043_02W 选择迪文库支持类型, 目前只支持2款型号, 其他也能支持, 但是功能上有细微差别 - 2.03. RT_USING_DW_CMD 开启迪文库finsh和msh命令插件, 注意开启该功能需要代码先开启finsh或者msh组件 - 2.04. RT_USING_DW_SYSTEM 开启迪文库系统设置和查询插件 - 2.05. RT_USING_DW_LOGIN 开启登陆机制插件 - 2.06. RT_USING_DW_VICON 开启变量图标插件 -~~~ - -ver 1.2.0 by liuguang -~~~ -1. 调整代码框架 -2. 调整函数命名 -3. 移除port底层接口, 改为在rtthread下使用串口设备 -~~~ - -ver 1.1.1 by liuguang -~~~ -1. 修改代码结构 -2. 修改代码名称 -~~~ - -ver 1.1.0 by liuguang -~~~ -1. 实现密码注册功能 -~~~ - -ver 1.0.0 by liuguang -1. 实现底层port接口 -2. 实现控制寄存器和数据寄存器的读写 -3. 实现对应控制寄存器相关功能 diff --git a/old/dwlib/basic/inc/dw_init.h b/old/dwlib/basic/inc/dw_init.h deleted file mode 100644 index 69aafa2..0000000 --- a/old/dwlib/basic/inc/dw_init.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __DW_INIT_H_ -#define __DW_INIT_H_ - -#include "dw_define.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* עĻ豸,Ŀǰֻ֧ͨ, жϽյĴ豸 */ -rt_err_t rt_device_dw_init(rt_device_dw_t device, const char *name, rt_uint8_t init_bl); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/old/dwlib/basic/inc/dw_space.h b/old/dwlib/basic/inc/dw_space.h deleted file mode 100644 index 8716869..0000000 --- a/old/dwlib/basic/inc/dw_space.h +++ /dev/null @@ -1,154 +0,0 @@ -#ifndef __DW_SPACE_H_ -#define __DW_SPACE_H_ - -#include "dw_define.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* 指令 */ -/* 寄存器空间读写响应指令 */ -#define RT_DW_COMMAND_READ_REG_SPACE (0x81) -#define RT_DW_COMMAND_WRITE_REG_SPACE (0x80) - -/* 变量空间读写响应指令 */ -#define RT_DW_COMMAND_READ_VAR_SPACE (0x83) -#define RT_DW_COMMAND_WRITE_VAR_SPACE (0x82) - -/* 曲线缓存空间写指令 */ -#define RT_DW_COMMAND_WRITE_CURVE_SPACE (0x84) - -/* 全局BUFFER大小 */ -#define RT_DW_FRAME_BUFFER_MAX_LENGTH (248) /* 手册提供 */ - -/* 数据帧头内容 */ -#define RT_DW_FRMAE_HIGH_CONTENT (0x5A) /* 帧头高字节内容 */ -#define RT_DW_FRMAE_LOW_CONTENT (0xA5) /* 帧头低字节内容 */ - -/* 寄存器空间相关宏定义 */ -/* 寄存器空间地址范围 */ -#define RT_DW_REG_SPACE_MIN_ADDRESS (0x00) /* 寄存器空间最小地址 */ -#define RT_DW_REG_SPACE_MAX_ADDRESS (0xFF) /* 寄存器空间最大地址 */ - -/* 寄存器数据帧内容偏移 */ -#define RT_DW_REG_SPACE_FRAME_HIGH_OFFSET (0) /* 帧头高字节 */ -#define RT_DW_REG_SPACE_FRAME_LOW_OFFSET (1) /* 帧头低字节 */ -#define RT_DW_REG_SPACE_DATA_LENGTH_OFFSET (2) /* 帧数据长度, 单位字节, 包含指令/地址/数据长度 */ -#define RT_DW_REG_SPACE_COMMAND_OFFSET (3) /* 帧控制命令 */ -#define RT_DW_REG_SPACE_ADDRESS_OFFSET (4) /* 读写寄存器地址 */ -#define RT_DW_REG_SPACE_DATA_OFFSET (5) /* 读写寄存器内容 */ - -/* 变量空间地址范围 */ -#define RT_DW_VAR_SPACE_MIN_ADDRESS (0x0000) /* 寄存器空间最小地址 */ - -/* 待补充所有迪文屏幕的变量数据大小 */ -#if defined(RT_USING_DMT48270M043_02W) || defined(RT_USING_DMT48270M050_02W) -#define RT_DW_VAR_SPACE_MAX_ADDRESS (0x1000) /* 寄存器空间最大地址:4K */ -#endif - -/* 变量数据帧内容偏移 */ -#define RT_DW_VAR_SPACE_FRAME_HIGH_OFFSET (0) /* 帧头高字节 */ -#define RT_DW_VAR_SPACE_FRAME_LOW_OFFSET (1) /* 帧头低字节 */ -#define RT_DW_VAR_SPACE_DATA_LENGTH_OFFSET (2) /* 帧数据长度, 单位字节, 包含指令/地址/数据长度 */ -#define RT_DW_VAR_SPACE_COMMAND_OFFSET (3) /* 帧控制命令 */ -#define RT_DW_VAR_SPACE_ADDRESS_OFFSET (4) /* 读写寄存器地址 */ -#define RT_DW_VAR_SPACE_DATA_OFFSET (6) /* 读写寄存器内容 */ - -/* 寄存器空间指令 */ -/* 格式:RT_DW_REG_XXH(寄存器地址, 16进制)_XXX(寄存器长度, 10进制)_功能缩写 */ -#if defined(RT_USING_DMT48270M043_02W) || defined(RT_USING_DMT48270M050_02W) -#define RT_DW_REG_00H_001_VERSION (0x00) // 迪文屏幕固件版本 -#define RT_DW_REG_01H_001_NOW_BL (0x01) // 当前背光亮度 -#define RT_DW_REG_02H_001_MAKE_BEEP (0x02) // 驱动蜂鸣, 单位10ms -#define RT_DW_REG_03H_002_NOW_PAGEID (0x03) // 系统当前页面ID -#define RT_DW_REG_05H_001_TOUCH_FLAG (0x05) // 触摸标志位 -#define RT_DW_REG_06H_001_TOUCH_STATE (0x06) // 触摸状态 -#define RT_DW_REG_07H_004_TOUCH_POS (0x07) // 触摸位置 -#define RT_DW_REG_0BH_001_TOUCH_EN (0x0B) // 触摸使能 -#define RT_DW_REG_0CH_004_RESERVE (0x0C) // 保留 -#define RT_DW_REG_10H_001_DRV_MODE (0x10) // R0, 驱动模式(迪文公司内部使用) -#define RT_DW_REG_11H_001_BRUDRATE (0x11) // R1, 通信波特率 -#define RT_DW_REG_12H_001_SYSCFG (0x12) // R2, 系统配置 -#define RT_DW_REG_13H_001_FARAME_H (0x13) // R3, 通信帧头高字节 -#define RT_DW_REG_14H_002_RESERVE (0x14) // R4R5, 保留 -#define RT_DW_REG_16H_001_LEDON_LEVEL (0x16) // R6, 背光点亮亮度 -#define RT_DW_REG_17H_001_LEDOFF_LEVEL (0x17) // R7, 背光熄灭亮度 -#define RT_DW_REG_18H_001_LEDON_KEEPTIME (0x18) // R8, 背光点亮保持时间, 单位1s -#define RT_DW_REG_19H_001_RESERVE (0x19) // R9, 保留 -#define RT_DW_REG_1AH_001_FARAME_L (0x1A) // RA, 通信帧头低字节 -#define RT_DW_REG_1BH_004_RESERVE (0x1B) // 保留 -#define RT_DW_REG_1FH_001_RTC_UPDATE_FLAG (0x1F) // 手动修改RTC更新标志位 -#define RT_DW_REG_20H_016_RTC (0x20) // RTC数据 -#define RT_DW_REG_30H_016_RESERVE (0x30) // 保留 -#define RT_DW_REG_40H_001_FONTLIB_OPT_EN (0x40) // 字库操作使能 -#define RT_DW_REG_41H_001_FONTLIB_OPT_MODE (0x41) // 字库模式 -#define RT_DW_REG_42H_001_FONTLIB_OPT_ID (0x42) // 字库ID -#define RT_DW_REG_43H_003_FONTLIB_OPT_ADDR (0x43) // 字库地址 -#define RT_DW_REG_46H_002_FONTLIB_OPT_VP (0x46) // 05系列支持 -#define RT_DW_REG_48H_002_FONTLIB_OPT_LENGTH (0x48) // 05系列支持 -#define RT_DW_REG_4AH_002_TIMER0_16BIT_4MS (0x4A) // 定时器0, 16位长度, 步进4MS, 误差±4mS -#define RT_DW_REG_4CH_001_TIMER1_08BIT_4MS (0x4C) // 定时器1, 08位长度, 步进4MS, 误差±4mS -#define RT_DW_REG_4DH_001_TIMER2_08BIT_4MS (0x4D) // 定时器2, 08位长度, 步进4MS, 误差±4mS -#define RT_DW_REG_4EH_001_RESERVE (0x4E) // 保留 -#define RT_DW_REG_4FH_001_KEYCODE (0x4F) // 按键值 -#define RT_DW_REG_50H_155_RESERVE (0x50) // 保留 -#define RT_DW_REG_EBH_001_CURVE_CLR (0xEB) // 清除曲线数据 -#define RT_DW_REG_ECH_001_FAST_REFRESH (0xEC) // 快速刷新 -#define RT_DW_REG_EDH_019_RESERVE (0xED) // 保留 -#define RT_DW_REG_F3H_002_DOWNLOAD_LIB (0xF3) // 下载字库 -#define RT_DW_REG_F5H_004_DOWNLOAD_PIC (0xF5) // 下载图片 -#define RT_DW_REG_F9H_001_RESERVE (0xF9) // 保留 -#define RT_DW_REG_FAH_001_DOWNLOAD_FLAG (0xFA) // 下载成功标志位 -#define RT_DW_REG_FBH_005_RESERVE (0xFB) // 保留 - -/* R2 SYSCFG掩码 */ -#define RT_DW_R2BIT0_BUZZER_EN_MASK (1<<0) // 蜂鸣器使能 -#define RT_DW_R2BIT1_RESERVE_MASK (1<<1) // 保留 -#define RT_DW_R2BIT2_VAR_INIT_MODE_MASK (1<<2) // 变量空间初始化模式, 1:上电全部初始化为0x00, 2由22号字库填充 -#define RT_DW_R2BIT3_DATA_AUTO_UPLOAD_MASK (1<<3) // 触摸数据自动上传 -#define RT_DW_R2BIT4_CRC_EN_MASK (1<<4) // 串口帧CRC使能, 不支持 -#define RT_DW_R2BIT5_BL_CTR_MASK (1<<5) // 触摸控制背光 -#define RT_DW_R2BIT6_HDS_MASK (1<<6) // 旋转180度 -#define RT_DW_R2BIT7_VHS_MASK (1<<7) // 旋转90度 -#endif - -/* 读寄存器空间 */ -rt_err_t rt_dw_read_reg_space( - rt_device_dw_t device, - rt_uint8_t addr, - rt_uint8_t length, - rt_uint8_t *rx_data); - -/* 写寄存器空间 */ -rt_err_t rt_dw_write_reg_space( - rt_device_dw_t device, - rt_uint8_t addr, - rt_uint8_t length, - rt_uint8_t *tx_data); - -/* 读变量空间 */ -rt_err_t rt_dw_read_var_space( - rt_device_dw_t device, - rt_uint16_t addr, - rt_uint8_t length, - rt_uint16_t *rx_data); - -/* 写变量空间 */ -rt_err_t rt_dw_write_var_space( - rt_device_dw_t device, - rt_uint16_t addr, - rt_uint8_t length, - rt_uint16_t *tx_data); - -/* 读参寄存器 */ -rt_err_t rt_dw_read_para_reg(rt_device_dw_t device, rt_uint8_t addr, rt_uint8_t *rx_data); -rt_err_t rt_dw_write_para_reg(rt_device_dw_t device, rt_uint8_t addr, rt_uint8_t tx_data); - -/* 写参寄存器 */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/old/dwlib/basic/src/dw_init.c b/old/dwlib/basic/src/dw_init.c deleted file mode 100644 index 7986ad1..0000000 --- a/old/dwlib/basic/src/dw_init.c +++ /dev/null @@ -1,171 +0,0 @@ -#include "dw_init.h" - -#if defined(RT_USING_DW_SYSTEM) -#include "dw_system.h" -#endif - -#if defined(RT_USING_DW_CMD) -#include "dw_cmd.h" -#endif - -static rt_err_t dw_read(rt_device_t device, char *c) -{ - rt_size_t size = 0; - - RT_ASSERT(c != RT_NULL); - RT_ASSERT(device != RT_NULL); - - size = rt_device_read(device, 0, c, 1); - - if(size != 1) - { - /* 写数据错误 */ - return RT_EIO; - } - - return RT_EOK; -} - -static rt_err_t dw_write(rt_device_t device, char *c) -{ - rt_size_t size = 0; - - RT_ASSERT(c != RT_NULL); - RT_ASSERT(device != RT_NULL); - - size = rt_device_write(device, 0, c, 1); - - if(size != 1) - { - /* 写数据错误 */ - return RT_EIO; - } - - return RT_EOK; -} - -static struct rt_dw_ops dw_ops = -{ - dw_read, - dw_write -}; - -/* 注册迪文屏幕设备,目前只支持普通发送, 中断接收的串口设备 */ -rt_err_t rt_device_dw_init(rt_device_dw_t device, const char *name, rt_uint8_t init_bl) -{ - rt_err_t ret = RT_ERROR; - - RT_ASSERT(device != RT_NULL); - RT_ASSERT(name != RT_NULL); - - device->parent = rt_device_find(name); - - if(device->parent == RT_NULL) - { - /* 没有发现串口设备 */ - return RT_EIO; - } - - ret = rt_device_open(device->parent, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX); - - if(ret != RT_EOK) - { - /* 打开设备失败 */ - device->parent = RT_NULL; - return ret; - } - - device->ops = &dw_ops; - - device->state = RT_DW_STATE_INIT; - - /* 获取屏幕相关参数 */ -#if defined(RT_USING_DW_DEBUG) && defined(RT_USING_DW_SYSTEM) - { - rt_uint8_t rx_data[10] = {0}; - - rt_kprintf("\n"); - - /* 打印固件版本 */ - rx_data[0] = rt_dw_fw_version(device); - rt_kprintf("[dwin]firmware version 0x%.2x\n", rx_data[0]); - - /* 上电默认亮度 */ - rt_dw_set_now_bl(device, init_bl); - - /* 打印屏幕亮度 */ - rx_data[0] = rt_dw_get_now_bl(device); - rt_kprintf("[dwin]now backlight level 0x%.2x\n", rx_data[0]); - - /* 蜂鸣1s */ - rt_dw_beep_nx10ms(device, 50); - - /* 上电初始化调整到第一幅页面 */ - rt_dw_jump_page(device, 0); /* 这里有个bug, 当有弹窗时,无法关闭弹窗 */ - - *((rt_uint16_t *)rx_data) = rt_dw_get_now_pageid(device); - rt_kprintf("[dwin]now page id %d\n", *((rt_uint16_t *)rx_data)); - - /* 获取串口波特率 */ - rx_data[0] = rt_dw_baudrate(device); - rt_kprintf("[dwin]baudrate index %d\n", rx_data[0]); - - /* 开机设备屏幕方向 */ - rt_dw_set_screen_dir(device, RT_DW_SCREEN_DIR_000); - - /* 获取屏幕方向 */ - rt_dw_get_screen_dir(device, (rt_dw_screen_dir_t *)&rx_data[0]); - rt_kprintf("[dwin]screen dir %d\n", rx_data[0]); - - /* 设置是否打开触摸控制背光 */ - rt_dw_set_bl_ctr_enable(device, RT_DW_ENABLE); - - /* 获取是否打开触摸控制背光 */ - rt_dw_get_bl_ctr_enable(device, &rx_data[0]); - rt_kprintf("[dwin]touch ctr backlight enable %d\n", rx_data[0]); - - /* 获取是否打开帧CRC功能 */ - rt_dw_get_crc_enable(device, &rx_data[0]); - rt_kprintf("[dwin]frame crc enable %d\n", rx_data[0]); - - /* 设置触摸数据不自动上传 */ - rt_dw_set_data_auto_update(device, RT_DW_DISABLE); - - /* 获取数据是否自动上传 */ - rt_dw_get_data_auto_update(device, &rx_data[0]); - rt_kprintf("[dwin]data auto update %d\n", rx_data[0]); - - /* 设置数据寄存器上电初始化模式, 0上电初始化为0x00, 1上电有L22字库文件加载 */ - rt_dw_set_var_init_mode(device, RT_DW_VAR_INIT_MODE_1); - - /* 获取数据寄存器上电初始化模式, 0上电初始化为0x00, 1上电有L22字库文件加载 */ - rt_dw_get_var_init_mode(device, (rt_dw_var_init_mode_t *)&rx_data[0]); - rt_kprintf("[dwin]var init mode %d\n", rx_data[0]); - - /* 设置蜂鸣器是否开启, 0开启 1未开启 注意必须是DWIN周期200MS才可以正常工作, 这里有BUG */ - // rt_dw_set_buzzer_enable(device, RT_DW_ENABLE); - - /* 获取蜂鸣器是否开启, 0开启 1未开启 */ - rt_dw_get_buzzer_enable(device, &rx_data[0]); - rt_kprintf("[dwin]buzzer enable %d\n", rx_data[0]); - - /* 初始化默认时间 */ - // rt_dw_set_rtc(device, 17, 8, 22, 22, 23, 0); - // rt_dw_set_rtc_timestamp(device, 1503412777UL); - - /* 获取RTC时间 */ - rt_dw_get_rtc(device, - &rx_data[0], &rx_data[1], &rx_data[2], - &rx_data[3], &rx_data[4], &rx_data[5]); - rt_kprintf("[dwin]now time 20%.2d-%.2d-%.2d %.2d:%.2d:%.2d\n", - rx_data[0], rx_data[1], rx_data[2], - rx_data[3], rx_data[4], rx_data[5]); - - /* 获取RTC时间戳 */ - rt_dw_get_rtc_timestamp(device, (time_t *)rx_data); - rt_kprintf("[dwin]now timestamp %ld\n", *(time_t *)rx_data); - } -#endif - - return RT_EOK; -} diff --git a/old/dwlib/basic/src/dw_space.c b/old/dwlib/basic/src/dw_space.c deleted file mode 100644 index 0023693..0000000 --- a/old/dwlib/basic/src/dw_space.c +++ /dev/null @@ -1,395 +0,0 @@ -#include "dw_space.h" - -/* 寄存器读写缓存, 使用全局是为了减少变量分配和释放的时间 */ -static rt_uint8_t reg_rx_buffer[RT_DW_FRAME_BUFFER_MAX_LENGTH]; -static rt_uint8_t reg_tx_buffer[RT_DW_FRAME_BUFFER_MAX_LENGTH]; - -/* 变量读写缓存, 使用全局是为了减少变量分配和释放的时间 */ -static rt_uint8_t var_rx_buffer[RT_DW_FRAME_BUFFER_MAX_LENGTH]; -static rt_uint8_t var_tx_buffer[RT_DW_FRAME_BUFFER_MAX_LENGTH]; - -/* 读寄存器空间等待响应, 线程安全阻塞等待 */ -static rt_err_t wait_read_reg_response(rt_device_dw_t device, rt_uint8_t length, rt_uint8_t *rx_data, rt_tick_t timeout) -{ - rt_uint8_t c; - rt_uint8_t rx_count = 0; - rt_tick_t timeout_tick = 0; - rt_uint8_t response_length = 0; - - RT_ASSERT(device != RT_NULL); - RT_ASSERT(rx_data != RT_NULL); - - response_length = length + 6; - timeout_tick = rt_tick_get() + timeout; - - while(rx_count != response_length) - { - /* 判断等待响应是否超时 */ - if(rt_tick_get() >= timeout_tick) - { - return RT_ETIMEOUT; - } - - /* 获取响应字节 */ - if(device->ops->read(device->parent, (char *)&c) == RT_EOK) - { - rx_data[rx_count++] = c; - } - } - - return RT_EOK; -} - -/* 读变量空间等待响应, 线程安全阻塞等待 */ -static rt_err_t wait_read_var_response(rt_device_dw_t device, rt_uint8_t length, rt_uint8_t *rx_data, rt_tick_t timeout) -{ - rt_uint8_t c; - rt_uint8_t rx_count = 0; - rt_tick_t timeout_tick = 0; - rt_uint8_t response_length = 0; - - RT_ASSERT(device != RT_NULL); - RT_ASSERT(rx_data != RT_NULL); - - response_length = length*2 + 7; - timeout_tick = rt_tick_get() + timeout; - - while(rx_count != response_length) - { - /* 判断等待响应是否超时 */ - if(rt_tick_get() >= timeout_tick) - { - return RT_ETIMEOUT; - } - - /* 获取响应字节 */ - if(device->ops->read(device->parent, (char *)&c) == RT_EOK) - { - rx_data[rx_count++] = c; - } - } - - return RT_EOK; -} - -/* 读寄存器空间 */ -rt_err_t rt_dw_read_reg_space(rt_device_dw_t device, rt_uint8_t addr, rt_uint8_t length, rt_uint8_t *rx_data) -{ - rt_uint8_t index = 0; - rt_err_t ret = RT_ERROR; - - RT_ASSERT(device != RT_NULL); - RT_ASSERT(rx_data != RT_NULL); - - /* 检测迪文屏幕设备是否已经初始化 */ - if(device->state == RT_DW_STATE_UNINIT) - { - /* 迪文屏幕未初始化 */ - return RT_ENOSYS; - } - -#if 0 - if((addr < RT_DW_REG_SPACE_MIN_ADDRESS) || (addr > RT_DW_REG_SPACE_MAX_ADDRESS)) - { - /* 读寄存器空间地址错误 */ - return RT_ERROR; - } -#endif - - /* 锁住资源 */ - RT_DW_CRITICAL_START(); - - /* 发送准备读的寄存器空间地址与长度 */ - reg_tx_buffer[RT_DW_REG_SPACE_FRAME_HIGH_OFFSET] = RT_DW_FRMAE_HIGH_CONTENT; - reg_tx_buffer[RT_DW_REG_SPACE_FRAME_LOW_OFFSET] = RT_DW_FRMAE_LOW_CONTENT; - - /* 准备读取的寄存器空间数据长度不可能超过1个字节, 所以数据段只可能是1, 所以长度就固定了 */ - reg_tx_buffer[RT_DW_REG_SPACE_DATA_LENGTH_OFFSET] = 3; - reg_tx_buffer[RT_DW_REG_SPACE_COMMAND_OFFSET] = RT_DW_COMMAND_READ_REG_SPACE; - reg_tx_buffer[RT_DW_REG_SPACE_ADDRESS_OFFSET] = addr; - reg_tx_buffer[RT_DW_REG_SPACE_DATA_OFFSET] = length; - - /* 读寄存器空间发送的帧数据长度固定为6个字节 */ - for(index = 0; index < 6; index++) - { - ret = device->ops->write(device->parent, (char *)®_tx_buffer[index]); - - if(ret != RT_EOK) - { - /* 读数据错误 */ - RT_DW_CRITICAL_END(); - - return ret; - } - } - - /* 等待迪文屏幕响应待询问的数据 */ - ret = wait_read_reg_response(device, length, reg_rx_buffer, RT_TICK_PER_SECOND/10); - - if(ret != RT_EOK) - { - /* 等待响应超时 */ - RT_DW_CRITICAL_END(); - - return ret; - } - - /* 简单验证响应数据是否正确 */ - if((reg_rx_buffer[RT_DW_REG_SPACE_FRAME_HIGH_OFFSET] != RT_DW_FRMAE_HIGH_CONTENT) || - (reg_rx_buffer[RT_DW_REG_SPACE_FRAME_LOW_OFFSET] != RT_DW_FRMAE_LOW_CONTENT) || - (reg_rx_buffer[RT_DW_REG_SPACE_DATA_LENGTH_OFFSET] != length + 3) || - (reg_rx_buffer[RT_DW_REG_SPACE_COMMAND_OFFSET] != RT_DW_COMMAND_READ_REG_SPACE) || - (reg_rx_buffer[RT_DW_REG_SPACE_ADDRESS_OFFSET] != addr) || - (reg_rx_buffer[RT_DW_REG_SPACE_DATA_OFFSET] != length)) - { - /* 读命令获取的响应帧错误 */ - RT_DW_CRITICAL_END(); - - return RT_ERROR; - } - - for(index = 0; index < length; index++) - { - rx_data[index] = reg_rx_buffer[RT_DW_REG_SPACE_DATA_OFFSET+1+index]; - } - - /* 释放资源 */ - RT_DW_CRITICAL_END(); - - return RT_EOK; -} - -/* 写寄存器空间 */ -rt_err_t rt_dw_write_reg_space(rt_device_dw_t device, rt_uint8_t addr, rt_uint8_t length, rt_uint8_t *tx_data) -{ - rt_uint8_t index = 0; - rt_err_t ret = RT_ERROR; - - RT_ASSERT(device != RT_NULL); - RT_ASSERT(tx_data != RT_NULL); - - /* 检测迪文屏幕设备是否已经初始化 */ - if(device->state == RT_DW_STATE_UNINIT) - { - /* 迪文屏幕未初始化 */ - return RT_ENOSYS; - } - -#if 0 - if((addr < RT_DW_REG_SPACE_MIN_ADDRESS) || (addr > RT_DW_REG_SPACE_MAX_ADDRESS)) - { - /* 读寄存器空间地址错误 */ - return RT_ERROR; - } -#endif - - RT_DW_CRITICAL_START(); - - /* 发送准备写的寄存器地址与长度和内容 */ - reg_tx_buffer[RT_DW_REG_SPACE_FRAME_HIGH_OFFSET] = RT_DW_FRMAE_HIGH_CONTENT; - reg_tx_buffer[RT_DW_REG_SPACE_FRAME_LOW_OFFSET] = RT_DW_FRMAE_LOW_CONTENT; - reg_tx_buffer[RT_DW_REG_SPACE_DATA_LENGTH_OFFSET] = length + 2; - reg_tx_buffer[RT_DW_REG_SPACE_COMMAND_OFFSET] = RT_DW_COMMAND_WRITE_REG_SPACE; - reg_tx_buffer[RT_DW_REG_SPACE_ADDRESS_OFFSET] = addr; - - for(index = 0; index < (length + 5); index++) - { - reg_tx_buffer[RT_DW_REG_SPACE_DATA_OFFSET + index] = tx_data[index]; - } - - /* 写寄存器空间 */ - for(index = 0; index < (length + 5); index++) - { - ret = device->ops->write(device->parent, (char *)®_tx_buffer[index]); - - if(ret != RT_EOK) - { - /* 读数据错误 */ - RT_DW_CRITICAL_END(); - - return ret; - } - } - - RT_DW_CRITICAL_END(); - - return RT_EOK; -} - -rt_err_t rt_dw_read_var_space(rt_device_dw_t device, rt_uint16_t addr, rt_uint8_t length, rt_uint16_t *rx_data) -{ - rt_uint8_t index = 0; - rt_err_t ret = RT_ERROR; - - RT_ASSERT(device != RT_NULL); - RT_ASSERT(rx_data != RT_NULL); - - /* 检测迪文屏幕设备是否已经初始化 */ - if(device->state == RT_DW_STATE_UNINIT) - { - /* 迪文屏幕未初始化 */ - return RT_ENOSYS; - } - -#if 1 - if(/*(addr < RT_DW_REG_SPACE_MIN_ADDRESS) || */(addr > RT_DW_REG_SPACE_MAX_ADDRESS)) - { - /* 读寄存器空间地址错误 */ - return RT_ERROR; - } -#endif - - RT_DW_CRITICAL_START(); - - /* 发送准备读的变量空间地址与长度 */ - var_tx_buffer[RT_DW_VAR_SPACE_FRAME_HIGH_OFFSET] = RT_DW_FRMAE_HIGH_CONTENT; - var_tx_buffer[RT_DW_VAR_SPACE_FRAME_LOW_OFFSET] = RT_DW_FRMAE_LOW_CONTENT; - - /* 准备读取的变量空间数据长度不可能超过1个字节, 所以数据段只可能是1, 所以长度就固定了 */ - var_tx_buffer[RT_DW_VAR_SPACE_DATA_LENGTH_OFFSET] = 4; - var_tx_buffer[RT_DW_VAR_SPACE_COMMAND_OFFSET] = RT_DW_COMMAND_READ_VAR_SPACE; - var_tx_buffer[RT_DW_VAR_SPACE_ADDRESS_OFFSET] = (rt_uint8_t)((addr & 0xFF00) >> 8); - var_tx_buffer[RT_DW_VAR_SPACE_ADDRESS_OFFSET+1] = (rt_uint8_t)((addr & 0x00FF) >> 0); - var_tx_buffer[RT_DW_VAR_SPACE_DATA_OFFSET] = length; - - /* 读变量空间发送的帧数据长度固定为7个字节 */ - for(index = 0; index < 7; index++) - { - ret = device->ops->write(device->parent, (char *)&var_tx_buffer[index]); - - if(ret != RT_EOK) - { - /* 读数据错误 */ - RT_DW_CRITICAL_END(); - - return ret; - } - } - - /* 等待迪文屏幕响应待询问的数据 */ - ret = wait_read_var_response(device, length, var_rx_buffer, RT_TICK_PER_SECOND/10); - - if(ret != RT_EOK) - { - /* 等待响应超时 */ - RT_DW_CRITICAL_END(); - - return ret; - } - - /* 简单验证响应数据是否正确 */ - if((var_rx_buffer[RT_DW_VAR_SPACE_FRAME_HIGH_OFFSET] != RT_DW_FRMAE_HIGH_CONTENT) || - (var_rx_buffer[RT_DW_VAR_SPACE_FRAME_LOW_OFFSET] != RT_DW_FRMAE_LOW_CONTENT) || - (var_rx_buffer[RT_DW_VAR_SPACE_DATA_LENGTH_OFFSET] != length*2 + 4) || - (var_rx_buffer[RT_DW_VAR_SPACE_COMMAND_OFFSET] != RT_DW_COMMAND_READ_VAR_SPACE) || - (var_rx_buffer[RT_DW_VAR_SPACE_ADDRESS_OFFSET] != (rt_uint8_t)((addr & 0xFF00) >> 8)) || - (var_rx_buffer[RT_DW_VAR_SPACE_ADDRESS_OFFSET+1] != (rt_uint8_t)((addr & 0x00FF) >> 0)) || - (var_rx_buffer[RT_DW_VAR_SPACE_DATA_OFFSET] != length)) - { - /* 读命令获取的响应帧错误 */ - RT_DW_CRITICAL_END(); - - return RT_ERROR; - } - - for(index = 0; index < length*2; index += 2) - { - ((rt_uint8_t *)rx_data)[index + 0] = (rt_uint8_t)var_rx_buffer[RT_DW_VAR_SPACE_DATA_OFFSET + 2 + index]; - ((rt_uint8_t *)rx_data)[index + 1] = (rt_uint8_t)var_rx_buffer[RT_DW_VAR_SPACE_DATA_OFFSET + 1 + index]; - } - - RT_DW_CRITICAL_END(); - - return RT_EOK; -} - -/* 写变量空间 */ -rt_err_t rt_dw_write_var_space(rt_device_dw_t device, rt_uint16_t addr, rt_uint8_t length, rt_uint16_t *tx_data) -{ - rt_uint8_t index = 0; - rt_err_t ret = RT_ERROR; - - RT_ASSERT(device != RT_NULL); - RT_ASSERT(tx_data != RT_NULL); - - /* 检测迪文屏幕设备是否已经初始化 */ - if(device->state == RT_DW_STATE_UNINIT) - { - /* 迪文屏幕未初始化 */ - return RT_ENOSYS; - } - -#if 1 - if(/*(addr < RT_DW_REG_SPACE_MIN_ADDRESS) || */(addr > RT_DW_REG_SPACE_MAX_ADDRESS)) - { - /* 读寄存器空间地址错误 */ - return RT_ERROR; - } -#endif - - RT_DW_CRITICAL_START(); - - /* 发送准备写的变量地址与长度和内容 */ - var_tx_buffer[RT_DW_VAR_SPACE_FRAME_HIGH_OFFSET] = RT_DW_FRMAE_HIGH_CONTENT; - var_tx_buffer[RT_DW_VAR_SPACE_FRAME_LOW_OFFSET] = RT_DW_FRMAE_LOW_CONTENT; - var_tx_buffer[RT_DW_VAR_SPACE_DATA_LENGTH_OFFSET] = length*2 + 3; - var_tx_buffer[RT_DW_VAR_SPACE_COMMAND_OFFSET] = RT_DW_COMMAND_WRITE_VAR_SPACE; - var_tx_buffer[RT_DW_VAR_SPACE_ADDRESS_OFFSET] = (rt_uint8_t)((addr & 0xFF00) >> 8); - var_tx_buffer[RT_DW_VAR_SPACE_ADDRESS_OFFSET+1] = (rt_uint8_t)((addr & 0x00FF) >> 0); - - for(index = 0; index < length*2; index += 2) - { - var_tx_buffer[RT_DW_VAR_SPACE_DATA_OFFSET + index] = ((char *)tx_data)[index + 1]; - var_tx_buffer[RT_DW_VAR_SPACE_DATA_OFFSET + index + 1] = ((char *)tx_data)[index]; - } - - /* 写变量空间 */ - for(index = 0; index < (length*2 + 6); index++) - { - ret = device->ops->write(device->parent, (char *)&var_tx_buffer[index]); - - if(ret != RT_EOK) - { - /* 读数据错误 */ - RT_DW_CRITICAL_END(); - - return ret; - } - } - - RT_DW_CRITICAL_END(); - - return RT_EOK; -} - -/* 读参数寄存器, 参数寄存器是在FLASH ID12的系统区域, 但是参数寄存器映射到了寄存器空间 */ -rt_err_t rt_dw_read_para_reg(rt_device_dw_t device, rt_uint8_t addr, rt_uint8_t *rx_data) -{ - rt_err_t ret = RT_ERROR; - - ret = rt_dw_read_reg_space(device, addr, 1, rx_data); - - if(ret != RT_EOK) - { - /* 读寄存器空间错误 */ - return ret; - } - - return RT_EOK; -} - -/* 写参数寄存器, 参数寄存器是在FLASH ID12的系统区域, 但是参数寄存器映射到了寄存器空间 */ -rt_err_t rt_dw_write_para_reg(rt_device_dw_t device, rt_uint8_t addr, rt_uint8_t tx_data) -{ - rt_err_t ret = RT_ERROR; - - ret = rt_dw_write_reg_space(device, addr, 1, &tx_data); - - if(ret != RT_EOK) - { - /* 写寄存器空间错误 */ - return ret; - } - - return RT_EOK; -} diff --git a/old/dwlib/dw.h b/old/dwlib/dw.h deleted file mode 100644 index 5b05f64..0000000 --- a/old/dwlib/dw.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef __DW_H_ -#define __DW_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "dw_init.h" - -#if defined(RT_USING_DW_CMD) - #include "dw_cmd.h" -#endif - -#if defined(RT_USING_DW_SYSTEM) - #include "dw_system.h" -#endif - -#if defined(RT_USING_DW_LOGIN) - #include "dw_login.h" -#endif - -#if defined(RT_USING_DW_VICON) - #include "dw_vicon.h" -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/old/dwlib/dw_define.h b/old/dwlib/dw_define.h deleted file mode 100644 index eaecf13..0000000 --- a/old/dwlib/dw_define.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef __DW_DEFINE_H_ -#define __DW_DEFINE_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* 默认时差:东8区 */ -#ifndef RT_DW_TIME_DIFFEREBCE -#define RT_DW_TIME_DIFFEREBCE (8) -#endif - -/* 临界代码区 */ -#define RT_DW_CRITICAL_START rt_enter_critical -#define RT_DW_CRITICAL_END rt_exit_critical - -/* 位操作宏 */ -#define RT_DW_SET_BIT(REG, BIT) ((REG) |= (BIT)) -#define RT_DW_CLR_BIT(REG, BIT) ((REG) &= ~(BIT)) -#define RT_DW_READ_BIT(REG, BIT) ((REG) & (BIT)) - -/* 使能宏 */ -#define RT_DW_DISABLE (0) -#define RT_DW_ENABLE (1) - -/* 迪文屏幕状态 */ -typedef enum -{ - RT_DW_STATE_UNINIT = 0, - RT_DW_STATE_INIT, -}rt_dw_state_t; - -/* 迪文屏幕底层读写数据接口 */ -struct rt_dw_ops -{ - rt_err_t (*read) (rt_device_t device, char *c); - rt_err_t (*write)(rt_device_t device, char *c); -}; -typedef struct rt_dw_ops* rt_dw_ops_t; - -/* 迪文设备句柄结构体 */ -struct rt_device_dw -{ - rt_device_t parent; /* 迪文屏幕句柄 */ - - rt_dw_state_t state; /* 迪文屏幕的状态 */ - rt_dw_ops_t ops; /* 迪文屏幕底层操作函数指针 */ -}; -typedef struct rt_device_dw* rt_device_dw_t; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/old/dwlib/plugins/cmd/dw_cmd.c b/old/dwlib/plugins/cmd/dw_cmd.c deleted file mode 100644 index 17f53ae..0000000 --- a/old/dwlib/plugins/cmd/dw_cmd.c +++ /dev/null @@ -1,471 +0,0 @@ -#include "dw_cmd.h" - -#include - -rt_device_dw_t cmd_device = RT_NULL; - -/* 系统功能插件 */ - -/* 获取固件版本 */ -rt_uint8_t fw_version(void) -{ - rt_uint8_t version = rt_dw_fw_version(cmd_device); - - rt_kprintf("[dwin] fw version 0x%x\n", version); - - return version; -} -FINSH_FUNCTION_EXPORT_ALIAS(fw_version, dwver, dwinlib read reg space); -MSH_CMD_EXPORT_ALIAS (fw_version, dwver, dwinlib read reg space); - -/* 获取当前背光亮度, 亮度为0x00~0x40 */ -rt_uint8_t now_bl(void) -{ - rt_uint8_t now_bl = rt_dw_get_now_bl(cmd_device); - - rt_kprintf("[dwin] now backlight level 0x%x\n", now_bl); - - return now_bl; -} -FINSH_FUNCTION_EXPORT_ALIAS(now_bl, dwnbl, dwin srceen now backlight level); -MSH_CMD_EXPORT_ALIAS (now_bl, dwnbl, dwin srceen now backlight level); - -/* 设置当前背光亮度, 亮度为0x00~0x40 */ -rt_err_t set_now_bl(rt_uint8_t now_bl) -{ - rt_err_t ret = RT_EOK; - - ret = rt_dw_set_now_bl(cmd_device, now_bl); - - if(ret == RT_EOK) - { - rt_kprintf("[dwin] now backlight level set succeed\n"); - } - - return ret; -} -FINSH_FUNCTION_EXPORT_ALIAS(set_now_bl, dwsnbl, dwin srceen set now backlight level); -MSH_CMD_EXPORT_ALIAS (set_now_bl, dwsnbl, dwin srceen set now backlight level); - -/* 控制蜂鸣n*10ms */ -rt_err_t beep_nx10ms(rt_uint8_t time) -{ - rt_err_t ret = RT_EOK; - - ret = rt_dw_beep_nx10ms(cmd_device, time); - - if(ret == RT_EOK) - { - rt_kprintf("[dwin] beep succeed\n"); - } - - return ret; -} -FINSH_FUNCTION_EXPORT_ALIAS(beep_nx10ms, dwbeep, dwin srceen beep n*10ms); -MSH_CMD_EXPORT_ALIAS (beep_nx10ms, dwbeep, dwin srceen beep n*10ms); - -/* 获取当前页 */ -rt_uint16_t get_now_pageid(void) -{ - rt_uint16_t page_id = 0; - - page_id = rt_dw_get_now_pageid(cmd_device); - - rt_kprintf("[dwin] now page id %d\n", page_id); - - return page_id; -} -FINSH_FUNCTION_EXPORT_ALIAS(get_now_pageid, dwgpage, get dwin srceen now page id); -MSH_CMD_EXPORT_ALIAS (get_now_pageid, dwgpage, get dwin srceen now page id); - -/* 跳转到指定页面, 但是弹窗不会关闭, 所以在迪文屏幕有弹窗出现时, 不要调用该函数 */ -rt_err_t jump_page(rt_uint16_t id) -{ - rt_err_t ret = RT_EOK; - - ret = rt_dw_jump_page(cmd_device, id); - - if(ret == RT_EOK) - { - rt_kprintf("[dwin] jump page id %d succeed\n", id); - } - - return ret; -} -FINSH_FUNCTION_EXPORT_ALIAS(jump_page, dwjump, jump the specified page id); -MSH_CMD_EXPORT_ALIAS (jump_page, dwjump, jump the specified page id); - -/* 获取当前波特率 */ -rt_uint8_t baudrate(void) -{ - rt_uint8_t baudrate = 0; - - baudrate = rt_dw_baudrate(cmd_device); - - rt_kprintf("[dwin] baudrate = "); - - switch(baudrate) - { - case 0x00: rt_kprintf("1200bps\n"); break; - case 0x01: rt_kprintf("2400bps\n"); break; - case 0x02: rt_kprintf("4800bps\n"); break; - case 0x03: rt_kprintf("9600bps\n"); break; - case 0x04: rt_kprintf("19200bps\n"); break; - case 0x05: rt_kprintf("38400bps\n"); break; - case 0x06: rt_kprintf("57600bps\n"); break; - case 0x07: rt_kprintf("115200bps\n"); break; - case 0x08: rt_kprintf("288000bps\n"); break; - case 0x09: rt_kprintf("768000bps\n"); break; - case 0x0A: rt_kprintf("625000bps\n"); break; - case 0x0B: rt_kprintf("1250000bps\n"); break; - case 0x0C: rt_kprintf("2500000bps\n"); break; - case 0x0D: rt_kprintf("2304000bps\n"); break; - case 0x0E: rt_kprintf("3456000bps\n"); break; - case 0x0F: rt_kprintf("6912000bps\n"); break; - case 0x10: rt_kprintf("9216000bps\n"); break; - } - - return baudrate; -} -FINSH_FUNCTION_EXPORT_ALIAS(baudrate, dwbaudrate, dwin dwbaudrate); -MSH_CMD_EXPORT_ALIAS (baudrate, dwbaudrate, dwin dwbaudrate); - -/* 设置屏幕旋转方向 */ -rt_err_t set_screen_dir(rt_dw_screen_dir_t dir) -{ - rt_err_t ret = RT_EOK; - - ret = rt_dw_set_screen_dir(cmd_device, dir); - - if(ret == RT_EOK) - { - rt_kprintf("[dwin] set screen dir succeed\n"); - } - - return ret; -} -FINSH_FUNCTION_EXPORT_ALIAS(set_screen_dir, dwsdir, set dwin screen dir); -MSH_CMD_EXPORT_ALIAS (set_screen_dir, dwsdir, set dwin screen dir); - -/* 获取当前屏幕方向 */ -rt_uint8_t get_screen_dir(void) -{ - rt_err_t ret = RT_EOK; - rt_dw_screen_dir_t dir; - - ret = rt_dw_get_screen_dir(cmd_device, &dir); - - if(ret == RT_EOK) - { - rt_kprintf("[dwin] now screen dir\n"); - } - - switch(dir) - { - case RT_DW_SCREEN_DIR_000: rt_kprintf("000 DIR\n"); break; - case RT_DW_SCREEN_DIR_090: rt_kprintf("090 DIR\n"); break; - case RT_DW_SCREEN_DIR_180: rt_kprintf("180 DIR\n"); break; - case RT_DW_SCREEN_DIR_270: rt_kprintf("270 DIR\n"); break; - } - - return (rt_uint8_t)dir; -} -FINSH_FUNCTION_EXPORT_ALIAS(get_screen_dir, dwgdir, get dwin screen dir); -MSH_CMD_EXPORT_ALIAS (get_screen_dir, dwgdir, get dwin screen dir); - -/* 获取背光是否由触摸控制, 0背光不受触摸控制, 1背光受触摸控制 */ -rt_uint8_t get_bl_ctr_enable(void) -{ - rt_err_t ret = RT_EOK; - rt_uint8_t enable; - - ret = rt_dw_get_bl_ctr_enable(cmd_device, &enable); - - if(ret == RT_EOK) - { - rt_kprintf("[dwin] backlight level ctr is enable = %d\n", enable); - } - - return enable; -} -FINSH_FUNCTION_EXPORT_ALIAS(get_bl_ctr_enable, dwgblce, get backlight level ctr is enable); -MSH_CMD_EXPORT_ALIAS (get_bl_ctr_enable, dwgblce, get backlight level ctr is enable); - -/* 获取是否开启帧CRC功能, 0未启动, 1启动 */ -rt_uint8_t get_crc_enable(void) -{ - rt_err_t ret = RT_EOK; - rt_uint8_t enable; - - ret = rt_dw_get_crc_enable(cmd_device, &enable); - - if(ret == RT_EOK) - { - rt_kprintf("[dwin] serial port crc is enable = %d\n", enable); - } - - return enable; -} -FINSH_FUNCTION_EXPORT_ALIAS(get_crc_enable, dwgcrc, get serial port crc is enable); -MSH_CMD_EXPORT_ALIAS (get_crc_enable, dwgcrc, get serial port ctr is enable); - -/* 设置是否开启帧CRC功能, 0未启动, 1启动 */ -rt_err_t set_crc_enable(rt_uint8_t enable) -{ - rt_err_t ret = RT_EOK; - - ret = rt_dw_set_crc_enable(cmd_device, enable); - - if(ret == RT_EOK) - { - rt_kprintf("[dwin] set serial port crc succeed\n"); - } - - return ret; -} -FINSH_FUNCTION_EXPORT_ALIAS(set_crc_enable, dwscrc, set serial port crc enable); -MSH_CMD_EXPORT_ALIAS (set_crc_enable, dwscrc, set serial port ctr enable); - -/* 获取触摸数据是否自动上传 */ -rt_uint8_t get_data_auto_update(void) -{ - rt_err_t ret = RT_EOK; - rt_uint8_t enable; - - ret = rt_dw_get_data_auto_update(cmd_device, &enable); - - if(ret == RT_EOK) - { - rt_kprintf("[dwin] dwin data auto update enable = %d\n", enable); - } - - return enable; -} -FINSH_FUNCTION_EXPORT_ALIAS(get_data_auto_update, dwgupdata, get data auto update); -MSH_CMD_EXPORT_ALIAS (get_data_auto_update, dwgupdata, get data auto update); - -/* 设置触摸数据是否自动上传 */ -rt_err_t set_data_auto_update(rt_uint8_t enable) -{ - rt_err_t ret = RT_EOK; - - ret = rt_dw_set_data_auto_update(cmd_device, enable); - - if(ret == RT_EOK) - { - rt_kprintf("[dwin] set data auto update succeed\n"); - } - - return ret; -} -FINSH_FUNCTION_EXPORT_ALIAS(set_data_auto_update, dwsupdata, set data auto update); -MSH_CMD_EXPORT_ALIAS (set_data_auto_update, dwsupdata, set data auto update); - -/* 获取数据寄存器上电初始化模式, 0上电初始化为0x00, 1上电有L22字库文件加载 */ -rt_uint8_t get_var_init_mode(void) -{ - rt_dw_var_init_mode_t mode; - rt_err_t ret = RT_EOK; - - ret = rt_dw_get_var_init_mode(cmd_device, &mode); - - if(ret == RT_EOK) - { - rt_kprintf("[dwin] get var init mode = %d\n", mode); - } - - return (rt_uint8_t)mode; -} -FINSH_FUNCTION_EXPORT_ALIAS(get_var_init_mode, dwgvim, get var init mode); -MSH_CMD_EXPORT_ALIAS (get_var_init_mode, dwgvim, get var init mode); - -/* 设置数据寄存器上电初始化模式, 0上电初始化为0x00, 1上电有L22字库文件加载 */ -rt_err_t set_var_init_mode(rt_dw_var_init_mode_t mode) -{ - rt_err_t ret = RT_EOK; - - ret = rt_dw_set_var_init_mode(cmd_device, mode); - - if(ret == RT_EOK) - { - rt_kprintf("[dwin] set var init mode succeed\n"); - } - - return ret; -} -FINSH_FUNCTION_EXPORT_ALIAS(set_var_init_mode, dwsvim, set var init mode); -MSH_CMD_EXPORT_ALIAS (set_var_init_mode, dwsvim, set var init mode); - -/* 获取蜂鸣器是否开启, 0开启 1未开启 */ -rt_uint8_t get_buzzer_enable(void) -{ - rt_uint8_t enable; - rt_err_t ret = RT_EOK; - - ret = rt_dw_get_buzzer_enable(cmd_device, &enable); - - if(ret == RT_EOK) - { - rt_kprintf("[dwin] dwin buzzer enable = %d\n", enable); - } - - return (rt_uint8_t)enable; -} -FINSH_FUNCTION_EXPORT_ALIAS(get_buzzer_enable, dwgbuzzer, get buzzer enable); -MSH_CMD_EXPORT_ALIAS (get_buzzer_enable, dwgbuzzer, get buzzer enable); - -/* 设置蜂鸣器是否开启, 0开启 1未开启 */ -rt_err_t set_buzzer_enable(rt_uint8_t enable) -{ - rt_err_t ret = RT_EOK; - - ret = rt_dw_set_buzzer_enable(cmd_device, enable); - - if(ret == RT_EOK) - { - rt_kprintf("[dwin] set buzzer enable succeed\n"); - } - - return ret; -} -FINSH_FUNCTION_EXPORT_ALIAS(set_buzzer_enable, dwsbuzzer, set buzzer enable); -MSH_CMD_EXPORT_ALIAS (set_buzzer_enable, dwsbuzzer, set buzzer enable); - -/* 获取RTC时间 */ -rt_err_t get_rtc(void) -{ - rt_err_t ret = RT_EOK; - rt_uint8_t year, month, day, hour, minute, seconds; - - ret = rt_dw_get_rtc(cmd_device, &year, &month, &day, &hour, &minute, &seconds); - - if(ret == RT_EOK) - { - rt_kprintf("[dwin] time 20%d-%d-%d %d:%d:%d\n", - year, month, day, hour, minute, seconds); - } - - return ret; -} -FINSH_FUNCTION_EXPORT_ALIAS(get_rtc, dwgrtc, get dwin rtc); -MSH_CMD_EXPORT_ALIAS (get_rtc, dwgrtc, get dwin rtc); - -/* 设置RTC时间 */ -rt_err_t set_rtc(rt_uint8_t year, rt_uint8_t month, rt_uint8_t day, - rt_uint8_t hour, rt_uint8_t minute, rt_uint8_t seconds) -{ - rt_err_t ret = RT_EOK; - - ret = rt_dw_set_rtc(cmd_device, year, month, day, hour, minute, seconds); - - if(ret == RT_EOK) - { - rt_kprintf("[dwin] set rtc time succeed\n"); - } - - return ret; -} -FINSH_FUNCTION_EXPORT_ALIAS(set_rtc, dwsrtc, set dwin rtc); -MSH_CMD_EXPORT_ALIAS (set_rtc, dwsrtc, set dwin rtc); - -/* 使用时间戳设置RTC时间 */ -rt_err_t set_rtc_timestamp(const time_t timestamp) -{ - rt_err_t ret = RT_EOK; - - ret = rt_dw_set_rtc_timestamp(cmd_device, timestamp); - - if(ret == RT_EOK) - { - rt_kprintf("[dwin] set timestamp succeed\n"); - } - - return ret; -} -FINSH_FUNCTION_EXPORT_ALIAS(set_rtc_timestamp, dwstimestamp, set dwin timestamp); -MSH_CMD_EXPORT_ALIAS (set_rtc_timestamp, dwstimestamp, set dwin timestamp); - -/* 获取RTC时间戳 */ -time_t get_rtc_timestamp(void) -{ - time_t timestamp; - rt_err_t ret = RT_EOK; - - ret = rt_dw_get_rtc_timestamp(cmd_device, ×tamp); - - if(ret == RT_EOK) - { - rt_kprintf("[dwin] timestamp %ld\n", timestamp); - } - - return timestamp; -} -FINSH_FUNCTION_EXPORT_ALIAS(get_rtc_timestamp, dwgtimestamp, get dwin timestamp); -MSH_CMD_EXPORT_ALIAS (get_rtc_timestamp, dwgtimestamp, get dwin timestamp); - -/* 登陆功能插件 */ -#if defined(RT_USING_DW_LOGIN) - -/* 添加用户密码, 注意要初始化login插件 */ -rt_err_t login_add(rt_uint32_t password) -{ - if(rt_dw_plugins_login_add(password) != RT_NULL) - { - rt_kprintf("[dwin] add login user succeed\n"); - } - - return RT_EOK; -} -FINSH_FUNCTION_EXPORT_ALIAS(login_add, dwadduser, add dwin login user); -MSH_CMD_EXPORT_ALIAS (login_add, dwadduser, add dwin login user); -#endif - -/* 变量图标功能插件 */ -#if defined(RT_USING_DW_VICON) - -/* 添加变量图标 */ -rt_err_t vicon_add(rt_uint16_t addr, rt_uint16_t default_value, - rt_uint16_t min_value, rt_uint16_t max_value) -{ - if(rt_dw_plugins_vicon_add(cmd_device, addr, default_value, min_value, max_value) == RT_NULL) - { - return RT_ERROR; - } - - rt_kprintf("[dwin] add vicon succeed\n"); - - return RT_EOK; -} -FINSH_FUNCTION_EXPORT_ALIAS(vicon_add, dwaddvicon, add dwin vicon); -MSH_CMD_EXPORT_ALIAS (vicon_add, dwaddvicon, add dwin vicon); - -/* 切换图标 */ -rt_err_t vicon_change(rt_uint16_t addr, rt_uint16_t value) -{ - rt_err_t ret = RT_EOK; - - /* 写变量空间 */ - ret = rt_dw_write_var_space(cmd_device, addr, 1, &value); - - if(ret != RT_EOK) - { - /* 写变量空间失败 */ - return ret; - } - - return RT_EOK; -} -FINSH_FUNCTION_EXPORT_ALIAS(vicon_change, dwcgvicon, change dwin vicon); -MSH_CMD_EXPORT_ALIAS (vicon_change, dwcgvicon, change dwin vicon); -#endif - -/* 注册dwinlib cmd插件使用的设备句柄 */ -rt_uint8_t rt_dw_plugins_cmd_init(rt_device_dw_t device) -{ - RT_ASSERT(device != RT_NULL); - - /* 注册cmd插件使用的迪文设备 */ - cmd_device = device; - - return RT_EOK; -} diff --git a/old/dwlib/plugins/cmd/dw_cmd.h b/old/dwlib/plugins/cmd/dw_cmd.h deleted file mode 100644 index 87018a0..0000000 --- a/old/dwlib/plugins/cmd/dw_cmd.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef __DW_CMD_H_ -#define __DW_CMD_H_ - -#include "rtthread.h" -#include "dw_define.h" - -/* 系统插件 */ -#ifdef RT_USING_DW_SYSTEM -#include "dw_system.h" -#endif - -/* 登陆插件 */ -#ifdef RT_USING_DW_LOGIN -#include "dw_login.h" -#endif - -/* 变量图标插件 */ -#ifdef RT_USING_DW_VICON -#include "dw_vicon.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* 注册dwinlib cmd插件使用的设备句柄 */ -rt_uint8_t rt_dw_plugins_cmd_init(rt_device_dw_t device); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/old/dwlib/plugins/login/dw_login.c b/old/dwlib/plugins/login/dw_login.c deleted file mode 100644 index 0142542..0000000 --- a/old/dwlib/plugins/login/dw_login.c +++ /dev/null @@ -1,182 +0,0 @@ -#include "dw_login.h" - -/* 登陆插件内部控制句柄 */ -rt_dw_login_t login_head = RT_DW_LOGIN_DEFAULT; - -/* 登陆插件监控线程 */ -void login_poll_thread_entry(void *p) -{ - rt_device_dw_t device = RT_NULL; - rt_dw_login_password_t *password_temp = RT_NULL; - - rt_uint16_t rx_data[2]; - rt_uint16_t tx_data[2]; - rt_uint32_t password = 0; - - device = (rt_device_dw_t)p; - password_temp = login_head.root_password; - - while(1) - { -__poll_start: - - /* 读取登陆退出标志位地址的键值 */ - rt_dw_read_var_space(device, login_head.login_exit_flag_addr, 1, rx_data); - - /* 判断是否是登陆标志(代表屏幕上登陆事件发生) */ - if(rx_data[0] == login_head.login_flag_value) - { - /* 将登陆事件清除 */ - tx_data[0] = 0xFFFF; - rt_dw_write_var_space(device, login_head.login_exit_flag_addr, 1, tx_data); - - /* 读取密码 */ - rt_dw_read_var_space(device, login_head.password_addr, 2, rx_data); - password = rx_data[0]*65536 + rx_data[1]; - - /* 打印密码便于调试 */ - rt_kprintf("\nuser input password = %d\n", password); - - /* 遍历密码链表 */ - do - { - if(password_temp->password == password) - { - /* 清除密码 */ - tx_data[0] = 0; - tx_data[1] = 0; - rt_dw_write_var_space(device, login_head.password_addr, 2, tx_data); - - /* 密码正确调用回调含食宿 */ - login_head.login_ok(device); - - /* 进入下一次轮询循环 */ - goto __poll_start; - } - - /* 指向下一个密码 */ - password_temp = (rt_dw_login_password_t *)(password_temp->list.next); - - }while(password_temp != login_head.root_password); /* 判断是否遍历完成 */ - - /* 清除密码 */ - tx_data[0] = 0; - tx_data[1] = 0; - rt_dw_write_var_space(device, login_head.password_addr, 2, tx_data); - - /* 所以密码都错误, 判定为错误 */ - login_head.login_error(device); - } - - /* 判断是否是退出标志(代表屏幕上退出事件发生) */ - if(rx_data[0] == login_head.exit_flag_value) - { - /* 将登陆事件清除 */ - tx_data[0] = 0xFFFF; - rt_dw_write_var_space(device, login_head.login_exit_flag_addr, 1, tx_data); - - login_head.exit(device); - } - - rt_thread_delay(RT_TICK_PER_SECOND/10); - } -} - -/* 添加用户密码 */ -rt_dw_login_password_t *rt_dw_plugins_login_add(rt_uint32_t password) -{ - rt_dw_login_password_t *user_password = RT_NULL; - - /* 分配根密码内存 */ - user_password = (rt_dw_login_password_t *)rt_malloc(sizeof(rt_dw_login_password_t)); - - if(user_password == RT_NULL) - { - /* 内存分配失败 */ - return RT_NULL; - } - - /* 初始化链表 */ - rt_list_init(&(user_password->list)); - - /* 尾插入密码链表 */ - rt_list_insert_before(&(login_head.root_password->list), &(user_password->list)); - - /* 添加密码 */ - user_password->password = password; - - return user_password; -} - -/* 删除用户密码 */ -rt_err_t rt_dw_plugins_login_del(rt_dw_login_password_t password) -{ - return RT_EOK; -} - -/* 初始化登陆插件 */ -int rt_dw_plugins_login_init( - rt_device_dw_t device, - rt_uint16_t password_addr, - rt_uint16_t login_exit_flag_addr, - rt_uint16_t login_flag_value, - rt_uint16_t exit_flag_value, - rt_uint32_t root_password, - void (*login_ok)(rt_device_dw_t device), - void (*login_error)(rt_device_dw_t device), - void (*exit)(rt_device_dw_t device)) -{ - rt_uint16_t tx_data[2]; - rt_thread_t login_poll = RT_NULL; - rt_dw_login_password_t *root = RT_NULL; - - RT_ASSERT(login_ok != RT_NULL); - RT_ASSERT(login_error != RT_NULL); - RT_ASSERT(exit != RT_NULL); - - /* 注册密码地址 */ - login_head.password_addr = password_addr; - - /* 清空密码 */ - tx_data[0] = 0; - tx_data[1] = 0; - rt_dw_write_var_space(device, login_head.password_addr, 2, tx_data); - - /* 注册登陆退出标志位地址 */ - login_head.login_exit_flag_addr = login_exit_flag_addr; - - /* 清空密码标志位 */ - tx_data[0] = 0xFFFF; - rt_dw_write_var_space(device, login_head.login_exit_flag_addr, 1, tx_data); - - /* 注册登陆退出键值 */ - login_head.login_flag_value = login_flag_value; - login_head.exit_flag_value = exit_flag_value; - - /* 注册回调函数 */ - login_head.login_ok = login_ok; - login_head.login_error = login_error; - login_head.exit = exit; - - /* 分配根密码内存 */ - root = (rt_dw_login_password_t *)rt_malloc(sizeof(rt_dw_login_password_t)); - login_head.root_password = root; - - /* 添加根密码 */ - login_head.root_password->password = root_password; - - /* 初始化链表 */ - rt_list_init(&(login_head.root_password->list)); - - /* 启动登陆轮询函数 */ - login_poll = rt_thread_create( - "login poll", login_poll_thread_entry, - (void *)device, 512, 4, 10); - - if(login_poll != RT_NULL) - { - rt_thread_startup(login_poll); - } - - return RT_EOK; -} diff --git a/old/dwlib/plugins/login/dw_login.h b/old/dwlib/plugins/login/dw_login.h deleted file mode 100644 index ccfe917..0000000 --- a/old/dwlib/plugins/login/dw_login.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef __DW_LOGIN_H_ -#define __DW_LOGIN_H_ - -#include "dw_space.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define RT_DW_LOGIN_DEFAULT {0xFFFF, RT_NULL} - -/* 密码结点 */ -struct rt_dw_login_password -{ - rt_list_t list; - - rt_uint32_t password; -}; -typedef struct rt_dw_login_password rt_dw_login_password_t; - -/* 登陆插件句柄 */ -struct rt_dw_login -{ - /* 登陆密码地址, 注意该插件要求存储密码为4字节 */ - rt_uint16_t password_addr; - - /* 登陆状态地址, 登陆标志值, 退出标志值 */ - rt_uint16_t login_exit_flag_addr; - rt_uint16_t login_flag_value; - rt_uint16_t exit_flag_value; - - /* 登陆与退出回调函数 */ - void (*login_ok)(rt_device_dw_t device); - void (*login_error)(rt_device_dw_t device); - void (*exit)(rt_device_dw_t device); - - /* 密码链表 */ - rt_dw_login_password_t *root_password; -}; -typedef struct rt_dw_login rt_dw_login_t; - -/* 初始化登陆插件 */ -int rt_dw_plugins_login_init( - rt_device_dw_t device, - rt_uint16_t password_addr, - rt_uint16_t login_exit_flag_addr, - rt_uint16_t login_flag_value, - rt_uint16_t exit_flag_value, - rt_uint32_t root_password, - void (*login_ok)(rt_device_dw_t device), - void (*login_error)(rt_device_dw_t device), - void (*exit)(rt_device_dw_t device)); - -/* 添加用户密码 */ -rt_dw_login_password_t *rt_dw_plugins_login_add(rt_uint32_t password); - -/* 删除用户密码 */ -rt_err_t rt_dw_plugins_login_del(rt_dw_login_password_t password); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/old/dwlib/plugins/readme.md b/old/dwlib/plugins/readme.md deleted file mode 100644 index 56bfca7..0000000 --- a/old/dwlib/plugins/readme.md +++ /dev/null @@ -1,26 +0,0 @@ -# 迪文屏幕组件说明 - -## cicon ## -~~~ -cicon:动画图标 -~~~ - -## login ## -~~~ -login:登陆功能 -~~~ - -## system ## -~~~ -system:系统配置与查看 -~~~ - -## vicon ## -~~~ -vicon:变量图标 -~~~ - -## cmd ## -~~~ -cmd:finsh和msh导出命令 -~~~ \ No newline at end of file diff --git a/old/dwlib/plugins/system/dw_system.c b/old/dwlib/plugins/system/dw_system.c deleted file mode 100644 index 410b40b..0000000 --- a/old/dwlib/plugins/system/dw_system.c +++ /dev/null @@ -1,681 +0,0 @@ -#include "dw_system.h" - -/* 获取迪文屏幕固件版本 */ -rt_uint8_t rt_dw_fw_version(rt_device_dw_t device) -{ - rt_err_t ret = RT_EOK; - rt_uint8_t version = 0; - - RT_ASSERT(device != RT_NULL); - - ret = rt_dw_read_reg_space(device, RT_DW_REG_00H_001_VERSION, 1, &version); - - if(ret != RT_EOK) - { - /* 读寄存器空间错误 */ - return 0; - } - - return version; -} - -/* 获取当前背光亮度, 亮度为0x00~0x40 */ -rt_uint8_t rt_dw_get_now_bl(rt_device_dw_t device) -{ - rt_err_t ret = RT_EOK; - rt_uint8_t now_bl = 0; - - RT_ASSERT(device != RT_NULL); - - ret = rt_dw_read_reg_space(device, RT_DW_REG_01H_001_NOW_BL, 1, &now_bl); - - if(ret != RT_EOK) - { - /* 读寄存器空间错误 */ - return 0; - } - - return now_bl; -} - -/* 设置当前背光亮度, 亮度为0x00~0x40 */ -rt_err_t rt_dw_set_now_bl(rt_device_dw_t device, rt_uint8_t now_bl) -{ - rt_err_t ret = RT_EOK; - - RT_ASSERT(device != RT_NULL); - - ret = rt_dw_write_reg_space(device, RT_DW_REG_01H_001_NOW_BL, 1, &now_bl); - - if(ret != RT_EOK) - { - /* 写寄存器空间错误 */ - return ret; - } - - return RT_EOK; -} - -/* 控制蜂鸣n*10ms */ -rt_err_t rt_dw_beep_nx10ms(rt_device_dw_t device, rt_uint8_t time) -{ - rt_err_t ret = RT_EOK; - - RT_ASSERT(device != RT_NULL); - - ret = rt_dw_write_reg_space(device, RT_DW_REG_02H_001_MAKE_BEEP, 1, &time); - - if(ret != RT_EOK) - { - /* 写寄存器空间错误 */ - return ret; - } - - return RT_EOK; -} - -/* 获取当前页 */ -rt_uint16_t rt_dw_get_now_pageid(rt_device_dw_t device) -{ - rt_err_t ret = RT_EOK; - rt_uint8_t id_temp[2]; - - RT_ASSERT(device != RT_NULL); - - RT_DW_CRITICAL_START(); - ret = rt_dw_read_reg_space(device, RT_DW_REG_03H_002_NOW_PAGEID, 2, id_temp); - RT_DW_CRITICAL_END(); - - if(ret != RT_EOK) - { - /* 读寄存器空间错误 */ - return 0xffff; - } - - return (rt_uint16_t)((id_temp[0] << 8) + id_temp[1]); -} - -/* 跳转到指定页面, 但是弹窗不会关闭, 所以在迪文屏幕有弹窗出现时, 不要调用该函数 */ -rt_err_t rt_dw_jump_page(rt_device_dw_t device, rt_uint16_t id) -{ - rt_err_t ret = RT_EOK; - rt_uint8_t id_temp[2]; - - RT_ASSERT(device != RT_NULL); - - id_temp[0] = (id >> 8); - id_temp[1] = (id << 8) >> 8; - - ret = rt_dw_write_reg_space(device, RT_DW_REG_03H_002_NOW_PAGEID, 2, id_temp); - - if(ret != RT_EOK) - { - /* 读寄存器空间错误 */ - return ret; - } - - return RT_EOK; -} - -/* 获取串口波特率: -[00 "1.2K" ] [01 "2.4K" ] [02 "4.8K" ] [03 "9.6K" ] -[04 "19.2K" ] [05 "38.4K" ] [06 "57.6K" ] [07 "115.2K"] -[08 "28.8K" ] [09 "76.8K" ] [10 "62.5K" ] [11 "125K" ] -[12 "250K" ] [13 "230.4K"] [14 "345.6K"] [15 "691.2K"] -[16 "921.6K"] */ -rt_uint8_t rt_dw_baudrate(rt_device_dw_t device) -{ - rt_err_t ret = RT_EOK; - rt_uint8_t buadrate = 0; - - RT_ASSERT(device != RT_NULL); - - ret = rt_dw_read_reg_space(device, RT_DW_REG_11H_001_BRUDRATE, 1, &buadrate); - - if(ret != RT_EOK) - { - /* 读寄存器空间错误 */ - return 0; - } - - return buadrate; -} - -/* 设置屏幕旋转方向 */ -rt_err_t rt_dw_set_screen_dir(rt_device_dw_t device, rt_dw_screen_dir_t dir) -{ - rt_uint8_t r2 = 0; - rt_err_t ret = RT_EOK; - - RT_ASSERT(device != RT_NULL); - - if(dir > RT_DW_SCREEN_DIR_270) - { - /* 方向参数输入错误 */ - return RT_ERROR; - } - - ret = rt_dw_read_para_reg(device, RT_DW_REG_12H_001_SYSCFG, &r2); - - if(ret != RT_EOK) - { - /* 读参数寄存器错误 */ - return RT_ERROR; - } - - switch(dir) - { - case RT_DW_SCREEN_DIR_000: RT_DW_CLR_BIT(r2, RT_DW_R2BIT6_HDS_MASK); RT_DW_CLR_BIT(r2, RT_DW_R2BIT7_VHS_MASK); break; - case RT_DW_SCREEN_DIR_090: RT_DW_SET_BIT(r2, RT_DW_R2BIT6_HDS_MASK); RT_DW_SET_BIT(r2, RT_DW_R2BIT7_VHS_MASK); break; - case RT_DW_SCREEN_DIR_180: RT_DW_SET_BIT(r2, RT_DW_R2BIT6_HDS_MASK); RT_DW_CLR_BIT(r2, RT_DW_R2BIT7_VHS_MASK); break; - case RT_DW_SCREEN_DIR_270: RT_DW_CLR_BIT(r2, RT_DW_R2BIT6_HDS_MASK); RT_DW_SET_BIT(r2, RT_DW_R2BIT7_VHS_MASK); break; - } - - ret = rt_dw_write_para_reg(device, RT_DW_REG_12H_001_SYSCFG, r2); - - if(ret != RT_EOK) - { - /* 写参数寄存器错误 */ - return RT_ERROR; - } - - return RT_EOK; -} - -/* 获取当前屏幕方向 */ -rt_err_t rt_dw_get_screen_dir(rt_device_dw_t device, rt_dw_screen_dir_t *dir) -{ - rt_uint8_t r2 = 0; - rt_uint8_t r2_6 = 0; - rt_uint8_t r2_7 = 0; - rt_err_t ret = RT_EOK; - - RT_ASSERT(device != RT_NULL); - - ret = rt_dw_read_para_reg(device, RT_DW_REG_12H_001_SYSCFG, &r2); - - if(ret != RT_EOK) - { - /* 读参数寄存器错误 */ - return ret; - } - - /* 获取r2参数寄存器第6和7位 */ - r2_6 = ((RT_DW_READ_BIT(r2, RT_DW_R2BIT6_HDS_MASK) == RT_DW_R2BIT6_HDS_MASK) ? 1:0); - r2_7 = ((RT_DW_READ_BIT(r2, RT_DW_R2BIT7_VHS_MASK) == RT_DW_R2BIT7_VHS_MASK) ? 1:0); - - if((r2_6 == 0) && (r2_7 == 0)) - { - *dir = RT_DW_SCREEN_DIR_000; - } - else if((r2_6 == 0) && (r2_7 == 0)) - { - *dir = RT_DW_SCREEN_DIR_090; - } - else if((r2_6 == 0) && (r2_7 == 0)) - { - *dir = RT_DW_SCREEN_DIR_180; - } - else /* ((r2_6 == 0) && (r2_7 == 0)) */ - { - *dir = RT_DW_SCREEN_DIR_270; - } - - return RT_EOK; -} - -/* 获取背光是否由触摸控制, 0背光不受触摸控制, 1背光受触摸控制 */ -rt_err_t rt_dw_get_bl_ctr_enable(rt_device_dw_t device, rt_uint8_t *enable) -{ - rt_uint8_t r2 = 0; - rt_err_t ret = RT_EOK; - - RT_ASSERT(device != RT_NULL); - - ret = rt_dw_read_para_reg(device, RT_DW_REG_12H_001_SYSCFG, &r2); - - if(ret != RT_EOK) - { - /* 读参数寄存器错误 */ - return ret; - } - - /* 获取r2参数寄存器第5位 */ - *enable = ((RT_DW_READ_BIT(r2, RT_DW_R2BIT5_BL_CTR_MASK) == RT_DW_R2BIT5_BL_CTR_MASK) - ? RT_DW_ENABLE : RT_DW_DISABLE); - - return RT_EOK; -} - -/* 设置背光是否由触摸控制, 0背光不受触摸控制, 1背光受触摸控制 */ -rt_err_t rt_dw_set_bl_ctr_enable(rt_device_dw_t device, rt_uint8_t enable) -{ - rt_uint8_t r2 = 0; - rt_err_t ret = RT_EOK; - - RT_ASSERT(device != RT_NULL); - - ret = rt_dw_read_para_reg(device, RT_DW_REG_12H_001_SYSCFG, &r2); - - if(ret != RT_EOK) - { - /* 读参数寄存器错误 */ - return ret; - } - - if(enable == RT_DW_DISABLE) - { - RT_DW_CLR_BIT(r2, RT_DW_R2BIT5_BL_CTR_MASK); - } - else if(enable == RT_DW_ENABLE) - { - RT_DW_SET_BIT(r2, RT_DW_R2BIT5_BL_CTR_MASK); - } - else - { - /* 输入参数错误 */ - return RT_ERROR; - } - - ret = rt_dw_write_para_reg(device, RT_DW_REG_12H_001_SYSCFG, r2); - - if(ret != RT_EOK) - { - /* 写参数寄存器错误 */ - return RT_ERROR; - } - - return RT_EOK; -} - -/* 获取是否开启帧CRC功能, 0未启动, 1启动 */ -rt_err_t rt_dw_get_crc_enable(rt_device_dw_t device, rt_uint8_t *enable) -{ - rt_uint8_t r2 = 0; - rt_err_t ret = RT_EOK; - - RT_ASSERT(device != RT_NULL); - - ret = rt_dw_read_para_reg(device, RT_DW_REG_12H_001_SYSCFG, &r2); - - if(ret != RT_EOK) - { - /* 读参数寄存器错误 */ - return ret; - } - - /* 获取r2参数寄存器第5位 */ - *enable = ((RT_DW_READ_BIT(r2, RT_DW_R2BIT4_CRC_EN_MASK) == RT_DW_R2BIT4_CRC_EN_MASK) - ? RT_DW_ENABLE : RT_DW_DISABLE); - - return RT_EOK; -} - -/* 设置是否开启帧CRC功能, 0未启动, 1启动 */ -rt_err_t rt_dw_set_crc_enable(rt_device_dw_t device, rt_uint8_t enable) -{ - rt_err_t ret = RT_EOK; - - RT_ASSERT(device != RT_NULL); - -/* 目前已经知道这2款屏幕不支持帧CRC功能 */ -#if defined(RT_USING_DMT48270M043_02W) || defined(RT_USING_DMT48270M050_02W) - ret = RT_ERROR; -#endif - - return ret; -} - -/* 获取触摸数据是否自动上传 */ -rt_err_t rt_dw_get_data_auto_update(rt_device_dw_t device, rt_uint8_t *enable) -{ - rt_uint8_t r2 = 0; - rt_err_t ret = RT_EOK; - - RT_ASSERT(device != RT_NULL); - - ret = rt_dw_read_para_reg(device, RT_DW_REG_12H_001_SYSCFG, &r2); - - if(ret != RT_EOK) - { - /* 读参数寄存器错误 */ - return ret; - } - - /* 获取r2参数寄存器第5位 */ - *enable = ((RT_DW_READ_BIT(r2, RT_DW_R2BIT3_DATA_AUTO_UPLOAD_MASK) == RT_DW_R2BIT3_DATA_AUTO_UPLOAD_MASK) - ? RT_DW_ENABLE : RT_DW_DISABLE); - - return RT_EOK; -} - -/* 设置触摸数据是否自动上传 */ -rt_err_t rt_dw_set_data_auto_update(rt_device_dw_t device, rt_uint8_t enable) -{ - rt_uint8_t r2 = 0; - rt_err_t ret = RT_EOK; - - RT_ASSERT(device != RT_NULL); - - ret = rt_dw_read_para_reg(device, RT_DW_REG_12H_001_SYSCFG, &r2); - - if(ret != RT_EOK) - { - /* 读参数寄存器错误 */ - return ret; - } - - if(enable == RT_DW_DISABLE) - { - RT_DW_CLR_BIT(r2, RT_DW_R2BIT3_DATA_AUTO_UPLOAD_MASK); - } - else if(enable == RT_DW_ENABLE) - { - RT_DW_SET_BIT(r2, RT_DW_R2BIT3_DATA_AUTO_UPLOAD_MASK); - } - else - { - /* 输入参数错误 */ - return RT_ERROR; - } - - ret = rt_dw_write_para_reg(device, RT_DW_REG_12H_001_SYSCFG, r2); - - if(ret != RT_EOK) - { - /* 写参数寄存器错误 */ - return RT_ERROR; - } - - return RT_EOK; -} - -/* 获取数据寄存器上电初始化模式, 0上电初始化为0x00, 1上电有L22字库文件加载 */ -rt_err_t rt_dw_get_var_init_mode(rt_device_dw_t device, rt_dw_var_init_mode_t *mode) -{ - rt_uint8_t r2 = 0; - rt_err_t ret = RT_EOK; - - RT_ASSERT(device != RT_NULL); - - ret = rt_dw_read_para_reg(device, RT_DW_REG_12H_001_SYSCFG, &r2); - - if(ret != RT_EOK) - { - /* 读参数寄存器错误 */ - return ret; - } - - /* 获取r2参数寄存器第5位 */ - *mode = ((RT_DW_READ_BIT(r2, RT_DW_R2BIT2_VAR_INIT_MODE_MASK) == RT_DW_R2BIT2_VAR_INIT_MODE_MASK) - ? RT_DW_VAR_INIT_MODE_1 : RT_DW_VAR_INIT_MODE_0); - - return RT_EOK; -} - -/* 设置数据寄存器上电初始化模式, 0上电初始化为0x00, 1上电有L22字库文件加载 */ -rt_err_t rt_dw_set_var_init_mode(rt_device_dw_t device, rt_dw_var_init_mode_t mode) -{ - rt_uint8_t r2 = 0; - rt_err_t ret = RT_EOK; - - RT_ASSERT(device != RT_NULL); - - ret = rt_dw_read_para_reg(device, RT_DW_REG_12H_001_SYSCFG, &r2); - - if(ret != RT_EOK) - { - /* 读参数寄存器错误 */ - return ret; - } - - if(mode == RT_DW_VAR_INIT_MODE_0) - { - RT_DW_CLR_BIT(r2, RT_DW_R2BIT2_VAR_INIT_MODE_MASK); - } - else if(mode == RT_DW_VAR_INIT_MODE_1) - { - RT_DW_SET_BIT(r2, RT_DW_R2BIT2_VAR_INIT_MODE_MASK); - } - else - { - /* 输入参数错误 */ - return RT_ERROR; - } - - ret = rt_dw_write_para_reg(device, RT_DW_REG_12H_001_SYSCFG, r2); - - if(ret != RT_EOK) - { - /* 写参数寄存器错误 */ - return RT_ERROR; - } - - return RT_EOK; -} - -/* 获取蜂鸣器是否开启, 0开启 1未开启 */ -rt_err_t rt_dw_get_buzzer_enable(rt_device_dw_t device, rt_uint8_t *enable) -{ - rt_uint8_t r2 = 0; - rt_err_t ret = RT_EOK; - - RT_ASSERT(device != RT_NULL); - - ret = rt_dw_read_para_reg(device, RT_DW_REG_12H_001_SYSCFG, &r2); - - if(ret != RT_EOK) - { - /* 读参数寄存器错误 */ - return ret; - } - - /* 获取r2参数寄存器第5位 */ - *enable = ((RT_DW_READ_BIT(r2, RT_DW_R2BIT0_BUZZER_EN_MASK) == RT_DW_R2BIT0_BUZZER_EN_MASK) - ? RT_DW_ENABLE : RT_DW_DISABLE); - - return RT_EOK; -} - -/* 设置蜂鸣器是否开启, 0开启 1未开启 */ -rt_err_t rt_dw_set_buzzer_enable(rt_device_dw_t device, rt_uint8_t enable) -{ - rt_uint8_t r2 = 0; - rt_err_t ret = RT_EOK; - - RT_ASSERT(device != RT_NULL); - - ret = rt_dw_read_para_reg(device, RT_DW_REG_12H_001_SYSCFG, &r2); - - if(ret != RT_EOK) - { - /* 读参数寄存器错误 */ - return ret; - } - - if(enable == RT_DW_DISABLE) - { - RT_DW_CLR_BIT(r2, RT_DW_R2BIT0_BUZZER_EN_MASK); - } - else if(enable == RT_DW_ENABLE) - { - RT_DW_SET_BIT(r2, RT_DW_R2BIT0_BUZZER_EN_MASK); - } - else - { - /* 输入参数错误 */ - return RT_ERROR; - } - - ret = rt_dw_write_para_reg(device, RT_DW_REG_12H_001_SYSCFG, r2); - - if(ret != RT_EOK) - { - /* 写参数寄存器错误 */ - return RT_ERROR; - } - - return RT_EOK; -} - -static rt_uint8_t bcd2decimal(rt_uint8_t bcd) -{ - return bcd-(bcd >> 4)*6; -} - -static rt_uint8_t decimal2bcd(rt_uint8_t decimal) -{ - return (rt_uint8_t)(decimal+(decimal / 10)*6); -} - -/* 获取RTC时间 */ -rt_err_t rt_dw_get_rtc(rt_device_dw_t device, - rt_uint8_t *year, rt_uint8_t *month, rt_uint8_t *day, - rt_uint8_t *hour, rt_uint8_t *minute, rt_uint8_t *seconds) -{ - rt_err_t ret = RT_EOK; - rt_uint8_t date_and_time[7] = {0}; - - ret = rt_dw_read_reg_space(device, RT_DW_REG_20H_016_RTC, 7, date_and_time); - - if(ret != RT_EOK) - { - /* 写寄存器空间错误 */ - return ret; - } - - /* 传入数据到函数入口 */ - *year = bcd2decimal(date_and_time[0]); - *month = bcd2decimal(date_and_time[1]); - *day = bcd2decimal(date_and_time[2]); - *hour = bcd2decimal(date_and_time[4]); - *minute = bcd2decimal(date_and_time[5]); - *seconds = bcd2decimal(date_and_time[6]); - - return RT_EOK; -} - -/* 设置RTC时间 */ -rt_err_t rt_dw_set_rtc(rt_device_dw_t device, - rt_uint8_t year, rt_uint8_t month, rt_uint8_t day, - rt_uint8_t hour, rt_uint8_t minute, rt_uint8_t seconds) -{ - rt_err_t ret = RT_EOK; - rt_uint8_t date_and_time[8]; - - /* 真正的RTC地址为0x20, 但是修改了RTC需要在0x1F处 - 写0x5a表明用户修改了RTC数据, 迪文屏幕在修改系 - RTC后会自动清零 */ - date_and_time[0] = 0x5a; - date_and_time[1] = decimal2bcd(year); - date_and_time[2] = decimal2bcd(month); - date_and_time[3] = decimal2bcd(day); - date_and_time[4] = 0x00; /* 周几, 可以随便设定 */ - date_and_time[5] = decimal2bcd(hour); - date_and_time[6] = decimal2bcd(minute); - date_and_time[7] = decimal2bcd(seconds); - - ret = rt_dw_write_reg_space(device, RT_DW_REG_1FH_001_RTC_UPDATE_FLAG, 8, date_and_time); - - if(ret != RT_EOK) - { - /* 写寄存器空间错误 */ - return ret; - } - - return RT_EOK; -} - -/* 时间戳相关宏与变量 */ -#define MINUTE (60) -#define HOUR (60*MINUTE) -#define DAY (24*HOUR) -#define YEAR (365*DAY) - -static int month[12] = -{ - 0, - DAY*(31), - DAY*(31+29), - DAY*(31+29+31), - DAY*(31+29+31+30), - DAY*(31+29+31+30+31), - DAY*(31+29+31+30+31+30), - DAY*(31+29+31+30+31+30+31), - DAY*(31+29+31+30+31+30+31+31), - DAY*(31+29+31+30+31+30+31+31+30), - DAY*(31+29+31+30+31+30+31+31+30+31), - DAY*(31+29+31+30+31+30+31+31+30+31+30) -}; - -static time_t rt_mktime(struct tm *tm) -{ - long res; - int year; - year = tm->tm_year - 70; - - res = YEAR * year + DAY * ((year + 1) / 4); - res += month[tm->tm_mon]; - - if(tm->tm_mon > 1 && ((year + 2) % 4)) - { - res -= DAY; - } - - res += DAY * (tm->tm_mday - 1); - res += HOUR * tm->tm_hour; - res += MINUTE * tm->tm_min; - res += tm->tm_sec; - - return res; -} - -/* 获取RTC时间戳, 十进制*/ -rt_err_t rt_dw_get_rtc_timestamp(rt_device_dw_t device, time_t *timestamp) -{ - rt_err_t ret = RT_EOK; - rt_uint8_t date_and_time[6] = {0}; - struct tm time; - - ret = rt_dw_get_rtc(device, - &date_and_time[0], &date_and_time[1], &date_and_time[2], - &date_and_time[3], &date_and_time[4], &date_and_time[5]); - - if(ret != RT_EOK) - { - /* 获取RTC错误 */ - return ret; - } - - time.tm_year = date_and_time[0] + 100; - time.tm_mon = date_and_time[1] - 1; - time.tm_mday = date_and_time[2]; - time.tm_hour = date_and_time[3] - RT_DW_TIME_DIFFEREBCE; - time.tm_min = date_and_time[4]; - time.tm_sec = date_and_time[5]; - - *timestamp = rt_mktime(&time); - - return RT_EOK; -} - -/* 使用时间戳设置RTC时间 */ -rt_err_t rt_dw_set_rtc_timestamp(rt_device_dw_t device, const time_t timestamp) -{ - rt_err_t ret = RT_EOK; - struct tm *time = RT_NULL; - - time = localtime(×tamp); - - ret = rt_dw_set_rtc(device, - time->tm_year - 100, time->tm_mon + 1, time->tm_mday, - time->tm_hour + RT_DW_TIME_DIFFEREBCE, time->tm_min, time->tm_sec); - - if(ret != RT_EOK) - { - /* 设置RTC错误 */ - return ret; - } - - return RT_EOK; -} diff --git a/old/dwlib/plugins/system/dw_system.h b/old/dwlib/plugins/system/dw_system.h deleted file mode 100644 index 9717fd8..0000000 --- a/old/dwlib/plugins/system/dw_system.h +++ /dev/null @@ -1,107 +0,0 @@ -#ifndef __DW_SYSTEM_H_ -#define __DW_SYSTEM_H_ - -#include -#include "dw_space.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum -{ - RT_DW_SCREEN_DIR_000 = 0, - RT_DW_SCREEN_DIR_090 = 1, - RT_DW_SCREEN_DIR_180 = 2, - RT_DW_SCREEN_DIR_270 = 3 -}rt_dw_screen_dir_t; - -typedef enum -{ - RT_DW_VAR_INIT_MODE_0 = 0, /* 默认0x00初始化 */ - RT_DW_VAR_INIT_MODE_1 = 1, /* 按照22号字库初始化 */ -}rt_dw_var_init_mode_t; - -/* 获取迪文屏幕固件版本 */ -rt_uint8_t rt_dw_fw_version(rt_device_dw_t device); - -/* 获取当前背光亮度, 亮度为0x00~0x40 */ -rt_uint8_t rt_dw_get_now_bl(rt_device_dw_t device); - -/* 设置当前背光亮度, 亮度为0x00~0x40 */ -rt_err_t rt_dw_set_now_bl(rt_device_dw_t device, rt_uint8_t now_bl); - -/* 控制蜂鸣n*10ms */ -rt_err_t rt_dw_beep_nx10ms(rt_device_dw_t device, rt_uint8_t time); - -/* 获取当前页 */ -rt_uint16_t rt_dw_get_now_pageid(rt_device_dw_t device); - -/* 跳转到指定页面, 但是弹窗不会关闭, 所以在迪文屏幕有弹窗出现时, 不要调用该函数 */ -rt_err_t rt_dw_jump_page(rt_device_dw_t device, rt_uint16_t id); - -/* 获取串口波特率: -[00 "1.2K" ] [01 "2.4K" ] [02 "4.8K" ] [03 "9.6K" ] -[04 "19.2K" ] [05 "38.4K" ] [06 "57.6K" ] [07 "115.2K"] -[08 "28.8K" ] [09 "76.8K" ] [10 "62.5K" ] [11 "125K" ] -[12 "250K" ] [13 "230.4K"] [14 "345.6K"] [15 "691.2K"] -[16 "921.6K"] */ -rt_uint8_t rt_dw_baudrate(rt_device_dw_t device); - -/* 设置屏幕旋转方向 */ -rt_err_t rt_dw_set_screen_dir(rt_device_dw_t device, rt_dw_screen_dir_t dir); - -/* 获取当前屏幕方向 */ -rt_err_t rt_dw_get_screen_dir(rt_device_dw_t device, rt_dw_screen_dir_t *dir); - -/* 获取背光是否由触摸控制, 0背光不受触摸控制, 1背光受触摸控制 */ -rt_err_t rt_dw_get_bl_ctr_enable(rt_device_dw_t device, rt_uint8_t *enable); - -/* 设置背光是否由触摸控制, 0背光不受触摸控制, 1背光受触摸控制 */ -rt_err_t rt_dw_set_bl_ctr_enable(rt_device_dw_t device, rt_uint8_t enable); - -/* 获取是否开启帧CRC功能, 0未启动, 1启动 */ -rt_err_t rt_dw_get_crc_enable(rt_device_dw_t device, rt_uint8_t *enable); - -/* 设置是否开启帧CRC功能, 0未启动, 1启动 */ -rt_err_t rt_dw_set_crc_enable(rt_device_dw_t device, rt_uint8_t enable); - -/* 获取触摸数据是否自动上传 */ -rt_err_t rt_dw_get_data_auto_update(rt_device_dw_t device, rt_uint8_t *enable); - -/* 设置触摸数据是否自动上传 */ -rt_err_t rt_dw_set_data_auto_update(rt_device_dw_t device, rt_uint8_t enable); - -/* 获取数据寄存器上电初始化模式, 0上电初始化为0x00, 1上电有L22字库文件加载 */ -rt_err_t rt_dw_get_var_init_mode(rt_device_dw_t device, rt_dw_var_init_mode_t *mode); - -/* 设置数据寄存器上电初始化模式, 0上电初始化为0x00, 1上电有L22字库文件加载 */ -rt_err_t rt_dw_set_var_init_mode(rt_device_dw_t device, rt_dw_var_init_mode_t mode); - -/* 获取蜂鸣器是否开启, 0开启 1未开启 */ -rt_err_t rt_dw_get_buzzer_enable(rt_device_dw_t device, rt_uint8_t *enable); - -/* 设置蜂鸣器是否开启, 0开启 1未开启 */ -rt_err_t rt_dw_set_buzzer_enable(rt_device_dw_t device, rt_uint8_t enable); - -/* 获取RTC时间 */ -rt_err_t rt_dw_get_rtc(rt_device_dw_t device, - rt_uint8_t *year, rt_uint8_t *month, rt_uint8_t *day, - rt_uint8_t *hour, rt_uint8_t *minute, rt_uint8_t *seconds); - -/* 设置RTC时间 */ -rt_err_t rt_dw_set_rtc(rt_device_dw_t device, - rt_uint8_t year, rt_uint8_t month, rt_uint8_t day, - rt_uint8_t hour, rt_uint8_t minute, rt_uint8_t seconds); - -/* 使用时间戳设置RTC时间 */ -rt_err_t rt_dw_set_rtc_timestamp(rt_device_dw_t device, const time_t timestamp); - -/* 获取RTC时间戳*/ -rt_err_t rt_dw_get_rtc_timestamp(rt_device_dw_t device, time_t *timestamp); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/old/dwlib/plugins/vicon/dw_vicon.c b/old/dwlib/plugins/vicon/dw_vicon.c deleted file mode 100644 index 094246a..0000000 --- a/old/dwlib/plugins/vicon/dw_vicon.c +++ /dev/null @@ -1,70 +0,0 @@ -#include "dw_vicon.h" - -#if defined(RT_USING_FINSH) && defined(RT_USING_DW_DEBUG) -#include -#endif - -/* 添加变量图标 */ -rt_dw_vicon_t rt_dw_plugins_vicon_add(rt_device_dw_t device, - rt_uint16_t addr, rt_uint16_t default_value, - rt_uint16_t min_value, rt_uint16_t max_value) -{ - rt_err_t ret = RT_EOK; - rt_dw_vicon_t vicon_temp = RT_NULL; - - /* 判断默认值是否超过最大小值 */ - if((default_value < min_value) || (default_value > max_value)) - { - rt_kprintf("value > max_value or value < min_value\n"); - return RT_NULL; - } - - /* 创建变量图标 */ - vicon_temp = (rt_dw_vicon_t)rt_malloc(sizeof(struct rt_dw_vicon)); - - /* 内存分配失败 */ - if(vicon_temp == RT_NULL) - { - rt_kprintf("create vicon failed:addr = 0x.4%x, value = %d\n", addr, default_value); - return RT_NULL; - } - - vicon_temp->addr = addr; - vicon_temp->max_value = max_value; - vicon_temp->min_value = min_value; - - /* 写变量空间 */ - ret = rt_dw_write_var_space(device, vicon_temp->addr, 1, &default_value); - - if(ret != RT_EOK) - { - /* 写变量空间失败 */ - return RT_NULL; - } - - return vicon_temp; -} - -/* 光标图标 */ -rt_err_t rt_dw_plugins_vicon_change(rt_device_dw_t device, rt_dw_vicon_t vicon, rt_uint16_t value) -{ - rt_err_t ret = RT_EOK; - - /* 判断默认值是否超过最大小值 */ - if((value < vicon->min_value) || (value > vicon->max_value)) - { - rt_kprintf("value > max_value or value < min_value\n"); - return RT_ERROR; - } - - /* 写变量空间 */ - ret = rt_dw_write_var_space(device, vicon->addr, 1, &value); - - if(ret != RT_EOK) - { - /* 写变量空间失败 */ - return ret; - } - - return RT_EOK; -} diff --git a/old/dwlib/plugins/vicon/dw_vicon.h b/old/dwlib/plugins/vicon/dw_vicon.h deleted file mode 100644 index ad69ca3..0000000 --- a/old/dwlib/plugins/vicon/dw_vicon.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef __DW_VICON_H_ -#define __DW_VICON_H_ - -#include "dw_space.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct rt_dw_vicon -{ - rt_uint16_t addr; - - rt_uint16_t max_value; - rt_uint16_t min_value; -}; -typedef struct rt_dw_vicon* rt_dw_vicon_t; - -/* 添加变量图标 */ -rt_dw_vicon_t rt_dw_plugins_vicon_add(rt_device_dw_t device, - rt_uint16_t addr, rt_uint16_t default_value, - rt_uint16_t min_value, rt_uint16_t max_value); - -/* 光标图标 */ -rt_err_t rt_dw_plugins_vicon_change(rt_device_dw_t device, rt_dw_vicon_t vicon, rt_uint16_t value); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/old/readme.md b/old/readme.md deleted file mode 100644 index 792d400..0000000 --- a/old/readme.md +++ /dev/null @@ -1,36 +0,0 @@ -# dwlib使用说明 # - -当前dwlib库暂时只支持rtthread(简称rtt)系统,整个库里面直接使用的是rtt操作系统系统资源,例如list内核链表、基础变量命名,底层读写操作使用的是rtt的IO设备驱动框架、finsh和msh组件。因此在其他平台使用dwlib修改代码量比较大,且不方便。 - -## 1. 添加库源码到rtt code中 ## -~~~ -1. 我们首先在github将dwlib的全部工程代码打包下载。 -2. 将dwlin库解压到rt-thread\components下,这样dwlib就成为了rtt的组件一部分。 -3. 在你自己的工程中找到rtconfig.h在末尾添加RT_USING_DWIN和对应屏幕的宏。 - (目前支持RT_USING_DMT48270M043_02W好RT_USING_DMT48270M050_02W,其他也应该能支持, - 只是有些功能多或者少的问题,没有对应宏的屏幕可以尝试使用上面已经有的2个宏)。 -4. 使用scons重新生成工程,这样dwlib的basic代码就添加到你的工程中了。 -~~~ - -## 2. dwlib插件使用 ## -在dwlib库中有很多很好用的插件。目前支持以下插件: -1. 系统插件:查看屏幕配置和配置屏幕参数。 -2. 登陆插件:实现1个超级密码和n个用户密码(动态内存和链表实现,只要内存够,就可以无限多的密码),支持将迪文屏幕中的按键注册为登陆和退出按键。 -3. 变量图标插件:支持修改迪文屏幕变量空间来改标屏幕中对于图标的图片。 -4. 命令插件:支持将使用插件功能导出到rtt的finsh和msh中,使用超级终端进行调试。 - -以下是开启这些插件的宏开关: -~~~ -1. 系统插件 RT_USING_DW_SYSTEM -2. 登陆插件 RT_USING_DW_LOGIN -3. 变量图标 RT_USING_DW_VICON -4. 命令插件 RT_USING_DW_CMD -~~~ - - -## 3. dwlib调试宏 ## -在开发阶段往往我们需要有打印函数调用状态的函数, 但是在发布时又不想有这些信息打印,所以我们添加了调试宏: -~~~ -RT_USING_DW_DEBUG -~~~ - diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..e69de29