Skip to content
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

Polyfilling mbed for extensions #13

Merged
merged 16 commits into from
Nov 6, 2020

Conversation

microbit-sam
Copy link
Collaborator

@microbit-sam microbit-sam commented Nov 3, 2020

Implements: PwmOut, InterruptIn, DigitalIn, DigitalOut, Ticker, (Mbed)Timer

Extensions wishing to use any of these will need to make sure that they #include "mbed.h"

Is there a define extensions can use determine which timer to use? e.g. Timer in on v1, and MbedTimer on v2

#ifdef IS_V2
MbedTimer timer;
#elseif
Timer timer;
#endif

Note: commit messages referencing extensions were chosen as they were top of this list rather than any favoritism!
microsoft/pxt-microbit#3506

@finneyj please critique!

inc/compat/MbedTimer.h Outdated Show resolved Hide resolved
@microbit-sam microbit-sam marked this pull request as ready for review November 4, 2020 16:19
@microbit-sam
Copy link
Collaborator Author

This doesn't compile properly in PXT..

error: reference to 'uBit' is ambiguous
   39 |             uBit.messageBus.listen(DEVICE_ID_MBED_TICKER, 0x0, this, &Ticker::onTick);
      |             ^~~~

~/pxt-microbit-next/projects/Untitled/built/codal/pxtapp/pxt.h:46:17: note: candidates are: 'codal::MicroBit pxt::uBit'
   46 | extern MicroBit uBit;

@microbit-sam
Copy link
Collaborator Author

Fixed by using __has_include to include pxt.h if it exists

I can replace it with a check for a define if __has_include isn't supported in all environments? Couldn't find a PXT_EXISTS type define anywhere

@microbit-sam
Copy link
Collaborator Author

Now uses MICROBIT_DAL_FIBER_USER_DATA to determine if it is in PXT or not

@finneyj
Copy link
Contributor

finneyj commented Nov 6, 2020

Thanks Sam - this looks really good. nice job - thanks!

@finneyj finneyj merged commit cfc40a6 into lancaster-university:master Nov 6, 2020
@microbit-sam microbit-sam deleted the extension-polyfills branch November 9, 2020 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants