ILI9341 Library
Aus ProjectWiki
Version vom 15. April 2015, 02:42 Uhr von Mat (Diskussion | Beiträge)
Inhaltsverzeichnis
Overview
ILI9341 driver library for ATXMega/ATMega with hardware/software SPI or 8/16 bit parallel mode. Includes Backlight control with a GPIO or a PWM signal generated by a timer. Supports screen rotation (4 directions). Most of the graphics routines are optimized for speed with inline Assembler.
Options
Enables the SPI- instead of the 8-Bit paralell interface
Const Lcd_enable_spi = False Use software SPI Const Lcd_use_soft_spi = False Enables the 16-Bit paralell interface Const Lcd_enable_16bit = False Enable backlight control Const Lcd_enable_backlight = False Use a timer to generate a PWM signal for the backlight instead of switching it on or off Const Lcd_enable_backlight_pwm = True ATMega only: select the timer to use for the PWM signal (XMega: automatic) Lcd_backlight_timer Alias Timer2 invert backlight logic (1: off, 0: on) Const Lcd_invert_backlight = False Select the port of the display control pins (XMega: PortC-PortF, ATMega: for HW SPI) Const Lcd_ctrl_port = Portc Const Lcd_ctrl_port = Portb 8 Bit mode data port Const Lcd_data_port_1 = Portf Const Lcd_data_port_1 = Portc 16 Bit mode data port #2 Const Lcd_data_port_2 = Portd Port where the display reset is connected to Const Lcd_reset_port = Lcd_ctrl_port Pin of the display reset signal Const Lcd_reset_pin = 0 SPI mode pin assignments Const Lcd_pin_dc = 1 Const Lcd_pin_dc = 4 Const Lcd_pin_cs = 4 Const Lcd_pin_cs = 0 Const Lcd_pin_sdo = 5 Const Lcd_pin_sdo = 2 Const Lcd_pin_clk = 7 Const Lcd_pin_clk = 1 parallel (8/16 Bit) mode pin assignments Const Lcd_pin_wr = 1 Const Lcd_pin_rd = 5 Const Lcd_pin_dc = 7 Const Lcd_pin_cs = 4 Port of the backlight control signal Const Lcd_backlight_port = Lcd_ctrl_port Pin of the backlight control signal Const Lcd_pin_backlight = 0 Const Lcd_pin_backlight = 6
API
Dim Lcd_screen_width As Word ' the actual max X and Y coordinates (after rotation) Dim Lcd_screen_height As Word
Dim Lcd_digit_font As Bit 'For reduced Digit font
' Initializes the control interface (paralell/serial), backlight control and the display Sub Lcd_init()
Dim Lcd_sleepmode As Bit
Sub Lcd_backlight(byval Value As Byte)
Sets the backlight value (0: Off, Standby On; 1-254: PWM, 255: On, Display Wakeup)
Sub Lcd_backlight_dim(byval Startvalue As Byte , Byval Endvalue As Byte , Byval Millisecs As Word)
Dim Lcd_rotation As Byte
Sub Lcd_set_rotation(byval Rotation As Byte)
Sub Lcd_fill_rect(byval X1 As Word , Byval Y1 As Word , Byval X2 As Word , Byval Y2 As Word , Byval Color As Word)
Sub Lcd_set_pixel(byval X As Word , Byval Y As Word , Byval Color As Word)
Sub Lcd_pic_flash(byval Xs As Word , Byval Ys As Word , Byval Width As Byte , Byval Height As Word)
Sub Lcd_pic_spi(byval Xs As Word , Byval Ys As Word , Byval Width As Word , Byval Height As Word , Byval Address As Dword)
Dim Lcd_ram_pics_free_ptr As Dword
Function Lcd_load_pic_flash2ram(byval Width As Word , Byval Height As Word) As Word
Sub Lcd_pic_ram(byval Xs As Word , Byval Ys As Word , Byval Width As Word , Byval Height As Word , Byval Address As Dword)
Sub Lcd_pic_bgf(byval Xoffset As Word , Byval Yoffset As Word)
Sub Lcd_clear(byval Color As Word)
Sub Lcd_invert(byval Inverted As Byte )
Sub Lcd_text(byval S As String , Byval Xoffset As Word , Byval Yoffset As Word , Byval Forecolor As Word , Byval Backcolor As Word)
Sub Lcd_line(byval X1 As Word , Byval Y1 As Word , Byval X2 As Word , Byval Y2 As Word , Byval Color As Word)
Sub Lcd_line_gradient(byval X1 As Word , Byval Y1 As Word , Byval X2 As Word , Byval Y2 As Word , Byval Color1 As Word , Byval Color2 As Word)
Sub Lcd_circle(byval Xcenter As Word , Byval Ycenter As Word , Byval Radius As Word , Byval Color As Word)
Sub Lcd_fill_circle(byval X As Word , Byval Y As Word , Byval Radius As Word , Byval Color As Word)
Sub Lcd_rect(byval X1 As Word , Byval Y1 As Word , Byval X2 As Word , Byval Y2 As Word , Byval Color As Word)
Sample
Sample project from the video
Electrical connection
ATXMega-A1 Xplained connections
Donate
This Software is Donationware. <paypal>1</paypal> See here for more informations