Skip to content

Re: TFT_Meter - How to draw two Needles on the same tft object? #1765

Answered by Bodmer
mprowe asked this question in Q&A - General
Discussion options

You must be logged in to vote

The myMeter example does not look like it plots two meters, but here are a few comments:

  1. An address is being sent to the constructor so it has to accept a pointer to the TFT_eSPI functions:
    In Needle.h:
Needle(TFT_eSPI* tft);

In Needle.cpp:

Needle::Needle(TFT_eSPI* tft)
  1. A class variable will be needed to hold the pointer:
TFT_eSPI* ntft;
  1. The processor may crash if you try to use Serial.print in the constructor, because the Serial class has not been loaded yet when the Needle instances are created.
  2. To call the TFT_eSPI library functions from the class you would need to use the funmction pointer with "->" instead of "." thus:
ntft->fillScreen(TFT_RED);

If you work on the sketch so…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Bodmer
Comment options

@mprowe
Comment options

@Bodmer
Comment options

Answer selected by mprowe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants