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

digital or analogue read or write of a touch pin breaks other touch pin #462

Open
martinwork opened this issue Jan 23, 2025 · 1 comment · May be fixed by lancaster-university/codal-core#179

Comments

@martinwork
Copy link
Collaborator

martinwork commented Jan 23, 2025

Related: microsoft/pxt-microbit#6072

With the sample below, P2 touch works until button A is pressed/

I suspect this line needs a "-1". I'll test and make a PR.
https://github.com/lancaster-university/codal-core/blob/master/source/drivers/TouchSensor.cpp#L111

#include "MicroBit.h"

MicroBit uBit;

void onButtonA(MicroBitEvent e)
{ 
  uBit.io.P0.setDigitalValue(0);
}

void forever()
{
    while (true)
    {
      if ( uBit.io.P0.isTouched())
        uBit.display.print('0');
      else if ( uBit.io.P1.isTouched())
        uBit.display.print('1');
      else if ( uBit.io.P2.isTouched())
        uBit.display.print('2');
      else
        uBit.display.clear();

      uBit.sleep(100);
    }
}

int main() {
    uBit.init();

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

    uBit.io.P0.isTouched( codal::TouchMode::Capacitative);
    uBit.io.P1.isTouched( codal::TouchMode::Capacitative);
    uBit.io.P2.isTouched( codal::TouchMode::Capacitative);

    create_fiber( forever);

    release_fiber();
    return 0;
}
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 a pull request may close this issue.

1 participant