<s> from calvin . runtime . south . plugins . io . gpio import gpiopin <EOL> class GPIOPin ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , node , pin , direction , pull ) : <EOL> """<STR_LIT>""" <EOL> self . gpio = gpiopin . GPIOPin ( node . sched . trigger_loop , pin , direction , pull ) <EOL> def detect_edge ( self , edge ) : <EOL> """<STR_LIT>""" <EOL> if edge == "<STR_LIT:f>" or edge == "<STR_LIT:r>" or edge == "<STR_LIT:b>" : <EOL> self . gpio . detect_edge ( edge ) <EOL> else : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> def edge_detected ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . gpio . edge_detected ( ) <EOL> def edge_value ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . gpio . edge_value ( ) <EOL> def set_state ( self , state ) : <EOL> """<STR_LIT>""" <EOL> self . gpio . set_state ( state ) <EOL> def get_state ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . gpio . get_state ( ) <EOL> def pwm_start ( self , frequency , dutycycle ) : <EOL> """<STR_LIT>""" <EOL> self . gpio . pwm_start ( frequency , dutycycle ) <EOL> def pwm_set_frequency ( self , frequency ) : <EOL> """<STR_LIT>""" <EOL> self . gpio . pwm_set_frequency ( frequency ) <EOL> def pwm_set_dutycycle ( self , dutycycle ) : <EOL> """<STR_LIT>""" <EOL> self . gpio . pwm_set_dutycycle ( dutycycle ) <EOL> def pwm_stop ( self ) : <EOL> """<STR_LIT>""" <EOL> self . gpio . pwm_stop ( ) <EOL> def shift_out ( self , data , repeat ) : <EOL> """<STR_LIT>""" <EOL> self . gpio . shift_out ( data , repeat ) <EOL> def close ( self ) : <EOL> """<STR_LIT>""" <EOL> self . gpio . close ( ) <EOL> class GPIOHandler ( object ) : <EOL> def __init__ ( self , node ) : <EOL> super ( GPIOHandler , self ) . __init__ ( ) <EOL> self . node = node <EOL> def open ( self , pin , direction , pull = None ) : <EOL> if direction != "<STR_LIT:i>" and direction != "<STR_LIT:o>" : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> if pull is not None : <EOL> if pull != "<STR_LIT:u>" and pull != "<STR_LIT:d>" : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> return GPIOPin ( self . node , pin , direction , pull ) <EOL> def close ( self , gpio ) : <EOL> gpio . close ( ) <EOL> def register ( node , actor = None ) : <EOL> """<STR_LIT>""" <EOL> return GPIOHandler ( node ) </s>
