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