KurtE
Senior Member+
Hi Michael,
I was playing around with analog.c recently, trying a couple of ways to add the two other analog pins on 49 and 50 as A23 and A24. The main way was to add like the others and add another if statement to create index into array... Pull request: https://github.com/PaulStoffregen/cores/pull/167
Paul made a comment about the efficiency where I kept things in order, so made adjustment and then wondered about what the size/speed differences would be to do straight lookup table, where the code simply checks to verify that pin number is not too large and then loads value from array and then checks to make sure not invalid (I used 0xff). I also noticed that ADC library appears to be doing something similar, So I made a version of analog.c that I could compile either way and made tables for all of the chips. I used test program to try to verify all of the analog pins, which I tested on T3.6, T3.2 and TLC. Did not test T3.0 as I don't have any. Code was smaller on T3.6, I believe same size on T3.2 and slightly larger on TLC (8-10 bytes?) and speed differences weren't much... If anyone is interested in looking at that version up at: https://github.com/KurtE/cores/tree/T3.6-Add-A23-A24-lookup
While doing this, I wished there were some #define for the special analog pins like temp, that was defined depending on board. Something like how PIN_LED is defined.
Was not sure if it should be something like: A_TEMP, A_VREF or like PIN_TEMP, PIN_VREF or... Also was not sure if worry about adding new defines breaking things, so if they should be added under some #ifdef like: DEFINE_EXTRA_ANALOG_PINS
As you mentioned Could not be 38 as on the T36 pin 38 is a real analog pin: A19.
Kurt
I was playing around with analog.c recently, trying a couple of ways to add the two other analog pins on 49 and 50 as A23 and A24. The main way was to add like the others and add another if statement to create index into array... Pull request: https://github.com/PaulStoffregen/cores/pull/167
Paul made a comment about the efficiency where I kept things in order, so made adjustment and then wondered about what the size/speed differences would be to do straight lookup table, where the code simply checks to verify that pin number is not too large and then loads value from array and then checks to make sure not invalid (I used 0xff). I also noticed that ADC library appears to be doing something similar, So I made a version of analog.c that I could compile either way and made tables for all of the chips. I used test program to try to verify all of the analog pins, which I tested on T3.6, T3.2 and TLC. Did not test T3.0 as I don't have any. Code was smaller on T3.6, I believe same size on T3.2 and slightly larger on TLC (8-10 bytes?) and speed differences weren't much... If anyone is interested in looking at that version up at: https://github.com/KurtE/cores/tree/T3.6-Add-A23-A24-lookup
While doing this, I wished there were some #define for the special analog pins like temp, that was defined depending on board. Something like how PIN_LED is defined.
Was not sure if it should be something like: A_TEMP, A_VREF or like PIN_TEMP, PIN_VREF or... Also was not sure if worry about adding new defines breaking things, so if they should be added under some #ifdef like: DEFINE_EXTRA_ANALOG_PINS
As you mentioned Could not be 38 as on the T36 pin 38 is a real analog pin: A19.
Kurt