Coder Social home page Coder Social logo

adafruit_tftlcd_8bit_stm32's Introduction

This is a library for the 8 bit parallel driven TFT displays, ported from the Adafruit library [https://github.com/adafruit/TFTLCD-Library] and adapted to STM32F103Cx controller. No other CPU architecture is supportted at the moment.

This library depends on the Libmaple core files from:

https://github.com/stevstrong/Arduino_STM32 or

https://github.com/rogerclarkmelbourne/Arduino_STM32.

The scope of this library is to achieve highest display update rate while maintaing the compatibility with original Adafruit display API. Only tested with ILI9328 and "unknown" ILI9341-compatitble driver chips.

Contribution from users for other display control types is welcome and made easy by allocating separate files for each controller type in part.

How to use:

  • Place the Adafruit_TFT library folder your /libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.

  • Also requires the Adafruit_GFX library for Arduino. https://github.com/adafruit/Adafruit-GFX-Library . Alternatively, you can change Adafruit_TFTLCD_8bit_STM32.h to #include <Adafruit_GFX_AS.h>, instead.

  • Pin connections can be configured near the top of Adafruit_TFTLCD_8bit_STM32.h . Note that the data lines have to be on consequtive pins of the same output register (PB0...PB7, by default). To use the higher pins (PX8..PX15), set TFT_DATA_SHIFT to 8. The four control pins must all be one output register (the same as the data pins, or a different one), but can be freely assigned within the register. The TFT reset line can be assigned, freely.

adafruit_tftlcd_8bit_stm32's People

Contributors

stevstrong avatar tfry-git 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

Watchers

 avatar  avatar  avatar  avatar  avatar

adafruit_tftlcd_8bit_stm32's Issues

multiple definition errors due to #include <Adafruit_GFX_AS.h>

Most examples #include <Adafruit_GFX.h>, while Adafruit_TFTLCD_8bit_STM32.h has #include <Adafruit_GFX_AS.h>. This results in "multiple definition" errors while compiling.

Adafruit_TFTLCD_8bit_STM32.h should either #include <Adafruit_GFX.h>, instead of <Adafruit_GFX_AS.h>, or the examples should omit the #include <Adafruit_GFX.h> line, or both.

Data Pin assigning problem

Hello there,

I have 3 questions.

  • I have found an issue while I was wiring. I am using the blue pill (20k ram 64k flash). the Data pin mentioned in the readme file is PB0-PB8 (TFT_DATA_SHIFT 0). But the problem is PB2 is used for boot. How to solve this?

image

  • If I enable TFT_DATA_SHIFT 8 then as mentioned to the readme file pX8-px15. What is the X means? Both PA and PB can be used? I am using TFT_DATA_SHIFT 8 and pin started from PB8-PB15.

  • where RST(Lcd ) pin will go? connected to Reset pin of stm32 blue pill.

-Erfan

libmaple dependency

Not everyone has libmaple. You need to let people know the dependencies before they waste their time downloading it

GPIOA Problem

Dear Sir

Thanks for the lib.

It seems that the library (even when it set to - #define TFT_DATA_LOW_NIBBLE 1) does affect all GPIOA ports, I use PA14, PA15 to control relays and I see that with no action at all sometimes they change to HIGH mode and cannot be changed to LOW even when I run command digitalWrite(PA14,LOW) they do stay on high mode (I don’t have anything else in my code that address those pins but the relay switch code).
Also checked with GPIO PA10, PA11,PA12 and it has the same problem...

I think that something is wrong with this code:

#define write8(c) { uint32_t val = (((c^0x00FF)<<16) | c)<<TFT_DATA_SHIFT; \
                              dataRegs->BSRR = val; WR_STROBE; }

If I change the pins from PA to PB (pins) or PC (pins) everything works well.

I don’t know what to look in your library that can affect those pins…

This Is a part from the H file.

#define TFT_DATA_PORT GPIOA
// Port data bits D0..D7:
// enable only one from below lines corresponding to your HW setup:
#define TFT_DATA_LOW_NIBBLE 1 // take the lower 8 bits: 0..7
//#define TFT_DATA_HIGH_NIBBLE 1 // take the higher 8 bits: 8..15
//Control pins |RD |WR |RS |CS |RST|
#define TFT_CNTRL_PORT GPIOB
#define TFT_RD PB4
#define TFT_WR PB5
#define TFT_RS PB10
#define TFT_CS PB11
#define TFT_RST PB3 //PB0
#define TFT_RD_MASK BIT4 // digitalPinToBitMask(TFT_RD) //
#define TFT_WR_MASK BIT5 // digitalPinToBitMask(TFT_WR) //
#define TFT_RS_MASK BIT10 // digitalPinToBitMask(TFT_RS) //
#define TFT_CS_MASK BIT11 // digitalPinToBitMask(TFT_CS) //

#if 0
            // use old definition, standard bit toggling, low speed
            #define RD_ACTIVE    digitalWrite(TFT_RD, LOW)
            #define RD_IDLE      digitalWrite(TFT_RD, HIGH)
            #define WR_ACTIVE    digitalWrite(TFT_WR, LOW)
            #define WR_IDLE      digitalWrite(TFT_WR, HIGH)
            #define CD_COMMAND   digitalWrite(TFT_RS, LOW)
            #define CD_DATA      digitalWrite(TFT_RS, HIGH)
            #define CS_ACTIVE    digitalWrite(TFT_CS, LOW)
            #define CS_IDLE      digitalWrite(TFT_CS, HIGH)
            #define CS_ACTIVE_CD_COMMAND      { CS_ACTIVE; CD_COMMAND; }
#else
            // use fast bit toggling, very fast speed!

extern gpio_reg_map * cntrlRegs;
            #define RD_ACTIVE                  { cntrlRegs->BRR  = TFT_RD_MASK; }
            #define RD_IDLE                       { cntrlRegs->BSRR = TFT_RD_MASK; }
            #define WR_ACTIVE                 { cntrlRegs->BRR  = TFT_WR_MASK; }
            #define WR_IDLE                      { cntrlRegs->BSRR = TFT_WR_MASK; }
            #define CD_COMMAND          { cntrlRegs->BRR  = TFT_RS_MASK; }
            #define CD_DATA                    { cntrlRegs->BSRR = TFT_RS_MASK; }
            #define CS_ACTIVE                  { cntrlRegs->BRR  = TFT_CS_MASK; }
            #define CS_IDLE                      { cntrlRegs->BSRR = TFT_CS_MASK; }
            #define CS_ACTIVE_CD_COMMAND      { cntrlRegs->BRR  = (TFT_CS_MASK|TFT_RS_MASK); }

#endif

#define WR_STROBE { WR_ACTIVE; WR_IDLE; }
extern uint8_t read8_(void);
#define read8(x) ( x = read8_() )

extern gpio_reg_map * dataRegs;

#if defined(TFT_DATA_LOW_NIBBLE)

//#warning "Using lower data nibble..."
            // set the pins to input mode
            #define setReadDir() ( dataRegs->CRL = 0x88888888 )     // set the lower 8 bits as input
           // #define setReadDir() ( dataRegs->CRL = 0x44444444 ) // set the lower 8 bits as input floating
            // set the pins to output mode
            #define setWriteDir() ( dataRegs->CRL = 0x33333333 )    // set the lower 8 bits as output
            #define TFT_DATA_SHIFT 0

#elif defined(TFT_DATA_HIGH_NIBBLE)

#warning "Using high data nibble..."
            // set the pins to input mode
            #define setReadDir() ( dataRegs->CRH = 0x88888888 )    // set the upper 8 bits as input
            // set the pins to output mode
            #define setWriteDir() ( dataRegs->CRH = 0x33333333 )   // set the lower 8 bits as output
            #define TFT_DATA_SHIFT 8

#endif

// set pins to output the 8 bit value
#if 0 // slow write

#define write8(c) { Serial.print(" write8: "); Serial.print(c,HEX); Serial.write(','); \
                             digitalWrite(PA0, (c&BIT0)?HIGH:LOW); \
                             digitalWrite(PA1, (c&BIT1)?HIGH:LOW); \
                             digitalWrite(PA2, (c&BIT2)?HIGH:LOW); \
                             digitalWrite(PA3, (c&BIT3)?HIGH:LOW); \
                             digitalWrite(PA4, (c&BIT4)?HIGH:LOW); \
                             digitalWrite(PA5, (c&BIT5)?HIGH:LOW); \
                             digitalWrite(PA6, (c&BIT6)?HIGH:LOW); \
                             digitalWrite(PA7, (c&BIT7)?HIGH:LOW); \
                             WR_STROBE; }

#else

**_#define write8(c) { uint32_t val = (((c^0x00FF)<<16) | c)<<TFT_DATA_SHIFT; \
                             /*Serial.print(" write8: "); Serial.print(val,HEX); Serial.write(',');*/ \
                             dataRegs->BSRR = val; WR_STROBE; }_**

#endif

Problem after reset and readid

Hi,

I have problems with this library.
Reset works, and read id as well, but I am not sure if correctly.
But, then, after readid, begin() does not work. Nor anything else.

I have a blue pill board.
My LCD is this: http://www.elecfreaks.com/wiki/index.php?title=2.4%22_TFT_LCD:_TFT01-2.4
The version I have is the ili9325

Your library reports mine as ili9328. I do not know why. But, at least, it does, and I guess that wiring is okey (because reset() and readid() works).

But then comes begin(). It does not work. And after begin, anything I try fails. For example, readID() fails after begin() (still if it worked after reset).

And, I am not sure if the library reporting ili9328 (and not ili9325) is okey.

Do you have some ideas about what is happening? Could you assist me a bit to do some more steps? I do not know what else to try.
I tested all the examples. Following the code I see that just reset() and readID() work.

Thanks in advance.

Problem bmp file show

I change the tftBMP example's library to this:
#include <Adafruit_TFTLCD_8bit_STM32.h> // Hardware-specific library

and define pins and... but when I complie it I have this error:
`

                   Arduino: 1.8.3 (Windows 10), Board: "Generic STM32F103C series, STM32F103C8 (20k RAM. 64k Flash),STLink, 72Mhz (Normal)"

                                            C:\Users\Mohammad\Documents\Arduino\LCDBMPTest\LCDBMPTest.ino: In function 'void bmpDraw(char*, int, int)':

              LCDBMPTest:220: error: 'class Adafruit_TFTLCD_8bit_STM32' has no member named 'color565'

                         lcdbuffer[lcdidx++] = tft.color565(r,g,b);

                                   ^

                 exit status 1
               'class Adafruit_TFTLCD_8bit_STM32' has no member named 'color565'

`

won't work in fast mode

I tried running on generic STM32F103C8T6 (blue pill) but had to run in slow mode, fast mode produced no output. Since the my board uses PB2 on one of the jumpers and won't boot unless it's grounded, I had to use GPIOA for dataregs and GPIOB for cntrlregs. I changed all the digitalWrite commands from PBx to PAx
don't think there's anything else I need to change.
Any ideas or suggestions for isolating the problem?

New sub-type of HD8357?

So I bought a board like this (https://www.ebay.de/itm/2-4-TFT-LCD-Display-Shield-Touch-Panel-ILI9341-240X320-for-Arduino-UNO-MEGA/192163706724?epid=7008035186&hash=item2cbdd97764:g:PDoAAOSwRUhY-IYe), sold as an ILI9341.

The ID is read out as "3838" (unknown). Turns out I can drive it by using tft.begin (0x8357). However, everything is mirrored, then. I can "fix" the mirroring using the patch, below, but obviously, it would be better if this would be handled by a #define, and best, if it was detected, automatically. Any further info I can provide to help?

diff --git a/Adafruit_TFTLCD_8bit_STM32.cpp b/Adafruit_TFTLCD_8bit_STM32.cpp
index 3bcf96e..44d1de9 100644
--- a/Adafruit_TFTLCD_8bit_STM32.cpp
+++ b/Adafruit_TFTLCD_8bit_STM32.cpp
@@ -412,17 +412,17 @@ void Adafruit_TFTLCD_8bit_STM32::setRotation(uint8_t x)
     
     switch (rotation) {
       case 1:
-        t = HX8357B_MADCTL_MY | HX8357B_MADCTL_MV | HX8357B_MADCTL_RGB;
+        t = HX8357B_MADCTL_MV | HX8357B_MADCTL_RGB;
         break;
       case 2:
-        t = HX8357B_MADCTL_RGB;
+        t = HX8357B_MADCTL_MX | HX8357B_MADCTL_RGB;
         break;
       case 3:
-        t = HX8357B_MADCTL_MX | HX8357B_MADCTL_MV | HX8357B_MADCTL_RGB;
+        t = HX8357B_MADCTL_MY | HX8357B_MADCTL_MX | HX8357B_MADCTL_MV | HX8357B_MADCTL_RGB;
         break;
       case 0:
       default:
-        t = HX8357B_MADCTL_MX | HX8357B_MADCTL_MY | HX8357B_MADCTL_RGB;
+        t = HX8357B_MADCTL_MY | HX8357B_MADCTL_RGB;
         break;
     }
     writeRegister8(ILI9341_MADCTL, t ); // MADCTL

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.