Adafruit_RA8875 ring/cicular display for values

Hi all

I am trying to get a ring meter/circular display to work for my engine management project

something similar to this example ( The posted code is not from this site)
https://cdn.instructables.com/FDE/1SSL/I7CCD8DR/FDE1SSLI7CCD8DR.LARGE.jpg

I have treid the following code but brings up an error and I cant work it out

Any ideas or example code to get me started would be much appreciated

Line 67 - expected unqualified -id before 'while'

Arduino UNO, Adafruit_RA8875, 5" TFT

#include <SPI.h>
#include "Adafruit_GFX.h"
#include "Adafruit_RA8875.h"
#define RA8875_INT 3
#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;     // time for next update

 

//#include "Temperature.h"
 
#define PI 3.1415926535897932384626433832795
#define Temp 10 
int a=1000,b=3500;
int n, f;
int j, j2 ,lj;
int i, i2 ,li;
int pct = 0;
int d[5] = {20, 20, 20, 20, 20};
uint16_t col[5] = {0x7006, 0xF986, 0x6905, 0x7FF7, 0x024D};
 
void setup() {
  //tft.reset();
  Serial.begin(9600);
 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);
  tft.setTextSize(2);
  
}
 
void loop() {
  // put your main code here, to run repeatedly:
  tft.fillScreen(0xffff);
  tft.setRotation(1);
//tft.drawBitmap(350, 70, Temp, 70, 180, 0x0000); - not an adafruitra8875 function
tft.fillCircle(385,213,25,RA8875_RED);
 
/for (int p = 0; p < 4000; p++) { j = 120 * (sin(PI * p / 2000)); i = 120 * (cos(PI * p / 2000)); j2 = 110 * (sin(PI * p / 2000)); i2 = 110 * (cos(PI * p / 2000)); tft.drawLine(i2 + 160, j2 + 160, i + 160, j + 160, RA8875_BLUE(100, 100, 100)); } ///////////////////////////////////////////////////////////////////// if (b>a){
    while (a<b) {
      j = 120 * (sin(PI * a / 2000));
      i = 120 * (cos(PI * a / 2000));
      j2 = 110 * (sin(PI * a / 2000));
      i2 = 110 * (cos(PI * a / 2000));
      tft.drawLine(i2 + 160, j2 + 160, i + 160, j + 160, RA8875_RED);
         tft.fillCircle(160,150,50,0xffff);
         tft.setTextSize(4);
        tft.setTextColor(0x0000);
    tft.setCursor(135, 145);
    tft.print(a/40); tft.print("%");delay(20);
 
      for (uint16_t c=0; c<13; c++){
     tft.drawLine(378+c, 213, 378+c, (200-a/40), RA8875_RED);}       //200=0 & 100=100
     for (uint16_t c=0; c<13; c++){
     tft.drawLine(378, 213+c, 378, (200-a/40)+c, RA8875_RED);}   
     
    a++;
    }b=0;}
 
  //////////////////////////////////////////////////////////////////
 
    while(b<a) {
      j = 120 * (sin(PI * a / 2000));
      i = 120 * (cos(PI * a / 2000));
      j2 = 110 * (sin(PI * a / 2000));
      i2 = 110 * (cos(PI * a / 2000));
      tft.drawLine(i2 + 160, j2 + 160, i + 160, j + 160, tft.color565(100, 100, 100));
               tft.fillCircle(160,150,50,0xffff);
         tft.setTextSize(4);
        tft.setTextColor(0x0000);
    tft.setCursor(135, 145);
    tft.print(a/40); tft.print("%");delay(50); 
 
          for (uint16_t c=0; c<13; c++){
     tft.drawLine(378+c, (200-a/40), 378+c, 100, tft.color565(0, 0, 0));}       //200=0 & 100=100
     for (uint16_t c=0; c<13; c++){
     tft.drawLine(378, (200-a/40)+c, 378, 100+c, tft.color565(0, 0, 0));}  
     
    a--;}
 
  ////////////////////////////////////////////////////////////////////
  while (1);
}

You have an extra closing brace (}). That is the cause of the error.

A very helpful troubleshooting tool is the Auto Format feature (Tools > Auto Format in the Arduino IDE or Ctrl + B in the Arduino Web Editor). If you do an Auto Format and then compare the resulting indentation to your intended program structure, it will quickly point you to where there is a missing or extra brace.

Another useful feature of the Arduino IDE/Arduino Web Editor is that when you place the cursor next to one bracket, it puts a box around the matching bracket. In the Arduino IDE, if the cursor is next to the closing bracket and the opening bracket is off the screen then it will show the opening bracket line in a tool tip after a short delay.

I made a few changes and it now compiles, but get nothing on the display now :confused:

#include <SPI.h>
#include "Adafruit_GFX.h"
#include "Adafruit_RA8875.h"
#define RA8875_INT 3
#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;     // time for next update



//#include "Temperature.h"

#define PI 3.1415926535897932384626433832795
#define Temp 10
int a = 1000, b = 3500;
int n, f;
int j, j2 , lj;
int i, i2 , li;
int pct = 0;
int d[5] = {20, 20, 20, 20, 20};
uint16_t col[5] = {0x7006, 0xF986, 0x6905, 0x7FF7, 0x024D};

void setup() {
//  tft.reset(); -not an RA8875 member name
  Serial.begin(9600);
  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);
  tft.setTextSize(2);

}

void loop() {
  // put your main code here, to run repeatedly:
  tft.fillScreen(RA8875_WHITE);
  tft.setRotation(1);
  //tft.drawBitmap(350, 70, Temp, 70, 180, 0x0000); - not an adafruitra8875 function
  tft.fillCircle(385, 213, 25, RA8875_RED);

  for (int p = 0; p < 4000; p++) {
    j = 120 * (sin(PI * p / 2000)); i = 120 * (cos(PI * p / 2000)); j2 = 110 * (sin(PI * p / 2000)); i2 = 110 * (cos(PI * p / 2000)); tft.drawLine(i2 + 160, j2 + 160, i + 160, j + 160, RA8875_BLUE);
  }
  if (b > a)

    while (a < b) {
      j = 120 * (sin(PI * a / 2000));
      i = 120 * (cos(PI * a / 2000));
      j2 = 110 * (sin(PI * a / 2000));
      i2 = 110 * (cos(PI * a / 2000));
      tft.drawLine(i2 + 160, j2 + 160, i + 160, j + 160, RA8875_RED);
      tft.fillCircle(160, 150, 50, 0xffff);
      tft.setTextSize(4);
      tft.setTextColor(0x0000);
      tft.setCursor(135, 145);
      tft.print(a / 40); tft.print("%"); delay(20);

      for (uint16_t c = 0; c < 13; c++) {
        tft.drawLine(378 + c, 213, 378 + c, (200 - a / 40), RA8875_RED);
      }       //200=0 & 100=100
      for (uint16_t c = 0; c < 13; c++) {
        tft.drawLine(378, 213 + c, 378, (200 - a / 40) + c, RA8875_RED);
      }

      a++;
    } b = 0;
  //}

  //////////////////////////////////////////////////////////////////

  while (b < a) {
    j = 120 * (sin(PI * a / 2000));
    i = 120 * (cos(PI * a / 2000));
    j2 = 110 * (sin(PI * a / 2000));
    i2 = 110 * (cos(PI * a / 2000));
    tft.drawLine(i2 + 160, j2 + 160, i + 160, j + 160, RA8875_RED);
    tft.fillCircle(160, 150, 50, 0xffff);
    tft.setTextSize(4);
    tft.setTextColor(0x0000);
    tft.setCursor(135, 145);
    tft.print(a / 40); tft.print("%"); delay(50);

    for (uint16_t c = 0; c < 13; c++) {
      tft.drawLine(378 + c, (200 - a / 40), 378 + c, 100, RA8875_RED);
    }       //200=0 & 100=100
    for (uint16_t c = 0; c < 13; c++) {
      tft.drawLine(378, (200 - a / 40) + c, 378, 100 + c, RA8875_RED);
    }

    a--;
  }

  
  while (1);
}

made a change, uncommented Line 40 - tft.drawBitmap(350, 70, Temp, 70, 180, RA8875_GREEN);// - not an adafruitra8875 function

Error

ring_meter:40:54: error: no matching function for call to 'drawBitmap(int, int, int, int, int, int)'
tft.drawBitmap(350, 70, Temp, 70, 180, RA8875_GREEN);

Arduino/libraries/Adafruit_RA8875master/Adafruit_GFX.h:68:5: note: candidate: void Adafruit_GFX::drawBitmap(int16_t, int16_t, const uint8_t*, int16_t, int16_t, uint16_t)
drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[],

Arduino/ring_meter/ring_meter.ino:40:54: warning: invalid conversion from 'int' to 'const uint8_t* {aka const unsigned char*}' [-fpermissive]
tft.drawBitmap(350, 70, Temp, 70, 180, RA8875_GREEN);

Arduino/libraries/Adafruit_RA8875master/Adafruit_GFX.h:72:5: note: candidate: void Adafruit_GFX::drawBitmap(int16_t, int16_t, uint8_t*, int16_t, int16_t, uint16_t)
drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,

Arduino/libraries/Adafruit_RA8875master/Adafruit_GFX.h:72:5: note: conversion of argument 3 would be ill-formed:
/home/russ/Arduino/ring_meter/ring_meter.ino:40:54: warning: invalid conversion from 'int' to 'uint8_t* {aka unsigned char*}' [-fpermissive]
tft.drawBitmap(350, 70, Temp, 70, 180, RA8875_GREEN);

exit status 1
no matching function for call to 'drawBitmap(int, int, int, int, int, int)'

#include <SPI.h>
#include "Adafruit_GFX.h"
#include "Adafruit_RA8875.h"
#define RA8875_INT 3
#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;     // time for next update



//#include "Temperature.h"

#define PI 3.1415926535897932384626433832795
#define Temp 10
int a = 1000, b = 3500;
int n, f;
int j, j2 , lj;
int i, i2 , li;
int pct = 0;
int d[5] = {20, 20, 20, 20, 20};
uint16_t col[5] = {0x7006, 0xF986, 0x6905, 0x7FF7, 0x024D};

void setup() {
  //  tft.reset(); -not an RA8875 member name
  Serial.begin(9600);
  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);
  tft.setTextSize(2);

}

void loop() {
  // put your main code here, to run repeatedly:
  tft.fillScreen(RA8875_WHITE);
  tft.setRotation(1);
  tft.drawBitmap(350, 70, Temp, 70, 180, RA8875_GREEN);// - not an adafruitra8875 function
  tft.fillCircle(385, 213, 25, RA8875_RED);

  for (int p = 0; p < 4000; p++) {
    j = 120 * (sin(PI * p / 2000)); i = 120 * (cos(PI * p / 2000)); j2 = 110 * (sin(PI * p / 2000)); i2 = 110 * (cos(PI * p / 2000)); tft.drawLine(i2 + 160, j2 + 160, i + 160, j + 160, RA8875_BLUE);
  }
  if (b > a)

    while (a < b) {
      j = 120 * (sin(PI * a / 2000));
      i = 120 * (cos(PI * a / 2000));
      j2 = 110 * (sin(PI * a / 2000));
      i2 = 110 * (cos(PI * a / 2000));
      tft.drawLine(i2 + 160, j2 + 160, i + 160, j + 160, RA8875_RED);
      tft.fillCircle(160, 150, 50, 0xffff);
      tft.setTextSize(4);
      tft.setTextColor(0x0000);
      tft.setCursor(135, 145);
      tft.print(a / 40); tft.print("%"); delay(20);

      for (uint16_t c = 0; c < 13; c++) {
        tft.drawLine(378 + c, 213, 378 + c, (200 - a / 40), RA8875_RED);
      }       //200=0 & 100=100
      for (uint16_t c = 0; c < 13; c++) {
        tft.drawLine(378, 213 + c, 378, (200 - a / 40) + c, RA8875_RED);
      }

      a++;
    } b = 0;
  //}

  //////////////////////////////////////////////////////////////////

  while (b < a) {
    j = 120 * (sin(PI * a / 2000));
    i = 120 * (cos(PI * a / 2000));
    j2 = 110 * (sin(PI * a / 2000));
    i2 = 110 * (cos(PI * a / 2000));
    tft.drawLine(i2 + 160, j2 + 160, i + 160, j + 160, RA8875_RED);
    tft.fillCircle(160, 150, 50, 0xffff);
    tft.setTextSize(4);
    tft.setTextColor(0x0000);
    tft.setCursor(135, 145);
    tft.print(a / 40); tft.print("%"); delay(50);

    for (uint16_t c = 0; c < 13; c++) {
      tft.drawLine(378 + c, (200 - a / 40), 378 + c, 100, RA8875_RED);
    }       //200=0 & 100=100
    for (uint16_t c = 0; c < 13; c++) {
      tft.drawLine(378, (200 - a / 40) + c, 378, 100 + c, RA8875_RED);
    }

    a--;
  }

 
  while (1);
}