?? frame.c
字號(hào):
//============================================================================
// Include
//============================================================================
#include <stdio.h>
#include <cyg/hal/drv_api.h>
#include <cyg/kernel/kapi.h>
#include <cyg/infra/cyg_type.h>
#include <cyg/infra/diag.h>
#include <cyg/io/rtc/fie702x_rtc.h>
#include <cyg/io/lcd/fie702x_lcd.h>
#include "RTCSystem.h"
#include "LCDSystem.h"
#include "FontSystem.h"
#define STACKSIZE (65536)
#define NUM(x) (sizeof(x)/sizeof(x[0]))
//============================================================================
// Global Variables
//============================================================================
cyg_io_handle_t lcd_handle, rtc_handle;
cyg_flag_t frame_go;
//============================================================================
// System
//============================================================================
void Frame(CYG_ADDRESS);
void Display(CYG_ADDRESS);
typedef void fun(CYG_ADDRWORD);
typedef struct _eCos_thread {
char *name;
fun *entry;
int prio;
cyg_handle_t t;
cyg_thread t_obj;
char stack[STACKSIZE];
} eCos_thread;
eCos_thread _thread[] = {
{"Count frame", Frame, 10},
{"Display", Display, 11},
};
void Frame (CYG_ADDRESS data)
{
while (1)
{
cyg_thread_delay(5);
// display one frame
API_LCD_dsiplay_Frame(lcd_handle);
}
}
char image[(320*240*3)/2];
/* clear Frame buffers*/void LCD_clear_Buffer (char *buf){ // clear as green memset(buf, 35, 320*240); memset(buf + 320*240, 212, (320*240/4)); memset(buf + 320*240 + (320*240/4), 144, (320*240/4));}
void Display (CYG_ADDRESS data)
{
int err;
char char_tmp[255];
int i, set;
RTC_Time time;
int display_time, display_sec, display_min;
err = cyg_io_lookup( "/dev/rtc", &rtc_handle );
if (ENOERR != err)
{
printf("Can't open '%s'\n", "/dev/rtc");
}
err = cyg_io_lookup( "/dev/lcd", &lcd_handle );
if (ENOERR != err)
{
printf("Can't open '%s'\n", "/dev/lcd");
}
API_LCD_init();
API_LCD_start(lcd_handle);
API_LCD_set_FrameRate(lcd_handle, 20);
LCD_clear_Buffer(image);
while (1)
{
for (i = 0; i < 20; i ++)
{
// clear count
API_Font_display_8x8String(" ", 0, 0, image);
// draw count
sprintf(char_tmp, "%d", i);
char_tmp[2] = '\0';
API_Font_display_8x8String(char_tmp, 16*i, 0, image);
// display real time
API_RTC_get_Time(rtc_handle, &time);
sprintf(char_tmp, "RTC -> %02d:%02d\n", time.minute, time.second);
char_tmp[12] = '\0';
API_Font_display_8x8String(char_tmp, 0, 32, image);
// display estimated time
display_time = API_LCD_get_DisplayTime(lcd_handle) / 1000;
display_sec = display_time % 60;
display_min = display_time / 60;
sprintf(char_tmp, "Estimated -> %02d:%02d\n", display_min, display_sec);
char_tmp[18] = '\0';
API_Font_display_8x8String(char_tmp, 0, 48, image);
// write to display frame
set = 1; cyg_io_write(lcd_handle, image, &set);
}
}
}
/* start eCOs
*/
void cyg_user_start(void)
{
int i;
eCos_thread *nx;
printf("SYSTEM START.\n");
nx = &_thread[0];
for (i = 0; i < NUM(_thread); i++, nx++) {
cyg_thread_create(nx->prio,
nx->entry,
(cyg_addrword_t)NULL,
nx->name,
(void *)nx->stack, STACKSIZE,
&nx->t,
&nx->t_obj);
cyg_thread_resume(nx->t);
}
cyg_flag_init(&frame_go);
printf("SYSTEM THREADS STARTED!\n");
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -