I've noticed in the ATtiny167 that I need to use different pin numbers for analogRead vs digitalRead. Is this intentional or a mistake? Shouldn't they be the same?
I think that the "standard" core corrects for this, and allows either analog "channel" numbers (0-6) or digital pin numbers (14-19) to be used by analogRead(). This code might be missing from the 167 core.
I guess my question is more along the lines of: what do we want?
There is something called analog_pin_to_channel that doesn't appear to be implemented in the ATtiny core. It's not a big deal. I can manage it. Digital pin 15 is Analog pin 10, even though it's physically the same pin. Okay.
The whole notion of Arduino pin mapping is, I presume, to make things easier and more portable. While working with this ATtiny I know I am going to be fixing bugs that I encounter. So I need some way to know if it's a bug or an intended simplification. Maybe it's up to me?
With pin mapping, it is up to you. For example, I have an ATtiny84 board that maps five physical pins to digital pins and has no analog pin mapping.
The analog pin numbers are usually just the multiplexer channel number (possibly with an offset) (e.g. ADC0 is analog pin zero, ADC1 is analog pin 1). That makes analogRead extremely simple. Luckily the m328 channel numbers coincide nicely with physical location / digital pin numbers. That is rarely (never?) true with ATtiny processors.
However, you are certainly free to add a bit of code to analogRead so the analog pin numbers can be translated. The code would be nearly identical to the code in the digital functions.
I see. I'll just leave it as is. I only asked because I'm expecting to find a few bugs in this core. I am using one pin for both analog and digital at the same time and it seemed weird to have two pin definitions in my sketch for the same physical pin.
The usual approach is to have the A* symbols map to the same physical pin. For example, on the Uno, A0 maps to digital pin 14 / analog pin 0; the same physical pin.
If the core you are using does not provide something similar I would consider that a bug.
It doesn't. It's A/D channel 9 but the symbol A9 doesn't even compile.
The way it's mapped now is also twisted in order to insure that SS,MOSI,MISO,SCK are 10,11,12,13. I guess that makes some sketches work without editing the pin numbers but it sure buggers the pattern. I sometimes get cross-eyed looking at it.
It's A/D channel 9 but the symbol A9 doesn't even compile.
Seems buggy to me.
The way it's mapped now is also twisted in order to insure that SS,MOSI,MISO,SCK are 10,11,12,13. I guess that makes some sketches work without editing the pin numbers but it sure buggers the pattern.