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

Commit

Permalink
connected microbit to debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
andreamah committed Feb 13, 2020
1 parent f7e5b52 commit 88bff5e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/common/debugger_communication_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
# (needs handle to device-specific debugger)
def debug_send_to_simulator(state, active_device):
global previous_state

if state != previous_state:
previous_state = copy.deepcopy(state)

Expand Down
2 changes: 2 additions & 0 deletions src/debug_user_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

# This import must happen after the sys.path is modified
from adafruit_circuitplayground.express import cpx
from microbit.__model.microbit_model import __mb as mb
from common import debugger_communication_client


Expand All @@ -45,6 +46,7 @@
cpx._Express__abs_path_to_code_file = abs_path_to_code_file
cpx._Express__debug_mode = True
cpx.pixels._Pixel__set_debug_mode(True)
mb._MicrobitModel__set_debug_mode(True)

# Execute the user's code file
with open(abs_path_to_code_file) as user_code_file:
Expand Down
12 changes: 10 additions & 2 deletions src/microbit/__model/display.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import copy
import time
import threading
from common import utils
import common

from . import constants as CONSTANTS
from .image import Image
Expand All @@ -18,6 +18,7 @@ def __init__(self):

self.__current_pid = None
self.__lock = threading.Lock()
self.__debug_mode = False

def scroll(self, value, delay=150, wait=True, loop=False, monospace=False):
"""
Expand Down Expand Up @@ -336,7 +337,13 @@ def __create_scroll_image(images):

def __update_client(self):
sendable_json = {"leds": self.__get_array()}
utils.send_to_simulator(sendable_json, CONSTANTS.MICROBIT)

if self.__debug_mode:
common.debugger_communication_client.debug_send_to_simulator(
sendable_json, CONSTANTS.MICROBIT
)
else:
common.utils.send_to_simulator(sendable_json, CONSTANTS.MICROBIT)

def __update_light_level(self, new_light_level):
if new_light_level is not None:
Expand All @@ -347,3 +354,4 @@ def __update_light_level(self, new_light_level):
@staticmethod
def sleep_ms(ms):
time.sleep(ms / 1000)

3 changes: 3 additions & 0 deletions src/microbit/__model/microbit_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,8 @@ def __update_temp(self, new_state):
if new_temp != previous_temp:
self._MicrobitModel__set_temperature(new_temp)

def __set_debug_mode(self, mode):
self.display._Display__debug_mode = mode


__mb = MicrobitModel()

0 comments on commit 88bff5e

Please sign in to comment.