mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-01-18 18:13:31 +08:00
fix lcd get_pixel
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@438 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
d014c0d6da
commit
b3d4ac3b66
@ -1,4 +1,4 @@
|
||||
#include "FMT0371.h"
|
||||
#include "fmt0371.h"
|
||||
#include "stm32f10x.h"
|
||||
|
||||
#define FSMC_GPIO_CONFIG
|
||||
|
@ -1,20 +1,31 @@
|
||||
#ifndef FMT0371_H_INCLUDED
|
||||
#define FMT0371_H_INCLUDED
|
||||
|
||||
//---------- LCD_RESET -------------
|
||||
/************** LCD_RESET ************/
|
||||
#define LCD_RST_PORT GPIOF
|
||||
#define LCD_RST_PIN GPIO_Pin_10
|
||||
#define LCD_RST_RCC RCC_APB2Periph_GPIOF
|
||||
/**************************************/
|
||||
#define LCD_RST_0 GPIO_ResetBits(LCD_RST_PORT,LCD_RST_PIN)
|
||||
#define LCD_RST_1 GPIO_SetBits(LCD_RST_PORT,LCD_RST_PIN)
|
||||
//---------- LCD_RESET -------------
|
||||
/************** LCD_RESET ************/
|
||||
|
||||
#define LCD_ADDR (*((volatile unsigned char *) 0x64000000)) // RS = 0
|
||||
#define LCD_DATA (*((volatile unsigned char *) 0x64000004)) // RS = 1
|
||||
#define LCD_ADDR (*((volatile unsigned char *) 0x64000000)) /* RS = 0 */
|
||||
#define LCD_DATA (*((volatile unsigned char *) 0x64000004)) /* RS = 1 */
|
||||
|
||||
#define LCD_DATA16(a) LCD_DATA = (unsigned char)(a>>8);LCD_DATA = (unsigned char)a // RS = 1 & WIDHT = 16
|
||||
#define LCD_DATA16_READ(a) do { a = (LCD_DATA << 8) | (LCD_DATA); } while (0)
|
||||
#include "rtdef.h"
|
||||
rt_inline void LCD_DATA16(rt_uint16_t data)
|
||||
{
|
||||
LCD_DATA = data>>8;
|
||||
LCD_DATA = data;
|
||||
}
|
||||
|
||||
rt_inline rt_uint16_t LCD_DATA16_READ(void)
|
||||
{
|
||||
rt_uint16_t temp;
|
||||
temp = (LCD_DATA << 8);
|
||||
temp |= LCD_DATA;
|
||||
return temp;
|
||||
}
|
||||
#define LCD_WR_CMD(a,b,c) LCD_ADDR = b;LCD_DATA16(c)
|
||||
#define LCD_WR_REG(a) LCD_ADDR = a
|
||||
#define LCD_WR_DATA8(a) LCD_DATA = a
|
||||
|
@ -1,21 +1,16 @@
|
||||
#include "stm32f10x.h"
|
||||
#include "rtthread.h"
|
||||
#include "board.h"
|
||||
#include <rtgui/rtgui.h>
|
||||
#include <rtgui/driver.h>
|
||||
#include <rtgui/rtgui_server.h>
|
||||
#include <rtgui/rtgui_system.h>
|
||||
|
||||
#define lcd_hw_version 1
|
||||
/*
|
||||
1 FMT0371
|
||||
2 ILI9325
|
||||
*/
|
||||
|
||||
#if (lcd_hw_version == 1)
|
||||
#if (LCD_VERSION == 1)
|
||||
#include "fmt0371/FMT0371.h"
|
||||
#endif
|
||||
|
||||
#if (lcd_hw_version == 2)
|
||||
#if (LCD_VERSION == 2)
|
||||
#include "ili9325/ili9320.h"
|
||||
#endif
|
||||
|
||||
@ -72,7 +67,7 @@ void radio_rtgui_init(void)
|
||||
player_init();
|
||||
}
|
||||
|
||||
#if (lcd_hw_version == 1)
|
||||
#if (LCD_VERSION == 1)
|
||||
void rt_hw_lcd_update(rtgui_rect_t *rect)
|
||||
{
|
||||
/* nothing for none-DMA mode driver */
|
||||
@ -105,8 +100,6 @@ void rt_hw_lcd_set_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y)
|
||||
|
||||
void rt_hw_lcd_get_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y)
|
||||
{
|
||||
unsigned short p;
|
||||
|
||||
/* set X point */
|
||||
LCD_ADDR = 0x02;
|
||||
LCD_DATA = x;
|
||||
@ -117,9 +110,10 @@ void rt_hw_lcd_get_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y)
|
||||
|
||||
/* read pixel */
|
||||
LCD_ADDR = 0x0F;
|
||||
LCD_DATA16_READ(p);
|
||||
/* dummy read */
|
||||
x = LCD_DATA;
|
||||
|
||||
*c = rtgui_color_from_565p(p);
|
||||
*c = rtgui_color_from_565p( LCD_DATA16_READ() );
|
||||
}
|
||||
|
||||
void rt_hw_lcd_draw_hline(rtgui_color_t *c, rt_base_t x1, rt_base_t x2, rt_base_t y)
|
||||
@ -210,6 +204,61 @@ rt_err_t rt_hw_lcd_init(void)
|
||||
ftm0371_port_init();
|
||||
ftm0371_init();
|
||||
|
||||
//LCD GRAM test
|
||||
{
|
||||
unsigned int test_x;
|
||||
unsigned int test_y;
|
||||
unsigned short temp;
|
||||
|
||||
rt_kprintf("\r\nLCD GRAM test....");
|
||||
|
||||
//write
|
||||
temp = 0;
|
||||
for( test_y=0; test_y<320; test_y++)
|
||||
{
|
||||
/* set X point */
|
||||
LCD_ADDR = 0x02;
|
||||
LCD_DATA = 0;
|
||||
|
||||
/* set Y point */
|
||||
LCD_ADDR = 0x03;
|
||||
LCD_DATA16( test_y );
|
||||
|
||||
/* write pixel */
|
||||
LCD_ADDR = 0x0E;
|
||||
for(test_x=0; test_x<240; test_x++)
|
||||
{
|
||||
LCD_DATA16(temp++);
|
||||
}
|
||||
}
|
||||
|
||||
temp = 0;
|
||||
for( test_y=0; test_y<320; test_y++)
|
||||
{
|
||||
/* set X point */
|
||||
LCD_ADDR = 0x02;
|
||||
LCD_DATA = 0;
|
||||
|
||||
/* set Y point */
|
||||
LCD_ADDR = 0x03;
|
||||
LCD_DATA16( test_y );
|
||||
|
||||
/* write pixel */
|
||||
LCD_ADDR = 0x0f;
|
||||
/* dummy read */
|
||||
test_x = LCD_DATA;
|
||||
for(test_x=0; test_x<240; test_x++)
|
||||
{
|
||||
if ( LCD_DATA16_READ() != temp++)
|
||||
{
|
||||
rt_kprintf(" LCD GRAM ERR!!");
|
||||
while(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
rt_kprintf(" TEST PASS!\r\n");
|
||||
}//LCD GRAM TEST
|
||||
|
||||
#ifndef DRIVER_TEST
|
||||
/* add lcd driver into graphic driver */
|
||||
rtgui_graphic_driver_add(&_rtgui_lcd_driver);
|
||||
@ -243,7 +292,7 @@ void cls()
|
||||
FINSH_FUNCTION_EXPORT(cls, clear screen);
|
||||
#endif
|
||||
|
||||
#if (lcd_hw_version == 2)
|
||||
#if (LCD_VERSION == 2)
|
||||
void rt_hw_lcd_update(rtgui_rect_t *rect)
|
||||
{
|
||||
/* nothing for none-DMA mode driver */
|
||||
|
Loading…
x
Reference in New Issue
Block a user