New to PlatformIO and coming from a Arduino IDE background. I have read a few threads on splitting .ino files into .cpp files and having few issues. I can get the basic examples working but when trying something a little more complex I get stuck.
main.cpp
#include <Arduino.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
#include <screen.h>
Adafruit_PCD8544 display = Adafruit_PCD8544(17, 18, 19, 20, 21);
String version = "v1.0";
void setup()
{
startScreen();
}
void loop()
{
}
screen.cpp
#include <Arduino.h>
#include "screen.h"
void startScreen()
{
display.clearDisplay();
display.println(version);
display.display();
}
screen.h
void startScreen();
I’m getting the following error:
src/screen.cpp: In function 'void startScreen()':
src/screen.cpp:12:3: error: 'display' was not declared in this scope
display.clearDisplay();
^
src/screen.cpp:14:19: error: 'version' was not declared in this scope
display.println(version);
What am I missing? Does display and version need to be somehow passed to screen.cpp?