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

MicroBitDisplay animate - support negative stride for js-event-semantics branch #485

Open
wants to merge 1 commit into
base: js-event-semantics
Choose a base branch
from

Conversation

martinwork
Copy link
Contributor

startingPosition refers to the leading edge

Test program:

#include "MicroBit.h"


MicroBit uBit;


MicroBitImage img("255 0 0 0 0 0 0 0 0 255\n"
                  "0 255 0 0 0 0 0 0 255 0\n"
                  "0 0 255 0 0 0 0 255 0 0\n"
                  "0 0 0 255 0 0 255 0 0 0\n"
                  "0 0 0 0 255 255 0 0 0 0\n");

int stride = 1;


void onButtonA(MicroBitEvent e)
{
    stride = -1;
    uBit.display.stopAnimation();
}


void onButtonB(MicroBitEvent e)
{
    stride = 1;
    uBit.display.stopAnimation();
}


void forever()
{
    while ( true)
    {
      uBit.display.stopAnimation();
      uBit.display.clear();
      uBit.display.animate(img, 500, stride, MICROBIT_DISPLAY_ANIMATE_DEFAULT_POS, 0);

      uBit.display.stopAnimation();
      uBit.display.clear();
      uBit.display.animate(img, 500, stride, 2, 0);
    }
}


int  main()
{
    uBit.init();

    uBit.messageBus.listen( MICROBIT_ID_BUTTON_A,  MICROBIT_BUTTON_EVT_CLICK, onButtonA);
    uBit.messageBus.listen( MICROBIT_ID_BUTTON_B,  MICROBIT_BUTTON_EVT_CLICK, onButtonB);

    create_fiber( forever);

    release_fiber();
}

@carlosperate
Copy link

Hi Martin, thanks for the PR! Is this different to #427?

@martinwork
Copy link
Contributor Author

It should be the same except targeted at the js-event-semantics branch.

@pacorreia
Copy link

Any estimate when this PR can be merged? and will it support V2?

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.

3 participants