I need to create an array of pointers of different types. Some variables are defined at the beginning and their vectors are assigned to different spaces in the array. Later, from another process, the values of these variables can be changed using the pointers stored in the array. Variables are accessed directly from the main process (without pointers)
In de main process at start:
void *values[255];
uint8_t val1 = 12;
uint16_t val2 = 3478;
SetIDVariable(&val1, 0);
SetIDVariable(&val2, 2);
Others functions:
void SetIDVariable(uint8_t *variable, uint8_t id) {
values[id] = variable;
}
void SetIDVariable(uint16_t *variable, uint8_t id) {
values[id] = variable;
}
In other process (x is a any number for check if value change):
values[0] = (void*)(val1 + x);
values[2] = (void*)(val2 + x);
In main process:
Serial.print("Value 1: "); Serial.println(val1);
Serial.print("Value 2: "); Serial.println(val2);
Values are always 12 and 3478. Any ideas?