打印
[Atmel]

用SAM-BA或JLINK跑ATSAM4E16的程序(8)显示字符串

[复制链接]
1172|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
其实,显示字符串例程都有,我只不过多看了一下这个屏的函数。

其中定义了如下函数:


uint32_t ili93xx_init(struct ili93xx_opt_t *p_opt);
void ili93xx_display_on(void);
void ili93xx_display_off(void);
void ili93xx_set_foreground_color(ili93xx_color_t ul_color);
void ili93xx_fill(ili93xx_color_t ul_color);
void ili93xx_set_window(uint32_t ul_x, uint32_t ul_y,
        uint32_t ul_width, uint32_t ul_height);
void ili93xx_set_cursor_position(uint16_t us_x, uint16_t us_y);
void ili93xx_scroll(int32_t ul_lines);
void ili93xx_enable_scroll(void);
void ili93xx_disable_scroll(void);
void ili93xx_set_display_direction(enum ili93xx_display_direction e_dd,
        enum ili93xx_shift_direction e_shd,
        enum ili93xx_scan_direction e_scd);
uint32_t ili93xx_draw_pixel(uint32_t ul_x, uint32_t ul_y);
ili93xx_color_t ili93xx_get_pixel(uint32_t ul_x, uint32_t ul_y);
void ili93xx_draw_line(uint32_t ul_x1, uint32_t ul_y1,
        uint32_t ul_x2, uint32_t ul_y2);
void ili93xx_draw_rectangle(uint32_t ul_x1, uint32_t ul_y1,
        uint32_t ul_x2, uint32_t ul_y2);
void ili93xx_draw_filled_rectangle(uint32_t ul_x1, uint32_t ul_y1,
        uint32_t ul_x2, uint32_t ul_y2);
uint32_t ili93xx_draw_circle(uint32_t ul_x, uint32_t ul_y, uint32_t ul_r);
uint32_t ili93xx_draw_filled_circle(uint32_t ul_x, uint32_t ul_y,
        uint32_t ul_r);
void ili93xx_draw_string(uint32_t ul_x, uint32_t ul_y, const uint8_t *p_str);
void ili93xx_draw_pixmap(uint32_t ul_x, uint32_t ul_y, uint32_t ul_width,
        uint32_t ul_height, const ili93xx_color_t *p_ul_pixmap);
void ili93xx_set_top_left_limit(ili93xx_coord_t x, ili93xx_coord_t y);
void ili93xx_set_bottom_right_limit(ili93xx_coord_t x, ili93xx_coord_t y);
void ili93xx_set_limits(ili93xx_coord_t start_x, ili93xx_coord_t start_y,
        ili93xx_coord_t end_x, ili93xx_coord_t end_y);
ili93xx_color_t ili93xx_read_gram(void);
void ili93xx_write_gram(ili93xx_color_t color);
void ili93xx_copy_pixels_to_screen(const ili93xx_color_t *pixels,
        uint32_t count);
void ili93xx_copy_raw_pixel_24bits_to_screen(const uint8_t *raw_pixels,
        uint32_t count);
void ili93xx_duplicate_pixel(const ili93xx_color_t color, uint32_t count);
void ili93xx_copy_pixels_from_screen(ili93xx_color_t *pixels, uint32_t count);
uint8_t ili93xx_device_type(void);
void ili93xx_vscroll_area_define(uint16_t us_tfa, uint16_t us_vsa,
        uint16_t us_bfa);
uint8_t ili93xx_device_type_identify(void);


我试了下画图填充的画圆函数。需要注意的是每次画圆,都要选确定一下前台的着色:

以下是程序:


#include "asf.h"
#include "stdio_serial.h"
#include "conf_board.h"
#include "conf_clock.h"
#include "smc.h"
#include "ili93xx.h"

/** Chip select number to be set */
#define ILI93XX_LCD_CS      1

struct ili93xx_opt_t g_ili93xx_display_opt;

/**
*  Configure UART console.
*/
static void configure_console(void)
{
        const usart_serial_options_t uart_serial_options = {
                .baudrate = CONF_UART_BAUDRATE,
                .paritytype = CONF_UART_PARITY
        };

        /** Configure console UART. */
        sysclk_enable_peripheral_clock(CONSOLE_UART_ID);
        stdio_serial_init(CONF_UART, &uart_serial_options);
}

/**
* \brief Application entry point for smc_lcd example.
*
* \return Unused (ANSI-C compatibility).
*/
int main(void)
{
        sysclk_init();
        board_init();

        /** Initialize debug console */
        configure_console();

        /** Enable peripheral clock */
        pmc_enable_periph_clk(ID_SMC);

        /** Configure SMC interface for Lcd */
        smc_set_setup_timing(SMC, ILI93XX_LCD_CS, SMC_SETUP_NWE_SETUP(2)
                        | SMC_SETUP_NCS_WR_SETUP(2)
                        | SMC_SETUP_NRD_SETUP(2)
                        | SMC_SETUP_NCS_RD_SETUP(2));
        smc_set_pulse_timing(SMC, ILI93XX_LCD_CS, SMC_PULSE_NWE_PULSE(4)
                        | SMC_PULSE_NCS_WR_PULSE(4)
                        | SMC_PULSE_NRD_PULSE(10)
                        | SMC_PULSE_NCS_RD_PULSE(10));
        smc_set_cycle_timing(SMC, ILI93XX_LCD_CS, SMC_CYCLE_NWE_CYCLE(10)
                        | SMC_CYCLE_NRD_CYCLE(22));
#if ((!defined(SAM4S)) && (!defined(SAM4E)))
        smc_set_mode(SMC, ILI93XX_LCD_CS, SMC_MODE_READ_MODE
                        | SMC_MODE_WRITE_MODE
                        | SMC_MODE_DBW_8_BIT);
#else
        smc_set_mode(SMC, ILI93XX_LCD_CS, SMC_MODE_READ_MODE
                        | SMC_MODE_WRITE_MODE);
#endif
        /** Initialize display parameter */
        g_ili93xx_display_opt.ul_width = ILI93XX_LCD_WIDTH;
        g_ili93xx_display_opt.ul_height = ILI93XX_LCD_HEIGHT;
        g_ili93xx_display_opt.foreground_color = COLOR_BLACK;
        g_ili93xx_display_opt.background_color = COLOR_WHITE;

        /** Switch off backlight */
        aat31xx_disable_backlight();

        /** Initialize LCD */
        ili93xx_init(&g_ili93xx_display_opt);

        /** Set backlight level */
        aat31xx_set_backlight(AAT31XX_AVG_BACKLIGHT_LEVEL);

        ili93xx_set_foreground_color(COLOR_DARKBLUE);
        ili93xx_draw_filled_rectangle(0, 0, ILI93XX_LCD_WIDTH,
                        ILI93XX_LCD_HEIGHT);
        /** Turn on LCD */
        ili93xx_display_on();
        ili93xx_set_cursor_position(0, 0);

        /** Draw text, image and basic shapes on the LCD */
        ili93xx_set_foreground_color(COLOR_WHITE);
        ili93xx_draw_string(10, 20, (uint8_t *)"ili93xx_lcd example");
       
        ili93xx_draw_string(10, 40, (uint8_t *)"This's 21ic's Atmel");

        ili93xx_set_foreground_color(COLOR_RED);
        ili93xx_draw_filled_circle(60, 160, 40);
        ili93xx_set_foreground_color(COLOR_GREEN);
        ili93xx_draw_filled_circle(120, 160, 40);
        ili93xx_set_foreground_color(COLOR_BLUE);
        ili93xx_draw_filled_circle(180, 160, 40);

        //ili93xx_set_foreground_color(COLOR_VIOLET);
        //ili93xx_draw_line(0, 0, 240, 320);
       
   
       
       

        while (1) {
        }
}

下面是运行结果:





相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:http://shop34182318.taobao.com/ http://shop562064536.taobao.com

2399

主题

6963

帖子

68

粉丝