-
-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added TXLed to Leonardo pin definition file #3680
Conversation
AFAIK I still see two problems:
|
I wonder if shifting pin numbers will cause problems. People should not be using pin numbers directly, but I suspect they do (from when the |
Why does it have to be at the array end? What about adding digitalPinHasPWM(p) at least? |
@matthijskooijman BTW that seems quite odd, because such numbers are not printed anywhere on the silk of the board, the only thing a user knows is that the analog pin 0 is marked as A0, so the typical usage may be: analogRead(0); // OK
analogRead(A0); // OK
//digitalWrite(0, HIGH); // This is not possible because 0 is D0 and not A0
digitalWrite(A0, HIGH); // OK If I really want to use |
@NicoHood |
Just this morning someone asked on IRC what "pin 60 on the mega" is. Apparently the Marlin 3D printer firmware uses this: I'm not sure if this should be supported (the library can be fixed in a backward compatible way easily by just using |
And the mega is not important here. The usage is stupid though, but not related to this 32u4 issue. I just dont understand why analog pins have to be at the end of the array. Anyways: Its stupid to not use the Ax definitions and that should not be a problem of Arduino. 1.6.x introduced a lot of changes anyways, especially the new USB-Core so you have to update most sketches anyways (Add include HID and Keyboard for example). And this so fast to fix, shouldnt be a real problem, even for library maintainers. |
@matthijskooijman @NicoHood
this is possible because internally there is a check like this: https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/wiring_analog.c#L44 as you can see |
Well that is easy to fix though. add -19 instead. what about that? |
So what about this now? Can we add a pin definition for the 32u4 TX Led now? Then we could also use USART SPI for the FastLED library. This is a really nice feature I'd like to see, but it requires an additional pin for the pin. Its broken out on some board, so you could really use this pin. |
I looked at the source again. This check is redundant it seems: You cannot input normal pin numbers anyways. So putting the TX Led at the end should not cause any problem. I havent tested this on hardware yet, but the subtraction doesnt seem to cause any problem at all. Putting it at the end keeps the original digital pin numbers though (instead of Ax if someone used this instead). Its just an addition. But I could also fix this by adding it in the middle. I will do some tests... Also the analogRead is not save, if someone calls it with a wrong pin number. But this applies to all Arduino boards. BTW: FastLED now also supports the TX Led as XCK pin. However its mapped to pin 24, but if this PR is merged, I will change that and add the missing Ax pins as well: FastLED/FastLED#214 |
Do we also still need this workaround? Since 1.5.6 we have a newer toolchain, so the file should be patched by now I guess? Or why dont you open a PR if those values are still wrong? |
I tested this now. All analog reads work as expected, since we never count from the end. We leave out the offset (18) and read from those analog ports. Since 30 is no analog port it will just not work like any other non analog pin. I see no reason why this PR isnt ready for merging. // the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(30, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(30, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(30, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
for (int i = A0; i <= A11; i++) {
Serial.print(i); // Converted to int 18-29
Serial.print("\t");
Serial.println(analogRead(i));
}
} |
What do you mean here? You can use analogRead(A0), which will, due to that check you linked, be the same as analogRead(0)? |
analogRead(0) will read A0 from what I understood. However it is not pin number 0. So pin numbers (except the A prefix) are not supported anyways. So we are not adding or removing features here and anything should be fine AnalogRead(30) will just not work, as analogRead(12) for example. |
After arduino/Arduino#3680 got merged, TX Led got officially supported. This means, we have to move the number upwards from 24 ( FastLED#214 ). The padding pins are the A6 - A11 definitions, which should now work as well.
Awesome :) |
Should improve PR #3129