I have a project to control the heater and pump for my swimming pool. I have already had a PCB fabricated and all the hardware works as expected. The code I have so far works also. Currently I'm trying to encapsulate parts of my code related to hardware devices into libraries for future use. I'm using a DS3232 RTC to time heater and pump on and off times and a Blackberry microTrackballer breakout board (from SparkFun) for menu navigation. I have the library for the RTC and the trackballer done and working [separately].
The thing is the trackballer uses PCINT0 and the RTC also uses PCINT0, pins 53 and 52 respectively (on the mega). In the original code the ISR was global and written to check which pin had changed and handle it accordingly. Since the RTC uses 1 interrupt and the trackballer uses 5 interrupts (1 for each direction and 1 for the button press) I have put the ISRs in the new trackball library. I know it would be far simpler to put the RTC on it's own PCINT. However, I've already fab'd the PCB. As it is now with the original code it's not a problem. It's only a problem with the trackball library if I want to use interrupt pins that share the same pin change interrupt. So, my question is:
Is it possible to conditionally substitute the Pin Change ISR in the trackball library. Or better yet, insert (when needed) the extra code to check the additional pin(s) used by other hardware?