def test_devname(devname): global dev, log group_file = 'UPY_G' # print(group_file) if '{}.config'.format(group_file) not in os.listdir(): group_file = '{}/{}'.format(upydev.__path__[0], group_file) with open('{}.config'.format(group_file), 'r', encoding='utf-8') as group: devices = json.loads(group.read()) # print(devices) devs = devices.keys() # NAME ENTRY POINT if devname in devs: dev_port = devices[devname][0] dev_baud = devices[devname][1] else: if devname != 'default': pass if devname == 'default': dev = Device(_PYBOARD_, autodetect=True) else: dev = Device(dev_port, baudrate=dev_baud, autodetect=True) extra = {'dev': devname, 'devp': dev.dev_platform.upper()} log = logging.LoggerAdapter(log, extra)
def test_devname(devname): global dev, log group_file = 'UPY_G' # print(group_file) if '{}.config'.format(group_file) not in os.listdir(): group_file = '{}/{}'.format(upydev.__path__[0], group_file) with open('{}.config'.format(group_file), 'r', encoding='utf-8') as group: devices = json.loads(group.read()) # print(devices) devs = devices.keys() # NAME ENTRY POINT if devname in devs: dev_uuid = devices[devname][0] dev_pass = devices[devname][1] else: if devname != 'default': # load upydev_.config file_conf = 'upydev_.config' if file_conf not in os.listdir(): file_conf = os.path.join(upydev.__path__[0], 'upydev_.config') with open(file_conf, 'r') as config_file: upy_conf = json.loads(config_file.read()) dev_uuid = upy_conf['uuid'] dev_pass = upy_conf['passwd'] if devname == 'default': dev = Device(_ESPDEV_BLE, init=True, autodetect=True) else: dev = Device(dev_uuid, init=True, autodetect=True) extra = {'dev': devname, 'devp': dev.dev_platform.upper()} log = logging.LoggerAdapter(log, extra)
def main(): # SerialDevice pyboard_led_callback = """ def toggle_led(): pyb.LED(1).toggle() if not not pyb.LED(1).intensity(): print('ON') else: print('OFF')""" print("Connecting to device...") mydev = Device("/dev/tty.usbmodem3370377430372", init=True) mydev.paste_buff(pyboard_led_callback) mydev.wr_cmd('\x04') mydev.wr_cmd("sw = pyb.Switch();sw.callback(toggle_led)") # # WebSocketDevice # mydev = Device('192.168.1.73', 'keyespw', init=True) # # BleDevice # mydev = Device('9998175F-9A91-4CA2-B5EA-482AFC3453B9', init=True) print("Connected") app = QApplication(sys.argv) action_widget = ActionWidget(dev=mydev) # action_widget.setGeometry(50, 50, 400, 600) # action_widget.setWindowTitle("Upydevice Button Led Toggle") controls_widget = ControlsWidget(dev=mydev, action_label=action_widget) action_widget._button = controls_widget main_w = MainWindow([action_widget, controls_widget]) # action_widget.show() main_w.show() app.exec_()
def main(): # SerialDevice print("Connecting to device...") mydev = Device("/dev/tty.usbmodem3370377430372", init=True) mydev.wr_cmd("from pyb import LED;yled = LED(3); bled= LED(4)") # # WebSocketDevice # mydev = Device('192.168.1.73', 'keyespw', init=True) # # BleDevice # mydev = Device('9998175F-9A91-4CA2-B5EA-482AFC3453B9', init=True) print("Connected") app = QApplication(sys.argv) KnobLedController = KnobsLedpanel(device=mydev) KnobLedController.show() sys.exit(app.exec_())
def main(): # SerialDevice print("Connecting to device...") mydev = Device("/dev/tty.usbmodem3370377430372", init=True) mydev.wr_cmd("from pyb import Servo;s1 = Servo(1)") # # WebSocketDevice # mydev = Device('192.168.1.73', 'keyespw', init=True) # # BleDevice # mydev = Device('9998175F-9A91-4CA2-B5EA-482AFC3453B9', init=True) print("Connected") app = QApplication(sys.argv) widget = QWidget() angle_slider = Slider(parent=widget, device=mydev) # angle_slider.show() # widget.setGeometry(300,300,350,250) widget.setWindowTitle("Pyboard Servo slider") widget.show() sys.exit(app.exec_())
def main(): # SerialDevice mydev = Device('/dev/tty.usbmodem3370377430372', init=True) # WebSocketDevice # mydev = Device('192.168.1.73', 'keyespw', init=True) # # BleDevice # mydev = Device('9998175F-9A91-4CA2-B5EA-482AFC3453B9', init=True) # mydev.wr_cmd('led.value(not led.value())') mydev.wr_cmd('led.toggle()') mydev.disconnect()
def main(): # SerialDevice print("Connecting to device...") mydev = Device("/dev/cu.usbserial-016418E3", init=True) # # WebSocketDevice # mydev = Device('192.168.1.51', 'keyespw', init=True) # # BleDevice # mydev = Device('9998175F-9A91-4CA2-B5EA-482AFC3453B9', init=True) print("Connected") app = QApplication(sys.argv) led_widget = LED_Widget(dev=mydev) led_widget.setGeometry(50, 50, 320, 200) led_widget.setWindowTitle("Upydevice Button Led Toggle") led_widget.show() sys.exit(app.exec_())