|
@@ -25,8 +25,8 @@
|
|
// 定义数据区大小
|
|
// 定义数据区大小
|
|
#define UART_FIFO_MAX 64
|
|
#define UART_FIFO_MAX 64
|
|
#define REC_DATA_BUFFER_SIZE 512
|
|
#define REC_DATA_BUFFER_SIZE 512
|
|
-#define REC_PIC_BUFFER_SIZE (1024 * 4)
|
|
|
|
#define PHOTO_DATA_MAX_SIZE (DEF_UI_WIDTH * DEF_UI_HEIGHT * LV_IMG_PX_SIZE_ALPHA_BYTE) //360*360*3
|
|
#define PHOTO_DATA_MAX_SIZE (DEF_UI_WIDTH * DEF_UI_HEIGHT * LV_IMG_PX_SIZE_ALPHA_BYTE) //360*360*3
|
|
|
|
+#define REC_PIC_BUFFER_SIZE PHOTO_DATA_MAX_SIZE + 4
|
|
#define DEVICE_ID_SIZE 8
|
|
#define DEVICE_ID_SIZE 8
|
|
#define PROJECT_ID_SIZE 4
|
|
#define PROJECT_ID_SIZE 4
|
|
#define WRITE_KEY_SIZE 160
|
|
#define WRITE_KEY_SIZE 160
|
|
@@ -70,8 +70,8 @@ uint8_t bySetTimeStep = 0;
|
|
static bool bSetPhotoReady = false;
|
|
static bool bSetPhotoReady = false;
|
|
static uint32_t glPhotoDataSize = 0;
|
|
static uint32_t glPhotoDataSize = 0;
|
|
static uint32_t glPhotoDataSizecheck = 0;
|
|
static uint32_t glPhotoDataSizecheck = 0;
|
|
-static uint16_t gwRecPhotoDataSize = 0;
|
|
|
|
-static uint32_t glRecPhotoDataOffset = 0;
|
|
|
|
|
|
+static uint32_t glRecPhotoDataSize = 0;
|
|
|
|
+//static uint32_t glRecPhotoDataOffset = 0;
|
|
static char *photo_name = "profile_photo_name"; // 文件名
|
|
static char *photo_name = "profile_photo_name"; // 文件名
|
|
|
|
|
|
extern uint8_t bySetHour;
|
|
extern uint8_t bySetHour;
|
|
@@ -88,6 +88,10 @@ extern bool aem_defender_factory_write_key(uint8_t * data, uint16_t len); // 写
|
|
extern uint16_t aem_factory_get_product_info(uint8_t *data, uint16_t in_len); // 获取产品信息
|
|
extern uint16_t aem_factory_get_product_info(uint8_t *data, uint16_t in_len); // 获取产品信息
|
|
extern uint32_t flash_write(const char *name, uint32_t offset, void *data, uint32_t size); // 写入数据到Flash
|
|
extern uint32_t flash_write(const char *name, uint32_t offset, void *data, uint32_t size); // 写入数据到Flash
|
|
extern uint32_t flash_erase(const char *name); // 擦除Flash
|
|
extern uint32_t flash_erase(const char *name); // 擦除Flash
|
|
|
|
+#ifdef CONFIG_UI_MEMORY_MANAGER
|
|
|
|
+extern void ui_mem_res_free(void * ptr);
|
|
|
|
+extern void * ui_mem_res_alloc(size_t size);
|
|
|
|
+#endif
|
|
|
|
|
|
#if 0
|
|
#if 0
|
|
static __attribute__((aligned(4))) uint8_t ota_img[] = //卡通表盘图片数据
|
|
static __attribute__((aligned(4))) uint8_t ota_img[] = //卡通表盘图片数据
|
|
@@ -610,7 +614,7 @@ static void flash_write_proc_timer_acts_handler(struct k_work *work)
|
|
{
|
|
{
|
|
uint8_t tx_buff[2] = {0}; // 定义发送缓冲区
|
|
uint8_t tx_buff[2] = {0}; // 定义发送缓冲区
|
|
|
|
|
|
- //x_buff[1] = (sizeof(ota_img) & 0x0000FF);
|
|
|
|
|
|
+ //tx_buff[1] = (sizeof(ota_img) & 0x0000FF);
|
|
//tx_buff[2] = (sizeof(ota_img) & 0x00FF00) >> 8;
|
|
//tx_buff[2] = (sizeof(ota_img) & 0x00FF00) >> 8;
|
|
//tx_buff[3] = (sizeof(ota_img) & 0xFF0000) >> 16;
|
|
//tx_buff[3] = (sizeof(ota_img) & 0xFF0000) >> 16;
|
|
// 根据接收到的命令,执行不同的操作
|
|
// 根据接收到的命令,执行不同的操作
|
|
@@ -628,14 +632,14 @@ static void flash_write_proc_timer_acts_handler(struct k_work *work)
|
|
{
|
|
{
|
|
tx_buff[0] = 0xAA;
|
|
tx_buff[0] = 0xAA;
|
|
glPhotoDataSizecheck = 0; // 清零
|
|
glPhotoDataSizecheck = 0; // 清零
|
|
- gwRecPhotoDataSize = 3; // index从3开始,前3个字节为图片大小,先设置为0,再由SET_PROFILE_PHOTO_OVER写入
|
|
|
|
- glRecPhotoDataOffset = 0; // 偏移量从0开始
|
|
|
|
|
|
+ glRecPhotoDataSize = 3; // index从3开始,前3个字节为图片大小,先设置为0,再由SET_PROFILE_PHOTO_OVER写入
|
|
|
|
+ //glRecPhotoDataOffset = 0; // 偏移量从0开始
|
|
bSetPhotoReady = true; // 设置准备标志
|
|
bSetPhotoReady = true; // 设置准备标志
|
|
}
|
|
}
|
|
|
|
|
|
- str_uart2_rec_data.pic_data = (uint8_t *)lv_mem_alloc(REC_PIC_BUFFER_SIZE);
|
|
|
|
|
|
+ str_uart2_rec_data.pic_data = (uint8_t *)ui_mem_res_alloc(REC_PIC_BUFFER_SIZE);
|
|
memset(str_uart2_rec_data.pic_data, 0, 3); // 清零
|
|
memset(str_uart2_rec_data.pic_data, 0, 3); // 清零
|
|
- flash_erase(photo_name); // 清空flash
|
|
|
|
|
|
+ //flash_erase(photo_name); // 清空flash
|
|
|
|
|
|
aem_activity_run(AEM_SHOW_ANIMATION, NULL); // 显示动画
|
|
aem_activity_run(AEM_SHOW_ANIMATION, NULL); // 显示动画
|
|
}
|
|
}
|
|
@@ -666,13 +670,14 @@ static void flash_write_proc_timer_acts_handler(struct k_work *work)
|
|
if (bSetPhotoReady && (str_uart2_rec_data.rec_data[3] > 0))
|
|
if (bSetPhotoReady && (str_uart2_rec_data.rec_data[3] > 0))
|
|
{
|
|
{
|
|
tx_buff[0] = 0xAA;
|
|
tx_buff[0] = 0xAA;
|
|
- if ((gwRecPhotoDataSize + str_uart2_rec_data.rec_data[3]) > REC_PIC_BUFFER_SIZE)
|
|
|
|
|
|
+ /*
|
|
|
|
+ if ((glRecPhotoDataSize + str_uart2_rec_data.rec_data[3]) > REC_PIC_BUFFER_SIZE)
|
|
{
|
|
{
|
|
- if (flash_write(photo_name, glRecPhotoDataOffset, str_uart2_rec_data.pic_data, gwRecPhotoDataSize) == 0)
|
|
|
|
|
|
+ if (flash_write(photo_name, glRecPhotoDataOffset, str_uart2_rec_data.pic_data, glRecPhotoDataSize) == 0)
|
|
//if (flash_write(photo_name, 3, ota_img, sizeof(ota_img)) == 0)
|
|
//if (flash_write(photo_name, 3, ota_img, sizeof(ota_img)) == 0)
|
|
{
|
|
{
|
|
- glRecPhotoDataOffset += gwRecPhotoDataSize; // 更新偏移量
|
|
|
|
- gwRecPhotoDataSize = 0; // 重新计数
|
|
|
|
|
|
+ glRecPhotoDataOffset += glRecPhotoDataSize; // 更新偏移量
|
|
|
|
+ glRecPhotoDataSize = 0; // 重新计数
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -681,10 +686,11 @@ static void flash_write_proc_timer_acts_handler(struct k_work *work)
|
|
}
|
|
}
|
|
|
|
|
|
if (tx_buff[0] == 0xAA)
|
|
if (tx_buff[0] == 0xAA)
|
|
|
|
+ */
|
|
{
|
|
{
|
|
for (uint16_t i = 0; i < str_uart2_rec_data.rec_data[3]; i++)
|
|
for (uint16_t i = 0; i < str_uart2_rec_data.rec_data[3]; i++)
|
|
{
|
|
{
|
|
- str_uart2_rec_data.pic_data[gwRecPhotoDataSize++] = str_uart2_rec_data.rec_data[4 + i];
|
|
|
|
|
|
+ str_uart2_rec_data.pic_data[glRecPhotoDataSize++] = str_uart2_rec_data.rec_data[4 + i];
|
|
}
|
|
}
|
|
|
|
|
|
glPhotoDataSizecheck += str_uart2_rec_data.rec_data[3]; // 累加数据长度
|
|
glPhotoDataSizecheck += str_uart2_rec_data.rec_data[3]; // 累加数据长度
|
|
@@ -698,36 +704,41 @@ static void flash_write_proc_timer_acts_handler(struct k_work *work)
|
|
tx_buff[0] = 0;
|
|
tx_buff[0] = 0;
|
|
if (glPhotoDataSizecheck == glPhotoDataSize) //头像照片数据长度校验
|
|
if (glPhotoDataSizecheck == glPhotoDataSize) //头像照片数据长度校验
|
|
{
|
|
{
|
|
- if (flash_write(photo_name, glRecPhotoDataOffset, str_uart2_rec_data.pic_data, gwRecPhotoDataSize) == 0)
|
|
|
|
|
|
+ tx_buff[0] = 0xAA;
|
|
|
|
+ send_frame(SET_PROFILE_PHOTO_OVER, tx_buff, 1);
|
|
|
|
+
|
|
|
|
+ if (flash_write(photo_name, 0, str_uart2_rec_data.pic_data, glRecPhotoDataSize) == 0)
|
|
{
|
|
{
|
|
- str_uart2_rec_data.pic_data[0] = (glPhotoDataSize & 0x0000FF);
|
|
|
|
- str_uart2_rec_data.pic_data[1] = (glPhotoDataSize & 0x00FF00) >> 8;
|
|
|
|
- str_uart2_rec_data.pic_data[2] = (glPhotoDataSize & 0xFF0000) >> 16;
|
|
|
|
- if (flash_write(photo_name, 0, str_uart2_rec_data.pic_data, 3) == 0) // 最后写入图片大小
|
|
|
|
- {
|
|
|
|
- glRecPhotoDataOffset = 3; // 更新偏移量
|
|
|
|
- gwRecPhotoDataSize = 0; // 重新计数
|
|
|
|
|
|
+ str_uart2_rec_data.pic_data[0] = (glPhotoDataSize & 0x0000FF);
|
|
|
|
+ str_uart2_rec_data.pic_data[1] = (glPhotoDataSize & 0x00FF00) >> 8;
|
|
|
|
+ str_uart2_rec_data.pic_data[2] = (glPhotoDataSize & 0xFF0000) >> 16;
|
|
|
|
|
|
- glPhotoDataSize = 0;
|
|
|
|
- glPhotoDataSizecheck = 0;
|
|
|
|
- bSetPhotoReady = false;
|
|
|
|
- tx_buff[0] = 0xAA;
|
|
|
|
|
|
+ if (flash_write(photo_name, 0, str_uart2_rec_data.pic_data, 3)) // 最后写入图片大小
|
|
|
|
+ {
|
|
|
|
+ flash_erase(photo_name); // 写入失败则清空flash
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //glRecPhotoDataOffset = 0; // 更新偏移量
|
|
|
|
+ glRecPhotoDataSize = 3; // 重新计数
|
|
|
|
+
|
|
|
|
+ glPhotoDataSize = 0;
|
|
|
|
+ glPhotoDataSizecheck = 0;
|
|
|
|
+ bSetPhotoReady = false;
|
|
}
|
|
}
|
|
else if (!bSetPhotoReady)
|
|
else if (!bSetPhotoReady)
|
|
{
|
|
{
|
|
tx_buff[0] = 0xAA;
|
|
tx_buff[0] = 0xAA;
|
|
|
|
+ send_frame(SET_PROFILE_PHOTO_OVER, tx_buff, 1);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
tx_buff[0] = 0x55;
|
|
tx_buff[0] = 0x55;
|
|
|
|
+ send_frame(SET_PROFILE_PHOTO_OVER, tx_buff, 1);
|
|
flash_erase(photo_name); // 清空flash
|
|
flash_erase(photo_name); // 清空flash
|
|
}
|
|
}
|
|
- memset(str_uart2_rec_data.rec_data, 0, REC_DATA_BUFFER_SIZE);
|
|
|
|
- send_frame(SET_PROFILE_PHOTO_OVER, tx_buff, 1);
|
|
|
|
|
|
|
|
- lv_mem_free(str_uart2_rec_data.pic_data);
|
|
|
|
|
|
+ memset(str_uart2_rec_data.rec_data, 0, REC_DATA_BUFFER_SIZE);
|
|
|
|
+ ui_mem_res_free(str_uart2_rec_data.pic_data);
|
|
str_uart2_rec_data.pic_data = NULL;
|
|
str_uart2_rec_data.pic_data = NULL;
|
|
|
|
|
|
aem_power_onoff_t on_off = { 0 };
|
|
aem_power_onoff_t on_off = { 0 };
|
|
@@ -956,7 +967,7 @@ static void uart_fifo_callback(const struct device *dev, void *user_data)
|
|
else
|
|
else
|
|
{
|
|
{
|
|
tx_buff[0] = 0x55;
|
|
tx_buff[0] = 0x55;
|
|
- send_frame(0xCB, tx_buff, 1);
|
|
|
|
|
|
+ send_frame(str_uart2_rec_data.rec_data[2], tx_buff, 1);
|
|
}
|
|
}
|
|
|
|
|
|
bReceiveFrameDone = false;
|
|
bReceiveFrameDone = false;
|