.. currentmodule:: omc048 .. _omc048.usb: class USB ================== Control the USB interface. The USB interface is most commonly used as a service interface. If the device would activate low power mode via (obs.lightsleep) the USB connection would be lost. To prevent this from happening the device does not enter lightsleep mode when the USB interface is connected to a PC. When de USB interface is turned off the device can not be accessed via USB, unit it is turned on again. Constructor ----------- .. class:: omc048.usb() Create an usb object Methods ------- .. method:: usb.power(state: bool) Set the usb peripheral on or off. Turn off for low power consumption mode. - ``bool`` is 1 or 0, True or False, corresponding to on and off. .. method:: usb.is_connected() -> bool Check if a USB cable is connected between the logger and the PC. Returns True if connected and False if not. .. method:: usb.is_addressed() -> bool Check if a USB cable is connected between the logger and the PC, if the handshaking process is in progress True is returned Example ------- The following example disables the usb interface :: import omc048 p1 = omc048.usb() p1.power(False) The following example shows a blue LED when the usb is connected, and a red LED when disconnected :: import omc048, obs usb = omc048.usb() led = omc048.LED() led.on() while True: if usb.is_connected(): led.colour('blue') else: led.colour('red') obs.delay(1000)