ili9341 suspicious looking library code

Go To Last Post
17 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I can't seem to draw anything below z=255 using this library and I suspect this bit of code:

 

void ili9341_setaddress(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2)//set coordinate for print or other function
{
ili9341_writecommand8(0x2A);
ili9341_writedata8(x1>>8);
ili9341_writedata8(x1);
ili9341_writedata8(x2>>8);
ili9341_writedata8(x2);

ili9341_writecommand8(0x2B);
ili9341_writedata8(y1>>8);
ili9341_writedata8(y1);
ili9341_writedata8(y2);		// Shouldn't this be y2>>8
ili9341_writedata8(y2);

ili9341_writecommand8(0x2C);//meory write
}

Should not the first write of "y2" be y2>>8?

 

Doesn't y2 get you to the room with the big rock?

 

Of course, the reason I ask is: changing that line of code does not seem to change behavior.

 

 

 

"We trained hard... but it seemed that every time we were beginning to form up into a team, we would be reorganized. I was to learn later in life that we tend to meet any new situation by reorganizing. And a wonderful method it can be of creating the illusion of progress while producing confusion, inefficiency and demoralization." Petronius Arbiter, approx. 2000 years ago.

Last Edited: Mon. Jan 14, 2019 - 10:36 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes,  it should be y2 >> 8

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yea. I'm thinking I have bogus example code.

 

I started off with adafruit's library, but there are so many #IF and such for all the different varieties of Arduini that I couldn't figure out how to get it out of the device's SPI port.

 

"We trained hard... but it seemed that every time we were beginning to form up into a team, we would be reorganized. I was to learn later in life that we tend to meet any new situation by reorganizing. And a wonderful method it can be of creating the illusion of progress while producing confusion, inefficiency and demoralization." Petronius Arbiter, approx. 2000 years ago.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Torby wrote:
I started off with adafruit's library, but there are so many #IF and such for all the different varieties of Arduini that I couldn't figure out how to get it out of the device's SPI port.

 

I believe that the preprocessor processes the compiler directives.

You can instruct Arduino to save the output of the preprocessor

by changing a line in the file preferences.txt

 

 

In the Arduino IDE preferences.txt file, the default line is:

 

preproc.save_build_files=false

Change this line to =true

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This isn't for an arduino. Otherwise, the adafruit library would see the defines and just make.

 

"We trained hard... but it seemed that every time we were beginning to form up into a team, we would be reorganized. I was to learn later in life that we tend to meet any new situation by reorganizing. And a wonderful method it can be of creating the illusion of progress while producing confusion, inefficiency and demoralization." Petronius Arbiter, approx. 2000 years ago.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Tom,

 

You need nothing more than a writedata() and a writecommand() function.   And they are nothing more than

DC = 1; spi(data); and DC = 0; spi(command);

 

Whether you are rendering text, graphics, photos, ... it all comes down to drawPixel(x, y, colour) or fillRect(x, y, w, h, colour)

A horizontal or vertical line is only a very thin rectangle.

 

You can write your basic functions in ASM, C, C++

 

And make use of existing Graphics libraries.    The advantage of C++ is that you can inherit from existing classes.

But ASM, C still end up with drawPixel() and fillRect()

 

Yes,  some libraries get messy with conditionals for different target hardware.   Especially with parallel interfaces

But as I show above,   an SPI interface is very straightforward to use.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Torby wrote:

This isn't for an arduino. Otherwise, the adafruit library would see the defines and just make.

 

I should have been more explicit in my post.

You said that you couldn't follow the Arduino source code from Adafruit because of all the #IF statements.

Let the Arduino toolchain sort all of that out for you.

 

Enable saving the preproc output files and then build.

The preproc will generate straight C code without the #IFs.

You can then read those files.

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Chuck99 wrote:

Torby wrote:

This isn't for an arduino. Otherwise, the adafruit library would see the defines and just make.

 

I should have been more explicit in my post.

You said that you couldn't follow the Arduino source code from Adafruit because of all the #IF statements.

Let the Arduino toolchain sort all of that out for you.

 

Enable saving the preproc output files and then build.

The preproc will generate straight C code without the #IFs.

You can then read those files.

 

 

 

 

 

Adafruit's library doesn't include a particle electron board.

 

"We trained hard... but it seemed that every time we were beginning to form up into a team, we would be reorganized. I was to learn later in life that we tend to meet any new situation by reorganizing. And a wonderful method it can be of creating the illusion of progress while producing confusion, inefficiency and demoralization." Petronius Arbiter, approx. 2000 years ago.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I googled " particle electron board" and it appears to be a STM32F205 board with Wireless.

 

There is an official STM32 Arduino Core from STMicroelectronics.

So it should be very easy to run Arduino C++ libraries.

 

But even if you stick with C.   You only need to know how to wiggle CS, DC, RST pins and a spi() function.

 

This is easy enough to do by direct ARM register commands but ST provide a HAL library for you.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, the first code I got working stubbornly refuses to draw anything if z > 240. It seems to be full of many other bugs.

 

So, I tried to adapt the adafruit class for a second time, but particle's silly IDE refuses to make spitft.cpp file, leaving all the virtual methods of the iliblablabla class unimplemented. I even put a snide remark in the file between two methods, and it doesn't raise a compile error. Perhaps one of the multiple #if statements isn't satisfied. The whole thing in enclosed in a big #if to make sure it doesn't make for a tiny 85.

 

"Um, Can I do this project with an xMega?"

 

"We trained hard... but it seemed that every time we were beginning to form up into a team, we would be reorganized. I was to learn later in life that we tend to meet any new situation by reorganizing. And a wonderful method it can be of creating the illusion of progress while producing confusion, inefficiency and demoralization." Petronius Arbiter, approx. 2000 years ago.

Last Edited: Thu. Jan 17, 2019 - 04:09 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have not done much with TFT displays, but I think I like UTFT better than the Adafruit lib.

Recently I also printed a list of TFT libs which are supported by platformio in:

https://www.avrfreaks.net/forum/tft-touch-suggestions

It has 183 entries, which quite surprised me.

When limiting the list to lib's supporting ILI9341 it spits out a much more reasonable 19:

paul@dualcore:~$ pio lib search ili9341
Found 19 libraries:

TFT_eSPI
========
#ID: 1559
A TFT and ePaper SPI graphics library for ESP8266 and ESP32

Keywords: tft, epaper, display, esp8266, nodemcu, esp32, m5stack, ili9341, st7735, ili9163, s6d02a1, ili9486, st7789
Compatible frameworks: Arduino
Compatible platforms: Espressif 32, Espressif 8266
Authors: Bodmer

Adafruit ILI9341
================
#ID: 571
Library for Adafruit ILI9341 displays

Keywords: display
Compatible frameworks: Arduino
Compatible platforms: Atmel AVR, Atmel SAM, Espressif 32, Espressif 8266, Intel ARC32, Microchip PIC32, Nordic nRF51, Nordic nRF52, ST STM32, Teensy, TI MSP430
Authors: Adafruit

ILI9341_t3
==========
#ID: 540
Optimized ILI9341 (320x240 Color TFT) Display

Keywords: display, tft, lcd, graphics, spi
Compatible frameworks: Arduino
Compatible platforms: Atmel AVR, Atmel SAM, Espressif 32, Espressif 8266, Intel ARC32, Microchip PIC32, Nordic nRF51, Nordic nRF52, ST STM32, Teensy, TI MSP430
Authors: Limor Fried, Paul Stoffregen

Ucglib
======
#ID: 943
True color TFT and OLED library, Up to 18 Bit color depth. Supported display controller: ST7735, ILI9163, ILI9325, ILI9341, ILI9486,LD50T6160, PCF8833, SEPS225, SSD1331, SSD1351, HX8352C.

Keywords: display
Compatible frameworks: Arduino
Compatible platforms: Atmel AVR, Atmel SAM, Espressif 32, Espressif 8266, Intel ARC32, Microchip PIC32, Nordic nRF51, Nordic nRF52, ST STM32, Teensy, TI MSP430
Authors: oliver

JeeH
====
#ID: 3082
Headers for framework- and platform-agnostic code

Keywords: experimental
Compatible frameworks: Arduino, CMSIS, libOpenCM3, mbed, STM32Cube
Compatible platforms: Atmel AVR, Espressif 32, ST STM32
Authors: JeeLabs

Adafruit ILI9341
================
#ID: 1478
Library for Adafruit ILI9341 displays

Keywords: display
Compatible frameworks: Arduino
Compatible platforms: Atmel AVR, Atmel SAM, Espressif 32, Espressif 8266, Intel ARC32, Microchip PIC32, Nordic nRF51, Nordic nRF52, ST STM32, Teensy, TI MSP430
Authors: Adafruit

Adafruit_ILI9341
================
#ID: 2148
Port of the Adafruit_ILI9341 library for MBED. Depends on BurstSPI. fillRect, drawFastVLine, drawFastHLine are optimized to use BurstSPI fastwrites and perform a clearRX afterwards. MIT license Due to 600 character ...

Keywords: ili9341, tft
Compatible frameworks: mbed
Compatible platforms: Atmel SAM, Freescale Kinetis, Maxim Integrated MAX32, Nordic nRF51, Nordic nRF52, NXP LPC, Silicon Labs EFM32, ST STM32, Teensy, WIZNet W7500
Authors: James Kidd

ILI9341
=======
#ID: 88
Seeed ILI9341 2.2 TFT+SD library

Keywords: display, tft, lcd, graphics, spi
Compatible frameworks: Energia
Compatible platforms: TI MSP430
Authors: Radoslav Malinov

UniGraphic
==========
#ID: 2819
Basically i glued Peter Drescher and Simon Ford libs in a GraphicsDisplay class, then derived TFT or LCD class (which inherits Protocols class), then the most derived ones (Inits), which ...

Keywords: ili9320, ili9325, ili9328, ili9341, ili9481, ili9486, ist3020, lcd, mipi, parallel, spi, ssd1306, st7565, tft, uc1608, uc1701
Compatible frameworks: mbed
Compatible platforms: Atmel SAM, Freescale Kinetis, Maxim Integrated MAX32, Nordic nRF51, Nordic nRF52, NXP LPC, Silicon Labs EFM32, ST STM32, Teensy, WIZNet W7500
Authors: GraphicsDisplay

SPI_TFT_ILI9341
===============
#ID: 2976
Lib for the new LCD Display with ILI9341 controller

Keywords: spi_tft_ili9341
Compatible frameworks: mbed
Compatible platforms: Atmel SAM, Freescale Kinetis, Maxim Integrated MAX32, Nordic nRF51, Nordic nRF52, NXP LPC, Silicon Labs EFM32, ST STM32, Teensy, WIZNet W7500
Authors: Peter Drescher

Show next libraries? [y/N]: y
ILI9341
=======
#ID: 1139
ILI9341 for DisplayCore

Keywords: display, displaycore, tft, lcd, glcd, oled, graphics, font
Compatible frameworks: Arduino
Compatible platforms: Microchip PIC32
Authors: Majenko Technologies

ILI9341_esp
===========
#ID: 5371
Optimized ILI9341 (320x240 Color TFT) Display Support different SPI buses

Keywords: display
Compatible frameworks: Arduino
Compatible platforms: Atmel AVR, Atmel SAM, Espressif 32, Espressif 8266, Intel ARC32, Microchip PIC32, Nordic nRF51, Nordic nRF52, ST STM32, Teensy, TI MSP430
Authors: Limor Fried, Adafruit, Paul Stoffregen, Kurt Eckhardt

ILI9341_ESP32
=============
#ID: 2956
A fast ILI9341 LCD driver to be used with ESP32.

Keywords: display
Compatible frameworks: Arduino
Compatible platforms: Espressif 32
Authors: the-fallen

MI0283QT9
=========
#ID: 148
MI0283QT-9 / -9A / -11 Display (ILI9341, SPI)

Keywords: spi, graphics, display, lcd
Compatible frameworks: Arduino
Compatible platforms: Atmel AVR
Authors: Watterott electronic

TFT_ILI9341_ESP
===============
#ID: 5691
A TFT ILI9341 SPI graphics library for ESP8266

Keywords: ili9341, esp8266, tft
Compatible frameworks: Arduino
Compatible platforms: Espressif 8266
Authors: Bodmer, Adafruit

BSP_DISCO_F429ZI
================
#ID: 2208
STM32F429ZI Discovery board drivers

Keywords: bsp, disco_f429zi
Compatible frameworks: mbed
Compatible platforms: Atmel SAM, Freescale Kinetis, Maxim Integrated MAX32, Nordic nRF51, Nordic nRF52, NXP LPC, Silicon Labs EFM32, ST STM32, Teensy, WIZNet W7500
Authors: ST

ILI9341_SPI
===========
#ID: 3783
ILI9341_SPI

Keywords: ili9341_spi
Compatible frameworks: mbed
Compatible platforms: Atmel SAM, Freescale Kinetis, Maxim Integrated MAX32, Nordic nRF51, Nordic nRF52, NXP LPC, Silicon Labs EFM32, ST STM32, Teensy, WIZNet W7500
Authors: TMNTmaker !

ILI9341_Graphic_Library
=======================
#ID: 3767
Wrapped version of the ILI9341 graphics library with some MBED tweaks

Keywords: ili9341_graphic_library
Compatible frameworks: mbed
Compatible platforms: Atmel SAM, Freescale Kinetis, Maxim Integrated MAX32, Nordic nRF51, Nordic nRF52, NXP LPC, Silicon Labs EFM32, ST STM32, Teensy, WIZNet W7500
Authors: Justin Howard

SX032QVGA008
============
#ID: 5261
aitendo SX032QVGA008

Keywords: aitendo, ili9341, spi, tft
Compatible frameworks: mbed
Compatible platforms: Atmel SAM, Freescale Kinetis, Maxim Integrated MAX32, Nordic nRF51, Nordic nRF52, NXP LPC, Silicon Labs EFM32, ST STM32, Teensy, WIZNet W7500
Authors: Imayan chan

 

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Today's project is putting a program in an ATTINY 10 for a silly girl's birthday present. 3d printed box, switch and servo to make a useless machine. Besides, her birthday is tomorrow.

 

Time for an up-your-confidence type project.

 

"We trained hard... but it seemed that every time we were beginning to form up into a team, we would be reorganized. I was to learn later in life that we tend to meet any new situation by reorganizing. And a wonderful method it can be of creating the illusion of progress while producing confusion, inefficiency and demoralization." Petronius Arbiter, approx. 2000 years ago.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Torby wrote:

Today's project is putting a program in an ATTINY 10 for a silly girl's birthday present. 3d printed box, switch and servo to make a useless machine. Besides, her birthday is tomorrow.

 

Time for an up-your-confidence type project.

 

Well... So much for that. My age-old Atmel ICE has passed away. In spite of its life support, the USB connector if flopping around loose inside again.

 

Dang. Moriah's birthday is tomorrow. I guess she's not getting this.

 

"We trained hard... but it seemed that every time we were beginning to form up into a team, we would be reorganized. I was to learn later in life that we tend to meet any new situation by reorganizing. And a wonderful method it can be of creating the illusion of progress while producing confusion, inefficiency and demoralization." Petronius Arbiter, approx. 2000 years ago.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As an emergency repair you can simply cut the end of an USB cable and solder it directly to your PCB. (Not the end you cut off, but the other end. Euhm, beginning?, no the beginning still has a connector. Intermediate part? Weird stuff, language.)

 

Or take some other USB connector, glue it in a hole of the case and route some wires to the PCB for a more permanent repair.

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com

Last Edited: Fri. Jan 18, 2019 - 11:26 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Paulvdh wrote:

As an emergency repair you can simply cut the end of an USB cable and solder it directly to your PCB. (Not the end you cut off, but the other end. Euhm, beginning?, no the beginning still has a connector. Intermediate part? Weird stuff, language.)

 

Or take some other USB connector, glue it in a hole of the case and route some wires to the PCB for a more permanent repair.

 

I've soldered the connector back on twice over the years, and strapping it to a board probably extended its life. Haven't taken it apart to see what the damage is this time.

 

Was going to make the pastor's daughter a useless machine for her birthday, today. As a last-ditch attempt, I decided to use an arduino, but... it won't program. She's getting a card.

 

"We trained hard... but it seemed that every time we were beginning to form up into a team, we would be reorganized. I was to learn later in life that we tend to meet any new situation by reorganizing. And a wonderful method it can be of creating the illusion of progress while producing confusion, inefficiency and demoralization." Petronius Arbiter, approx. 2000 years ago.

Last Edited: Sat. Jan 19, 2019 - 04:10 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You could make a useless machine with nothing but a DPDT toggle switch, a SPST limit switch, and a plain old motor. No servo or MCU needed. But I guess if the party is today that might be a tall order... ;-)

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Thu. Jan 24, 2019 - 05:50 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Right now, more worried about getting an avr programmer working, or finding some way to make money again.

 

"We trained hard... but it seemed that every time we were beginning to form up into a team, we would be reorganized. I was to learn later in life that we tend to meet any new situation by reorganizing. And a wonderful method it can be of creating the illusion of progress while producing confusion, inefficiency and demoralization." Petronius Arbiter, approx. 2000 years ago.