update FM3 easy kit IAR project

if define RT_USING_RTGUI in rtconfig.h
must be compiled by full edition of IAR Embedded Workbench
else
can be compiled by 32KB KickStart edition 

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1377 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
dzzxzz 2011-04-15 10:13:35 +00:00
parent c84fc53783
commit 73656d5333
12 changed files with 2920 additions and 250 deletions

View File

@ -14,13 +14,16 @@
#include <rtthread.h>
#include <rthw.h>
#include <rtgui/event.h>
#include <rtgui/rtgui_server.h>
#include <rtgui/rtgui_system.h>
#include "mb9bf506r.h"
#include "adc.h"
#include "led.h"
#include "lcd.h"
#ifdef RT_USING_RTGUI
#include <rtgui/event.h>
#include <rtgui/rtgui_server.h>
#include <rtgui/rtgui_system.h>
#endif
static struct rt_device adc;
@ -71,23 +74,36 @@ static rt_err_t rt_adc_control(rt_device_t dev, rt_uint8_t cmd, void *args)
return RT_EOK;
}
extern struct rt_messagequeue mq;
extern rt_thread_t info_tid;
rt_uint16_t adc_value;
static void adc_thread_entry(void *parameter)
{
rt_device_t device;
device = rt_device_find("adc");
#ifdef RT_USING_RTGUI
struct rtgui_event_command ecmd;
RTGUI_EVENT_COMMAND_INIT(&ecmd);
ecmd.type = RTGUI_CMD_USER_INT;
ecmd.command_id = ADC_UPDATE;
device = rt_device_find("adc");
#else
struct lcd_msg msg;
#endif
while(1)
{
rt_device_control(device, RT_DEVICE_CTRL_ADC_START, RT_NULL);
rt_device_control(device, RT_DEVICE_CTRL_ADC_RESULT, &adc_value);
pwm_update(adc_value/3);
#ifdef RT_USING_RTGUI
rtgui_thread_send(info_tid, &ecmd.parent, sizeof(ecmd));
#else
msg.type = ADC_MSG;
msg.adc_value = adc_value;
rt_mq_send(&mq, &msg, sizeof(msg));
#endif
rt_thread_delay(20);
}
}

View File

@ -20,21 +20,22 @@
#include <rtthread.h>
#include "board.h"
#include "led.h"
#ifdef RT_USING_RTGUI
#include "key.h"
#include "adc.h"
#include "lcd.h"
#include "cpuusage.h"
#ifdef RT_USING_RTGUI
#include <rtgui/rtgui.h>
extern void rtgui_startup();
#endif
struct rt_messagequeue mq;
static char msg_pool[2048];
void rt_init_thread_entry(void *parameter)
{
rt_hw_led_init();
#ifdef RT_USING_RTGUI
rt_hw_led_init();
rt_hw_key_init();
rt_hw_adc_init();
rt_hw_lcd_init();
@ -43,8 +44,75 @@ void rt_init_thread_entry(void *parameter)
/* re-init device driver */
rt_device_init_all();
#ifdef RT_USING_RTGUI
/* startup rtgui */
rtgui_startup();
#else
char buf[20] = {'\0'};
struct lcd_msg msg;
rt_device_t device;
device = rt_device_find("lcd");
rt_device_control(device, RT_DEVICE_CTRL_LCD_CLEAR_SCR, RT_NULL);
x = 1;
y = 1;
rt_device_control(device, RT_DEVICE_CTRL_LCD_PUT_STRING, "ADC");
x = 1;
y = 20;
rt_device_control(device, RT_DEVICE_CTRL_LCD_PUT_STRING, "CPU");
x = 1;
y = 40;
rt_device_control(device, RT_DEVICE_CTRL_LCD_PUT_STRING, "KEY");
while(1)
{
if (rt_mq_recv(&mq, &msg, sizeof(msg), RT_WAITING_FOREVER) == RT_EOK)
{
switch(msg.type)
{
case ADC_MSG:
x = 40;
y = 1;
rt_memset(buf, 0, sizeof(buf));
rt_sprintf(buf, "%04d", msg.adc_value);
rt_device_control(device, RT_DEVICE_CTRL_LCD_PUT_STRING, buf);
break;
case CPU_MSG:
x = 40;
y = 20;
rt_memset(buf, 0, sizeof(buf));
rt_sprintf(buf, "%03d %03d", msg.major, msg.minor);
rt_device_control(device, RT_DEVICE_CTRL_LCD_PUT_STRING, buf);
break;
case KEY_MSG:
x = 40;
y = 40;
rt_memset(buf, 0, sizeof(buf));
switch(msg.key)
{
case KEY_DOWN:
rt_sprintf(buf, "DOWN KEY ");
break;
case KEY_UP:
rt_sprintf(buf, "UP KEY ");
break;
case KEY_RIGHT:
rt_sprintf(buf, "RIGHT KEY");
break;
case KEY_LEFT:
rt_sprintf(buf, "LEFT KEY ");
break;
case KEY_ENTER:
rt_sprintf(buf, "ENTER KEY");
break;
default:
rt_sprintf(buf, "NO KEY ");
break;
}
rt_device_control(device, RT_DEVICE_CTRL_LCD_PUT_STRING, buf);
break;
}
}
}
#endif
}
@ -52,6 +120,8 @@ int rt_application_init()
{
rt_thread_t init_thread;
rt_mq_init(&mq, "mqt", &msg_pool[0], 128 - sizeof(void*), sizeof(msg_pool), RT_IPC_FLAG_FIFO);
init_thread = rt_thread_create("init", rt_init_thread_entry, RT_NULL, 1024, 21, 20);
if(init_thread != RT_NULL)
rt_thread_startup(init_thread);

View File

@ -1,9 +1,13 @@
#include <rtthread.h>
#include <rthw.h>
#include "cpuusage.h"
#include "lcd.h"
#ifdef RT_USING_RTGUI
#include <rtgui/event.h>
#include <rtgui/rtgui_server.h>
#include <rtgui/rtgui_system.h>
#include "cpuusage.h"
#endif
#define CPU_USAGE_CALC_TICK 10
#define CPU_USAGE_LOOP 100
@ -73,19 +77,30 @@ void cpu_usage_init()
/* set idle thread hook */
rt_thread_idle_sethook(cpu_usage_idle_hook);
}
extern struct rt_messagequeue mq;
extern rt_thread_t info_tid;
static void cpu_thread_entry(void *parameter)
{
#ifdef RT_USING_RTGUI
struct rtgui_event_command ecmd;
RTGUI_EVENT_COMMAND_INIT(&ecmd);
ecmd.type = RTGUI_CMD_USER_INT;
ecmd.command_id = CPU_UPDATE;
#else
struct lcd_msg msg;
#endif
while (1)
{
#ifdef RT_USING_RTGUI
rtgui_thread_send(info_tid, &ecmd.parent, sizeof(ecmd));
#else
msg.type = CPU_MSG;
msg.major = cpu_usage_major;
msg.minor = cpu_usage_minor;
rt_mq_send(&mq, &msg, sizeof(msg));
#endif
rt_thread_delay(20);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -45,7 +45,7 @@
</option>
<option>
<name>MemFile</name>
<state>$TOOLKIT_DIR$\CONFIG\debugger\Fujitsu\iomb9bf506.ddf</state>
<state></state>
</option>
<option>
<name>RunToEnable</name>
@ -117,7 +117,7 @@
</option>
<option>
<name>FlashLoadersV3</name>
<state>$TOOLKIT_DIR$\config\flashloader\Fujitsu\MB9BF506.board</state>
<state>$TOOLKIT_DIR$\config\flashloader\</state>
</option>
<option>
<name>OCImagesSuppressCheck1</name>

View File

@ -39,20 +39,20 @@
<option>
<name>Input variant</name>
<version>1</version>
<state>3</state>
<state>0</state>
</option>
<option>
<name>Input description</name>
<state>No specifier n, no float nor long long, no scan set, no assignment suppressing.</state>
<state>Full formatting.</state>
</option>
<option>
<name>Output variant</name>
<version>0</version>
<state>3</state>
<state>0</state>
</option>
<option>
<name>Output description</name>
<state>No specifier a, A, no specifier n, no float nor long long, no flags.</state>
<state>Full formatting.</state>
</option>
<option>
<name>GOutputBinary</name>

961
bsp/fm3/font.h Normal file
View File

@ -0,0 +1,961 @@
#ifndef __FONT_H
#define __FONT_H
/* Font definition */
#define ________ 0x00
#define _______X 0x01
#define ______X_ 0x02
#define ______XX 0x03
#define _____X__ 0x04
#define _____X_X 0x05
#define _____XX_ 0x06
#define _____XXX 0x07
#define ____X___ 0x08
#define ____X__X 0x09
#define ____X_X_ 0x0a
#define ____X_XX 0x0b
#define ____XX__ 0x0c
#define ____XX_X 0x0d
#define ____XXX_ 0x0e
#define ____XXXX 0x0f
#define ___X____ 0x10
#define ___X___X 0x11
#define ___X__X_ 0x12
#define ___X__XX 0x13
#define ___X_X__ 0x14
#define ___X_X_X 0x15
#define ___X_XX_ 0x16
#define ___X_XXX 0x17
#define ___XX___ 0x18
#define ___XX__X 0x19
#define ___XX_X_ 0x1a
#define ___XX_XX 0x1b
#define ___XXX__ 0x1c
#define ___XXX_X 0x1d
#define ___XXXX_ 0x1e
#define ___XXXXX 0x1f
#define __X_____ 0x20
#define __X____X 0x21
#define __X___X_ 0x22
#define __X___XX 0x23
#define __X__X__ 0x24
#define __X__X_X 0x25
#define __X__XX_ 0x26
#define __X__XXX 0x27
#define __X_X___ 0x28
#define __X_X__X 0x29
#define __X_X_X_ 0x2a
#define __X_X_XX 0x2b
#define __X_XX__ 0x2c
#define __X_XX_X 0x2d
#define __X_XXX_ 0x2e
#define __X_XXXX 0x2f
#define __XX____ 0x30
#define __XX___X 0x31
#define __XX__X_ 0x32
#define __XX__XX 0x33
#define __XX_X__ 0x34
#define __XX_X_X 0x35
#define __XX_XX_ 0x36
#define __XX_XXX 0x37
#define __XXX___ 0x38
#define __XXX__X 0x39
#define __XXX_X_ 0x3a
#define __XXX_XX 0x3b
#define __XXXX__ 0x3c
#define __XXXX_X 0x3d
#define __XXXXX_ 0x3e
#define __XXXXXX 0x3f
#define _X______ 0x40
#define _X_____X 0x41
#define _X____X_ 0x42
#define _X____XX 0x43
#define _X___X__ 0x44
#define _X___X_X 0x45
#define _X___XX_ 0x46
#define _X___XXX 0x47
#define _X__X___ 0x48
#define _X__X__X 0x49
#define _X__X_X_ 0x4a
#define _X__X_XX 0x4b
#define _X__XX__ 0x4c
#define _X__XX_X 0x4d
#define _X__XXX_ 0x4e
#define _X__XXXX 0x4f
#define _X_X____ 0x50
#define _X_X___X 0x51
#define _X_X__X_ 0x52
#define _X_X__XX 0x53
#define _X_X_X__ 0x54
#define _X_X_X_X 0x55
#define _X_X_XX_ 0x56
#define _X_X_XXX 0x57
#define _X_XX___ 0x58
#define _X_XX__X 0x59
#define _X_XX_X_ 0x5a
#define _X_XX_XX 0x5b
#define _X_XXX__ 0x5c
#define _X_XXX_X 0x5d
#define _X_XXXX_ 0x5e
#define _X_XXXXX 0x5f
#define _XX_____ 0x60
#define _XX____X 0x61
#define _XX___X_ 0x62
#define _XX___XX 0x63
#define _XX__X__ 0x64
#define _XX__X_X 0x65
#define _XX__XX_ 0x66
#define _XX__XXX 0x67
#define _XX_X___ 0x68
#define _XX_X__X 0x69
#define _XX_X_X_ 0x6a
#define _XX_X_XX 0x6b
#define _XX_XX__ 0x6c
#define _XX_XX_X 0x6d
#define _XX_XXX_ 0x6e
#define _XX_XXXX 0x6f
#define _XXX____ 0x70
#define _XXX___X 0x71
#define _XXX__X_ 0x72
#define _XXX__XX 0x73
#define _XXX_X__ 0x74
#define _XXX_X_X 0x75
#define _XXX_XX_ 0x76
#define _XXX_XXX 0x77
#define _XXXX___ 0x78
#define _XXXX__X 0x79
#define _XXXX_X_ 0x7a
#define _XXXX_XX 0x7b
#define _XXXXX__ 0x7c
#define _XXXXX_X 0x7d
#define _XXXXXX_ 0x7e
#define _XXXXXXX 0x7f
#define X_______ 0x80
#define X______X 0x81
#define X_____X_ 0x82
#define X_____XX 0x83
#define X____X__ 0x84
#define X____X_X 0x85
#define X____XX_ 0x86
#define X____XXX 0x87
#define X___X___ 0x88
#define X___X__X 0x89
#define X___X_X_ 0x8a
#define X___X_XX 0x8b
#define X___XX__ 0x8c
#define X___XX_X 0x8d
#define X___XXX_ 0x8e
#define X___XXXX 0x8f
#define X__X____ 0x90
#define X__X___X 0x91
#define X__X__X_ 0x92
#define X__X__XX 0x93
#define X__X_X__ 0x94
#define X__X_X_X 0x95
#define X__X_XX_ 0x96
#define X__X_XXX 0x97
#define X__XX___ 0x98
#define X__XX__X 0x99
#define X__XX_X_ 0x9a
#define X__XX_XX 0x9b
#define X__XXX__ 0x9c
#define X__XXX_X 0x9d
#define X__XXXX_ 0x9e
#define X__XXXXX 0x9f
#define X_X_____ 0xa0
#define X_X____X 0xa1
#define X_X___X_ 0xa2
#define X_X___XX 0xa3
#define X_X__X__ 0xa4
#define X_X__X_X 0xa5
#define X_X__XX_ 0xa6
#define X_X__XXX 0xa7
#define X_X_X___ 0xa8
#define X_X_X__X 0xa9
#define X_X_X_X_ 0xaa
#define X_X_X_XX 0xab
#define X_X_XX__ 0xac
#define X_X_XX_X 0xad
#define X_X_XXX_ 0xae
#define X_X_XXXX 0xaf
#define X_XX____ 0xb0
#define X_XX___X 0xb1
#define X_XX__X_ 0xb2
#define X_XX__XX 0xb3
#define X_XX_X__ 0xb4
#define X_XX_X_X 0xb5
#define X_XX_XX_ 0xb6
#define X_XX_XXX 0xb7
#define X_XXX___ 0xb8
#define X_XXX__X 0xb9
#define X_XXX_X_ 0xba
#define X_XXX_XX 0xbb
#define X_XXXX__ 0xbc
#define X_XXXX_X 0xbd
#define X_XXXXX_ 0xbe
#define X_XXXXXX 0xbf
#define XX______ 0xc0
#define XX_____X 0xc1
#define XX____X_ 0xc2
#define XX____XX 0xc3
#define XX___X__ 0xc4
#define XX___X_X 0xc5
#define XX___XX_ 0xc6
#define XX___XXX 0xc7
#define XX__X___ 0xc8
#define XX__X__X 0xc9
#define XX__X_X_ 0xca
#define XX__X_XX 0xcb
#define XX__XX__ 0xcc
#define XX__XX_X 0xcd
#define XX__XXX_ 0xce
#define XX__XXXX 0xcf
#define XX_X____ 0xd0
#define XX_X___X 0xd1
#define XX_X__X_ 0xd2
#define XX_X__XX 0xd3
#define XX_X_X__ 0xd4
#define XX_X_X_X 0xd5
#define XX_X_XX_ 0xd6
#define XX_X_XXX 0xd7
#define XX_XX___ 0xd8
#define XX_XX__X 0xd9
#define XX_XX_X_ 0xda
#define XX_XX_XX 0xdb
#define XX_XXX__ 0xdc
#define XX_XXX_X 0xdd
#define XX_XXXX_ 0xde
#define XX_XXXXX 0xdf
#define XXX_____ 0xe0
#define XXX____X 0xe1
#define XXX___X_ 0xe2
#define XXX___XX 0xe3
#define XXX__X__ 0xe4
#define XXX__X_X 0xe5
#define XXX__XX_ 0xe6
#define XXX__XXX 0xe7
#define XXX_X___ 0xe8
#define XXX_X__X 0xe9
#define XXX_X_X_ 0xea
#define XXX_X_XX 0xeb
#define XXX_XX__ 0xec
#define XXX_XX_X 0xed
#define XXX_XXX_ 0xee
#define XXX_XXXX 0xef
#define XXXX____ 0xf0
#define XXXX___X 0xf1
#define XXXX__X_ 0xf2
#define XXXX__XX 0xf3
#define XXXX_X__ 0xf4
#define XXXX_X_X 0xf5
#define XXXX_XX_ 0xf6
#define XXXX_XXX 0xf7
#define XXXXX___ 0xf8
#define XXXXX__X 0xf9
#define XXXXX_X_ 0xfa
#define XXXXX_XX 0xfb
#define XXXXXX__ 0xfc
#define XXXXXX_X 0xfd
#define XXXXXXX_ 0xfe
#define XXXXXXXX 0xff
const unsigned char FONTTYPE8_8[][8] = {
/* blank */
{
________,
________,
________,
________,
________,
________,
________,
________}
/* 0 */
,{
__XXX___,
_XX_XX__,
XX___XX_,
XX___XX_,
XX___XX_,
_XX_XX__,
__XXX___,
________}
/* 1 */
,{
___XX___,
__XXX___,
___XX___,
___XX___,
___XX___,
___XX___,
_XXXXXX_,
________}
/* 2 */
,{
_XXXXX__,
XX___XX_,
_____XX_,
___XXX__,
__XX____,
_XX__XX_,
XXXXXXX_,
________}
/* 3 */
,{
_XXXXX__,
XX___XX_,
_____XX_,
__XXXX__,
_____XX_,
XX___XX_,
_XXXXX__,
________}
/* 4 */
,{
___XXX__,
__XXXX__,
_XX_XX__,
XX__XX__,
XXXXXXX_,
____XX__,
___XXXX_,
________}
/* 5 */
,{
XXXXXXX_,
XX______,
XX______,
XXXXXX__,
_____XX_,
XX___XX_,
_XXXXX__,
________}
/* 6 */
,{
__XXX___,
_XX_____,
XX______,
XXXXXX__,
XX___XX_,
XX___XX_,
_XXXXX__,
________}
/* 7 */
,{
XXXXXXX_,
XX___XX_,
____XX__,
___XX___,
__XX____,
__XX____,
__XX____,
________}
/* 8 */
,{
_XXXXX__,
XX___XX_,
XX___XX_,
_XXXXX__,
XX___XX_,
XX___XX_,
_XXXXX__,
________}
/* 9 */
,{
_XXXXX__,
XX___XX_,
XX___XX_,
_XXXXXX_,
_____XX_,
____XX__,
_XXXX___,
________}
/* A */
,{
__XXX___,
_XX_XX__,
XX___XX_,
XXXXXXX_,
XX___XX_,
XX___XX_,
XX___XX_,
________}
/* B */
,{
XXXXXX__,
_XX__XX_,
_XX__XX_,
_XXXXX__,
_XX__XX_,
_XX__XX_,
XXXXXX__,
________}
/* C */
,{
__XXXX__,
_XX__XX_,
XX______,
XX______,
XX______,
_XX__XX_,
__XXXX__,
________}
/* D */
,{
XXXXX___,
_XX_XX__,
_XX__XX_,
_XX__XX_,
_XX__XX_,
_XX_XX__,
XXXXX___,
________}
/* E */
,{
XXXXXXX_,
_XX___X_,
_XX_X___,
_XXXX___,
_XX_X___,
_XX___X_,
XXXXXXX_,
________}
/* F */
,{
XXXXXXX_,
_XX___X_,
_XX_X___,
_XXXX___,
_XX_X___,
_XX_____,
XXXX____,
________}
/* G */
,{
__XXXX__,
_XX__XX_,
XX______,
XX______,
XX__XXX_,
_XX__XX_,
__XXX_X_,
________}
/* H */
,{
XX___XX_,
XX___XX_,
XX___XX_,
XXXXXXX_,
XX___XX_,
XX___XX_,
XX___XX_,
________}
/* I */
,{
__XXXX__,
___XX___,
___XX___,
___XX___,
___XX___,
___XX___,
__XXXX__,
________}
/* J */
,{
___XXXX_,
____XX__,
____XX__,
____XX__,
XX__XX__,
XX__XX__,
_XXXX___,
________}
/* K */
,{
XXX__XX_,
_XX__XX_,
_XX_XX__,
_XXXX___,
_XX_XX__,
_XX__XX_,
XXX__XX_,
________}
/* L */
,{
XXXX____,
_XX_____,
_XX_____,
_XX_____,
_XX___X_,
_XX__XX_,
XXXXXXX_,
________}
/* M */
,{
XX___XX_,
XXX_XXX_,
XXXXXXX_,
XXXXXXX_,
XX_X_XX_,
XX___XX_,
XX___XX_,
________}
/* N */
,{
XX___XX_,
XXX__XX_,
XXXX_XX_,
XX_XXXX_,
XX__XXX_,
XX___XX_,
XX___XX_,
________}
/* O */
,{
_XXXXX__,
XX___XX_,
XX___XX_,
XX___XX_,
XX___XX_,
XX___XX_,
_XXXXX__,
________}
/* P */
,{
XXXXXX__,
_XX__XX_,
_XX__XX_,
_XXXXX__,
_XX_____,
_XX_____,
XXXX____,
________}
/* Q */
,{
_XXXXX__,
XX___XX_,
XX___XX_,
XX___XX_,
XX___XX_,
XX__XXX_,
_XXXXX__,
____XXX_}
/* R */
,{
XXXXXX__,
_XX__XX_,
_XX__XX_,
_XXXXX__,
_XX_XX__,
_XX__XX_,
XXX__XX_,
________}
/* S */
,{
__XXXX__,
_XX__XX_,
__XX____,
___XX___,
____XX__,
_XX__XX_,
__XXXX__,
________}
/* T */
,{
_XXXXXX_,
_XXXXXX_,
_X_XX_X_,
___XX___,
___XX___,
___XX___,
__XXXX__,
________}
/* U */
,{
XX___XX_,
XX___XX_,
XX___XX_,
XX___XX_,
XX___XX_,
XX___XX_,
_XXXXX__,
________}
/* V */
,{
XX___XX_,
XX___XX_,
XX___XX_,
XX___XX_,
XX___XX_,
_XX_XX__,
__XXX___,
________}
/* W */
,{
XX___XX_,
XX___XX_,
XX___XX_,
XX_X_XX_,
XX_X_XX_,
XXXXXXX_,
_XX_XX__,
________}
/* X */
,{
XX___XX_,
XX___XX_,
_XX_XX__,
__XXX___,
_XX_XX__,
XX___XX_,
XX___XX_,
________}
/* Y */
,{
_XX__XX_,
_XX__XX_,
_XX__XX_,
__XXXX__,
___XX___,
___XX___,
__XXXX__,
________}
/* Z */
,{
XXXXXXX_,
XX___XX_,
X___XX__,
___XX___,
__XX__X_,
_XX__XX_,
XXXXXXX_,
________}
/* a */
,{
________,
________,
_XXXX___,
____XX__,
_XXXXX__,
XX__XX__,
_XXX_XX_,
________}
/* b */
,{
XXX_____,
_XX_____,
_XXXXX__,
_XX__XX_,
_XX__XX_,
_XX__XX_,
XX_XXX__,
________}
/* c */
,{
________,
________,
_XXXXX__,
XX___XX_,
XX______,
XX___XX_,
_XXXXX__,
________}
/* d */
,{
___XXX__,
____XX__,
_XXXXX__,
XX__XX__,
XX__XX__,
XX__XX__,
_XXX_XX_,
________}
/* e */
,{
________,
________,
_XXXXX__,
XX___XX_,
XXXXXXX_,
XX______,
_XXXXX__,
________}
/* f */
,{
__XXXX__,
_XX__XX_,
_XX_____,
XXXXX___,
_XX_____,
_XX_____,
XXXX____,
________}
/* g */
,{
________,
________,
_XXX_XX_,
XX__XX__,
XX__XX__,
_XXXXX__,
____XX__,
XXXXX___}
/* h */
,{
XXX_____,
_XX_____,
_XX_XX__,
_XXX_XX_,
_XX__XX_,
_XX__XX_,
XXX__XX_,
________}
/* i */
,{
___XX___,
________,
__XXX___,
___XX___,
___XX___,
___XX___,
__XXXX__,
________}
/* j */
,{
_____XX_,
________,
_____XX_,
_____XX_,
_____XX_,
_XX__XX_,
_XX__XX_,
__XXXX__}
/* k */
,{
XXX_____,
_XX_____,
_XX__XX_,
_XX_XX__,
_XXXX___,
_XX_XX__,
XXX__XX_,
________}
/* l */
,{
__XXX___,
___XX___,
___XX___,
___XX___,
___XX___,
___XX___,
__XXXX__,
________}
/* m */
,{
________,
________,
XXX_XX__,
XXXXXXX_,
XX_X_XX_,
XX_X_XX_,
XX_X_XX_,
________}
/* n */
,{
________,
________,
XX_XXX__,
_XX__XX_,
_XX__XX_,
_XX__XX_,
_XX__XX_,
________}
/* o */
,{
________,
________,
_XXXXX__,
XX___XX_,
XX___XX_,
XX___XX_,
_XXXXX__,
________}
/* p */
,{
________,
________,
XX_XXX__,
_XX__XX_,
_XX__XX_,
_XXXXX__,
_XX_____,
XXXX____}
/* q */
,{
________,
________,
_XXX_XX_,
XX__XX__,
XX__XX__,
_XXXXX__,
____XX__,
___XXXX_}
/* r */
,{
________,
________,
XX_XXX__,
_XXX_XX_,
_XX_____,
_XX_____,
XXXX____,
________}
/* s */
,{
________,
________,
_XXXXXX_,
XX______,
_XXXXX__,
_____XX_,
XXXXXX__,
________}
/* t */
,{
__XX____,
__XX____,
XXXXXX__,
__XX____,
__XX____,
__XX_XX_,
___XXX__,
________}
/* u */
,{
________,
________,
XX__XX__,
XX__XX__,
XX__XX__,
XX__XX__,
_XXX_XX_,
________}
/* v */
,{
________,
________,
XX___XX_,
XX___XX_,
XX___XX_,
_XX_XX__,
__XXX___,
________}
/* w */
,{
________,
________,
XX___XX_,
XX_X_XX_,
XX_X_XX_,
XXXXXXX_,
_XX_XX__,
________}
/* x */
,{
________,
________,
XX___XX_,
_XX_XX__,
__XXX___,
_XX_XX__,
XX___XX_,
________}
/* y */
,{
________,
________,
XX___XX_,
XX___XX_,
XX___XX_,
_XXXXXX_,
_____XX_,
XXXXXX__}
/* z */
,{
________,
________,
_XXXXXX_,
_X__XX__,
___XX___,
__XX__X_,
_XXXXXX_,
________}
};
#endif /* __FONT_H */

View File

@ -8,15 +8,18 @@
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* Date Author Notes
* 2011-03-03 lgnq
*/
#include <rtthread.h>
#include "key.h"
#include "lcd.h"
#ifdef RT_USING_RTGUI
#include <rtgui/event.h>
#include <rtgui/rtgui_server.h>
#endif
static void key_io_init(void)
{
@ -30,10 +33,12 @@ static void key_io_init(void)
static void key_thread_entry(void *parameter)
{
#ifdef RT_USING_RTGUI
rt_time_t next_delay;
struct rtgui_event_kbd kbd_event;
rt_uint8_t i;
struct rtgui_event_kbd kbd_event;
key_io_init();
/* init keyboard event */
@ -103,6 +108,53 @@ static void key_thread_entry(void *parameter)
/* wait next key press */
rt_thread_delay(next_delay);
}
#else
extern struct rt_messagequeue mq;
rt_time_t next_delay;
rt_uint8_t i;
struct lcd_msg msg;
msg.type = KEY_MSG;
key_io_init();
while (1)
{
msg.key = NO_KEY;
next_delay = RT_TICK_PER_SECOND/10;
if (KEY_ENTER_GETVALUE() == 0 )
{
msg.key = KEY_ENTER;
}
if (KEY_DOWN_GETVALUE() == 0)
{
msg.key = KEY_DOWN;
}
if (KEY_UP_GETVALUE() == 0)
{
msg.key = KEY_UP;
}
if (KEY_RIGHT_GETVALUE() == 0)
{
msg.key = KEY_RIGHT;
}
if (KEY_LEFT_GETVALUE() == 0)
{
msg.key = KEY_LEFT;
}
rt_mq_send(&mq, &msg, sizeof(msg));
/* wait next key press */
rt_thread_delay(next_delay);
}
#endif
}
static rt_thread_t key_thread;

View File

@ -21,6 +21,7 @@
#define KEY_LEFT (1<<2)
#define KEY_RIGHT (1<<3)
#define KEY_UP (1<<4)
#define NO_KEY (1<<5)
#define KEY_MASK (KEY_DOWN | KEY_ENTER | KEY_LEFT | KEY_RIGHT | KEY_UP)
#define KEY_PFR (FM3_GPIO->PFR7)

View File

@ -14,8 +14,15 @@
#include <rtthread.h>
#include "lcd.h"
#include "font.h"
static rt_uint8_t gui_disp_buf[GUI_LCM_YMAX/8][GUI_LCM_XMAX];
const unsigned char BIT_MASK[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
/* simple font: ' ', '0'~'9','a'~'z','A'~'Z' */
extern const unsigned char FONTTYPE8_8[][8];
rt_uint32_t x;
rt_uint32_t y;
struct rtgui_lcd_device
{
@ -291,6 +298,139 @@ static rt_err_t rt_lcd_init (rt_device_t dev)
return RT_EOK;
}
/*******************************************************************************
* Function Name : LCD_FillAll
* Description : Fill the whole LCD.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void LCD_FillAll(unsigned char* buffer)
{
unsigned char i,j = GUI_LCM_XMAX;
unsigned char* p = buffer;
for (i=0; i<GUI_LCM_PAGE; i++)
{
LCD_WriteCmd(Set_Page_Addr_0|i);
LCD_WriteCmd(Set_ColH_Addr_0);
LCD_WriteCmd(Set_ColL_Addr_0);
j = GUI_LCM_XMAX;
while (j--)
{
LCD_WriteData(*p++);
Delay();
}
}
}
/*******************************************************************************
* Function Name : LCD_ClearSCR
* Description : clean screen
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void LCD_ClearSCR(void)
{
for(unsigned char i=0; i<GUI_LCM_PAGE; i++)
{
for(unsigned char j = 0; j < GUI_LCM_XMAX; j++)
gui_disp_buf[i][j] = 0;
}
LCD_FillAll((unsigned char*)gui_disp_buf);
}
/****************************************************************************
* Function Name : LCD_UpdatePoint
* Description : refresh the point in screen
* Input : x X-coordinate
y Y-coordinate
* Output : None
* Return : None
****************************************************************************/
void LCD_UpdatePoint(unsigned int x, unsigned int y)
{
unsigned char coll, colh, page;
page = y / 8;
coll = x & 0x0f;
colh = x >> 4;
LCD_WriteCmd(Set_Page_Addr_0 | page); // page no.
LCD_WriteCmd(Set_ColH_Addr_0 | colh); // fixed col first addr
LCD_WriteCmd(Set_ColL_Addr_0 | coll);
LCD_WriteData(gui_disp_buf[page][x]);
}
/****************************************************************************
* Function Name : LCD_PutChar
* Description : output a char to screen
(the char only can be ' ','0'~'9','A'~'Z','a'~'z')
* Input : x X-coordinate
y Y-coordinate
ch character
* Output : None
* Return : 1 Success
0 Fail
****************************************************************************/
unsigned char LCD_PutChar(unsigned long x, unsigned long y, unsigned char ch)
{
unsigned char data;
if( x >=(GUI_LCM_XMAX-8) ) return(0);
if( y >=(GUI_LCM_YMAX-8) ) return(0);
if(ch == 0x20)
ch -= 0x20;
else if((ch >= 0x30)&&(ch <= 0x39))
ch -= 0x2f;
else if((ch >= 0x41)&&(ch <= 0x5a))
ch -= 0x36;
else if((ch >= 0x61)&&(ch <= 0x7a))
ch -= 0x3C;
else
return(0);
for(unsigned char i = 0; i < 8; i++)
{
data = FONTTYPE8_8[ch][i];
for(unsigned char j = 0; j < 8; j++)
{
if( (data&BIT_MASK[j]) == 0)
gui_disp_buf[y / 8][x] &= (~(0x01 << ( y % 8)));
else
gui_disp_buf[y / 8][x] |= (0x01 <<( y % 8));
LCD_UpdatePoint(x, y);
x ++;
}
x -= 8;
y++;
}
return(1);
}
/****************************************************************************
* Function Name : LCD_PutString
* Description : output string to screen
* Input : x X-coordinate
y Y-coordinate
str pointer to string
* Output : None
* Return : None
****************************************************************************/
void LCD_PutString(unsigned long x, unsigned long y, char *str)
{
while(1)
{
if( (*str)=='\0' ) break;
if( LCD_PutChar(x, y, *str++) == 0 ) break;
x += 6;
}
}
static rt_err_t rt_lcd_control (rt_device_t dev, rt_uint8_t cmd, void *args)
{
switch (cmd)
@ -307,6 +447,12 @@ static rt_err_t rt_lcd_control (rt_device_t dev, rt_uint8_t cmd, void *args)
case RT_DEVICE_CTRL_LCD_DISPLAY_OFF:
LCD_WriteCmd(Display_Off);
break;
case RT_DEVICE_CTRL_LCD_PUT_STRING:
LCD_PutString(x, y, (rt_uint8_t*)args);
break;
case RT_DEVICE_CTRL_LCD_CLEAR_SCR:
LCD_ClearSCR();
break;
}
return RT_EOK;
}

View File

@ -161,6 +161,27 @@ LCD_DATA[0..7] PORT5.[0..7]
#define RT_DEVICE_CTRL_LCD_UPDATE_POINT 8
#define RT_DEVICE_CTRL_LCD_DISPLAY_ON 9
#define RT_DEVICE_CTRL_LCD_DISPLAY_OFF 10
#define RT_DEVICE_CTRL_LCD_PUT_STRING 11
enum
{
ADC_MSG,
KEY_MSG,
CPU_MSG,
MAX_MSG,
};
struct lcd_msg
{
rt_uint8_t type;
rt_uint16_t adc_value;
rt_uint8_t key;
rt_uint16_t major;
rt_uint16_t minor;
};
extern rt_uint32_t x;
extern rt_uint32_t y;
void rt_hw_lcd_init(void);

View File

@ -63,7 +63,7 @@
/* SECTION: RTGUI support */
/* using RTGUI support */
#define RT_USING_RTGUI
//#define RT_USING_RTGUI
/* name length of RTGUI object */
#define RTGUI_NAME_MAX 16