예제 #1
0
파일: dsps_osc.py 프로젝트: dsp1986/FREAkit
    # Client (sending)
    ##
    client = udp_client.UDPClient(args.ip, args.port)  
    
    a = 0
    state = 0
    ####
    # LOOP
    ##
    #send()
    try:
        print ("Press CTRL+C to exit")
        while True:

            time.sleep(.1)        
            if(a != gpio.input(enc0A)):
                
                if(a == gpio.input(enc0B)):
                    state = state + 1
                else:
                    state = state - 1
                
                a = gpio.input(enc0A)
              
                print (state)
                osc_send(state,enc0)



    
    
예제 #2
0
__credits__ = ["Stefan Mavrodiev"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = __author__
__email__ = "*****@*****.**"

led = connector.gpio0p0     # This is the same as port.PH2
button = connector.gpio3p40

"""Init gpio module"""
gpio.init()

"""Set directions"""
gpio.setcfg(led, gpio.OUTPUT)
gpio.setcfg(button, gpio.INPUT)

"""Enable pullup resistor"""
gpio.pullup(button, gpio.PULLUP)
#gpio.pullup(button, gpio.PULLDOWN)     # Optionally you can use pull-down resistor

try:
    print ("Press CTRL+C to exit")
    while True:
        state = gpio.input(button)      # Read button state

        """Since we use pull-up the logic will be inverted"""
        gpio.output(led, not state)

except KeyboardInterrupt:
    print ("Goodbye.")
예제 #3
0
파일: dsps_osc.py 프로젝트: dsp1986/FREAkit
    ####
    # Client (sending)
    ##
    client = udp_client.UDPClient(args.ip, args.port)

    a = 0
    state = 0
    ####
    # LOOP
    ##
    #send()
    try:
        print("Press CTRL+C to exit")
        while True:

            time.sleep(.1)
            if (a != gpio.input(enc0A)):

                if (a == gpio.input(enc0B)):
                    state = state + 1
                else:
                    state = state - 1

                a = gpio.input(enc0A)

                print(state)
                osc_send(state, enc0)

    except KeyboardInterrupt:
        print("Goodbye.")