Hi everyone, let me first preface this with the fact that this is a high level concept question, and second let me give a brief description of what I am trying to accomplish.
What I want to do is to create a sensor class object that effectively has class variables pin, id, and value (not sensor value, just an int for the sensor set at construction). Then I want to create a sort of dataLink class which will be responsible for sending data packets via TCP/IP.
I want each to create 1x instance of the dataLink class and provide a handle/memory reference to each instance of the sensor class on construction. Then I want to register an interrupt for each sensor class so that when the pin goes high the sensor classes will call an internal function which will call a dataLink function to effectively queue data. (The dataLink class is just writing out data packets from the queue on a timer or at least that is the idea).
Now from what I have read, attaching interrupts to class functions IS technically possible but requires a little bit of hacky coding with a wrapper for the class due to the hidden object reference variable "this". (How to use attachInterrupt with a class member - Syntax & Programs - Arduino Forum)
But please correct me if I am wrong on this. Is there an easier way in setup() to just have myClassInstance.classFunction as the ISR/Callback function? Similarly I would like to use myClassInstance.myPin as the interrupt pin. Though I think that should be easy enough to just pull into a local variable in setup().
This ^ is effectively my first question, I just want to make sure I understand this.
My second question is how would I change class variables/properties during execution? Say I have 2 sensors class instances running with their ISR's waiting for a rising edge on the sensor pins. Sensor A is set with a value of 10 and sensor B is set with a value of 20, but now I want to change sensor A's value to 30. I am not sure how I would do that from a UI perspective. Programmatically it would be sensorA.val = 30; right, but once the setup() runs and the main loop() is running, I don't really have a live environment with access to the class instances.
From what I have read there are a few approaches. I could setup some sort of button system in the main code and have it increment vals up and down when pressed for example. I would prefer to do this via software though and I am not sure how or if I can do this at all. ( I read something about creating a serial command system to access variables but it was pretty non-specific)
For some perspective I am used to creating C++ classes and then creating dlls for them where all I do in my UI front end is create local handle to the memory address where the class lives. A good OOP example would be like Matlab with handles to C++ via mex functions. I am just not really sure what the process is for managing objects on a uController like Arduino.
Lastly, I don't really have any functional code for this (mainly because I am not sure how to do it) - just proof of concept things based on examples from the Arduino guides. Sorry about that, but this is sort of a high-level concept question.