📄 menucom.c
字号:
#include <stdio.h>
#include <string.h>
#include "Menu.H"
#include "ff.h"
#define LOCAL_DEBUG 1
#if LOCAL_DEBUG
#define DEBUG(x...) do { printf(x); }while(0)
#else
#define DEBUG(x...) do { }while(0)
#endif
//static FATFS fs;
int MenuGuiInit(void)
{
int ret = 0;
GUI_SetBkColor(MENU_BC);
GUI_SetColor(MENU_FC);
GUI_SetFont(MENU_CF);
#if 0
if (FR_OK != f_mount(1, &fs)) {
printf(" Mount SD Card fs error\r\n");
ret = -1;
}
#endif
return ret;
}
/* h>0 高亮显示屏幕的一个区域,h=0 去掉高亮效果*/
#define COLOR_PERCENT 35
void MenuHigLight(int x0, int y0, int xs, int ys, int h)
{
static unsigned short _tmp[6000];
int i, j, k = 0;
int cntr_xs = 0;
int cntr_ys = 0;
int r2 = 0;
unsigned short r, g, b, t;
if (xs * ys > 6000) {
return;
}
if (xs == ys) {
cntr_xs = xs / 2 - 1;
cntr_ys = ys / 2 - 1;
r2 = (cntr_ys - 1) * (cntr_ys - 1);
}
if (h > 0) {
for (i=0; i<ys; i++)
for (j=0; j<xs; j++) {
int dx, dy;
dx = (j - cntr_xs);
dy = (i - cntr_ys);
if (1
&& (xs == ys)
&& (dx * dx + dy * dy >= r2)
) {
continue;
}
t = LCD_L0_GetPixelIndex(x0 + j, y0 + i);
_tmp[k++] = t;
r = (t & 0x1f);
g = (t >> 5) & 0x3f;
b = (t >> 11) & 0x1f;
r += (0x1f - r) * COLOR_PERCENT / 100;
g += (0x3f - g) * COLOR_PERCENT / 100;
b += (0x1f - b) * COLOR_PERCENT / 100;
t = r | (g << 5) | (b << 11);
LCD_L0_SetPixelIndex(x0 + j, y0 + i, t);
}
} else {
for (i=0; i<ys; i++)
for (j=0; j<xs; j++) {
LCD_L0_SetPixelIndex(x0 + j, y0 + i, _tmp[k++]);
}
}
}
static FIL fil;
static void fun(unsigned int n, void *pd)
{
int ret;
unsigned int br, tol = 0;
char *p = pd;
do {
ret = f_read(&fil, p, n, &br);
if (ret != FR_OK)
return;
tol += br;
} while (tol < n && br > 0);
}
int GUI_ShowStreamBMP(int x0, int y0, void (*pfStream)(unsigned int, void *));
int MenuShowBmp(char *pfn, int x, int y)
{
int ret;
// f_mount(1, &fs);
ret = f_open(&fil, pfn, FA_READ);
if (ret) {
printf("\r\nopen file %s err", pfn);
return -1;
}
GUI_ShowStreamBMP(x, y, &fun);
f_close(&fil);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -