-
Notifications
You must be signed in to change notification settings - Fork 34
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
AnalogRead() does not accept A0 as pin number #242
Comments
@per1234 where should the |
The common convention is in the core variant:
Correct. You can see the Uno has |
So the challenge for me will be to either figure out a way to put it (with proper Long term, the elephant in the room here is that I think I've only solved the hardware mocks/ |
I may be reaching the practical limits of what I can accomplish with hardware mocks. I don't have any sort of document (nor even a validator) for what macros might be defined across all of the hardware support and port registers, so there's no way to check that my mocks are in sync with those. And that ignores the problem of what might be included with any given "core install". How should I be approaching this issue? @matthijskooijman based on your comments on #147 I'm really curious whether solving that is now the easiest path forward. |
imho one could implement all A0..An for all boards to keep it simple and to get started. |
To really properly mock different platforms and boards, I guess some separation along the same lines as the IDE uses (different platforms, and within platforms, different boards) would be the most powerful approach (i.e. have some AVR-specific stuff that is triggered by An alternative could be to do more extensive mocking of each platform, and then use the variants from the original platforms verbatim. This means that the (undocumented) interface from core to variant should be mocked as well, which will likely include low-level arch-specific stuff (e.g. AVR I/O registers, which you're already mocking now, but this might be more tricky for other architectures). This is more work for a platform, but then likely makes it a lot easier to support all boards of that platform (by copying variant files and board.txt contents, probably with some (automatable) transformations applied to them. I'm not sure what the best approach is here. Also, my suggestion in #147 does not really help here, since if you make an "ArduinoCI" platform that arduino-cli knows how to compile, you'd still need to define all available boards and variants inside that platform. There's no way to "import" board definitions from other platforms, so you cannot magically get support for all other Arduino boards in this way somehow (and this can't really be implemented either, since board definitions and variants are currently heavily coupled to their platform).
This also seems like a valid strategy. Essentially you then just do not try to perfectly mock each board with all its limitations, but instead you try to always mock enough so that most sketches will compile and run, even if the mocking is not perfect (i.e. because more pins are available than in reality). |
Note that what you call "board mocks" ( |
They shouldn't. Since we allow testing compilation on multiple platforms, the appropriate errors should be raised during that step. It just feels wrong to me that the unit test compilation would allow something that couldn't be compiled in an actual sketch. |
I'm interested in exploring this option first. Right now the way I'm copying the source files from Arduino's |
In a unit test I use an analogRead(), however it will not accept A0 etc as typical pin names.
imho users expect these to work
The text was updated successfully, but these errors were encountered: