ILI9341 Library: Unterschied zwischen den Versionen
Mat (Diskussion | Beiträge) K |
Mat (Diskussion | Beiträge) 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 | + | 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 . Most of the graphics routines are optimized for speed with inline Assembler. |
+ | |||
+ | Features: | ||
+ | * SPI (Soft-/Hardware), 8/16 Bit parallel interface | ||
+ | * ATMega/ATXmega | ||
+ | * Fast assembler-optimized routines | ||
+ | * Backlight control (Digital IO or PWM) | ||
+ | * Screen rotation (4 directions), Standby, Color inversion | ||
+ | * Basic graphics, pictures (fast SRAM-pictures), text | ||
Zeile 77: | Zeile 85: | ||
== API == | == API == | ||
− | the | + | Initializes the control interface (paralell/serial), backlight control and the display |
− | <pre> | + | <pre>Sub Lcd_init()</pre> |
− | |||
− | + | Inverts the screen's colors | |
− | <pre> | + | <pre>Sub Lcd_invert(byval Inverted As Byte )</pre> |
− | + | === Sleep mode === | |
− | <pre> | + | Indicates if the display is in sleep mode. |
+ | <pre>Dim Lcd_sleepmode As Bit</pre> | ||
− | + | Set display in sleep mode / wake up | |
− | <pre> | + | <pre>Sub Lcd_sleep(byval Value As Byte)</pre> |
+ | === Backlight === | ||
Sets the backlight value (0: BL Off, Standby On; 1-254: PWM, 255: BL On, Display Wakeup) | Sets the backlight value (0: BL Off, Standby On; 1-254: PWM, 255: BL On, Display Wakeup) | ||
<pre>Sub Lcd_backlight(byval Value As Byte)</pre> | <pre>Sub Lcd_backlight(byval Value As Byte)</pre> | ||
Zeile 102: | Zeile 111: | ||
+ | === Screen rotation === | ||
Indicates the current rotation | Indicates the current rotation | ||
<pre>Dim Lcd_rotation As Byte</pre> | <pre>Dim Lcd_rotation As Byte</pre> | ||
+ | |||
+ | |||
+ | the actual max X and Y coordinates (after rotation) | ||
+ | <pre>Dim Lcd_screen_width As Word | ||
+ | Dim Lcd_screen_height As Word</pre> | ||
Sets the display rotation (0: 0° Portrait, 1: 90° Landscape, 2: 180° Portrait, 3: 270° Landscape, 4: 0° ...) | Sets the display rotation (0: 0° Portrait, 1: 90° Landscape, 2: 180° Portrait, 3: 270° Landscape, 4: 0° ...) | ||
<pre>Sub Lcd_set_rotation(byval Rotation As Byte)</pre> | <pre>Sub Lcd_set_rotation(byval Rotation As Byte)</pre> | ||
+ | |||
+ | |||
+ | === Basic graphics === | ||
+ | Clears the screen. | ||
+ | <pre>Sub Lcd_clear(byval Color As Word) </pre> | ||
+ | |||
+ | |||
+ | Draws a rectangle | ||
+ | <pre>Sub Lcd_rect(byval X1 As Word , Byval Y1 As Word , Byval X2 As Word , Byval Y2 As Word , Byval Color As Word)</pre> | ||
Zeile 118: | Zeile 142: | ||
+ | Draws a line between two points | ||
+ | <pre>Sub Lcd_line(byval X1 As Word , Byval Y1 As Word , Byval X2 As Word , Byval Y2 As Word , Byval Color As Word)</pre> | ||
+ | |||
+ | |||
+ | Draws a line with color transition between two points | ||
+ | <pre>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)</pre> | ||
+ | |||
+ | |||
+ | Draws a circle | ||
+ | <pre>Sub Lcd_circle(byval Xcenter As Word , Byval Ycenter As Word , Byval Radius As Word , Byval Color As Word)</pre> | ||
+ | |||
+ | |||
+ | Draws a filled circle | ||
+ | <pre>Sub Lcd_fill_circle(byval X As Word , Byval Y As Word , Byval Radius As Word , Byval Color As Word)</pre> | ||
+ | |||
+ | |||
+ | === Pictures === | ||
Draws a BIN picture from the internal program flash memory. Image has to be loaded with ''Restore'' before. | Draws a BIN picture from the internal program flash memory. Image has to be loaded with ''Restore'' before. | ||
<pre>Sub Lcd_pic_flash(byval Xs As Word , Byval Ys As Word , Byval Width As Byte , Byval Height As Word)</pre> | <pre>Sub Lcd_pic_flash(byval Xs As Word , Byval Ys As Word , Byval Width As Byte , Byval Height As Word)</pre> | ||
Zeile 142: | Zeile 183: | ||
− | + | === Text === | |
− | + | For reduced Digit font | |
− | + | <pre>Dim Lcd_digit_font As Bit</pre> | |
− | |||
− | |||
− | <pre> | ||
Zeile 156: | Zeile 194: | ||
Draws a fixed-font text on the screen. | Draws a fixed-font text on the screen. | ||
<pre>Sub Lcd_text(byval S As String , Byval Xoffset As Word , Byval Yoffset As Word , Byval Forecolor As Word , Byval Backcolor As Word)</pre> | <pre>Sub Lcd_text(byval S As String , Byval Xoffset As Word , Byval Yoffset As Word , Byval Forecolor As Word , Byval Backcolor As Word)</pre> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Version vom 17. April 2015, 02:28 Uhr
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 . Most of the graphics routines are optimized for speed with inline Assembler.
Features:
- SPI (Soft-/Hardware), 8/16 Bit parallel interface
- ATMega/ATXmega
- Fast assembler-optimized routines
- Backlight control (Digital IO or PWM)
- Screen rotation (4 directions), Standby, Color inversion
- Basic graphics, pictures (fast SRAM-pictures), text
Options
Options and settings need to be set before the $include-statement, every setting has a default value that will be used if not specified otherwise. (in the list below the default values for the ATXMega are shown, values for ATMega are written in brackets () if applicable).
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: HW-SPI & PWM Timer fixed on PortC-PortF, ATMega: HW SPI on PortB, for SW SPI or parallel modes any GPIO will work)
Const Lcd_ctrl_port = Portc (Portb)
8 Bit mode data port
Const Lcd_data_port_1 = Portf (Portc)
16 Bit mode data port #2
Const Lcd_data_port_2 = Portd
Port of the display reset signal
Const Lcd_reset_port = Lcd_ctrl_port
Pin of the display reset signal
Const Lcd_reset_pin = 0
SPI mode pin assignments (HW SPI: fixed, SW SPI: any GPIO)
Const Lcd_pin_dc = 1 (4) Const Lcd_pin_cs = 4 (0) Const Lcd_pin_sdo = 5 (2) Const Lcd_pin_clk = 7 (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 (6)
API
Initializes the control interface (paralell/serial), backlight control and the display
Sub Lcd_init()
Inverts the screen's colors
Sub Lcd_invert(byval Inverted As Byte )
Sleep mode
Indicates if the display is in sleep mode.
Dim Lcd_sleepmode As Bit
Set display in sleep mode / wake up
Sub Lcd_sleep(byval Value As Byte)
Backlight
Sets the backlight value (0: BL Off, Standby On; 1-254: PWM, 255: BL On, Display Wakeup)
Sub Lcd_backlight(byval Value As Byte)
Smoothly dims the backlight (PWM only)
Sub Lcd_backlight_dim(byval Startvalue As Byte , Byval Endvalue As Byte , Byval Millisecs As Word)
Screen rotation
Indicates the current rotation
Dim Lcd_rotation As Byte
the actual max X and Y coordinates (after rotation)
Dim Lcd_screen_width As Word Dim Lcd_screen_height As Word
Sets the display rotation (0: 0° Portrait, 1: 90° Landscape, 2: 180° Portrait, 3: 270° Landscape, 4: 0° ...)
Sub Lcd_set_rotation(byval Rotation As Byte)
Basic graphics
Clears the screen.
Sub Lcd_clear(byval Color As Word)
Draws a rectangle
Sub Lcd_rect(byval X1 As Word , Byval Y1 As Word , Byval X2 As Word , Byval Y2 As Word , Byval Color As Word)
Draws a filled rectangle, checks for the display boundaries
Sub Lcd_fill_rect(byval X1 As Word , Byval Y1 As Word , Byval X2 As Word , Byval Y2 As Word , Byval Color As Word)
Sets a single pixel.
Sub Lcd_set_pixel(byval X As Word , Byval Y As Word , Byval Color As Word)
Draws a line between two points
Sub Lcd_line(byval X1 As Word , Byval Y1 As Word , Byval X2 As Word , Byval Y2 As Word , Byval Color As Word)
Draws a line with color transition between two points
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)
Draws a circle
Sub Lcd_circle(byval Xcenter As Word , Byval Ycenter As Word , Byval Radius As Word , Byval Color As Word)
Draws a filled circle
Sub Lcd_fill_circle(byval X As Word , Byval Y As Word , Byval Radius As Word , Byval Color As Word)
Pictures
Draws a BIN picture from the internal program flash memory. Image has to be loaded with Restore before.
Sub Lcd_pic_flash(byval Xs As Word , Byval Ys As Word , Byval Width As Byte , Byval Height As Word)
Draws a BIN picture stored on an external SPI DataFlash [1]
Sub Lcd_pic_spi(byval Xs As Word , Byval Ys As Word , Byval Width As Word , Byval Height As Word , Byval Address As Dword)
Set to the start address of the free SRAM memory section, where BIN pics should be loaded to
Dim Lcd_ram_pics_free_ptr As Dword
Loads a BIN picture from the program flash into the SRAM for faster access. Data will be loaded starting at Lcd_ram_pics_free_ptr, the function returns the start address of the actual picture.
Function Lcd_load_pic_flash2ram(byval Width As Word , Byval Height As Word) As Word
Draws a BIN picture from the SRAM memory.
Sub Lcd_pic_ram(byval Xs As Word , Byval Ys As Word , Byval Width As Word , Byval Height As Word , Byval Address As Dword)
Draws a BGF coded picture from the program flash memory.
Sub Lcd_pic_bgf(byval Xoffset As Word , Byval Yoffset As Word)
Text
For reduced Digit font
Dim Lcd_digit_font As Bit
Loads the font, following Lcd_text commands will use it. You need to call Restore [Font] before.
Sub Lcd_loadfont()
Draws a fixed-font text on the screen.
Sub Lcd_text(byval S As String , Byval Xoffset As Word , Byval Yoffset As Word , Byval Forecolor As Word , Byval Backcolor 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