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

Commit

Permalink
fixed circular dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
andreamah committed Feb 13, 2020
1 parent 429ef24 commit 8eae513
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
6 changes: 4 additions & 2 deletions src/adafruit_circuitplayground/express.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from collections import namedtuple
from applicationinsights import TelemetryClient
from .telemetry import telemetry_py
from common import debugger_communication_client
import common

Acceleration = namedtuple("acceleration", ["x", "y", "z"])

Expand Down Expand Up @@ -108,7 +108,9 @@ def light(self):

def __show(self):
if self.__debug_mode:
debugger_communication_client.debug_send_to_simulator(self.__state)
common.debugger_communication_client.debug_send_to_simulator(
self.__state, CONSTANTS.CPX
)
else:
utils.send_to_simulator(self.__state, CONSTANTS.CPX)

Expand Down
9 changes: 5 additions & 4 deletions src/adafruit_circuitplayground/pixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@

import json
import sys
from common import utils
import common
from . import constants as CONSTANTS

from applicationinsights import TelemetryClient
from . import constants as CONSTANTS
from .telemetry import telemetry_py
from common import debugger_communication_client


class Pixel:
Expand All @@ -23,9 +22,11 @@ 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:
debugger_communication_client.debug_send_to_simulator(self.__state)
common.debugger_communication_client.debug_send_to_simulator(
self.__state, CONSTANTS.CPX
)
else:
utils.send_to_simulator(self.__state, CONSTANTS.CPX)
common.utils.send_to_simulator(self.__state, CONSTANTS.CPX)

def __show_if_auto_write(self):
if self.auto_write:
Expand Down
6 changes: 1 addition & 5 deletions src/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,4 @@
ERROR_SENDING_EVENT = "Error trying to send event to the process : "
DEFAULT_PORT = "5577"


# class EventTypes(Enum):
# sensor = 1
# button = 2
# all = 3
ACTIVE_DEVICE_FIELD = "active_device"
7 changes: 3 additions & 4 deletions src/common/debugger_communication_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
import socketio
import copy

# from adafruit_circuitplayground import cpx
# from microbit import __mb as mb
from . import constants as CONSTANTS
from common import utils
from . import utils


from adafruit_circuitplayground.express import cpx
Expand Down Expand Up @@ -51,7 +49,8 @@ def init_connection(port=CONSTANTS.DEFAULT_PORT):
def __update_api_state(data):
try:
event_state = json.loads(data)
active_device = event_state.get("active_device")
active_device = event_state.get(CONSTANTS.ACTIVE_DEVICE_FIELD)
# can we do without this?
device_dict[active_device].update_state(data)
except Exception as e:
print(CONSTANTS.ERROR_SENDING_EVENT, e, file=sys.stderr, flush=True)
Expand Down

0 comments on commit 8eae513

Please sign in to comment.