I created a simple library for formatting text output on the serial monitor. It has thee functions, one that creates carriage returns, one that sets the number of spaces between characters and the last one prints dashes. I followed the tutorial on the Arduino.cc site. The problem I have is that I can’t pass the value to each of the functions when I call them in the code. If you look at the screenshot from the sketch when I create an instance of nFormat it requires me to put a value in and it passes that value to each of the functions (lines, spaces, dashes). I want to be able to specify the value directly when I call the function. See the second red line on the output screenshot. I know this post is a bit long I would appreciate it if someone could point me in the right direction.
nFormat.h
#ifndef nFormat_h
#define nFormat_h
#include "Arduino.h"
class nFormat
{
public:
nFormat(int counter);
void lines();
void spaces();
void dashes();
private:
int _counter;
};
#endif
nFormat.cpp
#include "Arduino.h"
#include "nFormat.h"
nFormat::nFormat(int counter)
{
_counter=counter;
}
void nFormat::lines()
{
for (int x = 0; x < _counter; x++)
{
Serial.println(" ");
}
}
void nFormat::spaces()
{
for (int x = 0; x < _counter; x++)
{
Serial.print(" ");
}
}
void nFormat::dashes()
{
for (int x = 0; x < _counter; x++)
{
Serial.print("-");
}