TFT FeatherWing Ring Meters


#1

Hi all,

I am using a TFT FeatherWing - 2.4" 320x240 Touchscreen with an Argon to alert and display based on data coming over my local network, and I want to display my data in some nice looking color meters.

I found this this page which looks like roughly what I want to achieve:

To get the TFTwing working, I’m using the following libraries:
Adafruit_GFX_RK
Adafruit_STMPE610_RK

I don’t understand what I need to do with the libraries (Adafruit_ILI9341_AS and Adafruit_GFX_AS) from the instructables project to get the meters to work on my display.

Can someone give me some guidance on what needs to happen to make this work? I’m not sure if I have enough knowledge to make it happen, but am ready to give it a try!

Alternatively, if anyone knows of other, ways to make nice looking color meter-type displays, I’m all ears!

thx


#2

You probably won’t need the Adafruit_GFX_AS as that should do pretty much the same as the _RK version, and for the ILI9341 library you should also got with Adafruit_ILI9341_RK

Before going into the details of the graphics you should first try some of the examples that come with the Adafruit_ILI9341_RK library to see whether your display actually works with your setup.


#3

Thanks, that’s good news. I’ve already been using the setup with _RK versions of the library, and the examples worked well.

I’ve been working on this this morning, and have had some good success, only seems to be one problem remaining… if I comment out the lines 179-189, it compiles fine and draws the meter graphic correctly, but I don’t know what to do to get the text value to display, looks like a function is missing from the _RK library that would allow the value to print:

tft.drawCentreString(buf, x - 5, y - 20, 6)

I tried to paste in the code from the _AS library for this function and renaming it _RK, but as the errors multiply I get lost!

The project without commenting out the problem lines:

https://go.particle.io/shared_apps/5c61c05512cdf50020e22c68

The missing function in question:

int Adafruit_GFX_AS::drawCentreString(char *string, int dX, int poY, int size)
{
    int sumX = 0;
    int len = 0;
    char *pointer = string;
    char ascii;

    while(*pointer)
    {
        ascii = *pointer;

#ifdef LOAD_GLCD
        if (size==1)len += 6;
#endif
#ifdef LOAD_FONT2
        if (size==2)len += 1+pgm_read_byte(widtbl_f16+ascii-32);
#endif
        //if (size==3)len += 1+pgm_read_byte(widtbl_f48+ascii-32)/2;
#ifdef LOAD_FONT4
        if (size==4)len += pgm_read_byte(widtbl_f32+ascii-32)-3;
#endif
        //if (size==5) len += pgm_read_byte(widtbl_f48+ascii-32)-3;
#ifdef LOAD_FONT6
        if (size==6) len += pgm_read_byte(widtbl_f64+ascii-32)-3;
#endif
#ifdef LOAD_FONT7
        if (size==7) len += pgm_read_byte(widtbl_f7s+ascii-32)+2;
#endif
#ifdef LOAD_FONT8
        if (size==8) len += pgm_read_byte(widtbl_f72+ascii-32)+2;
#endif

        *pointer++;
    }
    len = len*textsize;
    int poX = dX - len/2;

    if (poX < 0) poX = 0;

    while(*string)
    {
      int xPlus = drawChar(*string, poX, poY, size);
      sumX += xPlus;
      *string++;
      poX += xPlus;                  /* Move cursor right            */
    }
    
    return sumX;
}

It feels like I’m close, but I’m also lost!


#4

As I understand that function it’s just a convenience thing that allows you to print a text by providing the center point of your text to print. It then calculates the width of the text and offsets the origin by half the width to the left and then uses the normal drawChar() function.
You can do the same thing in your code without ever touching the library itself.

For that Adafruit_GFX_RK features a getTextBounds() function that might help getting the required offset for your given text and then use that with setCursor() and print().