I am humbled to be back at the well so soon but I have spent the better part of the day fighting with pointers. I am able to pass a pointer for one row of my structure but not for the entire structure. I recognize that I am doing something stupid and would appreciate a [gentle] slap on the head...here is my code
The called CPP library:
#ifndef Forms4Utft_h
#define Forms4Utft_h
class Forms4Utft {
public:
String test(struct F4Utft*);
};
#endif
The library .H
#include <Arduino.h>
#include "Forms4Utft.h"
struct F4Utft {
String name;
int x;
int y;
String formatName;
};
String Forms4Utft::test(struct F4Utft* menu) {
return(menu[0].formatName);
}
The calling INO:
#include <UTFT.h>
#include <UTouch.h>
#include <Forms4Utft.h>
Forms4Utft forms;
struct F4Utft {
String name;
int x;
int y;
String formatName;
};
const int DEF_MENU1 = 3;
struct F4Utft Def_Menu[DEF_MENU1] = {
{"selStats", 15, 195, "BigFontS"},
{"selGraph", 215, 195, "BigFontS"},
{"line2", 15, 185, "None"},
};
void setup() {
// For debugging messages
Serial.begin(57600);
struct F4Utft ptr = Def_Menu[2];
Serial.println("--->" + Def_Menu[0].formatName);
Serial.println("--->" + String(forms.test(&ptr)));
}
void loop() {
while (true) {
}
}
When I do what I think should be done:
Change...
struct F4Utft ptr = Def_Menu[0];
...to:
struct F4Utft ptr = &Def_Menu;
I get errors: conversion from F4Utft[3] to non-scalar type F4Utft requested