Voltage meter but display graphic instead of numbers

Hello everyone,

first off I will start that I am by no means an expert at coding and just love to research this and do it on my free time. I have tried to work on this project for almost 2 weeks now and cannot successfully make it work. ok I am trying to make basically a battery gauge for example on a 12v or 24v system:

if battery is 90-100% - display graphic 1
if battery is 80-89% - display graphic 2
if battery is 70-79% - display graphic 3
if battery is 60-69% - display graphic 4
.... etc
if battery is 1-10% - flash graphic 10

i hope this makes since. I cannot get sumotoy examples to work on my setup either. also I am using:

arduino Mega
adafruit RA8875
adafruit 40 pin 5" tft LCD (no touch)

any help is much a appreciated I just want to get on the right track and make this work for my droids. thank you all ahead of time

So, where is your code?

And what have you tries?

Can you display graphics (images) a all?

And can you determine the battery percentage?

I cannot even display graphics (or drawbitmap) I order the ethernet shield with sd to display from there (which i haven't tried) I can use the example code on the Adafruit_RA8875 but i can't use sumotoy RA8875 libraries for some reason?

okay*

  • Answer as accurate of you describing the problem…

im sorry i don't understand your response

We don't understand your problem.

Start by posting your code. While you're at it, post a schematic (NO Fritzing breadboard mess please!). Tell us what you want to do. Tell us what you tried. Tell us why you think it failed. etc

ok im sorry if i wasn’t clear:

my setup is arduino Mega
adafruit RA8875
adafruit 40 pin 5" tft LCD (no touch)

I am running through SPI (like adafruit recommends)
connections are as follows

because I’m running a mega i am using:

digital pins
10 - CS
9 - RST
52 - SCK
50 - MOSI
51 - MISO
3 - INT

This setup works fine and displays with adafruit_RA8875 library code:

#include <SPI.h>
#include "Adafruit_GFX.h"
#include "Adafruit_RA8875.h"


// Library only supports hardware SPI at this time
// Connect SCLK to UNO Digital #13 (Hardware SPI clock)
// Connect MISO to UNO Digital #12 (Hardware SPI MISO)
// Connect MOSI to UNO Digital #11 (Hardware SPI MOSI)
#define RA8875_INT 3
#define RA8875_CS 10
#define RA8875_RESET 9

Adafruit_RA8875 tft = Adafruit_RA8875(RA8875_CS, RA8875_RESET);
uint16_t tx, ty;

void setup() 
{
  Serial.begin(9600);
  Serial.println("RA8875 start");

  /* Initialise the display using 'RA8875_480x272' or 'RA8875_800x480' */
  if (!tft.begin(RA8875_480x272)) {
    Serial.println("RA8875 Not Found!");
    while (1);
  }

  Serial.println("Found RA8875");

  tft.displayOn(true);
  tft.GPIOX(true);      // Enable TFT - display enable tied to GPIOX
  tft.PWM1config(true, RA8875_PWM_CLK_DIV1024); // PWM output for backlight
  tft.PWM1out(255);

  // With hardware accelleration this is instant
  tft.fillScreen(RA8875_WHITE);

  // Play with PWM
  for (uint8_t i=255; i!=0; i-=5 ) 
  {
    tft.PWM1out(i); 
    delay(10);
  }  
  for (uint8_t i=0; i!=255; i+=5 ) 
  {
    tft.PWM1out(i); 
    delay(10);
  }
  tft.PWM1out(255); 
  
  tft.fillScreen(RA8875_RED);
  delay(500);
  tft.fillScreen(RA8875_YELLOW);
  delay(500);
  tft.fillScreen(RA8875_GREEN);
  delay(500);
  tft.fillScreen(RA8875_CYAN);
  delay(500);
  tft.fillScreen(RA8875_MAGENTA);
  delay(500);
  tft.fillScreen(RA8875_BLACK);
  
  // Try some GFX acceleration!
  tft.drawCircle(100, 100, 50, RA8875_BLACK);
  tft.fillCircle(100, 100, 49, RA8875_GREEN);
  
  tft.fillRect(11, 11, 398, 198, RA8875_BLUE);
  tft.drawRect(10, 10, 400, 200, RA8875_GREEN);
  tft.fillRoundRect(200, 10, 200, 100, 10, RA8875_RED);
  tft.drawPixel(10,10,RA8875_BLACK);
  tft.drawPixel(11,11,RA8875_BLACK);
  tft.drawLine(10, 10, 200, 100, RA8875_RED);
  tft.drawTriangle(200, 15, 250, 100, 150, 125, RA8875_BLACK);
  tft.fillTriangle(200, 16, 249, 99, 151, 124, RA8875_YELLOW);
  tft.drawEllipse(300, 100, 100, 40, RA8875_BLACK);
  tft.fillEllipse(300, 100, 98, 38, RA8875_GREEN);
  // Argument 5 (curvePart) is a 2-bit value to control each corner (select 0, 1, 2, or 3)
  tft.drawCurve(50, 100, 80, 40, 2, RA8875_BLACK);  
  tft.fillCurve(50, 100, 78, 38, 2, RA8875_WHITE);
  
  pinMode(RA8875_INT, INPUT);
  digitalWrite(RA8875_INT, HIGH);
  
  tft.touchEnable(true);
    
  Serial.print("Status: "); Serial.println(tft.readStatus(), HEX);
  Serial.println("Waiting for touch events ...");
}

void loop() 
{
  float xScale = 1024.0F/tft.width();
  float yScale = 1024.0F/tft.height();

  /* Wait around for touch events */
  if (! digitalRead(RA8875_INT)) 
  {
    if (tft.touched()) 
    {
      Serial.print("Touch: "); 
      tft.touchRead(&tx, &ty);
      Serial.print(tx); Serial.print(", "); Serial.println(ty);
      /* Draw a circle */
      tft.fillCircle((uint16_t)(tx/xScale), (uint16_t)(ty/yScale), 4, RA8875_WHITE);
    } 
  }
}

but with sumotoy’s RA8875 library it is not working with any configuration. I have tried to change pins, i read through al of his notes, and can’t figure it out. here is an example code im trying to get work, just a basic setup and can’t get this to work. I am just getting a white screen wit sumo toy’s library.

/*
Explain the minimal setup and how to use instances...
*/


#include <SPI.h>
#include <RA8875.h>

/*
Arduino's
You are using 4 wire SPI here, so:
 MOSI:  11//Arduino UNO
 MISO:  12//Arduino UNO
 SCK:   13//Arduino UNO
 the rest of pin below:
 */

#define RA8875_CS 10 //Uno and 8 bit AVR can use any pin
#define RA8875_RESET 9//any pin, if you wnat to disable just set at 255 or not use at all


RA8875 tft = RA8875(RA8875_CS,RA8875_RESET);//arduino's
//RA8875 tft = RA8875(RA8875_CS);//arduino's no rst


void setup() 
{
  Serial.begin(38400);
  //long unsigned debug_start = millis ();
  //while (!Serial && ((millis () - debug_start) <= 5000)) ;
  Serial.println("RA8875 start");
/*
    If you have an Adafruit RA8875 board + display choose:
Adafruit_480x272 , Adafruit_800x480
    If you have any other display you have to choose:
RA8875_480x272 , RA8875_800x480
*/
  tft.begin(RA8875_800x480);
/*
By default the library init display at 16bit color depth but
you can optionally force the display to work at 8 bit:
tft.begin(RA8875_480x272,8);//force 8bit color depth
*/

//Now that board it's inited you can use any draw or text command:
tft.print("Hello World!");//did you see it?
}

void loop() 
{

}

Getting the graphics to display with the screen is step one to me. then I will have to (which i think is way easier) assign a pin to read voltage (12v) and get the minimum working voltage (i believe its 9v still have to test) and divide the numbers in-between by 10 to get the arduino to just read the serial monitor and use those numbers to display a graphic. I hope this is more clear.

Why do you tell the Adafruit you have a 480x272

  /* Initialise the display using 'RA8875_480x272' or 'RA8875_800x480' */
  if (!tft.begin(RA8875_480x272)) {

And don’t you follow the instructions of Sumo Toy and you tell it you have a 800x480?

/*
    If you have an Adafruit RA8875 board + display choose:
Adafruit_480x272 , Adafruit_800x480
    If you have any other display you have to choose:
RA8875_480x272 , RA8875_800x480
*/
  tft.begin(RA8875_800x480);
/*

And why do you want to use the Sumo Toy library that bad?

I found out what i did wrong and it was as simple as changing RA8875_800X480 to Adafruit_800x480. I found it right after posting but didn't want to stop working. so Now i have coded everything except one portion which I am figuring out now. Septillion you dont have to be rude, and i want to use sumo toys library because I want to. I didn't know i had to explain myself??? I was just looking for help is all

I'm not rude :slight_smile: Not telling use you fixed it, THAT'S rude :wink:

But yeah, randomly switching library and coming here (for FREE help) because it doesn't work DOES need explanation :slight_smile: What we see here daily is people just grabbing some other library because some bird was whispering it would life easy without knowing why.