Mac_che:
Full pinout of the Waveshare/knockof. If someone wants to make a Waveshare<>ESP pinout that would be awesome. I had to make a lot of guesses today and it's not working (Sometimes with some ocassional flickering and gibberish on the serial). So if you want a free beer (or two) please tell me how to wire this puppy up.
The image attached appears to be corrupted so is not much use.
With reference to the image in post #103 and assuming a ESP8266 NodeMCU is used:
After figuring out the wiring (Thanx) and using your planespotter repo (and did the same modifications actually) to make it work with your graphics repo driver the display works.
Then I found out that Daniel silently updated his Planespotter repo and added touch.
Tested it, no modifications, works and ofcourse no screen but that wasn't important for testing
So I did some modifications to the Graphics library (Added some missing functions Planespotter uses like getTextBounds and a few others, lazy copied from Adafruit ) modified the sketch to make use of the Graphics library, changed some code like getWidth > widt and getHeight > height and compiled.
It compiles but when started it reboots due to some stack error.
So I took Bodmer repo, hacked in the touch part from Daniel,
That works but when touched it restarts. (TP_CS on D2 and without T_IRQ connected)
So, wired T_IRQ to D4 but didn't made any difference.
I think it's related to the touch screen since testing with only touch examples fails.
(XPT2046 touch screen according to the PCB)
Mac_che:
I think it's related to the touch screen since testing with only touch examples fails.
(XPT2046 touch screen according to the PCB)
I had not noticed Daniel's update to use the touch screen, so that is interesting.
I have a screen with a XPT2046 connected so I tried Paul's library here. The example worked fine on an ESP8266 (NodeMCU) without problems when the pins are setup. Here is the sketch I used:
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
// These are the pins for all ESP8266 boards
#define PIN_D0 16
#define PIN_D1 5
#define PIN_D2 4
#define PIN_D3 0
#define PIN_D4 2
#define PIN_D5 14 // SCLK
#define PIN_D6 12 // MISO
#define PIN_D7 13 // MOSI
#define PIN_D8 15
#define PIN_D9 3
#define PIN_D10 1
#define CS_PIN PIN_D1 // XPT2046 chip select
#define TFT_CS PIN_D8 // TFT chip select
XPT2046_Touchscreen ts(CS_PIN);
void setup() {
Serial.begin(38400);
digitalWrite(TFT_CS, 1); // Disable TFT for test only
ts.begin();
while (!Serial && (millis() <= 1000));
}
void loopB() {
TS_Point p = ts.getPoint();
Serial.print("Pressure = ");
Serial.print(p.z);
if (ts.touched()) {
Serial.print(", x = ");
Serial.print(p.x);
Serial.print(", y = ");
Serial.print(p.y);
}
Serial.println();
// delay(100);
delay(30);
}
void loop() {
if (ts.touched()) {
TS_Point p = ts.getPoint();
Serial.print("Pressure = ");
Serial.print(p.z);
Serial.print(", x = ");
Serial.print(p.x);
Serial.print(", y = ");
Serial.print(p.y);
delay(30);
Serial.println();
}
}
Note that MISO needs to be connected up as well as MOSI. To play safe for the test I have made sure the TFT cannot respond and upset the MISO data by setting TFT chip select high in setup. Don't try amd use the touch IRQ line as that will not work with an ESP8266.
Now, with your Planespotter when pressed, I see a menu and it's no longer crashing.
And now it also know more about coding Arduino sketches so it wasn't a waste of time
It seems no commands are defined so I going to dive into the world of buttons and touch and commands.
Let's see if I can merge PS and WS together.
Now, with your Planespotter when pressed, I see a menu and it's no longer crashing.
And now it also know more about coding Arduino sketches so it wasn't a waste of time
It seems no commands are defined so I going to dive into the world of buttons and touch and commands.
Let's see if I can merge PS and WS together.
OK, good to hear it is working. I had a look a Daniel's code and it is a "work in progress" as there the touch response code is incomplete and commented out.
The WS code uses a lot of SPIFFS memory (more than 1 Mbyte) so allocate 3 MBytes.
The output of the touch library could be calibrated and scaled into pixel units, that would help identify different screen areas.
Does that mean that we cannot use something like this or wouldn't that only be inaccurate?
if ((pt.x>=420) && (pt.x<=480) && (pt.y>=0) && (pt.y<=40)) {
I already created a menu with up down, left right and zoom + - on the right upper side.
The part works, short press brings that menu up, longer press brings up MainMenu.
The commands for Zoom in and zoom out are quite easy to create I think. It requires to grab the currentzoomlevel and do a i++ or i-- for every touch, download that map and display that map.
I was thinking of something like this:
if ((pt.x>=420) && (pt.x<=480) && (pt.y>=0) && (pt.y<=40)) {
if (currentPage == '0'){
// Page 0 PanAndZoom, page 1 MainMenu, Page 2 manual update, based on presstime
tft.fillScreen(TFT_BLACK);
Serial.println("Zoom IN pressed") ;
currentZoomlevel = geoMap.getCurrentZoomlevel(); //added in geomap.h
for (int i = currentZoomlevel; i++;){
delay(500);
geoMap.downloadMap(mapCenter, i, _downloadCallback);
geoMap.convertToCoordinates({0,0});
geoMap.convertToCoordinates({MAP_WIDTH, MAP_HEIGHT});
tft.fillRect(0, geoMap.getMapHeight(), tft.width(), tft.height() - geoMap.getMapHeight(), TFT_BLACK);
You can find the (probably not compiling version due to missing brackets to close the loop) code here
Mac_che:
Does that mean that we cannot use something like this or wouldn't that only be inaccurate?
If you run the code in post #122 you will see in the Serial Monitor window that the coordinates are in raw ADC values. These could be used but are likely to be in the range 0 - 4095. Also the coordinate origin of the touch screen may not be in the same place as the origin of the screen.
How hard would it be to write (just for debug purposes) an Adafruit compatible driver using ILI9431 as a template. Tried myself but cannot get the init to work (Used your init and notro's init, screen stays white) Any idea's?
Nevermind, it wasn't that :o. After setting a few print statements I saw that it crashed on setFreeFont
Setting it to setTextFont(2); worked.
Have to change a few settings to make it fit the 480*320. It even works on 160MHZ.
I had to use the JPEGDecoder version from FredericPlante. Yours gave me everything but no Google Maps background.
it takes a few changes. (I'll save you the trouble, i'll upload a working sketch) I made a few changes to a few libraries so it's easier to upload it and attach it here since Github is kinda new. (TODO, upload to Github)
I changed a lot to make it fit my screen (320*240) and my wishes. Still working on the touch, I am close.
It sometimes reset and lines (heading) aren't drawn, which it dit initially, have to look in to that.
I want bigger font and more space between the text but hey, I came this far
I took me a while to figure it all out but I managed. Experience in c++ or Arduino code is still below any average. It took a steap learning curve and mostly some time,coffee & perseverance
As always, it wasn't that hard if you know what you're doing (I have some clues what I am doing) but I liked the leaning course. I tried to make as much comments as possible while changing things.
I also included the library's I modified (TFT_eSPi) in the next post (Due to upload size). Read the original readme by Daniel for the others)
fredericplante's Jpegdecoder changed names due to recovery and is now called JPEG_CODEC, old one will work also.
You can find it here
Huge thanx to Bodmer for the liTFT brary and the responses!
By the way, you need this for touch: XPT2046_Touchscreen PaulStoffregen
And ofcourse credits to Daniel Eichhorn who made the whole Planespotter sketch in the first place. See blog
His Github for Planespotter: esp8266-plane-spotter-color
The sketch is as is, I did not gave myself credits in this one. Free to use.
If you cannot open the zip, it's actually a renamed rar file (due to forum limitations)
Modified TFT_eSPI (Added some functions)
Only cpp and .h are modified, Download Bodmer original library here and copy them over.
(Forum limitations and things like that)
Mac_che:
Is there an easy way to download (6Kb) bmp (from a/my internal server) and throw them out of memory when no longer needed?
The simplest method if the server handles http GET commands is to use a method like this example. However as the image is small, and I assume frequently fetched and erased, then the image can be stored in a RAM array otherwise you could wear out the FLASH memory.
What I assume (Please verify) is that it is not possible to write to SPIFFS during runtime, only during setup phase.
Since i can't store the 1500+ images directly to SPIFFS since it's total size is more than 5MB, i was thinking that I simply download the images I need while they're being seen (silhouettes of the airplane) and store them on SPIFFS. I don't think I will ever see all the 1500+ Airplanes on the device so that's not a problem.
Everyime I download the images during runtime it resets and throws a stack trace on the serial interface.
The images are ok since storing (a few ofcourse) of them to SPIFFS directly and show them on the display works.
I am ok with storing them into ram but well, i can't find any examples for it.