ILI9341 Library

Aus ProjectWiki
Version vom 13. April 2015, 22:28 Uhr von Mat (Diskussion | Beiträge) (Created page with "== Overview == == Options == <pre>' Enables the SPI- instead of the 8-Bit paralell interface #if Not Varexist( "Lcd_enable_spi") Const Lcd_enable_spi = False #endif ' Use s...")
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu:Navigation, Suche

Overview

Options

' Enables the SPI- instead of the 8-Bit paralell interface
#if Not Varexist( "Lcd_enable_spi")
   Const Lcd_enable_spi = False
#endif

' Use software SPI
#if Not Varexist( "Lcd_use_soft_spi") And Lcd_enable_spi = True
   Const Lcd_use_soft_spi = False
#endif

' Enables the 16-Bit paralell interface
#if Not Varexist( "Lcd_enable_16bit")
   Const Lcd_enable_16bit = False
#endif

' Enable backlight control
#if Not Varexist( "Lcd_enable_backlight")
   Const Lcd_enable_backlight = False
#endif

' Use a timer to generate a PWM signal for the backlight instead of switching it on or off
#if Not Varexist( "Lcd_enable_backlight_pwm")
   Const Lcd_enable_backlight_pwm = True
#endif

' ATMega only: select the timer to use for the PWM signal (XMega: automatic)
#if Not Varexist( "Lcd_backlight_timer") And Lcd_enable_backlight_pwm = True And _xmega = False
   Lcd_backlight_timer Alias Timer2
#endif

' invert backlight logic (1: off, 0: on)
#if Not Varexist( "Lcd_invert_backlight") And(lcd_enable_backlight = True Or Lcd_enable_backlight_pwm = True)
   Const Lcd_invert_backlight = False
#endif

' Select the port of the display control pins (XMega: PortC-PortF, ATMega: for HW SPI)
#if Not Varexist( "Lcd_ctrl_port")
   #if _xmega = True
      Const Lcd_ctrl_port = Portc
   #else
      Const Lcd_ctrl_port = Portb
   #endif
#endif

' 8 Bit mode data port
#if Not Varexist( "Lcd_data_port_1") And Lcd_enable_spi = False
   #if _xmega = True
      Const Lcd_data_port_1 = Portf
   #else
      Const Lcd_data_port_1 = Portc
   #endif
#endif

' 16 Bit mode data port #2
#if Not Varexist( "Lcd_data_port_2") And Lcd_enable_16bit = True
   Const Lcd_data_port_2 = Portd
#endif

' Port where the display reset is connected to
#if Not Varexist( "Lcd_reset_port")
   Const Lcd_reset_port = Lcd_ctrl_port
#endif

' Pin of the display reset signal
#if Not Varexist( "Lcd_reset_pin")
   Const Lcd_reset_pin = 0
#endif

#if Lcd_enable_spi = True
   ' SPI mode pin assignments
   #if Not Varexist( "Lcd_pin_dc")
      #if _xmega = True
         Const Lcd_pin_dc = 1
      #else
         Const Lcd_pin_dc = 4
      #endif
   #endif
   ' (HW: fixed, SW: select any)
   #if Not Varexist( "Lcd_pin_cs")
      #if _xmega = True
         Const Lcd_pin_cs = 4
      #else
         Const Lcd_pin_cs = 0
      #endif
   #endif
   #if Not Varexist( "Lcd_pin_sdo")
      #if _xmega = True
         Const Lcd_pin_sdo = 5
      #else
         Const Lcd_pin_sdo = 2
      #endif
   #endif
   #if Not Varexist( "Lcd_pin_clk")
      #if _xmega = True
         Const Lcd_pin_clk = 7
      #else
         Const Lcd_pin_clk = 1
      #endif
   #endif
'   Const Lcd_pin_sdi = 6
#else
   ' parallel (8/16 Bit) mode pin assignments
   #if Not Varexist( "Lcd_pin_wr")
      Const Lcd_pin_wr = 1
   #endif
   #if Not Varexist( "Lcd_pin_rd")
      Const Lcd_pin_rd = 5
   #endif
   #if Not Varexist( "Lcd_pin_dc")
      Const Lcd_pin_dc = 7
   #endif
   #if Not Varexist( "Lcd_pin_cs")
      Const Lcd_pin_cs = 4
   #endif
#endif

' Port of the backlight control signal
#if Not Varexist( "Lcd_backlight_port") And(lcd_enable_backlight = True Or Lcd_enable_backlight_pwm = True)
   Const Lcd_backlight_port = Lcd_ctrl_port
#endif

' Pin of the backlight control signal
#if Not Varexist( "Lcd_pin_backlight" ) And(lcd_enable_backlight = True Or Lcd_enable_backlight_pwm = True)
   #if _xmega = True
      Const Lcd_pin_backlight = 0
   #else
      Const Lcd_pin_backlight = 6
   #endif
#endif

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

=

Electrical connection

LCD connection schematic

ATXMega-A1 Xplained connections

This Software is Donationware. <paypal>1</paypal> See here for more informations


Download