diff --git a/Processors/TFT_eSPI_RP2040.h b/Processors/TFT_eSPI_RP2040.h index f57198ad..6bd05cdb 100644 --- a/Processors/TFT_eSPI_RP2040.h +++ b/Processors/TFT_eSPI_RP2040.h @@ -22,6 +22,11 @@ // Processor ID reported by getSetup() #define PROCESSOR_ID 0x2040 +// Transactions always supported +#ifndef SUPPORT_TRANSACTIONS + #define SUPPORT_TRANSACTIONS +#endif + // Include processor specific header // None @@ -285,6 +290,25 @@ spi.transfer(0); spi.transfer((C)>>8); \ spi.transfer(0); spi.transfer((C)>>0) + #elif defined (ILI9225_DRIVER) // Needs gaps between commands + data bytes, so use slower transfer functions + + // These all end in 8 bit mode + #define tft_Write_8(C) spi.transfer(C); + + // Note: the following macros do not wait for the end of transmission + + #define tft_Write_16(C) spi.transfer16(C) + + #define tft_Write_16N(C) spi.transfer16(C) + + #define tft_Write_16S(C) spi.transfer16((C)<<8 | (C)>>8) + + #define tft_Write_32(C) spi.transfer16((C)>>16); spi.transfer16(C) + + #define tft_Write_32C(C,D) spi.transfer16(C); spi.transfer16(D) + + #define tft_Write_32D(C) spi.transfer16(C); spi.transfer16(C) + #else // This swaps to 8 bit mode, then back to 16 bit mode diff --git a/Processors/pio_SPI_18bit.pio b/Processors/pio_SPI_18bit.pio new file mode 100644 index 00000000..25df4c00 --- /dev/null +++ b/Processors/pio_SPI_18bit.pio @@ -0,0 +1,89 @@ +// Raspberry Pi Pico PIO program to output 18 bit data to a TFT +// controller via a SPI output data path. + +//"Set" set: 1 output pin, TFT_DC +// Side set: 1 output pin, TFT_SCLK +// Data set: 1 output pin, TFT_MOSI + +.program tft_io +.side_set 1 opt ; The TFT_SCLK output. + +// The C++ code switches between the 8 bits and 16 bits loops +// by waiting for the SM to be idle and setting its PC. +// + +// 8 bit transfer +public start_8: + // Pull the next 32 bit value from the TX FIFO. + pull side 0 + // Lose the top 24 bits, send 1st bit + out pins, 25 + // Now send remaining bits + jmp spi_out side 1 + +public set_addr_window: + // Loop count in x for caset, paset and ramwr + set x, 2 side 0 +pull_cmd: + // Set DC low + set pins, 0 + // Fetch and output LS byte (caset, paset or ramwr), discarding top 24 bits, set WR low + pull side 0 + out pins, 25 + nop side 1 +next_cmd_bit: + out pins, 1 side 0 + jmp !osre, next_cmd_bit side 1 + // Set DC high + set pins, 1 side 0 + // Finish if 3rd cmd byte ramwr sent (x == 0) + jmp !x, start_tx + pull +next_xy: + // send 32 bit start and end coordinates + out pins, 1 side 0 + jmp !osre, next_xy side 1 + // Loop back for next command + jmp x--, pull_cmd side 0 + // End + jmp start_tx + +public block_fill: + // Fetch colour value + pull side 0 + // Move colour to x + mov x, osr + // Fetch pixel count + pull + // Move pixel count to y + mov y, osr +next_16: + // Copy colour value back into osr + mov osr, x side 0 + // Lose the top 8 bits, send 1st bit + out pins, 9 side 0 + nop side 1 +next_bit: + // Output next remaining bits + out pins, 1 side 0 + // Set TFT_SCLK high and jump for next bit + jmp !osre, next_bit side 1 + // Decrement count and loop + jmp y--, next_16 side 0 + // Now drop back to 16 bit output + +.wrap_target +public start_tx: + // Pull the next 32 bit value from the TX FIFO. + // Send the bottom 24 bits + pull side 0 + // Drop the first 8 bits, write first bit + out pins, 9 side 0 + nop side 1 +spi_out: + // Output the remaining bits + out pins, 1 side 0 + // Set TFT_SCLK high and jump for next bit + jmp !osre, spi_out side 1 + // Return to start +.wrap diff --git a/Processors/pio_SPI_18bit.pio.h b/Processors/pio_SPI_18bit.pio.h new file mode 100644 index 00000000..bd13a660 --- /dev/null +++ b/Processors/pio_SPI_18bit.pio.h @@ -0,0 +1,73 @@ +// -------------------------------------------------- // +// This file is autogenerated by pioasm; do not edit! // +// -------------------------------------------------- // + +#pragma once + +#if !PICO_NO_HARDWARE +#include "hardware/pio.h" +#endif + +// ------ // +// tft_io // +// ------ // + +#define tft_io_wrap_target 27 +#define tft_io_wrap 31 + +#define tft_io_offset_start_8 0u +#define tft_io_offset_set_addr_window 3u +#define tft_io_offset_block_fill 17u +#define tft_io_offset_start_tx 27u + +static const uint16_t tft_io_program_instructions[] = { + 0x90a0, // 0: pull block side 0 + 0x6019, // 1: out pins, 25 + 0x181e, // 2: jmp 30 side 1 + 0xf022, // 3: set x, 2 side 0 + 0xe000, // 4: set pins, 0 + 0x90a0, // 5: pull block side 0 + 0x6019, // 6: out pins, 25 + 0xb842, // 7: nop side 1 + 0x7001, // 8: out pins, 1 side 0 + 0x18e8, // 9: jmp !osre, 8 side 1 + 0xf001, // 10: set pins, 1 side 0 + 0x003b, // 11: jmp !x, 27 + 0x80a0, // 12: pull block + 0x7001, // 13: out pins, 1 side 0 + 0x18ed, // 14: jmp !osre, 13 side 1 + 0x1044, // 15: jmp x--, 4 side 0 + 0x001b, // 16: jmp 27 + 0x90a0, // 17: pull block side 0 + 0xa027, // 18: mov x, osr + 0x80a0, // 19: pull block + 0xa047, // 20: mov y, osr + 0xb0e1, // 21: mov osr, x side 0 + 0x7009, // 22: out pins, 9 side 0 + 0xb842, // 23: nop side 1 + 0x7001, // 24: out pins, 1 side 0 + 0x18f8, // 25: jmp !osre, 24 side 1 + 0x1095, // 26: jmp y--, 21 side 0 + // .wrap_target + 0x90a0, // 27: pull block side 0 + 0x7009, // 28: out pins, 9 side 0 + 0xb842, // 29: nop side 1 + 0x7001, // 30: out pins, 1 side 0 + 0x18fe, // 31: jmp !osre, 30 side 1 + // .wrap +}; + +#if !PICO_NO_HARDWARE +static const struct pio_program tft_io_program = { + .instructions = tft_io_program_instructions, + .length = 32, + .origin = -1, +}; + +static inline pio_sm_config tft_io_program_get_default_config(uint offset) { + pio_sm_config c = pio_get_default_sm_config(); + sm_config_set_wrap(&c, offset + tft_io_wrap_target, offset + tft_io_wrap); + sm_config_set_sideset(&c, 2, true, false); + return c; +} +#endif diff --git a/TFT_Drivers/ILI9341_Defines.h b/TFT_Drivers/ILI9341_Defines.h index fd8b3bee..70e17624 100644 --- a/TFT_Drivers/ILI9341_Defines.h +++ b/TFT_Drivers/ILI9341_Defines.h @@ -1,7 +1,7 @@ // Change the width and height if required (defined in portrait mode) // or use the constructor to over-ride defaults -#if defined (ILI9341_DRIVER) || ILI9341_2_DRIVER +#if defined (ILI9341_DRIVER) || defined (ILI9341_2_DRIVER) #define TFT_WIDTH 240 #define TFT_HEIGHT 320 #elif defined (ILI9342_DRIVER) diff --git a/TFT_Drivers/ILI9341_Init.h b/TFT_Drivers/ILI9341_Init.h index 5cec6a02..05a703ef 100644 --- a/TFT_Drivers/ILI9341_Init.h +++ b/TFT_Drivers/ILI9341_Init.h @@ -5,7 +5,7 @@ // // See ST7735_Setup.h file for an alternative format -#if defined (ILI9341_DRIVER) | defined (ILI9342_DRIVER) +#if defined (ILI9341_DRIVER) || defined (ILI9342_DRIVER) { writecommand(0xEF); writedata(0x03); diff --git a/TFT_eSPI.h b/TFT_eSPI.h index 7f319bf6..9e734ff7 100644 --- a/TFT_eSPI.h +++ b/TFT_eSPI.h @@ -16,7 +16,7 @@ #ifndef _TFT_eSPIH_ #define _TFT_eSPIH_ -#define TFT_ESPI_VERSION "2.4.44" +#define TFT_ESPI_VERSION "2.4.45" // Bit level feature flags // Bit 0 set: viewport capability diff --git a/keywords.txt b/keywords.txt index d0c780f0..fb47c5e4 100644 --- a/keywords.txt +++ b/keywords.txt @@ -12,13 +12,17 @@ drawFastHLine KEYWORD2 fillRect KEYWORD2 height KEYWORD2 width KEYWORD2 +readPixel KEYWORD2 +setWindow KEYWORD2 +pushColor KEYWORD2 + setRotation KEYWORD2 getRotation KEYWORD2 invertDisplay KEYWORD2 setAddrWindow KEYWORD2 -setWindow KEYWORD2 setViewport KEYWORD2 +checkViewport KEYWORD2 resetViewport KEYWORD2 getViewportX KEYWORD2 getViewportY KEYWORD2 @@ -26,28 +30,23 @@ getViewportWidth KEYWORD2 getViewportHeight KEYWORD2 getViewportDatum KEYWORD2 frameViewport KEYWORD2 - -# Smooth (anti-aliased) graphics functions -fillRectHGradient KEYWORD2 -fillRectVGradient KEYWORD2 -fillSmoothCircle KEYWORD2 -fillSmoothRoundRect KEYWORD2 -drawSpot KEYWORD2 -drawWideLine KEYWORD2 -drawWedgeLine KEYWORD2 - -pushColor KEYWORD2 +resetViewport KEYWORD2 +clipAddrWindow KEYWORD2 +clipWindow KEYWORD2 pushColors KEYWORD2 pushBlock KEYWORD2 pushPixels KEYWORD2 -readPixel KEYWORD2 + tft_Read_8 KEYWORD2 begin_SDA_Read KEYWORD2 end_SDA_Read KEYWORD2 + fillScreen KEYWORD2 + drawRect KEYWORD2 drawRoundRect KEYWORD2 fillRoundRect KEYWORD2 + drawCircle KEYWORD2 drawCircleHelper KEYWORD2 fillCircle KEYWORD2 @@ -56,22 +55,28 @@ drawEllipse KEYWORD2 fillEllipse KEYWORD2 drawTriangle KEYWORD2 fillTriangle KEYWORD2 + setSwapBytes KEYWORD2 getSwapBytes KEYWORD2 + drawBitmap KEYWORD2 drawXBitmap KEYWORD2 + setPivot KEYWORD2 getPivotX KEYWORD2 getPivotY KEYWORD2 + readRect KEYWORD2 pushRect KEYWORD2 pushImage KEYWORD2 readRectRGB KEYWORD2 + drawNumber KEYWORD2 drawFloat KEYWORD2 drawString KEYWORD2 drawCentreString KEYWORD2 drawRightString KEYWORD2 + setCursor KEYWORD2 getCursorX KEYWORD2 getCursorY KEYWORD2 @@ -90,13 +95,16 @@ decodeUTF8 KEYWORD2 write KEYWORD2 setCallback KEYWORD2 fontsLoaded KEYWORD2 + spiwrite KEYWORD2 writecommand KEYWORD2 +writeRegister KEYWORD2 writedata KEYWORD2 commandList KEYWORD2 readcommand8 KEYWORD2 readcommand16 KEYWORD2 readcommand32 KEYWORD2 + color565 KEYWORD2 color8to16 KEYWORD2 color16to8 KEYWORD2 @@ -104,15 +112,18 @@ color16to24 KEYWORD2 color24to16 KEYWORD2 alphaBlend KEYWORD2 alphaBlend24 KEYWORD2 + initDMA KEYWORD2 deInitDMA KEYWORD2 pushImageDMA KEYWORD2 pushPixelsDMA KEYWORD2 dmaBusy KEYWORD2 dmaWait KEYWORD2 + startWrite KEYWORD2 writeColor KEYWORD2 endWrite KEYWORD2 + setAttribute KEYWORD2 getAttribute KEYWORD2 getSetup KEYWORD2 @@ -128,6 +139,14 @@ getTouch KEYWORD2 calibrateTouch KEYWORD2 setTouch KEYWORD2 +# Smooth (anti-aliased) graphics functions +fillRectHGradient KEYWORD2 +fillRectVGradient KEYWORD2 +fillSmoothCircle KEYWORD2 +fillSmoothRoundRect KEYWORD2 +drawSpot KEYWORD2 +drawWideLine KEYWORD2 +drawWedgeLine KEYWORD2 # Smooth font functions diff --git a/library.json b/library.json index aa626ffc..08874848 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "TFT_eSPI", - "version": "2.4.44", + "version": "2.4.45", "keywords": "Arduino, tft, display, ttgo, LilyPi, WT32_SC01, ePaper, display, Pico, RP2040 Nano Connect, RP2040, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9481, ILI9486, ILI9488, ST7789, ST7796, RM68140, SSD1351, SSD1963, ILI9225, HX8357D, GC9A01, R61581", "description": "A TFT and ePaper SPI graphics library with optimisation for Raspberry Pi Pico, RP2040, ESP8266, ESP32 and STM32", "repository": diff --git a/library.properties b/library.properties index 681eee71..d2a6c7fb 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TFT_eSPI -version=2.4.44 +version=2.4.45 author=Bodmer maintainer=Bodmer sentence=TFT graphics library for Arduino processors with performance optimisation for RP2040, STM32, ESP8266 and ESP32 diff --git a/license.txt b/license.txt index 32d1df9a..87db4c9d 100644 --- a/license.txt +++ b/license.txt @@ -96,16 +96,16 @@ sketch. In 2019 the library was adapted to be able to use it with any 32 bit Arduino compatible processor. It will run on 8 bit and 16 bit processors but will be -slow due to extensive use of 32 bit varaibles. +slow due to extensive use of 32 bit variables. -Many of the example sketches are original work, that contain code created +Many of the example sketches are original work that contain code created for my own projects. For all the original code the FreeBSD licence applies and is compatible with the GNU GPL. vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvStartvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv Software License Agreement (FreeBSD License) -Copyright (c) 2020 Bodmer (https://github.com/Bodmer) +Copyright (c) 2022 Bodmer (https://github.com/Bodmer) All rights reserved.