OLED display - newbee struggeling with compiler errors

Hi all,
I'm trying to learn Arduino programming, but I seem to take 3 steps forward and 2-1/2 back....
I want to - eventually - drive several OLED displays with a single Arduino from analog inputs.
I understand many of the issues and will figure them out eventually....
But for now, I managed to nicely display some basics on just one OLED - and then get stuck making it do something useful....
Here is my latest iteration which fails to compile.
I have a UNO, a Nano and a SEED XIAO to play with. The last iteration was done on the XIAO.
Could someone point out the concepts I'm missing and send me on the right path, please?
Cheers,
Joe

DiffTemp_to_OLED.ino (2.41 KB)

Post your code, post your error message(s)

Sorry, I attached the code as a file.
Here is the code (I hope):

Test for SEEED XIAO
*/

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

// Declaration for SSD1306 display connected using software SPI (default case):

#define DiffTempSensorPin 10 //diff temperature sensor pin

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_MOSI 3
#define OLED_CLK 4
#define OLED_DC 1
#define OLED_CS 0
#define OLED_RESET 2
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS); //set display active

void setup() {
Serial.begin(115200);

display.begin(SSD1306_SWITCHCAPVCC); {
}
}

void loop() {
// }
int DiffTempSensorValue; // variable to store the value
float DifftempC; // variable to store the value in deg C

DiffTempSensorValue = analogRead(DiffTempSensorPin); // read temp sensor and set it equal to tempC variable
DifftempC = (5.0 * DifftempC * 200.0) / 1023.0; // to convert the analog input to a temperature in degrees Celcius, assuming that '200' turns out to be correct as a calibration factor
// Serial.print("Diff Temperature: "); //for testing only
// Serial.println(DifftempC); //Print the value in deg C

void drawchar(void) {
display.clearDisplay();
display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
display.cp437(true); // use charactoer page 437 for degree character
display.setCursor(18, 3); // Start corner
display.write("DIFF TEMPERATURE");
display.setTextSize(2); // Normal 1:2 pixel scale
display.setCursor(43, 34); // Start corner
// display.write("76"); // Will be a variable based on temperature measurement - just testing, worked.... see next line: doesn't wirk....
display.write(DifftempC); // Diff Temp in deg C
display.write(248); // Degree symbol ° in CP437
display.write("C");
display.display();
}
}
void drawroundrect(void) {
display.drawRoundRect(15, 23, 98, 36, 5, SSD1306_WHITE); // Draw frame around numerical text (starting x,y, width,height, corner radius, colour)
display.display();
}

And here are the errors:
I changed lots of positions of various variables, declarations etc around, but it gets stuck here how....

C:\Arduino\DiffTemp_to_OLED\DiffTemp_to_OLED.ino: In function 'void loop()':

DiffTemp_to_OLED:40:23: error: a function-definition is not allowed here before '{' token

void drawchar(void) {

^
exit status 1

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

You appear to have the definition of drawchar embedded in loop()

Please remember to use code tags when posting code.

This line is a comment, which the compiler ignores. Is that what you intended?

 // }

Thanks for spotting that!
Closed the loop before the drawchar() (removed the // after the void loop() } line and the now redundant closing }

Now I get completely different errors - again:

DiffTemp_to_OLED:35:3: error: 'DiffTempSensorValue' does not name a type
DiffTempSensorValue = analogRead(DiffTempSensorPin); // read temp sensor and set it equal to tempC variable
^~~~~~~~~~~~~~~~~~~
DiffTemp_to_OLED:36:3: error: 'DifftempC' does not name a type
DifftempC = (5.0 * DifftempC * 200.0) / 1023.0; // to convert the analog input to a temperature in degrees Celcius, assuming that '200' turns out to be correct as a calibration factor
^~~~~~~~~

I'm missing some important concepts, I think....
Please have a look at these errors.

Now you've got code that isn't in a function.

Post your revised code.

Use code tags when posting code. The ide lets you copy for forum with the tags already included or you just click on the <> icon when posting.