TeensyUserInterface update to support ST7796

Hi Ken

Glad you finally got it working. Forgot about having to have the fonts library installed- just assumed which is on me.

The greyed out button is intentional. Sketch starts out having the slider disabled then after a 5 second delay it reenables it. Tried to put most of the commands in the test sketch.

It appears that the has include ifs aren’t working the way they should
 
Hi @mjs513, I sent you a zip file with changes to the text output, which I think gets rid of most of the issues
with text not being overwritten when it gets smaller.

One of the major problems was there was still assumptions about using system font and *8 and the like both in the draw text function
as well as a fillRect called before it using hard coded black.
 
Had to get a local copy of this LIB - showed as a problem before? Not sure what the linkage is?

Not sure if the clear text overwrite was done? The red background showed some garbage.

And it is using it?
Code:
Multiple libraries were found for "font_Arial.h"
 Used: T:\T_Drive\tCode\libraries\ILI9341_fonts
 Not used: T:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\ILI9341_fonts
 Not used: T:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\ILI9341_t3
Using library ST7735_t3 at version 1.0.1 in folder: T:\T_Drive\tCode\libraries\ST7735_t3
Using library SPI at version 1.0 in folder: T:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\SPI
Using library ILI9341_fonts at version 1.0 in folder: T:\T_Drive\tCode\libraries\ILI9341_fonts
Using library Adafruit_FT6206_Library at version 1.1.0 in folder: T:\T_Drive\tCode\libraries\Adafruit_FT6206_Library
Using library Adafruit_BusIO at version 1.17.1 in folder: T:\T_Drive\tCode\libraries\Adafruit_BusIO
Using library Wire at version 1.0 in folder: T:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\Wire
Using library HX8357_t3n-master at version 1.0 in folder: T:\T_Drive\tCode\libraries\HX8357_t3n-master
 
Last edited:
Yesterday I was playing around with the text and garbage at ends... I don't think this would be the final fix, but I have it
now measuring the size of the text and then erase before and after if the width is less than the previous call, I also commented
out the call before it displayed the text that was writing a black rectangle

Edit: Note: I was doing this with the ST7796, did not test on others and maybe apis might be different on others.
As for HX8357, Have not tried much with it in awhile, as I believe the only one available was from Adafruit.
 

Attachments

  • sliderM_class_v2-251007a.zip
    7.9 KB · Views: 17
As for HX8357, Have not tried much with it in awhile, as I believe the only one available was from Adafruit.
Just was investigating this and found that if I substitute
Code:
#include <st7735_t3_font_Arial.h>

The issue goes away with the sketch trying to compile for the HX8357. Now for the mods to drawcenteredtext
 
Ok all - just update the sketch/class with @KurtE's changes and included the font in the structure so that each slider control will have its own font. May have to adjust lib so that the font is display font is selected in the draw text function - thats next I guess

EDIT: Updated to include setFont when it redraws the slider:
 

Attachments

  • sliderM_class_v2-251008a.zip
    8.1 KB · Views: 22
Last edited:
It builds - theough still pulling in:
Using library HX8357_t3n-master at version 1.0 in folder: T:\T_Drive\tCode\libraries\HX8357_t3n-master

Anyone notice:: You can TOUCH BOTH Sliders at once in the central bars! Not the repeat test end buttons.

Except for some extra black in the RED background - all the text redraw looks clean now.
 
Looks like good progress is being made. Here are a few notes I made:

Like @defragster, on my system it still requires the HX8357_t3n library. The st7735_t3_font_Arial.h is present in the beta 5 release, so not sure why it isn’t finding it, but it won't compile if I delete HX8357_t3n.

I noticed that there are some functions that pass in 4 parameters, but use 3, like setSliderColors() and setBump().

The default font style in the header file is set for italic which can be seen on the default vertical slider. Seems like the default should be regular font? const ILI9341_t3_font_t* font = &Arial_12_Italic;

Padding on the text value label background could be improved a bit which is what causes black in the red background on numbers < 100 with a plus sign displayed. The text is also offset vertically.

1759946437468.jpeg
 
Playing around a little more, I removed the + sign with
slider.setSliderPrint(menu1BacklightSliderH, 3, 0, false);

And now get this when running the slider down to 1. Perhaps a clue there? This is Arial_16 BTW, though Arial_12 looks the same.

1759947568858.jpeg
 
Last edited:
If rotation changed (3) to (1) : tft.setRotation(1);

It needs to change the Touch Math - then this works:
Code:
#if __has_include("Adafruit_FT6206.h")
//      BtnX = tft.width() - BtnX;
//      BtnY = BtnY;
      BtnX = BtnX;
      BtnY = tft.height() -BtnY;
 
@mjs513 missed one of the lines I changed:
Code:
   //d->fillRect(s.xValueCenterLoc - ((s.placesBeforeTheDecimal + s.placesAfterTheDecimal + 2) * 4), s.yValueCenterLoc - 4, (s.placesBeforeTheDecimal + s.placesAfterTheDecimal + 2) * 8, 10, C_BLACK);

   s.textWidthPrev = centerDrawText(outString, s.xValueCenterLoc + 1, s.yValueCenterLoc, s.valueColor, s.valueBgColor, s.textWidthPrev);
I think that is line 506 the fillRect I commented out, should probably just remove
 
Like @defragster, on my system it still requires the HX8357_t3n library. The st7735_t3_font_Arial.h is present in the beta 5 release, so not sure why it isn’t finding it, but it won't compile if I delete HX8357_t3n.
That seems to be coming from the ILI99341_font library - have to go through to see why that is happening. Its now included in the library so can set up a default font.

I noticed that there are some functions that pass in 4 parameters, but use 3, like setSliderColors() and setBump().
Surprised thats all I missed. Just fixed it.

The default font style in the header file is set for italic which can be seen on the default vertical slider. Seems like the default should be regular font? const ILI9341_t3_font_t* font = &Arial_12_Italic;
Did that on purpose to make sure the fonts were working for each slider - can put back now.

I think that is line 506 the fillRect I commented out, should probably just remove
Will fix - completely missed that. Too early in the morning. Seems to be working now

Anyone notice:: You can TOUCH BOTH Sliders at once in the central bars! Not the repeat test end buttons.
Probably the same way in Mark's original code. I did notice with the arrows you have to touch them fairly accurately other wise it doesn't register.

This is Arial_16 BTW, though Arial_12 looks the same.
Just set up horizontal slider to 16 and default to be 12. There does seem to be a difference

1759953839497.png


If rotation changed (3) to (1) : tft.setRotation(1);

It needs to change the Touch Math - then this works:
Yep only set up for single rotation of 3.

This set of changes attached. Still have some cleaning to do
 

Attachments

  • sliderM_class_v2-251008a.zip
    8.1 KB · Views: 19
Like @defragster, on my system it still requires the HX8357_t3n library. The st7735_t3_font_Arial.h is present in the beta 5 release, so not sure why it isn’t finding it, but it won't compile if I delete HX8357_t3n.
Found the issue right away, got lucky didnt have to go through all the font files.

In font_ArialBlack.h
C++:
#elif __has_include(<ST7735_t3.h>)
    #include "HX8357_t3n.h"
should be
#elif __has_include(<ST7735_t3.h>)
    #include "ST7735_t3.h"

Just updated the library on Github: https://github.com/mjs513/ILI9341_fonts

No longer compiles requiring the HX8357_t3n library
 
Can confirm that all the changes worked as advertised. You guys are fast!

This is Arial_16 BTW, though Arial_12 looks the same.
Just set up horizontal slider to 16 and default to be 12. There does seem to be a difference
Sorry, this was just poor verbiage on my part. The font size does change, I meant the issue remained independent of the font size used.

I personally find the sliders a little easier to use if I increase the time between touch checks from 20 to something like 50. Makes it easier to hit exact numbers. if((checkTouch > 50 ) && processTouchscreen() ) {

The only thing I am noticing now (and this is a minor nit in the scheme of things) is that if I remove the '+' sign via
slider.setSliderPrint(menu1BacklightSliderH, 3, 0, false);
when the text gets down to 1, there are usually a couple of stray white pixels.
1759960105229.jpeg
 
Confirmed. Good find.

Wasn't sure if the DUAL TOUCH report was unique to the "FT6206"? But the code does read with it.

In the original implementation, using the RA8875 display with its associated touch controller (FT6206 ??), I set the number of unique touches allowed to "1", so you could touch multiple places (on any button, slider, or any part of each), but only the point last touched was used/processed. Probably a gross assumption on my part (targeted to the use case on my TMPS), but should be easy to clean up & make correct.

Thanks to everyone for all of your efforts on this !!

Mark J Culross
KD5RXT
 
In the original implementation, using the RA8875 display with its associated touch controller (FT6206 ??), I set the number of unique touches allowed to "1", so you could touch multiple places (on any button, slider, or any part of each), but only the point last touched was used/processed. Probably a gross assumption on my part (targeted to the use case on my TMPS), but should be easy to clean up & make correct.
Not sure how dual touch will working out. Was doing some digging and found for getPoint
nThe # index (0 or 1) to the points we can detect. In theory we can detect 2 points but we've found that you should only use this for single-touch since the two points cant share the same half of the screen.
see: https://adafruit.github.io/Adafruit..._t6206.html#a4ef0e1c061003dd83c4e21df4f8d547f

Might be more trouble than its worth.

With that said I just looked again and it looks like the ST7796 IPS display is actually using a FT6336U as a its driver that looks like it supports dual touch. Found a driver for it on github:

appears to be working with dual touch.
 
The only thing I am noticing now (and this is a minor nit in the scheme of things) is that if I remove the '+' sign via
slider.setSliderPrint(menu1BacklightSliderH, 3, 0, false);
when the text gets down to 1, there are usually a couple of stray white pixels.
Was playing with this and doesn't appear to happen all the time - starting looking but didnt see anything obvious.
 
I may have to play more with the capacitive touch code. Trying to remember which diversion I was doing where I updated a copy
of touchpaint code for multiple fingers. I was playing with it with at least three fingers...

But I think that was probably the GIGA display on zephyr. May have to try a new version of it for the ST7796 and see
 
Was playing with this and doesn't appear to happen all the time - starting looking but didnt see anything obvious.
Where is that in the code... Probably should just look.

Or more specifically where is this called? I don't see any references to it.
 
Good Morning all

@KurtE hacked up the lib so the name of the control is used as opposed to passing it, i.e.

C++:
sliderM menu1BacklightSliderH(&tft, "menu1BacklightSliderH", sliderM::SLIDER_MODE::SLIDER_MODE_HORIZONTAL);


then in setup
  menu1BacklightSliderH.init(  200,  180, 150,  30, true, true);
  menu1BacklightSliderH.setAxis( 1.0, 255.0, 16, 2);
  menu1BacklightSliderH.setBump( 1.0, true, true, true);

Thank you Kurt - been distracted with Zephyr camera stuff ...
 

Attachments

  • sliderM_class_v2-251009a.zip
    8.1 KB · Views: 17
Thank you Kurt - been distracted with Zephyr camera stuff ...
distracted with ..., never been there 😆 oops busy now syncing up to latest zephyr changes
And always fun trying to get a PR done with N commits, each of with have to meet some criteria and not do other things
 
Distractions abound ... and 'latency' response times so much longer these days ...
down to 1, there are usually a couple of stray white pixels.
Still seeing these - and they can continue into double digits with right bump
1760119095475.png

And this seems to float a line high on vertical?
1760119123154.png
 
Checking in to see if there is a plan to eventually roll this new slider functionality into the TeensyUserInterface library?
 
Back
Top