Git Product home page Git Product logo

arduino_st7789_fast's Introduction

Arduino_ST7789_Fast

Fast SPI library for the ST7789 240x240 IPS display

Significantly optimized for 16MHz AVR Arduino boards (2.5-5x faster than other libraries).

Achieved 6.9Mbps SPI transfer rate (at DIV2/16MHz clock)

In compatiliblity mode it could work with other MCUs, but I didn't test it. For STM32 (BluePill) there is separate optimized version here: https://github.com/cbm80amiga/Arduino_ST7789_STM

YouTube video:

https://youtu.be/GciLKcWQZK4

YouTube playlist with all videos related to ST7789:

https://www.youtube.com/playlist?list=PLxb1losWErZ7thUyB05phRR3DoiYN_kcD

Recent optimizations

After recent optimizations (more AVR assembler) all fill and copy operations work with max speed of about 7.1Mbps for 16MHz Arduino and the library flash memory usage is reduced by about 800-900 bytes

Configuration

Use "define COMPATIBILITY_MODE" - then the library should work on all Arduino compatible boards

Remove above for the best performance on 16MHz AVR

Use "#define CS_ALWAYS_LOW" for LCD boards where CS pin is internally connected to the ground, it gives better performance

Tested with Arduino IDE 1.6.5 and Adafruit_GFX 1.5.6

Extra Features

  • invertDisplay()
  • sleepDisplay()
  • enableDisplay()
  • idleDisplay() - saves power by limiting colors to 3 bit mode (8 colors)
  • resetDisplay() - software reset
  • partialDisplay() and setPartArea() - limiting display area for power saving
  • setScrollArea() and setScroll() - smooth vertical scrolling
  • fast drawImage() from RAM
  • fast drawImage() from flash (PROGMEM)

Connections:

LCD pin LCD pin name Arduino
#01 GND GND
#02 VCC VCC (3.3V only!)
#03 SCL D13/SCK
#04 SDA D11/MOSI
#05 RES D8 or any digital
#06 DC D7 or any digital
#07 BLK NC

If you find it useful and want to buy me a coffee or a beer:

https://www.paypal.me/cbm80amiga

arduino_st7789_fast's People

Contributors

cbm80amiga avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduino_st7789_fast's Issues

Support for pi pico on CircuitPython or MicroPython

Your library is amazing! I tested it with Arduino and it's really fast. Now I have a Raspberry Pi Pico and although it is a 120mhz board, the examples I found are really slow. Is there a CircuitPython or MicroPython version of this library?

Use with 320x240 TFT...

Thanks for a nice library...

I have a ST7789 TFT 320x240 and I can get it to work with some of the examples, but the rest of screen outside 240x240 is flickering as assumed it should be in this mode...

I’m not an experienced Arduino programmer, but I’ve tried to change to 320x240 in the example code, but I am not sure exactly where to set it up, if possible...?

Is there any chance to update or change code in this driver for use 320x240 TFT screens...?

https://www.waveshare.com/wiki/2inch_LCD_Module

Thanks!

More error

ST7735_AmigaBall:60:41: error: 'RGBto565' was not declared in this scope
uint16_t bgCol = RGBto565(160,160,160);
^
ST7735_AmigaBall:61:38: error: 'RGBto565' was not declared in this scope
uint16_t bgColS = RGBto565(90,90,90);
^
ST7735_AmigaBall:62:40: error: 'RGBto565' was not declared in this scope
uint16_t lineCol = RGBto565(150,40,150);
^
ST7735_AmigaBall:63:38: error: 'RGBto565' was not declared in this scope
uint16_t lineColS = RGBto565(80,10,80);
^
C:\Users\Admin\Documents\Arduino\Arduino_ST7735_STM-master\examples\ST7735_AmigaBall\ST7735_AmigaBall.ino: In function 'void drawBall(int, int)':
ST7735_AmigaBall:119:5: error: 'lcd' was not declared in this scope
lcd.drawImage(0,yy,SCR_WD,1,line);
^
C:\Users\Admin\Documents\Arduino\Arduino_ST7735_STM-master\examples\ST7735_AmigaBall\ST7735_AmigaBall.ino: In function 'void setup()':
ST7735_AmigaBall:126:3: error: 'lcd' was not declared in this scope
lcd.init();
^
C:\Users\Admin\Documents\Arduino\Arduino_ST7735_STM-master\examples\ST7735_AmigaBall\ST7735_AmigaBall.ino: In function 'void loop()':
ST7735_AmigaBall:155:38: error: 'WHITE' was not declared in this scope
palette[i+1] = ((i+anim)%14)<7 ? WHITE : RED;
^
ST7735_AmigaBall:155:46: error: 'RED' was not declared in this scope
palette[i+1] = ((i+anim)%14)<7 ? WHITE : RED;

possible port to ESP32

Does this library work with esp32 boards ?
Would it be possible to modify the pins to match esp32 pins ?

Downloading link

Good day cbm80amiga, kindly review the downloading link. file cant be downloaded

blurry / not working / resister needed with Arduino UNO

HI, this is really a good library, thank you for your contribution.

I'm testing this library on an Arduino UNO board just as the YouTube video shows: LINK
connecting my IPS 240x240 display directly on UNO

but my display are always "black" (or just very blurry with only some pixel moving)
I only get the correct image in a split second when I press the reset button.

After searching for a while, I see a comment under that YouTube video saying adding some 1K resister will help.

so I have tested it and can confirm adding an 1K resister on each communicate pin (SCA/SCL/RES/DC) will resolve this problem.

I'm wondering this might be a "hardware issue" but not a "software issue", might have something to do with 5V instead of 3.3V system
so maybe we can add some instruction / notice on "README.md" or even in the file to help future user ?

if the author thinks this is a thing worth to do, I can test most boards on my hands and create a pull request.

Any suggestion will be appreciate, or may be I can be wrong on the hole thing(?)

Error during build: MKR WiFi 1010

I'm using the Adafruit_Benchmark sketch in examples. I have all the pins connected to where they are on the script, but it just gives me a compile error. I can't figure out why. Here's the screen.
`/usr/local/bin/arduino-cli compile --fqbn arduino:samd:mkrwifi1010 --libraries /home/builder/opt/libraries/latest --build-cache-path /tmp --output-dir /tmp/678866825/build --build-path /tmp/arduino-build-76DF854C77286D0A3301CE7F253E6996 --library /mnt/create-efs/webide/3e/7f/3e7f228b930eb20eecb4c767fb9cfa48:perrys3177/libraries_v2/Adafruit ST7735 and ST7789 Library --library /mnt/create-efs/webide/3e/7f/3e7f228b930eb20eecb4c767fb9cfa48:perrys3177/libraries_v2/Fast ST7789 Library /tmp/678866825/sketch_feb24a

Using library adafruit_busio_1_11_1 at version 1.11.1 in folder: /home/builder/opt/libraries/adafruit_busio_1_11_1

Using library Wire at version 1.0 in folder: /home/builder/.arduino15/packages/arduino/hardware/samd/1.8.12/libraries/Wire

/mnt/create-efs/webide/3e/7f/3e7f228b930eb20eecb4c767fb9cfa48:perrys3177/libraries_v2/Fast ST7789 Library/Arduino_ST7789_Fast.cpp: In member function 'void Arduino_ST7789::writeSPI(uint8_t)':

/mnt/create-efs/webide/3e/7f/3e7f228b930eb20eecb4c767fb9cfa48:perrys3177/libraries_v2/Fast ST7789 Library/Arduino_ST7789_Fast.cpp:126:5: error: 'SPDR' was not declared in this scope

SPDR = c;

^~~~

/mnt/create-efs/webide/3e/7f/3e7f228b930eb20eecb4c767fb9cfa48:perrys3177/libraries_v2/Fast ST7789 Library/Arduino_ST7789_Fast.cpp:126:5: note: suggested alternative: 'SPI1'

SPDR = c;

^~~~

SPI1

/mnt/create-efs/webide/3e/7f/3e7f228b930eb20eecb4c767fb9cfa48:perrys3177/libraries_v2/Fast ST7789 Library/Arduino_ST7789_Fast.cpp: In member function 'void Arduino_ST7789::writeMulti(uint16_t, uint16_t)':

/mnt/create-efs/webide/3e/7f/3e7f228b930eb20eecb4c767fb9cfa48:perrys3177/libraries_v2/Fast ST7789 Library/Arduino_ST7789_Fast.cpp:176:32: error: 'SPDR' was not declared in this scope

: [spdr] "I" (_SFR_IO_ADDR(SPDR)), [lo] "r" ((uint8_t)color), [hi] "r" ((uint8_t)(color>>8))

^~~~

/mnt/create-efs/webide/3e/7f/3e7f228b930eb20eecb4c767fb9cfa48:perrys3177/libraries_v2/Fast ST7789 Library/Arduino_ST7789_Fast.cpp:176:32: note: suggested alternative: 'SPI1'

: [spdr] "I" (_SFR_IO_ADDR(SPDR)), [lo] "r" ((uint8_t)color), [hi] "r" ((uint8_t)(color>>8))

^~~~

SPI1

/mnt/create-efs/webide/3e/7f/3e7f228b930eb20eecb4c767fb9cfa48:perrys3177/libraries_v2/Fast ST7789 Library/Arduino_ST7789_Fast.cpp:176:19: error: '_SFR_IO_ADDR' was not declared in this scope

: [spdr] "I" (_SFR_IO_ADDR(SPDR)), [lo] "r" ((uint8_t)color), [hi] "r" ((uint8_t)(color>>8))

^~~~~~~~~~~~

/mnt/create-efs/webide/3e/7f/3e7f228b930eb20eecb4c767fb9cfa48:perrys3177/libraries_v2/Fast ST7789 Library/Arduino_ST7789_Fast.cpp:176:19: note: suggested alternative: 'FLASH_ADDR'

: [spdr] "I" (_SFR_IO_ADDR(SPDR)), [lo] "r" ((uint8_t)color), [hi] "r" ((uint8_t)(color>>8))

^~~~~~~~~~~~

FLASH_ADDR

/mnt/create-efs/webide/3e/7f/3e7f228b930eb20eecb4c767fb9cfa48:perrys3177/libraries_v2/Fast ST7789 Library/Arduino_ST7789_Fast.cpp: In member function 'void Arduino_ST7789::copyMulti(uint8_t*, uint16_t)':

/mnt/create-efs/webide/3e/7f/3e7f228b930eb20eecb4c767fb9cfa48:perrys3177/libraries_v2/Fast ST7789 Library/Arduino_ST7789_Fast.cpp:212:32: error: 'SPDR' was not declared in this scope

: [spdr] "I" (_SFR_IO_ADDR(SPDR)), [img] "e" (img), [lo] "r" (lo), [hi] "r" (hi)

^~~~

/mnt/create-efs/webide/3e/7f/3e7f228b930eb20eecb4c767fb9cfa48:perrys3177/libraries_v2/Fast ST7789 Library/Arduino_ST7789_Fast.cpp:212:32: note: suggested alternative: 'SPI1'

: [spdr] "I" (_SFR_IO_ADDR(SPDR)), [img] "e" (img), [lo] "r" (lo), [hi] "r" (hi)

^~~~

SPI1

/mnt/create-efs/webide/3e/7f/3e7f228b930eb20eecb4c767fb9cfa48:perrys3177/libraries_v2/Fast ST7789 Library/Arduino_ST7789_Fast.cpp:212:19: error: '_SFR_IO_ADDR' was not declared in this scope

: [spdr] "I" (_SFR_IO_ADDR(SPDR)), [img] "e" (img), [lo] "r" (lo), [hi] "r" (hi)

^~~~~~~~~~~~

/mnt/create-efs/webide/3e/7f/3e7f228b930eb20eecb4c767fb9cfa48:perrys3177/libraries_v2/Fast ST7789 Library/Arduino_ST7789_Fast.cpp:212:19: note: suggested alternative: 'FLASH_ADDR'

: [spdr] "I" (_SFR_IO_ADDR(SPDR)), [img] "e" (img), [lo] "r" (lo), [hi] "r" (hi)

^~~~~~~~~~~~

FLASH_ADDR

In file included from /home/builder/.arduino15/packages/arduino/hardware/samd/1.8.12/cores/arduino/Arduino.h:51:0,

from /mnt/create-efs/webide/3e/7f/3e7f228b930eb20eecb4c767fb9cfa48:perrys3177/libraries_v2/Fast ST7789 Library/Arduino_ST7789_Fast.h:16,

from /mnt/create-efs/webide/3e/7f/3e7f228b930eb20eecb4c767fb9cfa48:perrys3177/libraries_v2/Fast ST7789 Library/Arduino_ST7789_Fast.cpp:4:

/mnt/create-efs/webide/3e/7f/3e7f228b930eb20eecb4c767fb9cfa48:perrys3177/libraries_v2/Fast ST7789 Library/Arduino_ST7789_Fast.cpp: In member function 'void Arduino_ST7789::commonST7789Init(const uint8_t*)':

/home/builder/.arduino15/packages/arduino/hardware/samd/1.8.12/variants/mkrwifi1010/variant.h:52:51: error: cannot convert 'volatile uint32_t* {aka volatile long unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in assignment

#define portOutputRegister(port) (&(port->OUT.reg))

^

/mnt/create-efs/webide/3e/7f/3e7f228b930eb20eecb4c767fb9cfa48:perrys3177/libraries_v2/Fast ST7789 Library/Arduino_ST7789_Fast.cpp:314:12: note: in expansion of macro 'portOutputRegister'

dcPort = portOutputRegister(digitalPinToPort(dcPin));

^~~~~~~~~~~~~~~~~~

Error during build: exit status 1`

IPS 240x240 does not work

I cannot get this library to work with an IPS 240x240 TFT? I have tried 2 different IPS to ensure it was not a hardware issue. Both have the backlight illuminate; but will not operate. I have tried several of the example codes and none work at all. I have ensured the connections and I am using an Arduino Nano. I read past issues and even tried placing a 1k resistor on each communication line; still only a blank screen with the backlight lit. I am using 3.3v and the wiring is correct. Anything I might be able to try? Thanks

Using with 1.14" 135x240 Display

Hello, really good and fast library! Just one thing, i am using an 1.14" 135x240 pixel display and the origin (x 0, y 0) is not on the display but on the outside so just can see the half of the displayed things. I tried to edit the defined size in the .h and .cpp file but I can't get it to work.

I would be very happy if there is a solution for my problem!

ST7789 use 240x280 does not work

Hi, i im using ST7789V2 (tied CS to GND) and all is working except resolution, in library i see that is defined WIDTH and HEIGHT of 240x240 but i need to be 240x280 because i need to get all pixels working on my display.

Here is code that i write from example library:

`#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Arduino_ST7789_Fast.h"

#define SCR_WD 240
#define SCR_HT 280

#define TFT_DC 7
#define TFT_RST 8
//#define TFT_CS 9
#define CS_ALWAYS_LOW

Arduino_ST7789 tft = Arduino_ST7789(TFT_DC, TFT_RST);

void setup() {
// put your setup code here, to run once:
tft.init(SCR_WD, SCR_HT);
tft.begin();
tft.setRotation(1);
tft.fillScreen(BLACK);
//tft.setCursor(0, 0);
//tft.setTextColor(WHITE); tft.setTextSize(2);
//tft.println("IPS 240x280 ST7789V");
}

void loop() {
// put your main code here, to run repeatedly:

}
`

And here is the picture what i was getting as output:

1673957999144

As you can see screen is black for 240x240 (library limit), i define 240x280 but it have white color and that is missing 40 pixels....can you please update your library to be working with higher resolutions others that 240x240?

Thanks.

4 and 8-bit bitmap with palette help?

Hello.

Firstly thank you very much for providing for a great library. I am struggling to get 4 or 8 bit bitmap with palette working with your bitmap example. A 24 bitmap generated with your bmp2src works fine, but if I use a 4 or 8 bit it doesn't work.
Would you be able to provide an example please or steer me in the right direction?

Thanks in advance,

Regards

Error compiling for SAMD Board

I'm using arduino mkr wifi 1010 and I'm getting this error:
Arduino\libraries\Arduino_ST7789_Fast-master/Arduino_ST7789_Fast.h:19:10: fatal error: avr/pgmspace.h: No such file or directory
#include <avr/pgmspace.h>

Will this ever work for a SAMD board or am I just missing a library ?

Errors compiling for nodemcu

Hi,

I get the following error when I try to compile the code with your library for nodemcu (ESP-12).
It works fine with the Adafruit library.

#include <SPI.h>
#include <Adafruit_GFX.h>    // Core graphics library
//#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <Arduino_ST7789_Fast.h>

// ST7789 TFT module connections
#define TFT_DC    5     // TFT DC  pin is connected to NodeMCU pin D1 (GPIO5)
#define TFT_RST   4     // TFT RST pin is connected to NodeMCU pin D2 (GPIO4)
//#define TFT_CS    D8     // TFT CS  pin is connected to NodeMCU pin D8 (GPIO15)

#define SCR_WD   240
#define SCR_HT   240 

#define COMPATIBILITY_MODE
//#define CS_ALWAYS_LOW

//Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
Arduino_ST7789 tft = Arduino_ST7789(TFT_DC, TFT_RST);
C:\---\Arduino\libraries\Arduino_ST7789_Fast\Arduino_ST7789_Fast.cpp:62:0: warning: "CS_IDLE" redefined [enabled by default]

 #define CS_IDLE

 ^

C:\---\Arduino\libraries\Arduino_ST7789_Fast\Arduino_ST7789_Fast.cpp:56:0: note: this is the location of the previous definition

 #define CS_IDLE    *csPort |= csMask

 ^

C:\---\Arduino\libraries\Arduino_ST7789_Fast\Arduino_ST7789_Fast.cpp:63:0: warning: "CS_ACTIVE" redefined [enabled by default]

 #define CS_ACTIVE

 ^

C:\---\Arduino\libraries\Arduino_ST7789_Fast\Arduino_ST7789_Fast.cpp:57:0: note: this is the location of the previous definition

 #define CS_ACTIVE  *csPort &= ~csMask

 ^

C:\---\Arduino\libraries\Arduino_ST7789_Fast\Arduino_ST7789_Fast.cpp: In member function 'void Arduino_ST7789::writeSPI(uint8_t)':

C:\---\Arduino\libraries\Arduino_ST7789_Fast\Arduino_ST7789_Fast.cpp:75:5: error: 'SPDR' was not declared in this scope

     SPDR = c;

     ^

C:\---\Arduino\libraries\Arduino_ST7789_Fast\Arduino_ST7789_Fast.cpp: In member function 'void Arduino_ST7789::commonST7789Init(const uint8_t*)':

C:\---\Arduino\libraries\Arduino_ST7789_Fast\Arduino_ST7789_Fast.cpp:169:10: error: cannot convert 'volatile uint32_t* {aka volatile unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in assignment

   dcPort = portOutputRegister(digitalPinToPort(dcPin));

          ^

Can you help me?
As far as I found by asking google it's something about the SPI.

Dynamic text

Hello!

How to make dynamic text.

There is a text and a value after the text, how to make the value not overlap each other?

void setup(){
   while (1) {
      sens_signal = analogRead(IR_SENSOR_PIN);
      lcd.setCursor(10, 30);
      lcd.setTextColor(RED);
      lcd.setTextSize(2);
      lcd.println("IR");
      lcd.setCursor(40, 65);
      lcd.println("SENSOR");
      lcd.setCursor(100, 90);
      lcd.println(sens_signal);
      if (millis() - reset_timer > 5000) break;
    }
}

I need to display a digital value from the sens_signal variable, it changes and overlaps, it turns out nonsense.

lcd.println(sens_signal);

Can't connect bare display to Arduino uno

Hey I have the 12 pin ST7789 display but instead of using the 7 pin module display I am trying to connect the bare 12 pin display itself. I used this library to upload the Hello World sketch to my Arduino and it works fine on the 7 pin module version of the display. However when I wire up the 12 pin the screen flashes white before going blank.

Here are my connections:
All 4 GND of display: GND on Arduino,
LEDK: 3.3V Power,
LEDA Arduino GND,
VDD: 3.3V,
D/C: D7 on Arduino,
CS: GND,
RES: D8 on Arduino,
SDA: SDA on Arduino,
SCL: SCL on Arduino.

Since this works with the module version I assume it's a wiring issue. Anyone else here able to use the bare 12 pin screen with Arduino? Appreciate any help I can get, thanks.

Display does not show picture in full (video)

Hello!
I used your Benchmark script (actually some other as well with the same result). The display does not show full pictures but only some of dots. If I press reset button it display as normal untill I release the button. I use Arduino (Genuino) UNO.
What can be an issue?

20221019_170317.video-converter.com.1.mp4

135x240 Display Not Working/porting to other displays

Hi I’m trying to get the library to work with a 135x240 display. I’ve modified the initialisation and screen rotation elements in the .cpp which all seem to be specifically ported from adafruit for the 240x240 display. But haven’t got it working yet.

Has anyone attempted to modify the code for other resolution?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.