ILI9341 Library: Unterschied zwischen den Versionen

Aus ProjectWiki
Wechseln zu:Navigation, Suche
K (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...")
 
K
Zeile 1: Zeile 1:
 
== Overview ==
 
== 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
 +
<pre>Const Lcd_enable_spi = False
  
== Options ==
+
Use software SPI
<pre>' Enables the SPI- instead of the 8-Bit paralell interface
+
Const Lcd_use_soft_spi = False
#if Not Varexist( "Lcd_enable_spi")
 
  Const Lcd_enable_spi = False
 
#endif
 
  
' Use software SPI
+
Enables the 16-Bit paralell interface
#if Not Varexist( "Lcd_use_soft_spi") And Lcd_enable_spi = True
+
Const Lcd_enable_16bit = False
  Const Lcd_use_soft_spi = False
 
#endif
 
  
' Enables the 16-Bit paralell interface
+
Enable backlight control
#if Not Varexist( "Lcd_enable_16bit")
+
Const Lcd_enable_backlight = False
  Const Lcd_enable_16bit = False
 
#endif
 
  
' Enable backlight control
+
Use a timer to generate a PWM signal for the backlight instead of switching it on or off
#if Not Varexist( "Lcd_enable_backlight")
+
Const Lcd_enable_backlight_pwm = True
  Const Lcd_enable_backlight = False
 
#endif
 
  
' Use a timer to generate a PWM signal for the backlight instead of switching it on or off
+
ATMega only: select the timer to use for the PWM signal (XMega: automatic)
#if Not Varexist( "Lcd_enable_backlight_pwm")
+
Lcd_backlight_timer Alias Timer2
  Const Lcd_enable_backlight_pwm = True
 
#endif
 
  
' ATMega only: select the timer to use for the PWM signal (XMega: automatic)
+
invert backlight logic (1: off, 0: on)
#if Not Varexist( "Lcd_backlight_timer") And Lcd_enable_backlight_pwm = True And _xmega = False
+
Const Lcd_invert_backlight = False
  Lcd_backlight_timer Alias Timer2
 
#endif
 
  
' invert backlight logic (1: off, 0: on)
+
Select the port of the display control pins (XMega: PortC-PortF, ATMega: for HW SPI)
#if Not Varexist( "Lcd_invert_backlight") And(lcd_enable_backlight = True Or Lcd_enable_backlight_pwm = True)
+
Const Lcd_ctrl_port = Portc
  Const Lcd_invert_backlight = False
+
Const Lcd_ctrl_port = Portb
#endif
 
  
' Select the port of the display control pins (XMega: PortC-PortF, ATMega: for HW SPI)
+
8 Bit mode data port
#if Not Varexist( "Lcd_ctrl_port")
+
Const Lcd_data_port_1 = Portf
  #if _xmega = True
+
Const Lcd_data_port_1 = Portc
      Const Lcd_ctrl_port = Portc
 
  #else
 
      Const Lcd_ctrl_port = Portb
 
  #endif
 
#endif
 
  
' 8 Bit mode data port
+
16 Bit mode data port #2
#if Not Varexist( "Lcd_data_port_1") And Lcd_enable_spi = False
+
Const Lcd_data_port_2 = Portd
  #if _xmega = True
 
      Const Lcd_data_port_1 = Portf
 
  #else
 
      Const Lcd_data_port_1 = Portc
 
  #endif
 
#endif
 
  
' 16 Bit mode data port #2
+
Port where the display reset is connected to
#if Not Varexist( "Lcd_data_port_2") And Lcd_enable_16bit = True
+
Const Lcd_reset_port = Lcd_ctrl_port
  Const Lcd_data_port_2 = Portd
 
#endif
 
  
' Port where the display reset is connected to
+
Pin of the display reset signal
#if Not Varexist( "Lcd_reset_port")
+
Const Lcd_reset_pin = 0
  Const Lcd_reset_port = Lcd_ctrl_port
 
#endif
 
  
' Pin of the display reset signal
+
SPI mode pin assignments
#if Not Varexist( "Lcd_reset_pin")
+
Const Lcd_pin_dc = 1
  Const Lcd_reset_pin = 0
+
Const Lcd_pin_dc = 4
#endif
+
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
  
#if Lcd_enable_spi = True
+
parallel (8/16 Bit) mode pin assignments
  ' SPI mode pin assignments
+
Const Lcd_pin_wr = 1
  #if Not Varexist( "Lcd_pin_dc")
+
Const Lcd_pin_rd = 5
      #if _xmega = True
+
Const Lcd_pin_dc = 7
        Const Lcd_pin_dc = 1
+
Const Lcd_pin_cs = 4
      #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
+
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
  Const Lcd_backlight_port = Lcd_ctrl_port
 
#endif
 
  
' Pin of the backlight control signal
+
Pin of the backlight control signal
#if Not Varexist( "Lcd_pin_backlight" ) And(lcd_enable_backlight = True Or Lcd_enable_backlight_pwm = True)
+
Const Lcd_pin_backlight = 0
  #if _xmega = True
+
Const Lcd_pin_backlight = 6</pre>
      Const Lcd_pin_backlight = 0
 
  #else
 
      Const Lcd_pin_backlight = 6
 
  #endif
 
#endif</pre>
 
  
 
== API ==
 
== API ==
Zeile 207: Zeile 138:
  
  
===  
+
=== Sample project from the video ===
  
  

Version vom 15. April 2015, 02:42 Uhr

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

LCD connection schematic

ATXMega-A1 Xplained connections

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


Download