Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Conversation

@andreamah
Copy link
Contributor

Description:

Currently, the microbit does not respond to sensor/button input in debug mode.

This is because the handle to the microbit model instance is different in debugger_communication_client.py compared to everywhere else. Since micropython and microbit are both packages (although microbit is inside of the micropython package), instances imported as from microbit.__model.microbit_model import __mb as mb and from micropython.microbit.__model.microbit_model import __mb as mb deal with two different instances of mb. As a result, the mb that was getting an updated state was different than the one being referenced by the user code.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Testing:

Simple code using any sensors/buttons in DEBUG MODE such as this:

from microbit import *

while True:
    if button_a.is_pressed():
        display.show(Image.HAPPY)
    else:
        display.show(Image.HEART)

Checklist:

  • My code follows the style guidelines of this project
  • My code has been formatted with npm run format and passes the checks in npm run check
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Copy link

@nasadigital nasadigital left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! LGTM!

Copy link
Contributor

@xnkevinnguyen xnkevinnguyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for fixing it

@andreamah andreamah merged commit 2679ad6 into dev Apr 2, 2020
@andreamah andreamah deleted the users/t-anmah/microbit-debugger-fix branch April 2, 2020 17:24
)

sys.path.insert(0, abs_path_to_parent_dir)
# Insert absolute path to Micropython libraries for micro:bit into sys.path

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put this comment above the line it's referring to (or maybe remove the line break on line 20).
Now it seems as if it's referring to the next three lines where we calculate the path.

Comment on lines -7 to -8
from adafruit_circuitplayground import express
from common import debugger_communication_client

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, if we used relative paths would the tests use the correct library?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants