Yes I think that's way more easy (just took a variable size of 1000 for testing purposes).
I could write
printf("SensorData:%5d" "%5d" "%5d", MyArray[0], MyArray[1], MyArray[2]); // and so on...
But that would result in a huge line and would be somewhat clumpy.
Also I would like to stop output at the maximum number of used sensors (which may differ from maximum possible sensors - see last line below in my example).
So I need to create a string containing the sensor-number line, then a line with 10 sensor data as long as Sensors >= 10, then continue with the next line and so on.
As soon as the last sensor is reached I want him to stop that line at that place.
Then after that I would like him to add all lines to a long string to support to my function (if that isn't wasting huge ammounts of memory for many Arrays).
Like at the end of my sketch below.
I already tested with printf() and it works with me putting that in one line by hand. But I really don't know how to put all the sensor readings in one string or one string per line automatically.
I don't understand if I need to define a 2 dimensional array to fill (like I started to try above my test) or some pointer to a one dimensional Array or so on....
I in general know what pointers are from programming assembly but somehow I can't get it in C.
I stopped writing my for statement since I'm pretty sure I'm on the wrong path somehow....
// ----- Error Email Body definition ------------------------------------------------------
#define Zeile2 "\nLETZTE MESSWERTE:\n\n"
#define Zeile4 "Wasserstand Tank: "
#define Zeile5 "Wasserstand D-Mix: "
#define Zeile6 "Temperatur (°C): "
#define Zeile7 "Helligkeit: "
// \n
// \n
#define Zeile10 "Feuchtigkeitssensoren:\n"
#define ZeileTrenn "___________________________________________________________\n"
#define Zeile12 "Topf: 1 2 3 4 5 6 7 8 9 10\n"
#define Zeile13 "Messwert: 100 100 100 100 100 100 100 100 100 100\n"
// ---
#define Zeile15 "Topf: 11 12 13 14 15 16 17 18 19 20\n"
#define Zeile16 "Messwert: 100 100 100 100 100 100 100 100 100 100\n"
// ---
#define Zeile18 "Topf: "
#define Zeile19 "Messwert:"
// ---
#define Zeile21 "Topf: 31 32 33 34 35 36 37 38 39 40\n"
#define Zeile22 "Messwert: 100 100 100 100 100 100 100 100 100 100\n"
// ---
#define Zeile24 "Topf: 41 42 43 44 45 46 47 48 49 50\n"
#define Zeile25 "Messwert: 100 100 100 100 100 100 100 100 100 100\n"
// ---
#define Zeile27 "Topf: 51 52 53 54 55 56 57\n"
#define Zeile28 "Messwert: 100 100 100 100 100 100 100\n"
// ---
// \n
// \n
#define Zeile32 "Hinweis: Sensorfehler oder fehlende Kalibration = -1"
// ----------------------------------------------------------------------------------------
int TestValue1 = 100;
int TestValue2 = 2;
int TestValue3 = 60;
int NoSens = 16; // 16 Sensors of 56 possible
char MailString[1000] = {}; // Entire String for output
char TestArray[6][59] = {}; // Lines for output
int SensorReadings[56] = {
270, 400, 600, 770, 270, 400, 600, 770,
270, 400, 600, 770, 270, 400, 600, 770,
270, 400, 600, 770, 270, 400, 600, 770,
270, 400, 600, 770, 270, 400, 600, 770,
270, 400, 600, 770, 270, 400, 600, 770,
270, 400, 600, 770, 270, 400, 600, 770,
270, 400, 600, 770, 270, 400, 600, 770
};
void setup()
{
Serial.begin(115200);
}
void loop()
{
/*
for (int i = 0; < 6 ; i++)
{
for (int j = 0; < 10)
{
if(j < NoSens)
{
TestArray[i][j] = sprintf("Messwert:%5d" ); // And so on....
}
else
{
TestArray[i][j] = "\n" // If last pot reached
}
}
}
*/
Serial.println("\n\n\n---------------------------------------------------------------------------------------------");
printf(Zeile2 Zeile4 "%d\n" Zeile5 "%d\n" Zeile6 "%d\n" Zeile7 "%d\n\n\n" Zeile10
ZeileTrenn Zeile12 Zeile13 ZeileTrenn Zeile15 "Messwert:%5d" "%5d" "%5d"
, TestValue1, TestValue2, TestValue3, TestValue1, TestValue3, TestValue2, TestValue1);
delay(5000);
}
/*
// ----- Needed Email Body ------------------------------------------------------
#define Zeile1 "\n"
#define Zeile2 "LETZTE MESSWERTE:\n"
#define Zeile3 "\n"
#define Zeile4 "Wasserstand Tank: "
#define Zeile5 "Wasserstand Düngermix: "
#define Zeile6 "Temperatur (°C): "
#define Zeile7 "Helligkeit: "
#define Zeile8 "\n"
#define Zeile9 "\n"
#define Zeile10 "Feuchtigkeitssensoren:\n"
#define Zeile11 "___________________________________________________________"
#define Zeile12 "Topf: 1 2 3 4 5 6 7 8 9 10"
#define Zeile13 "Messwert: 100 100 100 100 100 100 100 100 100 100"
#define Zeile14 "___________________________________________________________"
#define Zeile15 "Topf: 11 12 13 14 15 16 17 18 19 20"
#define Zeile16 "Messwert: 100 100 100 100 100 100 100 100 100 100"
#define Zeile17 "___________________________________________________________"
#define Zeile18 "Topf: 21 22 23 24 25 26 27 28 29 30"
#define Zeile19 "Messwert: 100 100 100 100 100 100 100 100 100 100"
#define Zeile20 "___________________________________________________________"
#define Zeile21 "Topf: 31 32 33 34 35 36 37 38 39 40"
#define Zeile22 "Messwert: 100 100 100 100 100 100 100 100 100 100"
#define Zeile23 "___________________________________________________________"
#define Zeile24 "Topf: 41 42 43 44 45 46 47 48 49 50"
#define Zeile25 "Messwert: 100 100 100 100 100 100 100 100 100 100"
#define Zeile26 "___________________________________________________________"
#define Zeile27 "Topf: 51 52 53 54 55 56 57"
#define Zeile28 "Messwert: 100 100 100 100 100 100 100"
#define Zeile29 "___________________________________________________________"
#define Zeile30 "\n"
#define Zeile31 "\n"
#define Zeile32 "Hinweis: Sensorfehler oder fehlende Kalibration = -1"
// ----------------------------------------------------------------------------------------
*/