Code Monkey home page Code Monkey logo

tftlcd-library's Introduction

Adafruit library for 8-bit TFT LCDs such as ILI9325, ILI9328, etc

This is a library for our Adafruit 16-channel PWM & Servo driver, shield or FeatherWing

Pick one up today in the adafruit shop!

These displays use 8-bit parallel to communicate, 12 or 13 pins are required to interface (RST is optional).

Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!

Written by Limor Fried/Ladyada for Adafruit Industries. BSD license, check license.txt for more information.

All text above must be included in any redistribution

To install, use the Arduino Library Manager and search for "Adafruit 2.8" TFT display Library" and install the library.

tftlcd-library's People

Contributors

driverblock avatar evaherrada avatar hoffmannjan avatar ladyada avatar makermelissa avatar paintyourdragon avatar siddacious avatar tdicola 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  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

tftlcd-library's Issues

TFTLCD.h missing header guard

TFTLCD.h does not have a header guard (#ifndef #define #endif). Because of this I am unable to use the TFTLCD library from an external .cpp file. (Both the .cpp file and the .ino file have to #include TFTLCD.h in order for the compiler to find it, but when I do so I get errors about duplicate definitions.) I added the header guards myself and now my sketch compiles, but this complicates things for anybody working downstream from me.

ESP32 Support

I have a program running on a Mega in 8-bit mode writing to the Adafruit 3.5" TFT display with touchscreen.

In the examples for this screen it mentions that the D0-D7 pins are hardcoded to certain pins on the uno and the mega.

Does this library support other boards such as ESP32? I assume all I need to do is change the configuration for the D0-D7 pins. Can you confirm this is the case?

Problem with 'textsize'

Hello,
first of all, thank you for making such a good library.

I tried using the example tftbmp on my arduino mega to display bmp on my screen
(the screen model : https://www.amazon.fr/Kuman-Tactile-Arduino-Module-Fonction/dp/B075CXXL1M/ref=sr_1_1?ie=UTF8&qid=1528549257&sr=8-1&keywords=tft+arduino+uno )

Here's the problem. When I try to upload the code, I get the following error :

TFTLCD-Library-master\Adafruit_TFTLCD.cpp:115:3: error: 'textsize' was not declared in this scope

textsize = 1;

How may I solve it ?

Constructor is setting a digital pin before setting OUTPUT mode.

In the constructor
Adafruit_TFTLCD::Adafruit_TFTLCD(uint8_t cs, uint8_t cd, uint8_t wr, uint8_t rd, uint8_t reset)

we see the following lines of code:

  if (reset) {
    digitalWrite(reset, HIGH);
    pinMode(reset, OUTPUT);
  }

Is it valid to be setting the line to HIGH before the pinMode is set? On SAMD51 the default pin mode is INPUT_PULLUP.

Arduino Due

I have this library working with the Due, would you be interested in a patch?

Lots of bugs on Mega 2560

`In file included from \Arduino\libraries\Adafruit_TFTLCD_Library\Adafruit_TFTLCD.cpp:19:0:

\Arduino\libraries\Adafruit_TFTLCD_Library\pin_magic.h:282:33: warning: backslash and newline separated by space

#define read8inline(result) { \

                             ^

\Arduino\libraries\Adafruit_TFTLCD_Library\Adafruit_TFTLCD.cpp:803:0: warning: "read8" redefined

#define read8(x) x=read8fn()

^

In file included from C:\Users\Patryk\Documents\Arduino\libraries\Adafruit_TFTLCD_Library\Adafruit_TFTLCD.cpp:19:0:

\Arduino\libraries\Adafruit_TFTLCD_Library\pin_magic.h:183:0: note: this is the location of the previous definition

#define read8 read8inline

^

\Arduino\libraries\Adafruit_TFTLCD_Library\Adafruit_TFTLCD.cpp: In member function 'void Adafruit_TFTLCD::init()':

\Arduino\libraries\Adafruit_TFTLCD_Library\Adafruit_TFTLCD.cpp:115:3: error: 'textsize' was not declared in this scope

textsize = 1;

^

In file included from \Arduino\libraries\Adafruit_TFTLCD_Library\Adafruit_TFTLCD.cpp:19:0:

\Arduino\libraries\Adafruit_TFTLCD_Library\Adafruit_TFTLCD.cpp: In member function 'void Adafruit_TFTLCD::begin(uint16_t)':

\Arduino\libraries\Adafruit_TFTLCD_Library\pin_magic.h:401:21: warning: large integer implicitly truncated to unsigned type [-Woverflow]

hi = (d) >> 8; lo = (d); CD_DATA ; write8(hi); write8(lo); }

                 ^

\Arduino\libraries\Adafruit_TFTLCD_Library\pin_magic.h:187:29: note: in expansion of macro 'writeRegister16inline'

#define writeRegister16 writeRegister16inline

                         ^

\Arduino\libraries\Adafruit_TFTLCD_Library\Adafruit_TFTLCD.cpp:283:5: note: in expansion of macro 'writeRegister16'

 writeRegister16(ILI9341_VCOMCONTROL1, 0x2B2B);

 ^

exit status 1
`
My console output when trying to load graphictest

Backwards Compatibility

Some methods such as readRegister() are missing in the new commit, which breaks backwards compatibility with older items.

wiring conflict in examples.

tfpaint:
// D0 connects to digital pin 8
// D1 connects to digital pin 9
#define YM 9
#define XP 8

and

#define YP A3
#define XM A2
#define LCD_CS A3
#define LCD_CD A2

This is needless confusing.

tftbmp:
#define SD_CS 10
#define LCD_CS A3

there is a CS on 8 bit side and a CS on SPI side along with a CSS.
which is it? Very simple to be specific.

//connect the SD card with DI going to pin 11, DO going to pin 12 and SCK going to pin 13
I think you mean mosi, miso, and clk? you know how it says on the board that you produce?

esp32 Support

Dear Adafruit,

I am trying to add 8-bit parallel support for your tft 3.5" breakout board. My experience in programming this close to the hardware is limited. I figured out how to directly manipulate the ports of the esp32, but I can't get it to compile. Could anybody help me to finish this?

Help would greatly be appreciated!

warning: backslash and newline separated by space

  • Arduino board: Mega

  • Arduino IDE version (found in Arduino -> About Arduino menu): 1.8.9

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too):

The following code
`#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library

void setup() {
// put your setup code here, to run once:

}

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

}`

Gives the following error
`Arduino\libraries\Adafruit_TFTLCD_Library\pin_magic.h:282:33: warning: backslash and newline separated by space

#define read8inline(result) { \

                             ^`

Really need soft SPI with Mega?

Hi, I'm using the touchscreen breakout board with an Arduino Mega.

In file "tftbmp.pde" it says:
// If using an Arduino Mega, make sure the SD library is configured for
// 'soft' SPI in the file Sd2Card.h.

I didn't do anything to configure the SD library for 'soft' SPI and it still works. A bit of googling suggests that this comment might be outdated.

If true, please remove.

Thanks!

Improvements to TFTLCD Library

The following small diff adds the ability to have a text background color, including the special 0x10000 color which represents transparent background (don't draw on the background) to preserve the existing behavior. For backwards compatibility, the default text background color is initialized as transparent.

diffs are Modified code

% diff ~/Desktop/tftlcd/TFTLCD.h TFTLCD.h
99a100
>   void setTextBGColor(uint32_t c); // 16 bit color but special 0x10000 for transparent.
156a158
>   uint32_t textbgcolor;

% diff ~/Desktop/tftlcd/TFTLCD.cpp TFTLCD.cpp
76a77,80
> void TFTLCD::setTextBGColor(uint32_t c) {
>   textbgcolor = c;
> }
> 
107c111
<   for (uint8_t i =0; i<5; i++ ) {

---
>   for (uint8_t i =0; i<(bicolor == 0x10000 ? 5 : 6); i++ ) {  // No need to run through 6th column if transparent background
108c112
<       uint8_t ine = pgm_read_byte(font+(c*5)+i);

---
>       uint8_t line = (i==5 ? 0 : pgm_read_byte(font+(c*5)+i);
116a121,127
>       else if (textbgcolor != 0x10000) // If not transparent bg color
>       {
>         if (size == 1) // default size
>           drawPixel(x+i, y+j, textbgcolor & 0xffff);
>         else // big size
>           fillRect(x+i*size, y+j*size, size, size, textbgcolor&0xffff);
>       }
669a681
>   textbgcolor = 0x10000;  // Default to transparent

Support for Leonardo (mega32u4)

Currently the Sketch doesn't compile for Leonardo compatible boards. From looking through the code there are directives which force support for the older boards.

It looks like all that needs to be done are changing pin assignments. I can make and submit changes, if I can be told what needs to be done.

Cheers, Peenak

Can you please add the ILI9486?

I want to do a calculator on my 3.5" TFT Display but this library works with the touchscreen library without failing. Can you please add a driver for that chip?

LCD_RESET

To get the tftbmp example to work I had to use the LCD_RESET. I could not get it to work otherwise.

The two lines I had to add/modify prior to "void setup()" were

// you can also just connect RESET to the arduino RESET pin
#define LCD_RESET A4

// our TFT wiring
TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

Sorry if this was not the right place to address this. if there is an appropriate blog, let me know and I'll post it there.

Bob

Can this be used on Edison Yocto?

I am a bit new to this, but am having very hard time finding information, so any help would be appreciated. I want to use TFT LCD ILI9341 with Edison in 8bit mode and compile/build as C++ (my application is already written in C++). I have used Lutz Latta's (Edidoom) library, but it is optimized for all pins being within specific 32bit region, which mine are not currently (and unfortunately).
So my additional restriction is that pins are already assigned and are not in the same DW.
Is this possible with existing libraries? What is necessary? Thank you

adafruit_tftlcd.cpp: 'textsize' was not declared in this scope

  • Arduino board: UNO R3
  • Arduino IDE version (found in Arduino -> About Arduino menu): 1.8.10
  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too):
    Set board & port.
    Open tftbmp example sketch.
    Compile.

Error log in arduino:

[me]\Documents\Arduino\libraries\Adafruit_TFTLCD_Library\Adafruit_TFTLCD.cpp: In member function 'void Adafruit_TFTLCD::init()':

[me]\Documents\Arduino\libraries\Adafruit_TFTLCD_Library\Adafruit_TFTLCD.cpp:115:3: error: 'textsize' was not declared in this scope

textsize = 1;

^~~~~~~~

[me]\Documents\Arduino\libraries\Adafruit_TFTLCD_Library\Adafruit_TFTLCD.cpp:115:3: note: suggested alternative: 'textsize_x'

textsize = 1;

^~~~~~~~

textsize_x

Multiple libraries were found for "SPI.h"
Used: [me]\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2\libraries\SPI
Multiple libraries were found for "Adafruit_GFX.h"
Used: [me]\Documents\Arduino\libraries\Adafruit_GFX_Library
Multiple libraries were found for "Adafruit_TFTLCD.h"
Used: [me]\Documents\Arduino\libraries\Adafruit_TFTLCD_Library
Multiple libraries were found for "SD.h"
Used: C:\Program
exit status 1
Error compiling for board Arduino Uno.


The arduino error cuts off on the space in "Program Files"?! Wow.

Thank you! Stay awesome!

ARDUINO giga support

  • Arduino board: Arduino Giga r1 WiFi

  • Arduino IDE version (found in Arduino -> About Arduino menu): 2.3.2

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too): Attempt to upload any sketch containing the ADAFRUIT_TFTLCD library to the giga.

  • Issue Description:
    When attempting to use this library on the arduino giga r1 WiFi the uploader/programmer throws many errors. The exit code is 1.

Errors/Warnings:
(Pasted in file below)

Sketch:
Literally any sketch in any form in the IDE containing the library.

If the board is not supported, like some errors point to, It would truly be great if your team could add support for such a capable board. If not however, please explain or point to a library that is capable of using the ILI9341 in 8bit parallel mode on the Giga. Thank you!!
Error Messages.txt

Bug in fillTriangle()

This code demonstrates the problem:

You can also refer to my more complete description of the problem in the adafruit forums where it seems the solution offered by adafruit to any request is merely to ask the poster to go do something else.

http://forums.adafruit.com/viewtopic.php?f=47&t=26204

#include <TFTLCD.h>

// Modify as needed for your configuration
#define LCD_RESET A4
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_BL 8

#define FACECENTRX 63
#define FACECENTRY 63

TFTLCD lcd(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

// This should initialize the display and draw a diamond shaped hand rotating around the dial ala a second hand on a clock.
// This example is reduced from an actual clock application to the minimum necessary to replicate the library bug
void setup()
{
  lcd.reset();
  lcd.initDisplay();
  lcd.fillScreen(lcd.Color565(0,0,0));
  lcd.setRotation(2);
  pinMode(LCD_BL, OUTPUT);
  digitalWrite(LCD_BL, HIGH);
  int i;
  while (1)
  {
    for(i=0; i<360; i+=6)
    {
      drawHand(lcd, i, 46, 255,255,255, 10);
      delay(1000);
      drawHand(lcd, i, 46, 0, 0, 0, 10);
    }
  }
}

void drawHand(TFTLCD D2, int a, int d, byte r, byte g, byte b, int width)
{
  float c,w, z;
  int dh_x2, dh_y2;
  int dh_x1, dh_y1;
  unsigned int co;
  float rad;
  co=D2.Color565(r,g,b);
  c = ((a+270)%360); // orient correctly
  z = c = c * PI/180;
  // Draw hands as polygons (fast)
  dh_x1 = cos(c)*d+FACECENTRX; dh_y1 = sin(c)*d+FACECENTRY; // tip of hand
  w=width*PI/180;
  c -= w/2;  // Widen (go counterclockwise w/2 radians (== width/2 degrees)
  rad = d*(d<40 ? 0.6 : 0.8);
  dh_x2 = cos(c)*rad+FACECENTRX; dh_y2 = sin(c)*rad+FACECENTRY; // Counterclockwise wide point
  D2.fillTriangle(FACECENTRX, FACECENTRY, dh_x1, dh_y1, dh_x2, dh_y2, D2.Color565(r, g, b)); // Draw counterclockwise half of hand
  c += w;    // Widen other direction (clockwise w radians == width degrees from counterclockwise edge)
  dh_x2 = cos(c)*rad+FACECENTRX; dh_y2 = sin(c)*rad+FACECENTRY; // Colckwise wide point
  D2.fillTriangle(FACECENTRX, FACECENTRY, dh_x1, dh_y1, dh_x2, dh_y2, D2.Color565(r, g, b)); // Draw clockwise half of hand
}

void loop()
{
}

Add support for Genuino 101 board.

I have successfully used my Adafruit 3.5" 320x480 Color TFT Touchscreen Breakout with my Arduino Leonardo and Micro boards. I would like to use it with my new Genuino 101 board which uses an Intel processor and has different pin definitions. I have attempted to implement it myself but haven't succeeded yet.

reset issue

I encountered an issue using the graphicstest sketch with an ILI9341 controller.

If readID() is called directly after reset() ( as the graphicstest sketch does )
the ILI9341 does not have enough time to properly reset before readID() is called.
In my case this caused an erroneous id of: 0xC0C0 to be reported.
Adding a delay of 2 ms. between readID() and reset() resolves this issue.

Rather than modifying each sketch, a better solution would of course be to add the
delay to the reset() function within Adafruit_TFTLCD.cpp as follows:

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void Adafruit_TFTLCD::reset(void) {

CS_IDLE;
// CD_DATA;
WR_IDLE;
RD_IDLE;

ifdef USE_ADAFRUIT_SHIELD_PINOUT

digitalWrite(5, LOW);
delay(2);
digitalWrite(5, HIGH);

else

if(_reset) {
digitalWrite(_reset, LOW);
delay(2);
digitalWrite(_reset, HIGH);
}

endif

delay(2);       // add delay here

// Data transfer sync
CS_ACTIVE;
CD_COMMAND;
write8(0x00);
for(uint8_t i=0; i<3; i++) WR_STROBE; // Three extra 0x00s
CS_IDLE;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Cheers,
Russ

How to fix writeRegister16(ILI9341_VCOMCONTROL1, 0x2B2B);

Hi I'm new for arduino and I use arduino mega 2560 with tftlcd 2.4 with shield but after I test the program this code is show.

C:\Users\Administrator\Documents\Arduino\libraries\TFTLCD-Library-1.0.3\Adafruit_TFTLCD.cpp:933:0: warning: "read8" redefined
#define read8(x) x = read8fn()

In file included from C:\Users\Administrator\Documents\Arduino\libraries\TFTLCD-Library-1.0.3\Adafruit_TFTLCD.cpp:17:0:
C:\Users\Administrator\Documents\Arduino\libraries\TFTLCD-Library-1.0.3\pin_magic.h:230:0: note: this is the location of the previous definition
#define read8 read8inline

C:\Users\Administrator\Documents\Arduino\libraries\TFTLCD-Library-1.0.3\Adafruit_TFTLCD.cpp: In member function 'void Adafruit_TFTLCD::begin(uint16_t)':
C:\Users\Administrator\Documents\Arduino\libraries\TFTLCD-Library-1.0.3\pin_magic.h:533:12: warning: large integer implicitly truncated to unsigned type [-Woverflow]
lo = (d);
^
C:\Users\Administrator\Documents\Arduino\libraries\TFTLCD-Library-1.0.3\pin_magic.h:234:25: note: in expansion of macro 'writeRegister16inline'
#define writeRegister16 writeRegister16inline
^~~~~~~~~~~~~~~~~~~~~
C:\Users\Administrator\Documents\Arduino\libraries\TFTLCD-Library-1.0.3\Adafruit_TFTLCD.cpp:352:5: note: in expansion of macro 'writeRegister16'
writeRegister16(ILI9341_VCOMCONTROL1, 0x2B2B);
^~~~~~~~~~~~~~~

And it can still upload to board but the screen not show anything.
Please ask for advice.

Tiney RTC and TFT

When i use RTC.now() the screen reset!
A4 A5 arduino pin use for tiny RTC
how should i solve thia

TFTLCD - Library

Im new to Arduino and library's. I use the library and the demo work fine my question is there a document with all the commands?

Thanks

Johann

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.