a function-definition is not allowed here before '{' token {

Hi there newish to arduino about a month now.
I'm trying to build an heating thermostat so far so good until i started to merge guage code into my project.

Im getting:-

NEW-Touch-Smart-Thermostat-Landscape-Gauge.ino: In function 'void loop()':
NEW-Touch-Smart-Thermostat-Landscape-Gauge:374:3: error: a function-definition is not allowed here before '{' token
{
^
NEW-Touch-Smart-Thermostat-Landscape-Gauge:473:3: error: a function-definition is not allowed here before '{' token
{
^

Below is a copy of my sketch

 // #########################################################################
  //  Draw the meter on the screen, returns x coord of righthand side
  // #########################################################################
  int ringMeter(int value, int vmin, int vmax, int x, int y, int r, char *units, byte scheme, int old)
  {
    // .kbv optional old argument only redraws the changed area.  10x speed increase
    // .kbv colours are always drawn in numbered segments. map value to the segment number
    // Minimum value of r is about 52 before value text intrudes on ring
    // drawing the text first is an option

    x += r; y += r;   // Calculate coords of centre of ring

    int w = r / 4;    // Width of outer ring is 1/4 of radius

    int segnum = 160 / 5;  // Half the sweep angle of meter (300 degrees)

    int text_colour = 0; // To hold the text colour

    int v = map(value, vmin, vmax, -segnum, segnum); // Map the value to an segnum v

    byte segdegree = 5; // Segments are 5 degrees wide = 60 segments for 300 degrees
    byte inc = 2; // Draw segments every 5 degrees, increase to 10 for segmented ring

    int lo, hi;
    if (old == -9999) lo = -segnum, hi = segnum;
    else {
      old = map(old, vmin, vmax, -segnum, segnum);
      lo = (old < v) ? old : v;
      hi = (old > v) ? old : v;
    }
    // Draw colour blocks every inc degrees
    for (int i = lo; i < hi; i += inc) {

      // Choose colour from scheme
      int colour = 0;
      switch (scheme) {
        case 0: colour = ILI9341_RED; break; // Fixed colour
        case 1: colour = ILI9341_GREEN; break; // Fixed colour
        case 2: colour = ILI9341_BLUE; break; // Fixed colour
        case 3: colour = rainbow(map(i, -segnum, segnum, 0, 127)); break; // Full spectrum blue to red
        case 4: colour = rainbow(map(i, -segnum, segnum, 63, 127)); break; // Green to red (high temperature etc)
        case 5: colour = rainbow(map(i, -segnum, segnum, 127, 63)); break; // Red to green (low battery etc)
        default: colour = ILI9341_BLUE; break; // Fixed colour
      }

      // Calculate pair of coordinates for segment start
      float segradian = (i * segdegree - 90) * 0.0174532925;
      float sx = cos(segradian);
      float sy = sin(segradian);
      uint16_t x0 = sx * (r - w) + x;
      uint16_t y0 = sy * (r - w) + y;
      uint16_t x1 = sx * r + x;
      uint16_t y1 = sy * r + y;

      // Calculate pair of coordinates for segment end
      segradian += segdegree * 0.0174532925;
      float sx2 = cos(segradian);
      float sy2 = sin(segradian);
      int x2 = sx2 * (r - w) + x;
      int y2 = sy2 * (r - w) + y;
      int x3 = sx2 * r + x;
      int y3 = sy2 * r + y;

      if (i >= v) colour = ILI9341_GREY;    //blank colour
      else text_colour = colour;            // Save the last colour drawn
      // Fill in segments with 2 triangles
      tft.fillTriangle(x0, y0, x1, y1, x2, y2, colour);
      tft.fillTriangle(x1, y1, x2, y2, x3, y3, colour);
    }

    // Convert value to a string
    char buf[10];
    byte len = 4; if (value > 999) len = 5;
#if defined(ARDUINO_ARCH_STM32)
    dtostrf(value, len + 2, 0, buf);
    char *p = strchr(buf, '.');
    if (p != NULL) *p = '\0';
#else
    dtostrf(value, len, 0, buf);
#endif
    // Set the text colour to default
    tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
    // Uncomment next line to set the text colour to the last segment value!
    // tft.setTextColor(text_colour, ILI9341_BLACK);

    // .kbv use helper function instead of GFX_AS method
    // Print value, if the meter is large then use big font 6, othewise use 4
    if (r > 84) drawCentreString(buf, x - 5, y - 20, 6); // Value in middle
    else drawCentreString(buf, x - 5, y - 20, 4); // Value in middle

    // Print units, if the meter is large then use big font 4, othewise use 2
    tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
    if (r > 84) drawCentreString(units, x, y + 30, 4); // Units display
    else drawCentreString(units, x, y + 5, 2); // Units display

    // Calculate and return right hand side x coordinate
    return x + r;
  }

  // #########################################################################
  // Return a 16 bit rainbow colour
  // #########################################################################
  unsigned int rainbow(byte value)
  {
    // Value is expected to be in range 0-127
    // The value is converted to a spectrum colour from 0 = blue through to 127 = red

    byte red = 0; // Red is the top 5 bits of a 16 bit colour value
    byte green = 0;// Green is the middle 6 bits
    byte blue = 0; // Blue is the bottom 5 bits

    byte quadrant = value / 32;

    if (quadrant == 0) {
      blue = 31;
      green = 2 * (value % 32);
      red = 0;
    }
    if (quadrant == 1) {
      blue = 31 - (value % 32);
      green = 63;
      red = 0;
    }
    if (quadrant == 2) {
      blue = 0;
      green = 63;
      red = value % 32;
    }
    if (quadrant == 3) {
      blue = 0;
      green = 63 - 2 * (value % 32);
      red = 31;
    }
    return (red << 11) + (green << 5) + blue;
  }

}

I have been through the code to make sure { has } to close front to back, back to front a 100 times and can not see the error.

Thanks in advance
Shaun

The code that you posted is incomplete

No that is not a complete sketch. The problem is stated to be in function void loop(). The code you posted does not contain a function void loop().

Steve

also the first part of the loop

void loop(void) {

  {
    if (temperaturedht > 15.00)
      digitalWrite(RELAY_1, HIGH);
    //  Serial.println( "Heating_Relay_ON" );
    //  Serial3.println( "Heating_Relay_ON" );
    //    tft.fillCircle(149, 19, 8, GREY);
    //    tft.fillCircle(149, 19, 8, GGREEN);
  }
  {
    if (temperaturedht < 15.00)
      digitalWrite(RELAY_1, LOW);
    // Serial.println( "Heating_Relay_OFF" );
    // Serial3.println( "Heating_Relay_OFF" );
    //  tft.fillCircle(149, 19, 8, GREY);
    //tft.fillCircle(149, 19, 8, RRED);
  }


  {
    bool down = Touch_getXY();
    heating_on_btn.press(down && heating_on_btn.contains(pixel_x, pixel_y));
    heating_off_btn.press(down && heating_off_btn.contains(pixel_x, pixel_y));
    desired_temp_up_btn.press(down && desired_temp_up_btn.contains(pixel_x, pixel_y));
    desired_temp_down_btn.press(down && desired_temp_down_btn.contains(pixel_x, pixel_y));
    desired_temp_set_btn.press(down && desired_temp_set_btn.contains(pixel_x, pixel_y));
    menu_btn.press(down && menu_btn.contains(pixel_x, pixel_y));
    if (heating_on_btn.justReleased())
      heating_on_btn.drawButton();
    if (heating_off_btn.justReleased())
      heating_off_btn.drawButton();
    if (desired_temp_up_btn.justReleased())
      desired_temp_up_btn.drawButton();
    if (desired_temp_set_btn.justReleased())
      desired_temp_set_btn.drawButton();
    if (desired_temp_down_btn.justReleased())
      desired_temp_down_btn.drawButton();
    if (menu_btn.justReleased())
      menu_btn.drawButton();
    if (heating_on_btn.justPressed()) {
      heating_on_btn.drawButton(true);
      tft.fillCircle(189, 19, 8, GGREEN);
    }
    if (heating_off_btn.justPressed()) {
      heating_off_btn.drawButton(true);
      tft.fillCircle(189, 19, 8,  RRED);
    }
    if (desired_temp_up_btn.justPressed()) {
      desired_temp_up_btn.drawButton(true);
      tft.fillCircle(63, 220, 6, RRED);
    }
    if (desired_temp_down_btn.justPressed()) {
      desired_temp_down_btn.drawButton(true);
      tft.fillCircle(63, 220, 6,  BBLUE);
    }
    if (desired_temp_set_btn.justPressed()) {
      desired_temp_set_btn.drawButton(true);
      tft.fillCircle(63, 220, 6,  GGREEN);
    }
    if (menu_btn.justPressed()) {
      menu_btn.drawButton(true);
      tft.fillCircle(240, 220, 5,  GREY);      // Change to load menu
    }
  }
  /* Measure temperature and humidity.  If the functions returns
     true, then a measurement is available. */
  {
    if ( measure_environment( &temperaturedht, &humiditydht ) == true )

      if (bmp280.getMeasurements(temperaturebmp, pressurebmp, altitudebmp))    // Check if the measurement is complete
      {
        Serial.print( "Indoor_Temp = " );
        Serial.print( temperaturedht, 1 );
        Serial.print( " *C, Indoor_Humidity = " );
        Serial.print( humiditydht, 1 );
        Serial.println( "%" );
        Serial.print( "Outdoor_Temp = " );
        Serial.print(temperaturebmp);                    // Display the results
        Serial.print(F(" *C   "));
        Serial.print( "Outdoor_Pressure = " );
        Serial.print(pressurebmp);
        Serial.print(F(" hPa   "));
        Serial.print( "Outdoor_Altitude = " );
        Serial.print(altitudebmp);
        Serial.println(F(" m"));

        Serial3.print( "Indoor_Temp = " );
        Serial3.print( temperaturedht, 1 );
        Serial3.print( " *C, Indoor Humidity = " );
        Serial3.print( humiditydht, 1 );
        Serial3.println( "%" );
        Serial3.print( "Outdoor_Temp = " );
        Serial3.print(temperaturebmp);                    // Display the results    Serial 3
        Serial3.print(F(" *C   "));
        Serial3.print( "Outdoor_Pressure = " );
        Serial3.print(pressurebmp);
        Serial3.print(F(" hPa   "));
        Serial3.print( "Outdoor_Altitude = " );
        Serial3.print(altitudebmp);
        Serial3.println(F(" m"));

        tft.fillRect(12, 148, 65, 19, GREY);
        tft.fillRect(116, 148, 65, 19, GREY);
        tft.setTextColor(BBLUE);
        tft.setCursor(18, 150);
        tft.println(temperaturebmp);
        tft.setCursor(120, 150);
        tft.println(temperaturedht);
      }
  }



  {
    if (millis() - runTime >= 2000L) { // Execute every 2s
      runTime = millis();


      int xpos, ypos, gap, radius;


      // Draw a large meter
      xpos = 20, ypos = 120, gap = 10, radius = 40;
      reading = 18;
      ringMeter(reading, -10, 30, xpos, ypos, radius, " *C", BLUE2RED); // Draw analogue meter

      // Draw a large meter
      xpos = 115, ypos = 120, gap = 10, radius = 40;
      reading = 28;
      ringMeter(reading, -10, 30, xpos, ypos, radius, " *C", BLUE2RED); // Draw analogue meter

      // Draw a large meter
      xpos = 220, ypos = 120, gap = 10, radius = 40;
      reading = 25;
      ringMeter(reading, -10, 30, xpos, ypos, radius, " *C", BLUE2RED); // Draw analogue meter
    }
  }

Thanks in advance
Shaun

I am not looking until I can see the whole sketch

Sorry it restricts to 9000 characters for new users and 5 mins between posts.

I will have to follow with the rest of the sketch 5 mins apart 9000 characters a time :sob:

Thanks
Shaun

void loop(void) {

  {
    if (temperaturedht > 15.00)
      digitalWrite(RELAY_1, HIGH);
    //  Serial.println( "Heating_Relay_ON" );
    //  Serial3.println( "Heating_Relay_ON" );
    //    tft.fillCircle(149, 19, 8, GREY);
    //    tft.fillCircle(149, 19, 8, GGREEN);
  }

Why is that if inside its own compound statement?

I will have to follow with the rest of the sketch 5 mins apart 9000 characters a time

Or you could just attach it to a post

I assume that you did not read the stickies at the top of the page which give advice on how to post a programming question

UKHeliBob:
Or you could just attach it to a post

I assume that you did not read the stickies at the top of the page which give advice on how to post a programming question

I did hence the code is in code tags as requested
I've been reading on here a while now and one thing I senced is members going out there way not to help with whats being asked? I dont sence the community spirt of a forum more try cause shit.

TheMemberFormerlyKnownAsAWOL:

void loop(void) {

{
   if (temperaturedht > 15.00)
     digitalWrite(RELAY_1, HIGH);
   //  Serial.println( "Heating_Relay_ON" );
   //  Serial3.println( "Heating_Relay_ON" );
   //    tft.fillCircle(149, 19, 8, GREY);
   //    tft.fillCircle(149, 19, 8, GGREEN);
 }



Why is that if inside its own compound statement?

Appologies buddy I have no idea thats why i made point of saying im new to arduino

Below is setup

#include <Adafruit_GFX.h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
#include <TouchScreen.h>
#include <dht_nonblocking.h>
#include <RelayModule.h>

#define RELAY_1   24

RelayModule* relay1 = NULL;

/* Uncomment according to your sensortype. */
#define DHT_SENSOR_TYPE DHT_TYPE_11
//#define DHT_SENSOR_TYPE DHT_TYPE_21
//#define DHT_SENSOR_TYPE DHT_TYPE_22

static const int DHT_SENSOR_PIN = 22;
DHT_nonblocking dht_sensor( DHT_SENSOR_PIN, DHT_SENSOR_TYPE );

#include <BMP280_DEV.h>                           // Include the BMP280_DEV.h library

float temperaturebmp, pressurebmp, altitudebmp, temperaturedht, humiditydht;            // Create the temperature, pressure and altitude variables
BMP280_DEV bmp280;                                // Instantiate (create) a BMP280_DEV object and set-up for I2C operation

#define MINPRESSURE 100
#define MAXPRESSURE 1000

// ALL Touch panels and wiring is DIFFERENT
// copy-paste results from TouchScreen_Calibr_native.ino
const int XP = 8, XM = A2, YP = A3, YM = 9; //ID=0x9341
//const int TS_LEFT = 943, TS_RT = 99, TS_TOP = 81, TS_BOT = 895;   //Portrate
const int TS_LEFT = 81, TS_RT = 895, TS_TOP = 99, TS_BOT = 943;   //Landscape

TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

Adafruit_GFX_Button desired_temp_up_btn, desired_temp_down_btn, desired_temp_set_btn, heating_on_btn, heating_off_btn, menu_btn;

int pixel_x, pixel_y;     //Touch_getXY() updates global vars
bool Touch_getXY(void)
{
  TSPoint p = ts.getPoint();
  pinMode(YP, OUTPUT);      //restore shared pins
  pinMode(XM, OUTPUT);
  digitalWrite(YP, HIGH);   //because TFT control pins
  digitalWrite(XM, HIGH);
  bool pressed = (p.z > MINPRESSURE && p.z < MAXPRESSURE);
  if (pressed) {
    pixel_x = map(p.y, TS_LEFT, TS_RT, 0, tft.width()); //.kbv makes sense to me
    pixel_y = map(p.x, TS_TOP, TS_BOT, 0, tft.height());
  }
  return pressed;
}

#define BLACK   0x0000
#define BBLUE    0x001F
#define RRED     0xF800
#define GGREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF
#define ORANGE  0xFDC0
#define GREY    0x8C51
#define GREY_L  0xCE79
#define GREY_D  0x5AEB

// Meter colour schemes
#define RED2RED 0
#define GREEN2GREEN 1
#define BLUE2BLUE 2
#define BLUE2RED 3
#define GREEN2RED 4
#define RED2GREEN 5
#define ILI9341_BLACK 0x0000 //
#define ILI9341_WHITE 0xFFFF //
#define ILI9341_RED 0xF800 //
#define ILI9341_GREEN 0x07E0 //
#define ILI9341_BLUE 0x001F //
#define ILI9341_GREY 0x2104 // Dark grey 16 bit colour

// some typical Free Fonts
#include "Fonts/FreeSansBold9pt7b.h"
#include "Fonts/FreeSansBold12pt7b.h"
#include "Fonts/FreeSansBold18pt7b.h"
#include "Fonts/FreeSansBold24pt7b.h"

// .kbv put font addresses in an array.   NULL giives 7x5 system font
const GFXfont *fonts[] = {NULL, NULL, &FreeSansBold9pt7b, NULL, &FreeSansBold12pt7b, NULL, &FreeSansBold18pt7b, NULL, /*&FreeSans24pt7b, NULL, */};

uint32_t runTime = -99999;       // time for next update

int reading = 0; // Value to be displayed
int d = 0; // Variable used for the sinewave test waveform

// .kbv write a helper function to replace GFX_AS method
void drawCentreString(char *buf, int x, int y, int sz)
{
  const GFXfont *f = fonts[sz];
  tft.setFont(f);
  //   y += f->yAdvance;    //you need the letter height not the line advance
  y += 12;               //this is a guess value
  int16_t x1, y1;
  uint16_t w, h;
  tft.getTextBounds(buf, x, y, &x1, &y1, &w, &h); //calc width of new string
  tft.fillRect(x1 - w / 2, y1, w + 10, h, TFT_BLACK); //guess a bit more width
  tft.setCursor(x - w / 2, y);
  tft.print(buf);
}

void setup(void) {
  {

    bmp280.begin(BMP280_I2C_ALT_ADDR);              // Default initialisation with alternative I2C address (0x76), place the BMP280 into SLEEP_MODE
    //bmp280.setPresOversampling(OVERSAMPLING_X4);    // Set the pressure oversampling to X4
    //bmp280.setTempOversampling(OVERSAMPLING_X1);    // Set the temperature oversampling to X1
    //bmp280.setIIRFilter(IIR_FILTER_4);              // Set the IIR filter to setting 4
    bmp280.setTimeStandby(TIME_STANDBY_500MS);     // Set the standby time to 0.1 seconds
    bmp280.startNormalConversion();                 // Start BMP280 continuous conversion in NORMAL_MODE
  }
  {
    relay1 = new RelayModule(RELAY_1);
  }
  {
    Serial.begin(115200);
    Serial3.begin(115200);

    uint16_t ID = tft.readID();
    Serial.print("TFT ID = 0x");
    Serial.println(ID, HEX);
    Serial.println("Calibrate for your Touch Panel");
    if (ID == 0xD3D3) ID = 0x9486; // write-only shield
    tft.begin(ID);

    tft.setRotation(1);            //Landscape
    tft.setFont(&FreeSansBold9pt7b);
    tft.fillScreen(GREY_D);
    tft.setTextColor(BLACK);
    tft.fillRect(5, 5, 310, 30, GREY);
    tft.drawRect(5, 5, 310, 30, BLACK);
    tft.setCursor(10, 25);
    tft.println("Heating Status");
    tft.fillCircle(189, 19, 8, ORANGE);
    tft.fillCircle(149, 19, 8, GREY);
    tft.fillRect(5, 40, 310, 35, GREY);
    tft.drawRect(5, 40, 310, 35, BLACK);
    tft.setCursor(10, 63);
    tft.println("Date                    Time ");

    tft.fillRect(5, 80, 100, 90, GREY);
    tft.drawRect(5, 80, 100, 90, BLACK);
    tft.fillRect(110, 80, 100, 90, GREY);
    tft.drawRect(110, 80, 100, 90, BLACK);
    tft.fillRect(215, 80, 100, 90, GREY);
    tft.drawRect(215, 80, 100, 90, BLACK);

    tft.setCursor(18, 98);
    tft.println("Outdoor");
    tft.setCursor(127, 98);
    tft.println("Kitchen");
    tft.setCursor(216, 98);
    tft.println("Livingroom");

    tft.setTextColor(BBLUE);
    tft.setCursor(75, 163);
    tft.println(" *C");
    tft.setCursor(179, 163);
    tft.println(" *C");
    tft.setCursor(283, 163);
    tft.println(" *C");



    tft.fillRect(5, 175, 225, 60, GREY);
    tft.drawRect(5, 175, 225, 60, BLACK);
    tft.setTextColor(BLACK);
    tft.setCursor(48, 192);
    tft.println("Desired Temp");
    tft.setCursor(10, 225);
    tft.setTextSize(2);
    tft.setTextColor(BBLUE);
    tft.println("23 ");
    tft.setCursor(44, 210);
    tft.setTextColor(BBLUE);
    tft.setTextSize(1);
    tft.println(" *C");

    tft.setFont();
    heating_on_btn.initButton(&tft,  230, 20, 50, 22, BLACK, GREY_L, BLACK, "ON", 2);
    heating_off_btn.initButton(&tft, 285, 20, 50, 22, BLACK, GREY_L, BLACK, "OFF", 2);
    desired_temp_up_btn.initButton(&tft,  100, 215, 45, 30, BLACK, GREY_L, BLACK, "+", 2);
    desired_temp_down_btn.initButton(&tft, 150, 215, 45, 30, BLACK, GREY_L, BLACK, "-", 2);
    desired_temp_set_btn.initButton(&tft, 200, 215, 45, 30, BLACK, GREY_L, BLACK, "SET", 2);
    menu_btn.initButton(&tft, 275, 205, 60, 50, BLACK, GREY, BLACK, "MENU", 2);
    heating_on_btn.drawButton(false);
    heating_off_btn.drawButton(false);
    desired_temp_up_btn.drawButton(false);
    desired_temp_down_btn.drawButton(false);
    desired_temp_set_btn.drawButton(false);
    menu_btn.drawButton(false);

    tft.fillCircle(119, 255, 05, ORANGE);

  }
}
/*
   Poll for a measurement, keeping the state machine alive.  Returns
   true if a measurement is available.
*/
static bool measure_environment( float *temperaturedht, float *humiditydht )
{
  static unsigned long measurement_timestamp = millis( );

  /* Measure once every four seconds. */
  if ( millis( ) - measurement_timestamp > 1ul )
  {
    if ( dht_sensor.measure( temperaturedht, humiditydht ) == true )
    {
      measurement_timestamp = millis( );
      return ( true );
    }
  }

  return ( false );
}

extern int ringMeter(int value, int vmin, int vmax, int x, int y, int r, char *units, byte scheme, int old = -9999);
int olds[5] = { -9999, -9999, -9999, -9999, -9999};   //magic unlikely value

Many Thanks
Shaun

I've been reading on here a while now and one thing I senced is members going out there way not to help with whats being asked?

If you have ben reading here for a while then you will appreciate the need to have full information in order to provide answers. Your original post is a prime example. The error message indicates that the problem is in the loop() function

NEW-Touch-Smart-Thermostat-Landscape-Gauge.ino: In function 'void loop()':
NEW-Touch-Smart-Thermostat-Landscape-Gauge:374:3: error: a function-definition is not allowed here before '{' token
 {

but you did not post code containing that function. When that was pointed out you posted just part of the loop() function. Whilst it is true that there is a 9000 character limit on inline posting, the advice topics at the top of the page explain that a file containing the full code can be attached to a post

Please help us to help you and attach the full code to a post. Your problem is almost certainly going to be easy to fix (probably caused by mismatched { and } pairs), but the problem could be anywhere in the code in the case of a missing } at the end of the loop() function, but we cannot help without seeing your full code

Really helpful that Bob :smiley:

I am glad that it was helpful

Are you going to attach your whole sketch to a post ?

Full sketch is there buddy if you look, i cant help the rules set.
Are you going stop being a jobs worth?

Many Thanks
Shaun

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.

You can attach your codes ino file to your post, then we can see it all.

What model Arduino are you going to run your code on?

Tom.... :slight_smile:

For you Bob full sketch ;D

Hi Tom,

Its running on a Mega2560 its the R3 version with the ESP8266 on board.

Many Thanks
Shaun

NEW-Touch-Smart-Thermostat-Landscape-Gauge.ino (17.8 KB)

For you Bob full sketch

That wasn't too hard was it ?

All function definitions should line up on the left margin after Auto Formatting in the IDE but yours don't which usually indicates mismatched { and } pairs

Where does the loop() function end ?

      xpos = 220, ypos = 120, gap = 10, radius = 40;
      reading = 25;
      ringMeter(reading, -10, 30, xpos, ypos, radius, " *C", BLUE2RED); // Draw analogue meter
    }
  }
  // #########################################################################
  //  Draw the meter on the screen, returns x coord of righthand side
  // #########################################################################
  int ringMeter(int value, int vmin, int vmax, int x, int y, int r, char *units, byte scheme, int old)
  {

Presumably it should be before the start of the ringMeter() function which, as you will see, is not on the left margin after Auto Format

Your code has many redundant pairs of { and }, which is confusing, but get it to compile first then it can be tidied up

Hi Bob,

As you can probably see its many sketches hacked and cobbled together, lots in there displaying temperature readings to the LCD which wont be needed with the gauge's in place so that will come out.

I have been using the Auto format function but it still doesnt stand out to a novice like me, highlighting closing } and following to the opening { checking all the code between to make sure where { i can see }.

The end of the loop from my eyes although probably wrong is the end of the sketch

    if (quadrant == 3) {
      blue = 0;
      green = 63 - 2 * (value % 32);
      red = 31;
    }
    return (red << 11) + (green << 5) + blue;
  }

}

The guage meter is from mcufriend problem - Displays - Arduino Forum if it helps any.

Sorry I'm abit clueless still with the code side

Any help is appreciated
Many Thanks
Shaun

The end of the loop from my eyes although probably wrong is the end of the sketch

That is the problem

The loop() function must end before another function definition, which it doesn't

I cannot compile your sketch because I don't have the required libraries installed but try adding a closing } before these comments to end the loop() function and delete the very last } in the sketch and Auto Format the code again

// #########################################################################
//  Draw the meter on the screen, returns x coord of righthand side
// #########################################################################

As far as I can see, all of the function definitions now start (and end) on the left margin. Does the code compile now ?

You legend it now compiles and loads to the board.

The gauges need a good adjusting tonight, but it looks good now.

Thanks for your help the adjustments you said to make, now make sence.

Thanks again, sure I will be back soon with my next problem.

Shaun