slviajero / tinybasic

A BASIC interpreter for Arduino, ESP, RP2040, STM32, Infineon XMC and POSIX with IoT and microcontroller features.
GNU General Public License v3.0
205 stars 32 forks source link

TFT parallel display #66

Open Leizar06001 opened 1 month ago

Leizar06001 commented 1 month ago

Hi, I am trying to make it run on a ESP32-8048S043 board, which contains a 800 * 480 display and a SD So I set #define ARDUINOILI9488 Then in runtime, changed

#ifdef ARDUINOILI9488
#include <Arduino_GFX_Library.h>
#endif

And also lower in the same file

#define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin
#define TFT_BL 2
/* More data bus class: https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class */
//Arduino_DataBus *bus = create_default_Arduino_DataBus();

/* More display class: https://github.com/moononournation/Arduino_GFX/wiki/Display-Class */
//Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 0 /* rotation */, false /* IPS */);
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
    40 /* DE */, 41 /* VSYNC */, 39 /* HSYNC */, 42 /* PCLK */,
    45 /* R0 */, 48 /* R1 */, 47 /* R2 */, 21 /* R3 */, 14 /* R4 */,
    5 /* G0 */, 6 /* G1 */, 7 /* G2 */, 15 /* G3 */, 16 /* G4 */, 4 /* G5 */,
    8 /* B0 */, 3 /* B1 */, 46 /* B2 */, 9 /* B3 */, 1 /* B4 */,
    0 /* hsync_polarity */, 8 /* hsync_front_porch */, 4 /* hsync_pulse_width */, 8 /* hsync_back_porch */,
    0 /* vsync_polarity */, 8 /* vsync_front_porch */, 4 /* vsync_pulse_width */, 8 /* vsync_back_porch */,
    1 /* pclk_active_neg */, 16000000 /* prefer_speed */);
Arduino_RGB_Display tft = Arduino_RGB_Display(
    800 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */);

/* Everything else stays the same excepted : (I removed the last arg) */
void dspprintchar(char c, uint8_t col, uint8_t row) {  if (c) tft.drawChar(col*dspfontsize, row*dspfontsize, c, dspfgcolor, dspbgcolor); }

Those are the correct settings for this display The display seems to be initialized correctly, I can change its bg color, but for everything else it just stays black. Any idea ?

slviajero commented 3 weeks ago

Hi,

sorry for replying so late, but I have been moving house the last couple of days and was confronted with a few technical problems of a simpler nature.

If the display initialises correctly and can be accesses, which is obvious from being able to change the bg color, the most probable root cause can be color handling. BASIC maps colors using two functions converting from vga 16 colors to rgb. The code that does this is somehow messy because I had to integrate many boards with totally different color handling.

You could try to call dspprintchar() with fixed arguments for the color first. Do really hard coded color. If this works you know that tft.drawChar does the right thing. Then you could look into color handling. Is dspfgcolor constructed right in the upstream code.

I can help you with this.

On 21. Sep 2024, at 18:55, Leizar06001 @.***> wrote:

Hi, I am trying to make it run on a ESP32-8048S043 board, which contains a 800 * 480 display and a SD So I set #define ARDUINOILI9488 Then in runtime, changed

ifdef ARDUINOILI9488

include

endif

And also lower in the same file

define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin

define TFT_BL 2

/ More data bus class: https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class / //Arduino_DataBus *bus = create_default_Arduino_DataBus();

/ More display class: https://github.com/moononournation/Arduino_GFX/wiki/Display-Class / //Arduino_GFX gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 0 / rotation /, false / IPS /); Arduino_ESP32RGBPanel rgbpanel = new Arduino_ESP32RGBPanel( 40 / DE /, 41 / VSYNC /, 39 / HSYNC /, 42 / PCLK /, 45 / R0 /, 48 / R1 /, 47 / R2 /, 21 / R3 /, 14 / R4 /, 5 / G0 /, 6 / G1 /, 7 / G2 /, 15 / G3 /, 16 / G4 /, 4 / G5 /, 8 / B0 /, 3 / B1 /, 46 / B2 /, 9 / B3 /, 1 / B4 /, 0 / hsync_polarity /, 8 / hsync_front_porch /, 4 / hsync_pulse_width /, 8 / hsync_back_porch /, 0 / vsync_polarity /, 8 / vsync_front_porch /, 4 / vsync_pulse_width /, 8 / vsync_back_porch /, 1 / pclk_active_neg /, 16000000 / prefer_speed /); Arduino_RGB_Display tft = Arduino_RGB_Display( 800 / width /, 480 / height /, rgbpanel, 0 / rotation /, true / auto_flush /);

/ Everything else stays the same excepted : (I removed the last arg) / void dspprintchar(char c, uint8_t col, uint8_t row) { if (c) tft.drawChar(coldspfontsize, rowdspfontsize, c, dspfgcolor, dspbgcolor); } Those are the correct settings for this display The display seems to be initialized correctly, I can change its bg color, but for everything else it just stays black. Any idea ?

— Reply to this email directly, view it on GitHub https://github.com/slviajero/tinybasic/issues/66, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSY56F6XSL33TNSGCO4XFTZXWQHLAVCNFSM6AAAAABOTXSPQCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGU2DANBRGE4TCMQ. You are receiving this because you are subscribed to this thread.

Leizar06001 commented 3 weeks ago

Hey !

Now worries, I know unfortunately there is a life outside of the code ^^

So I've managed to print something, first if I put tft.drawChar(10, 10, 'X', 0xFFFF, 0); in dspbegin, I got it on the screen. But putting a hard coded color in 'dspprintchar' didnt change anything

I noticed that the text was printed in the serial com and looking at the docs I found that with #define STANDALONE I can get it printed on the display, but following it there seems to be the prompt '>' printed endlessly, the display looks like this :

-------------------------------------------------------------------
|>  >  >  >  >  >  >  >  >  >  >  >  >  >                         |
|>  >  >  >  >  >  >  >  >  >  >  >  >  >                         |
|>  >  >  >  >  >  >  >  >  >  >  >  >  >                         |
|>  >  >  >  >  >  >  >  >  >  >  >  >  >                         |
|>  >  >  >  >  >  >  >  >  >  >  >  >  >                         |
|>  >  >  >  >  >  >  >  >  >  >  >  >  >                         |
|                                                                 |
|                                                                 |
|                                                                 |
|                                                                 |
-------------------------------------------------------------------

So, I wonder if maybe I didnt use the right defines, for now I have set those :

define DISPLAYCANSCROLL

define ARDUINOILI9488

define ARDUINOEEPROM

define STANDALONE

define ARDUINORTC

Second thing, It seems that the display is not fully used, is there somewhere else in the code where the resolution is defined ?

For information, I don't have any inputs connected to the esp, can it be messing with the display ? I was thinking, if I can get your code working on my device, to try adding support for bluetooth keyboards later

slviajero commented 3 weeks ago

Ok, I think now I understand the problem. If you go back to the original code and also leave STANDALONE unset then you should be able to access the display like this from the serial console:

PRINT &2, “Hello Display”

This should provide the output on the display. You also should be able to change color and plot on the display.

In this mode, the display is the secondary output device and serial is the primary output and input device.

Do you have a keyboard connected? Because only then STANDALONE makes sense. All other defines you use are ok

On 28. Sep 2024, at 22:51, Leizar06001 @.***> wrote:

Hey !

Now worries, I know unfortunately there is a life outside of the code ^^

So I've managed to print something, first if I put tft.drawChar(10, 10, 'X', 0xFFFF, 0); in dspbegin, I got it on the screen. But putting a hard coded color in 'dspprintchar' didnt change anything

I noticed that the text was printed in the serial com and looking at the docs I found that with #define STANDALONE I can get it printed on the display, but following it there seems to be the prompt '>' printed endlessly, the display looks like this :


> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >

So, I wonder if maybe I didnt use the right defines, for now I have set those :

define DISPLAYCANSCROLL

define ARDUINOILI9488

define ARDUINOEEPROM

define STANDALONE

define ARDUINORTC

Second thing, It seems that the display is not fully used, is there somewhere else in the code where the resolution is defined ?

For information, I don't have any inputs connected to the esp, can it be messing with the display ? I was thinking, if I can get your code working on my device, to try adding support for bluetooth keyboards later

— Reply to this email directly, view it on GitHub https://github.com/slviajero/tinybasic/issues/66#issuecomment-2380891897, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSY56GACNQFLFWL44W4N63ZY4JGXAVCNFSM6AAAAABOTXSPQCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBQHA4TCOBZG4. You are receiving this because you commented.

Leizar06001 commented 3 weeks ago

Yep it works, I don't have a keyboard plugged yet, I only have USB ones right now, I didn't think I'll ever need a PS2 one again !

My idea was to learn BASIC and for that I wanted to have a dedicated device that could only do that. At first I was looking at old computers but they are quite expensive now and have specific inputs/outputs. It only lately that I discovered projects for running this language on ESP.

I also use a bluetooth keyboard everyday and I'd like to make this a portable device, so at the end it will be standalone, and when I set STANDALONE it behave as I described. Maybe the fact no keyboard is plugged make it believe I am pressing some keys ?

For the display size I only found now that there is dsp_rows and dsp_columns so that's good ! I'll make a specific define for this display instead of using the ILI9488 one

slviajero commented 3 weeks ago

A few word on the STANDALONE features, to explain how it works.

BASIC uses output channel. Channel 1 is always the serial input and output. Channel 2 is always the display and keyboard.

The two variables in runtime.cpp

int8_t idd = ISERIAL; // default input stream in interactive mode int8_t odd = OSERIAL; // default output stream in interactive mode

define which channel is used for input (idd) and output (odd) when the interpreter goes to interactive mode. This is

Whenever the interpreter goes to interactive mode, these two settings are used and the interpreter uses this channel.

When you set STANDALONE the following thing happens:

/ a standalone system runs from keyboard and display /

ifdef STANDALONE

idd = IKEYBOARD; odd = ODSP;

endif

output is directed interactively to the display and input comes from the keyboard channel.

If you set standalone and have no keyboard, then the default keyboard methods always return a zero to the interpreter code and you have the effect of the repeated prompt.

You have three options:

  1. Use BASIC on the device and program it through the serial interface. Then STANDALONE must be off. The BASIC output command

PRINT “Hello World”

prints to the serial channel while

PRINT &2, “Hello world”

prints to the displaz.

  1. Connect a keyboard. PS2 is fully supported, ZX81 keyboards and USB only alpha. I have not yet implemented bluetooth keyboards, but probably on an ESP 32 this would be fun.

With a keyboard you can set STANDALONE and the serial stream stays inactive. You can still use it. Channel 1 is always present. Always. You can do PRINT &1, “Hello World” on a standalone system and print to the serial stream.

  1. Hack a little and use serial just for input and the display for output.

For this you could change the idd=IKEYBOARD to idd=ISERIAL in the second definition and keep STANDALONE active. Then BASIC would print to the display and get data from the serial line. There may be issued with local echo code but they could be fixed.

On 29. Sep 2024, at 17:12, Leizar06001 @.***> wrote:

Yep it works, I don't have a keyboard plugged yet, I only have USB ones right now, I didn't think I'll ever need a PS2 one again !

My idea was to learn BASIC and for that I wanted to have a dedicated device that could only do that. At first I was looking at old computers but they are quite expensive now and have specific inputs/outputs. It only lately that I discovered projects for running this language on ESP.

I also use a bluetooth keyboard everyday and I'd like to make this a portable device, so at the end it will be standalone, and when I set STANDALONE it behave as I described. Maybe the fact no keyboard is plugged make it believe I am pressing some keys ?

For the display size I only found now that there is dsp_rows and dsp_columns so that's good ! I'll make a specific define for this display instead of using the ILI9488 one

— Reply to this email directly, view it on GitHub https://github.com/slviajero/tinybasic/issues/66#issuecomment-2381393805, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSY56A2MJDMEYXXXRM65TLZZAKHPAVCNFSM6AAAAABOTXSPQCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBRGM4TGOBQGU. You are receiving this because you commented.