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

The example code for usage without "uBit" no longer compiles #83

Open
lvml opened this issue Jun 10, 2023 · 1 comment
Open

The example code for usage without "uBit" no longer compiles #83

lvml opened this issue Jun 10, 2023 · 1 comment

Comments

@lvml
Copy link

lvml commented Jun 10, 2023

At

#include "MicroBit.h"
MicroBitDisplay display;
int main()
{
while(1)
display.scroll(":)");
}
a code example is presented on how to use individual classes from Codal, rather than its entirety via a global "uBit" instance.

This example no longer compiles, as the MicroBitDisplay class has no constructor without parameters. This requires several additional objects, making this example no longer trivial. The smallest working replacement for MicroBitDisplay display; I found was this:

static const MatrixPoint ledMatrixPositions[5*5] =
{
    {0,0},{0,1},{0,2},{0,3},{0,4},
    {1,0},{1,1},{1,2},{1,3},{1,4},
    {2,0},{2,1},{2,2},{2,3},{2,4},
    {3,0},{3,1},{3,2},{3,3},{3,4},
    {4,0},{4,1},{4,2},{4,3},{4,4}
};

auto capTouchTimer = NRFLowLevelTimer(NRF_TIMER3, TIMER3_IRQn);
auto touchSensor = NRF52TouchSensor(capTouchTimer);
auto adcTimer = NRFLowLevelTimer(NRF_TIMER2, TIMER2_IRQn);
auto adc = NRF52ADC(adcTimer, 91);
auto io = MicroBitIO(adc, touchSensor);
NRF52Pin* ledRowPins[5] = {&io.row1, &io.row2, &io.row3, &io.row4, &io.row5};
NRF52Pin* ledColPins[5] = {&io.col1, &io.col2, &io.col3, &io.col4, &io.col5};
const MatrixMap ledMatrixMap = MatrixMap{ 5, 5, 5, 5, (Pin**)ledRowPins, (Pin**)ledColPins, ledMatrixPositions};
auto display = MicroBitDisplay(ledMatrixMap);

... which may be too long for a convincing example.

@lvml
Copy link
Author

lvml commented Jun 10, 2023

I should mention, though, that above cumbersome replacement did allow me to almost halve the size of the resulting binary for my software. So not using uBit is still an interesting option to save resources.

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

No branches or pull requests

1 participant