let's say that I am working with an IoT device. The device can have many sensors, each of them has an address, i/o direction and a reading method.
temperature=d2,input,digital
humidity=d3,input,digital
lcd=a1,output,analog
From my program, I should read this configuration file and start getting data for example from the temperature sensor, which I know is at address d2 and provides digital input. How can I abstract this? I mean, I can't have something like
if(direction == input) {
if(type == digital) {
readDigital(d2)
} else {
readAnalog(d2)
}
} else {
if(type == digital) {
writeDigital(d2)
} else {
writeAanalog(d2)
}
}
This is absolutely not abstract stuff, and it kinda sucks. How can I connect my configuration to my code?