I'm not clear on the syntax... how do I dereference a member variable in a struct:
byte tempSensor[][8] = { // Array of sensor ID's
{0x28, 0xFF, 0x0D, 0x4C, 0x05, 0x16, 0x03, 0xC7},
{0x28, 0xFF, 0x25, 0x1A, 0x01, 0x16, 0x04, 0xCD},
{0x28, 0xFF, 0x89, 0x19, 0x01, 0x16, 0x04, 0x57},
{0x28, 0xFF, 0x21, 0x9F, 0x61, 0x15, 0x03, 0xF9},
{0x28, 0xFF, 0x16, 0x6B, 0x00, 0x16, 0x03, 0x08},
{0x28, 0xFF, 0x90, 0xA2, 0x00, 0x16, 0x04, 0x76},
{0x10, 0xE9, 0x6B, 0x0A, 0x03, 0x08, 0x00, 0xAC},
{0x10, 0x44, 0x4E, 0x0B, 0x03, 0x08, 0x00, 0x1F}
};
struct Sensors{
float T;
byte address[8];
};
Sensors mySensors[8];
Sensors* bus1[] = {&mySensors[0], &mySensors[1], &mySensors[2], &mySensors[3]}; // group sensors by which pin they're connected to
Sensors* bus2[] = {&mySensors[4], &mySensors[5], &mySensors[6]};
Sensors* bus3[] = {&mySensors[7]};
void setup()
{
Serial.begin(9600);
for(int i = 0; i < 8; i++)
{
for(int j = 0; j < 8; j++)
{
mySensors[i].address[j] = tempSensor[i][j];
}
}
}
void loop()
{
myFunction(bus1, sizeof(bus1)/sizeof(bus1[0]));
}
void myFunction(struct Sensors** ptrArray, size_t size) // pointer to array of pointers
{
for(int i = 0; i < size; i++)
{
*ptrArray[i]->T = float(i); // <<<<<< HERE (just stuffing any old number here)
}
}
*ptrArray[i]->T = float(i);
gives error:
error: invalid type argument of unary '*' (have 'float')