Then you did not implement it correctly. A simple example:
Main .ino file:
#include "Displaydef.h"
void setup() {
startDisplay();
display.clearDisplay();
display.setCursor(0, 0);
display.println("Hello World");
}
void loop() {
}
Displaydef.h
#ifndef displaydef_H
#define displaydef_H
#include <Adafruit_SSD1306.h>
void startDisplay();
extern Adafruit_SSD1306 display;
#endif
Displaydef.cpp
#include "Displaydef.h"
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define SCREEN_ADDRESS 0x3C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void startDisplay() {
display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
}
1 Like
I was joking man! I tried again and again and I made it!
Thank you very much Man!
I didn't answere becouse I runned out of messages!
BTW with the "extern" and after some tries i made it!!
Thanks again, I'll mention you on my theis!!
gfvalvo:
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void startDisplay() {
display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
Right! Now it works well! Thank you so much! I'll save your example for the future implementations! THanks again!
Hey Man, I made some changes/improvment.. in your opinion, is it good like this or did I make too much functions?
#include "PINOUT.h"
#include "FS.h"
#include "SC.h"
#include "Time_Sleep.h"
#include "displaydef.h"
#include "RPTemp.h"
#include "StartWifi.h"
//////////////////////////
void setup() {
Serial.begin(115200);
PinDeclar();
/////DHT_Dallas_Begin/////
Start_TempSens();
/////OLED_I2C///////
Start_Display();
//connect to WiFi
Start_Wifi();
delay(1000);
printLocalTime();
delay(2000);
}
boolean FS = true ;
void loop() {
if ( FS == true){FirstStart(); L4S(); FS = false;} ////FIRST START + LOOK FOR SUN
SolarCheck(); //every 5 minutes
RPTemp(); //every 10 minutes
Closing();
Sleepnight();
}
Why not simply call FirstStart and L4S in setup?
1 Like
Aw, that's true ahahah I'm a noob sorry
system
Closed
September 15, 2021, 12:21pm
29
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.