c_cpp 使用按键控制图像
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp 使用按键控制图像相关的知识,希望对你有一定的参考价值。
/**
******************************************************************************
* @brief 使用流程及示例程序(基于前后台非操作系统环境),基于ELinkSTM/ELinkSTM_Pro核心板
* @function xxxxxzzzz
******************************************************************************
#include "Creelinks.h"
int main(void)
{
ceSystemOp.initial(); //Creelinks环境初始化
ceSystemOp.initialDebug(R9Uart); //通过Uart串口输出Debug信息到上位机
//TODO:请在此处插入模块初始化等操作
while (1)
{
ceSystemOp.mainTask(); //Creelinks环境主循环任务,请保证此函数能够被周期调用
//TODO:请在此处插入用户操作
};
}
******************************************************************************
*/
/**
******************************************************************************
* @brief 使用流程及示例程序(基于前后台非操作系统环境),基于ELinkSTM核心板
@function CeTfCard读写文件,遍历目录,获取容量等测试(可使用CeTft系列任意屏幕进行调试输出,只需改动下面的宏定义即可。使用宏替换使代码改动降到最小)
******************************************************************************/
#include "Creelinks.h"
#include "CeTfCard/CeTfCard.h" //编译时请将CeTfCard\ff9\src目录下的diskio.c和ff.c加入到工程中,不然链接时会报错
#include "CeTft180.h"
const unsigned char CN1616_B4B4[] = //创
{ 0x0C, 0x06, 0x0C, 0x06, 0x1E, 0x06, 0x1B, 0x36, 0x31, 0xB6, 0x60, 0xF6, 0xFF, 0x36, 0x33, 0x36, 0x33, 0x36, 0x33, 0x36, 0x3F, 0x36, 0x36, 0x36, 0x30, 0xC6, 0x30, 0xC6, 0x1F, 0xDE, 0x00, 0x0C };
const unsigned char CN1616_A3E5[] = //e
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x06, 0x60, 0x0C, 0x30, 0x0F, 0xF0, 0x0C, 0x00, 0x0C, 0x00, 0x06, 0x30, 0x03, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char CN1616_C1AA[] = //联
{0x00, 0xCC, 0xFE, 0x6C, 0x6C, 0x78, 0x6C, 0x00, 0x7D, 0xFE, 0x6C, 0x30, 0x6C, 0x30, 0x7C, 0x30, 0x6F, 0xFF, 0x6C, 0x30, 0x6E, 0x78, 0x7C, 0x78, 0xEC, 0xCC, 0x0C, 0xCC, 0x0D, 0x86, 0x0F, 0x03};
const unsigned char CN1616_B1B1[] = //北
{0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x66, 0x06, 0x6C, 0x7E, 0x78, 0x06, 0x70, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x63, 0x1E, 0x63, 0xF6, 0x63, 0x66, 0x3F, 0x06, 0x00};
const unsigned char CN1616_BEA9[] = //京
{0x03, 0x00, 0x01, 0x80, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, 0xF8, 0x01, 0x80, 0x19, 0x98, 0x19, 0x8C, 0x31, 0x86, 0x67, 0x86, 0x03, 0x00};
const unsigned char CN1616_B4F3[] = //大
{0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0xFF, 0xFF, 0x01, 0x80, 0x01, 0x80, 0x03, 0xC0, 0x03, 0xC0, 0x06, 0x60, 0x06, 0x60, 0x0C, 0x30, 0x18, 0x18, 0x30, 0x0C, 0xE0, 0x07};
const unsigned char CN1616_D0C5[] = //信
{0x0C, 0x60, 0x0C, 0x30, 0x0F, 0xFF, 0x18, 0x00, 0x18, 0x00, 0x39, 0xFE, 0x38, 0x00, 0x78, 0x00, 0xD9, 0xFE, 0x18, 0x00, 0x18, 0x00, 0x19, 0xFE, 0x19, 0x86, 0x19, 0x86, 0x19, 0xFE, 0x19, 0x86};
const unsigned char CN1616_BFC6[] = //科
{0x0C, 0x18, 0x1F, 0x98, 0xF8, 0xD8, 0x18, 0xD8, 0x18, 0x18, 0xFF, 0x98, 0x18, 0xD8, 0x3C, 0xD8, 0x3E, 0x18, 0x78, 0x1F, 0x7B, 0xF8, 0xD8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18};
const unsigned char CN1616_BCBC[] = //技
{0x18, 0x30, 0x18, 0x30, 0x18, 0x30, 0x1B, 0xFF, 0xFE, 0x30, 0x18, 0x30, 0x18, 0x30, 0x1F, 0xFE, 0x1C, 0xC6, 0x38, 0xCC, 0xF8, 0x6C, 0x18, 0x78, 0x18, 0x30, 0x18, 0x78, 0x79, 0xCC, 0x37, 0x07};
CeTft180 ceTft180;
CeTfCard ceTfCard;
FATFS fatFs; //Work area (file system object) for logical drive
FIL fileObject; //file objects
FRESULT result;
char filePath[128] = { 0 };
char buffer[4096] = { 0 };
uint32 bufferByte = 0;
int8 showIndex = 0x00;
uint8 set = 0;
CeInt IntUp;
CeInt IntDown;
void intEventCallBack22(void *pAddPar)
{
// 打印调试信息
ceSystemOp.printf("Enter the interrupt, Gpio status:%d\n", ceIntOp.getGpioBit((CeInt*)(pAddPar)));//进入中断事件后,打印调试信息
showIndex--;
if (showIndex < 0)
{
showIndex = 6;
}
ceSystemOp.sprintf(filePath, "%d:/128x160/%d.bin", 0, showIndex);
//读文件测试
ceSystemOp.printf("CeTfCard read file test......\n\r");
result = ceTfCardOp.f_open(&fileObject, filePath, FA_OPEN_ALWAYS | FA_READ);
if (result != FR_OK)
{
ceSystemOp.printf("CeTfCard open file error: %d\n\r", result);
}
else
{
uint8 readBuf[CE_TFT180_WIDTH * 2];
uint16 i = 0;
ceSystemOp.printf("CeTfCard ceTfCardOp.f_open() success .. \r\n");
for (i = 0; i < CE_TFT180_HIGHT; i++)
{
result = ceTfCardOp.f_read(&fileObject, readBuf, CE_TFT180_WIDTH * 2, &bufferByte);
if (result == FR_OK)
{
ceTft180Op.drawData(&ceTft180, 0, i, readBuf, CE_TFT180_WIDTH, 1);
}
else
{
ceSystemOp.printf("CeTfCard read file error: %d\n\r", result);
break;
}
}
ceTfCardOp.f_close(&fileObject); //close file
//卸载文件系统
result = f_mount(0, CE_NULL);
set = 0;
ceSystemOp.delayMs(500);
}
}
void intEventCallBack23(void *pAddPar)
{
// 打印调试信息
ceSystemOp.printf("Enter the interrupt, Gpio status:%d\n", ceIntOp.getGpioBit((CeInt*)(pAddPar)));//进入中断事件后,打印调试信息
showIndex++;
if (showIndex > 6)
{
showIndex = 0;
}
ceSystemOp.sprintf(filePath, "%d:/128x160/%d.bin", 0, showIndex);
//读文件测试
ceSystemOp.printf("CeTfCard read file test......\n\r");
result = ceTfCardOp.f_open(&fileObject, filePath, FA_OPEN_ALWAYS | FA_READ);
if (result != FR_OK)
{
ceSystemOp.printf("CeTfCard open file error: %d\n\r", result);
}
else
{
uint8 readBuf[CE_TFT180_WIDTH * 2];
uint16 i = 0;
ceSystemOp.printf("CeTfCard ceTfCardOp.f_open() success .. \r\n");
for (i = 0; i < CE_TFT180_HIGHT; i++)
{
result = ceTfCardOp.f_read(&fileObject, readBuf, CE_TFT180_WIDTH * 2, &bufferByte);
if (result == FR_OK)
{
ceTft180Op.drawData(&ceTft180, 0, i, readBuf, CE_TFT180_WIDTH, 1);
}
else
{
ceSystemOp.printf("CeTfCard read file error: %d\n\r", result);
break;
}
}
ceTfCardOp.f_close(&fileObject); //close file
//卸载文件系统
result = f_mount(0, CE_NULL);
set = 0;
ceSystemOp.delayMs(500);
}
}
int main(void)
{
ceSystemOp.initial(); //Creelinks环境初始化
ceSystemOp.initialDebug(R9Uart); //通过Uart串口输出Debug信息到上位机
//TODO:请在此处插入模块初始化等操作
IntUp.ceResource = R22AGI; //指定资源中断功能模块使用的资源号
IntUp.ceMode = CE_INT_TRIGGER_FALLING; //指定外部中断是下降沿中断
IntUp.pAddPar = &IntUp; //设置空指针指向自己,在中断回调里使用
IntUp.callBack = intEventCallBack22; //指定事件回调函数
ceIntOp.initial(&IntUp); //初始化外部中断
ceIntOp.start(&IntUp); //使能外部中断
IntDown.ceResource = R23AGI; //指定资源中断功能模块使用的资源号
IntDown.ceMode = CE_INT_TRIGGER_FALLING; //指定外部中断是下降沿中断
IntDown.pAddPar = &IntDown; //设置空指针指向自己,在中断回调里使用
IntDown.callBack = intEventCallBack23; //指定事件回调函数
ceIntOp.initial(&IntDown); //初始化外部中断
ceIntOp.start(&IntDown); //使能外部中断
ceSystemOp.printf("ELinkSTM build Data: %s Time: %s.\n", __DATE__, __TIME__);
ceTft180Op.initial(&ceTft180, R12Spi, R2TI2c);
ceTfCardOp.initial(&ceTfCard, R7Spi, R5ACGPW);
ceTft180Op.fill(&ceTft180, CE_TFT180_COLOR_RED);
ceSystemOp.delayMs(500);
ceTft180Op.fill(&ceTft180, CE_TFT180_COLOR_GREEN);
ceSystemOp.delayMs(500);
ceTft180Op.fill(&ceTft180, CE_TFT180_COLOR_BLUE);
ceSystemOp.delayMs(500);
ceTft180Op.fill(&ceTft180, CE_TFT180_COLOR_BLACK);
ceTft180Op.showCN1616(&ceTft180, 40, 40, CE_TFT180_COLOR_WHITE, CE_TFT180_COLOR_BLACK, CN1616_B4B4);
ceTft180Op.showCN1616(&ceTft180, 40 + 16, 40, CE_TFT180_COLOR_WHITE, CE_TFT180_COLOR_BLACK, CN1616_A3E5);
ceTft180Op.showCN1616(&ceTft180, 40 + 32, 40, CE_TFT180_COLOR_WHITE, CE_TFT180_COLOR_BLACK, CN1616_C1AA);
ceTft180Op.showString(&ceTft180, 28, 56, CE_TFT180_COLOR_WHITE, CE_TFT180_COLOR_BLACK, "CREELINKS", CE_TFT180_EN_SIZE_F8X16);
ceTft180Op.showCN1616(&ceTft180, 16 * 1, 72, CE_TFT180_COLOR_WHITE, CE_TFT180_COLOR_BLACK, CN1616_B1B1);
ceTft180Op.showCN1616(&ceTft180, 16 * 2, 72, CE_TFT180_COLOR_WHITE, CE_TFT180_COLOR_BLACK, CN1616_BEA9);
ceTft180Op.showCN1616(&ceTft180, 16 * 3, 72, CE_TFT180_COLOR_WHITE, CE_TFT180_COLOR_BLACK, CN1616_B4F3);
ceTft180Op.showCN1616(&ceTft180, 16 * 4, 72, CE_TFT180_COLOR_WHITE, CE_TFT180_COLOR_BLACK, CN1616_D0C5);
ceTft180Op.showCN1616(&ceTft180, 16 * 5, 72, CE_TFT180_COLOR_WHITE, CE_TFT180_COLOR_BLACK, CN1616_BFC6);
ceTft180Op.showCN1616(&ceTft180, 16 * 6, 72, CE_TFT180_COLOR_WHITE, CE_TFT180_COLOR_BLACK, CN1616_BCBC);
ceSystemOp.delayMs(2000);
while (1)
{
ceSystemOp.mainTask(); //Creelinks环境主循环任务,请保证此函数能够被周期调用
//TODO:请在此处插入用户操作
// 如果已经挂载文件系统了,就不再执行后面的内容了
if (set)
{
continue;
}
if (ceTfCardOp.getExists(&ceTfCard) == CE_STATUS_SUCCESS) //检测是否存在
{
//挂载文件系统
result = ceTfCardOp.f_mount(0, &fatFs);
if (result != FR_OK)
{
ceSystemOp.printf("CeTfCard mount filesystem: %d failed: %d\n\r", 0, result);
}
set = 1;
ceSystemOp.delayMs(500);
}
else
{
ceSystemOp.printf("\n\rCeTfCard TfCard not exits......\n\r");
}
ceSystemOp.delayMs(200);
};
}
/******************************************************************************
*/
以上是关于c_cpp 使用按键控制图像的主要内容,如果未能解决你的问题,请参考以下文章
c_cpp CV - 使用随机样本共识(RANSAC)匹配图像。