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

Commit

Permalink
moved debug_mode reference
Browse files Browse the repository at this point in the history
  • Loading branch information
andreamah committed Apr 1, 2020
1 parent 717fc7c commit 4fae4db
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 24 deletions.
5 changes: 2 additions & 3 deletions src/adafruit_circuitplayground/express.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ def __init__(self):
"touch": [False] * 7,
"shake": False,
}
self.__debug_mode = False
self.pixels = Pixel(self.__state, self.__debug_mode)
self.pixels = Pixel(self.__state)

@property
def acceleration(self):
Expand Down Expand Up @@ -114,7 +113,7 @@ def light(self):
return self.__state["light"]

def __show(self):
if self.__debug_mode:
if utils.debug_mode:
common.debugger_communication_client.debug_send_to_simulator(
self.__state, CONSTANTS.CPX
)
Expand Down
8 changes: 2 additions & 6 deletions src/adafruit_circuitplayground/pixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@


class Pixel:
def __init__(self, state, debug_mode=False):
def __init__(self, state):
self.__state = state
self.auto_write = True
self.__debug_mode = debug_mode
self.telemetry_state = False

def show(self):
# Send the state to the extension so that React re-renders the Webview
# or send the state to the debugger (within this library)
if self.__debug_mode:
if utils.debug_mode:
common.debugger_communication_client.debug_send_to_simulator(
self.__state, CONSTANTS.CPX
)
Expand All @@ -32,9 +31,6 @@ def __show_if_auto_write(self):
if self.auto_write:
self.show()

def __set_debug_mode(self, debug_mode):
self.__debug_mode = debug_mode

def __getitem__(self, index):
if type(index) is not slice:
if not self.__valid_index(index):
Expand Down
5 changes: 0 additions & 5 deletions src/adafruit_circuitplayground/test/test_pixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ def setup_method(self):
}
)

@pytest.mark.parametrize("debug_mode", [True, False])
def test_set_debug_mode(self, debug_mode):
self.pixel._Pixel__set_debug_mode(debug_mode)
assert debug_mode == self.pixel._Pixel__debug_mode

def test_get_item_out_of_bounds(self):
with pytest.raises(IndexError):
p = self.pixel[3]
Expand Down
1 change: 1 addition & 0 deletions src/common/debugger_communication_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
def debug_send_to_simulator(state, active_device):
global previous_state
if state != previous_state:
print("here!")
previous_state = copy.deepcopy(state)

updated_state = utils.update_state_with_device_name(state, active_device)
Expand Down
2 changes: 1 addition & 1 deletion src/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
previous_state = {}

abs_path_to_user_file = ""

debug_mode=False

def update_state_with_device_name(state, device_name):
updated_state = dict(state)
Expand Down
4 changes: 1 addition & 3 deletions src/debug_user_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@

# Init API variables
utils.abs_path_to_user_file = abs_path_to_code_file
cpx._Express__debug_mode = True
cpx.pixels._Pixel__set_debug_mode(True)
mb._MicrobitModel__set_debug_mode(True)
utils.debug_mode = True

# Execute the user's code file
with open(abs_path_to_code_file, encoding="utf8") as user_code_file:
Expand Down
3 changes: 1 addition & 2 deletions src/micropython/microbit/__model/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ 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 @@ -352,7 +351,7 @@ def __create_scroll_image(images):
def __update_client(self):
sendable_json = {"leds": self.__get_array()}

if self.__debug_mode:
if common.utils.debug_mode:
common.debugger_communication_client.debug_send_to_simulator(
sendable_json, CONSTANTS.MICROBIT
)
Expand Down
4 changes: 0 additions & 4 deletions src/micropython/microbit/__model/microbit_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,4 @@ def __update_gesture(self, new_state):
new_gesture = new_state.get(CONSTANTS.EXPECTED_INPUT_GESTURE)
self.accelerometer._Accelerometer__update_gesture(new_gesture)

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


__mb = MicrobitModel()

0 comments on commit 4fae4db

Please sign in to comment.