I've recently started learning C++ for the STM32F103 microcontroller, and I'm using a library called STM32plus. The problem is, I'm not used to C++ and pointers at all, and this library practically relies on them.
So currently, I have 1 source file where all my code is located, and I want to start splitting it into sections. At the top of my main source file, I have declarations like this:
#include "config/stm32plus.h"
#include "config/display/tft.h"
using namespace stm32plus;
using namespace stm32plus::display;
typedef Fsmc16BitAccessMode<FsmcBank1NorSram1> LcdAccessMode;
typedef SSD1289_Landscape_64K<LcdAccessMode> LcdPanel;
LcdAccessMode *_accessMode;
LcdPanel *dsp;
Font *font;
there's more, but it looks something like that (this section is for the display, there's more for the SD card and other components). I mostly understand what's going on here. One of my functions in this file looks like this:
template <class T>
void print(T text)
{
textx+=dsp->measureString(text);
*dsp<<Point(textx,texty)<<text;
}
void println()
{
textx=0;
texty+=font->getHeight()+1;
}
template <class T>
void println(T text)
{
print(text);
println();
}
Now, I wanted to try and move this into a separate file or class (Print.cpp and Print.h), but after trying all sorts of different things like extern class, including the whole library, forward declarations, and after googling over 10 different errors I got trying to compile that code, and googling what I'm trying to do, I simply cannot find any solution. I would post examples of what I've tried, but I deleted all my previous attempts, and they didn't work at all anyway.
So, can anyone give me an example of a class or way to put these functions in a separate file/class so I can use it in the main program, while still allowing the main program to use display functions?
Any help/advice is appreciated. Note that I'm still new to C++, and that this is an embedded system, so RAM is limited (I can't make another instance of the display objects/classes)