优化工程目录
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: CC0-1.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/timers.h"
|
||||
#include "esp_chip_info.h"
|
||||
#include "esp_flash.h"
|
||||
#include "esp_system.h"
|
||||
|
||||
#include "esp_log.h"
|
||||
|
||||
#include "spi.h"
|
||||
|
||||
#include "lcd.h"
|
||||
|
||||
TimerHandle_t periodic_timer = NULL;
|
||||
|
||||
// 定时器回调函数(在定时器服务任务中执行)
|
||||
void periodic_timer_callback(TimerHandle_t xTimer)
|
||||
{
|
||||
//printf("每秒执行一次的函数\n");
|
||||
// 在这里执行你的周期性任务
|
||||
// 注意:此回调函数应尽快返回,避免阻塞定时器服务任务
|
||||
|
||||
lcd_one_second_task();
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
printf("Hello world!\n");
|
||||
|
||||
/* Print chip information */
|
||||
esp_chip_info_t chip_info;
|
||||
uint32_t flash_size;
|
||||
esp_chip_info(&chip_info);
|
||||
printf("This is %s chip with %d CPU core(s), %s%s%s%s, ",
|
||||
CONFIG_IDF_TARGET,
|
||||
chip_info.cores,
|
||||
(chip_info.features & CHIP_FEATURE_WIFI_BGN) ? "WiFi/" : "",
|
||||
(chip_info.features & CHIP_FEATURE_BT) ? "BT" : "",
|
||||
(chip_info.features & CHIP_FEATURE_BLE) ? "BLE" : "",
|
||||
(chip_info.features & CHIP_FEATURE_IEEE802154) ? ", 802.15.4 (Zigbee/Thread)" : "");
|
||||
|
||||
unsigned major_rev = chip_info.revision / 100;
|
||||
unsigned minor_rev = chip_info.revision % 100;
|
||||
printf("silicon revision v%d.%d, ", major_rev, minor_rev);
|
||||
if (esp_flash_get_size(NULL, &flash_size) != ESP_OK)
|
||||
{
|
||||
printf("Get flash size failed");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%" PRIu32 "MB %s flash\n", flash_size / (uint32_t)(1024 * 1024),
|
||||
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
|
||||
|
||||
printf("Minimum free heap size: %" PRIu32 " bytes\n", esp_get_minimum_free_heap_size());
|
||||
|
||||
printf("sizeof(int) ==%d\n", sizeof(int));
|
||||
|
||||
spi_init();
|
||||
lcd_init();
|
||||
|
||||
// 配置一个每隔一秒运行一次的函数 用于计算fps等
|
||||
// 创建周期性软件定时器
|
||||
// 参数: 定时器名称, 周期(单位: Tick), 自动重载, 回调参数, 回调函数
|
||||
periodic_timer = xTimerCreate(
|
||||
"PeriodicTimer", // 定时器名称
|
||||
pdMS_TO_TICKS(1000), // 周期:1000毫秒 (转换为Tick)
|
||||
pdTRUE, // 自动重载 (pdTRUE为周期性,pdFALSE为单次)
|
||||
(void *)0, // 传递给回调函数的参数
|
||||
periodic_timer_callback // 回调函数
|
||||
);
|
||||
|
||||
if (periodic_timer != NULL)
|
||||
{
|
||||
// 启动定时器 (0 ticks后启动)
|
||||
xTimerStart(periodic_timer, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("创建定时器失败!\n");
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
lcd_clear_buf(rand());
|
||||
lcd_send_full_buf();
|
||||
vTaskDelay(1); // 必须让出CPU
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user