Source code for commanduino.commanddevices.commanddigitalwrite

"""

.. module:: CommandDigitalWrite
   :platform: Unix
   :synopsis: Represents a DigitalWrite Arduino device.

.. moduleauthor:: Jonathan Grizou <Jonathan.Grizou@gla.ac.uk>

"""
from .commanddevice import CommandDevice

import logging
module_logger = logging.getLogger(__name__)


#Bonjour Information
BONJOUR_ID = 'DIGITALWRITE'
CLASS_NAME = 'CommandDigitalWrite'

#Outgoing (Write)
CMD_SET_LEVEL = 'W'


[docs]class CommandDigitalWrite(CommandDevice): """ DigitalWrite Arduino device. Base: CommandDevice """ def __init__(self): CommandDevice.__init__(self) ##
[docs] def set_level(self, level): """ Sets the level of the device. Args: level (int): The level setting. """ self.send(CMD_SET_LEVEL, int(bool(level)))
[docs] def low(self): """ Sets the level to LOW. """ self.set_level(0)
[docs] def high(self): """ Sets the level to HIGH. """ self.set_level(1)