Esempio n. 1
0
def configureHardware(postMotionEvent, postButtonClickEvent):
    wiringpi.wiringPiSetupGpio()

    # PIR motion detector
    def reportMotion():
        if wiringpi.digitalRead(BCM_PIR) == 1:
            postMotionEvent()

    wiringpi.pinMode(BCM_PIR, wiringpi.GPIO.INPUT)
    wiringpi.pullUpDnControl(BCM_PIR, wiringpi.GPIO.PUD_OFF)
    wiringpi.wiringPiISR(BCM_PIR, wiringpi.GPIO.INT_EDGE_BOTH, reportMotion)

    # Display buttons
    for btnNum, bcmPin in (
        (1, BCM_BTN_1),
        (2, BCM_BTN_2),
        (3, BCM_BTN_3),
    ):

        @debounce(0.02)
        def reportClick(_bcmPin=bcmPin, _btnNum=btnNum):
            if wiringpi.digitalRead(_bcmPin) == 0:
                postButtonClickEvent(_btnNum)

        wiringpi.pinMode(bcmPin, wiringpi.GPIO.INPUT)
        wiringpi.pullUpDnControl(bcmPin, wiringpi.GPIO.PUD_UP)
        wiringpi.wiringPiISR(bcmPin, wiringpi.GPIO.INT_EDGE_BOTH, reportClick)

    # Servos
    wiringpi.pinMode(BCM_SERVO_ACTIVATION, wiringpi.GPIO.OUTPUT)
    wiringpi.pinMode(BCM_SERVO_SPRING, wiringpi.GPIO.OUTPUT)
    wiringpi.pinMode(BCM_SERVO_HOLDER, wiringpi.GPIO.OUTPUT)
Esempio n. 2
0
    def __init__(self, gpio=0):
        global _linearEncoder

        # singleton
        if _linearEncoder is not None:
            raise Exception("Already created!")

        _linearEncoder = weakref.ref(self)

        # safety
        self.lock = threading.Lock()

        # tracking
        self.prevSampleTime = 0
        self.prevNumPulses = 0
        self.numPulses = 0

        # calibrations
        self.Calibration = calibration_pb2.Calibration()
        self.calMiles = None
        self.calDurationSec = None
        self.calRevolutions = None
        self.calRevToMilesScale = 0.0

        # GPIO
        wiringpi.wiringPiSetup()
        self.gpio = gpio
        wiringpi.wiringPiISR(self.gpio, wiringpi.INT_EDGE_FALLING,
                             LinearEncoder._myInterrupt)
        wiringpi.piHiPri(99)
Esempio n. 3
0
def configureHardware(postMotionEvent, postButtonClickEvent):
    wiringpi.wiringPiSetupGpio()

    # PIR motion detector
    def reportMotion():
        if wiringpi.digitalRead(BCM_PIR) == 1:
            postMotionEvent()

    wiringpi.pinMode(BCM_PIR, wiringpi.GPIO.INPUT)
    wiringpi.pullUpDnControl(BCM_PIR, wiringpi.GPIO.PUD_OFF)
    wiringpi.wiringPiISR(BCM_PIR, wiringpi.GPIO.INT_EDGE_BOTH, reportMotion)

    # Display buttons
    for btnNum, bcmPin in (
                (1, BCM_BTN_1),
                (2, BCM_BTN_2),
                (3, BCM_BTN_3),
            ):
        @debounce(0.02)
        def reportClick(_bcmPin=bcmPin, _btnNum=btnNum):
            if wiringpi.digitalRead(_bcmPin) == 0:
                postButtonClickEvent(_btnNum)

        wiringpi.pinMode(bcmPin, wiringpi.GPIO.INPUT)
        wiringpi.pullUpDnControl(bcmPin, wiringpi.GPIO.PUD_UP)
        wiringpi.wiringPiISR(bcmPin, wiringpi.GPIO.INT_EDGE_BOTH, reportClick)

    # Servos
    wiringpi.pinMode(BCM_SERVO_ACTIVATION, wiringpi.GPIO.OUTPUT)
    wiringpi.pinMode(BCM_SERVO_SPRING, wiringpi.GPIO.OUTPUT)
    wiringpi.pinMode(BCM_SERVO_HOLDER, wiringpi.GPIO.OUTPUT)
Esempio n. 4
0
def ensure_button_setup():
    import wiringpi

    ensure_wiringpi_setup()

    for button_pin in button_pins:
        wiringpi.pinMode(button_pin, wiringpi.INPUT)
        wiringpi.wiringPiISR(button_pin, wiringpi.INT_EDGE_BOTH, GPIO_callback)
def setup():
    piwiring.wiringPiSetup()
    piwiring.pinMode(SigPin, piwiring.INPUT)
    piwiring.pullUpDnControl(
        SigPin, piwiring.PUD_UP
    )  # Set Pin's mode is input, and pull up to high level(3.3V)
    piwiring.wiringPiISR(SigPin, piwiring.INT_EDGE_RISING,
                         count)  # wait for falling
Esempio n. 6
0
def ensure_button_setup():
    import wiringpi

    ensure_wiringpi_setup()

    for button_pin in button_pins:
        wiringpi.pinMode(button_pin, wiringpi.INPUT)
        wiringpi.wiringPiISR(button_pin, wiringpi.INT_EDGE_BOTH, GPIO_callback)
Esempio n. 7
0
 def set_callback(self, callback_function, *callback_args):
     """ Register a function that is called when the knob is turned """
     self._callback_function = callback_function
     self._callback_args = callback_args
     wiringpi.wiringPiISR(self.gpio_pin_a, wiringpi.INT_EDGE_BOTH,
                          self._decode_rotary)
     wiringpi.wiringPiISR(self.gpio_pin_b, wiringpi.INT_EDGE_BOTH,
                          self._decode_rotary)
Esempio n. 8
0
    def __init__(self):
        self.rgbled = RGBLED()
        self.buzzer = BUZZER(4)
        self.rgbled.pwmDriver.setPwmFreq(600)
        self.lcd = LCD1602(0x27)
        self.rotEnc = ROTARYENCODER()

        wp.wiringPiISR(self.rotEnc.getSWButtonPin(), wp.GPIO.INT_EDGE_FALLING,
                       self.buttonISR)
Esempio n. 9
0
    def __init__(self, pin):
        super(WiringPiPump, self).__init__(pin)

        # wiringpi.wiringPiSetupGpio()
        wiringpi.wiringPiSetupPhys()

        wiringpi.pinMode(pin, wiringpi.GPIO.INPUT)
        wiringpi.pullUpDnControl(
            pin, wiringpi.GPIO.PUD_OFF)  # use external pull-down resistor
        wiringpi.wiringPiISR(pin, wiringpi.GPIO.INT_EDGE_BOTH, self.event)
Esempio n. 10
0
def setupTacho():
	global rpmChkStartTime

	print("Setting up Tacho input pin")
	wiringpi.wiringPiSetupGpio()
	wiringpi.pinMode(tachoPin,wiringpi.INPUT)
	wiringpi.pullUpDnControl(tachoPin,wiringpi.PUD_UP)
	rpmChkStartTime=time.time()
	#print("{:4d}".format(wiringpi.INT_EDGE_FALLING))
	wiringpi.wiringPiISR(tachoPin,wiringpi.INT_EDGE_FALLING,tachoISR)
	return
Esempio n. 11
0
    def __init__(self):
    ###############################################
	wiringpi.wiringPiSetupGpio()   # initialise wiringpi
	wiringpi.wiringPiISR(ENC_PIN, wiringpi.INT_EDGE_FALLING, self.tick_int)
        rospy.init_node("diffBot_rwheel", anonymous = True);
#        self.nodename = rospy.get_name()
#        rospy.loginfo("%s started" % self.nodename)
        
        self.tick_count = 0
	self.pub_wheel = rospy.Publisher('diffBot/rwheel', Int16, queue_size=10) #1)
	rospy.init_node('diffBot_rwheel', anonymous = True)
	self.rate = rospy.Rate(1) # 1hz
Esempio n. 12
0
    def __init__(self, **kwargs):
        super(CamelRaceApp, self).__init__(**kwargs)
        self._keyboard = Window.request_keyboard(self._keyboard_closed, self)
        self._keyboard.bind(on_key_down=self._on_keyboard_down)
        self.gameOver = False

        for idx, pinList in enumerate(self.pinsToSense):
            player = self.getPlayers()[idx]
            for pinIdx, pin in enumerate(pinList):
                wiringpi.pinMode(pin, wiringpi.GPIO.INPUT)
                wiringpi.pullUpDnControl(pin, wiringpi.GPIO.PUD_UP)
                wiringpi.wiringPiISR(
                    pin, wiringpi.GPIO.INT_EDGE_BOTH,
                    lambda x: self.increment(player, 10 * pinIdx))
Esempio n. 13
0
 def __init__(self, carrier=F_433, callback=None):
     self.carrier = carrier
     self.callback = (lambda x: None) if callback is None else callback
     wiringpi.wiringPiSetup()
     wiringpi.wiringPiSPISetupMode(0, 4000000, 0)  # spi initialization
     wiringpi.pinMode(GDO0, wiringpi.INPUT)
     wiringpi.pinMode(GDO2, wiringpi.INPUT)
     self.reset()  # CC1101 reset
     self.regConfigSettings(self.carrier)  # CC1101 register config
     self.spiWriteBurstReg(CC1101_PATABLE,
                           (0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60,
                            0x60))  # CC1101 PATABLE config
     wiringpi.pinMode(GDO0, wiringpi.GPIO.INPUT)
     wiringpi.pullUpDnControl(GDO0, wiringpi.GPIO.PUD_UP)
     wiringpi.wiringPiISR(GDO0, wiringpi.GPIO.INT_EDGE_FALLING,
                          lambda: self.callback(buffer=self.receiveData()))
Esempio n. 14
0
 def __init__(self, callback):
     log.debug('GpioButtons.__init__')
     wiringpi.wiringPiSetupGpio()
     self.debounce = dict()
     self.debounce_time = fire_pong.util.config['InputManager']['gpio']['debounce_time']
     self.callback = callback
     for action in ['quit', 'start', 'swipe1', 'swipe2']:
         try:
             pin = fire_pong.util.config['InputManager']['gpio'][action]
             wiringpi.pinMode(pin, wiringpi.GPIO.INPUT)
             wiringpi.pullUpDnControl(pin, wiringpi.GPIO.PUD_UP)
             wiringpi.wiringPiISR(pin, wiringpi.GPIO.INT_EDGE_FALLING, getattr(self, action))
             self.debounce[action] = 0
             log.debug('GpioButtons.__init__() %s => pin %s' % (action, pin))
             
         except KeyError as e:
             log.warning('GpioButtons.__init__(): %s' % e)
             pass
Esempio n. 15
0
def init():
    wiringpi.wiringPiSetupGpio()

    wiringpi.pinMode(PWM_PIN, wiringpi.PWM_OUTPUT)
    wiringpi.pwmSetMode(wiringpi.PWM_MODE_MS)
    wiringpi.pwmSetClock(3840)
    wiringpi.pwmSetRange(250)

    wiringpi.pinMode(SPEED_SENSE_PIN, wiringpi.INPUT)
    wiringpi.pullUpDnControl(SPEED_SENSE_PIN, wiringpi.PUD_DOWN)

    wiringpi.pinMode(INCLINE_UP_PIN, wiringpi.OUTPUT)
    wiringpi.pullUpDnControl(INCLINE_UP_PIN, wiringpi.PUD_DOWN)

    wiringpi.pinMode(INCLINE_DOWN_PIN, wiringpi.OUTPUT)
    wiringpi.pullUpDnControl(INCLINE_DOWN_PIN, wiringpi.PUD_DOWN)

    wiringpi.pinMode(INCLINE_SENSE_PIN, wiringpi.INPUT)
    wiringpi.pullUpDnControl(INCLINE_SENSE_PIN, wiringpi.PUD_UP)
    wiringpi.wiringPiISR(INCLINE_SENSE_PIN, wiringpi.INT_EDGE_FALLING, incline_sense_callback)
Esempio n. 16
0
        def __init__(self, callback):
            log.debug('GpioButtons.__init__')
            wiringpi.wiringPiSetupGpio()
            self.debounce = dict()
            self.debounce_time = fire_pong.util.config['InputManager']['gpio'][
                'debounce_time']
            self.callback = callback
            for action in ['quit', 'start', 'swipe1', 'swipe2']:
                try:
                    pin = fire_pong.util.config['InputManager']['gpio'][action]
                    wiringpi.pinMode(pin, wiringpi.GPIO.INPUT)
                    wiringpi.pullUpDnControl(pin, wiringpi.GPIO.PUD_UP)
                    wiringpi.wiringPiISR(pin, wiringpi.GPIO.INT_EDGE_FALLING,
                                         getattr(self, action))
                    self.debounce[action] = 0
                    log.debug('GpioButtons.__init__() %s => pin %s' %
                              (action, pin))

                except KeyError as e:
                    log.warning('GpioButtons.__init__(): %s' % e)
                    pass
Esempio n. 17
0
 def WiringPiInit(self):
     '''
     WiringPiの初期化
     '''
     # BCMモードで初期化
     wiringpi.wiringPiSetupGpio()
     # BCMのn番ピンを入力・プルアップに設定
     for i in self.__GpioPin:
         # IoExpICのINT出力監視先ポートの設定
         wiringpi.pinMode(i, wiringpi.GPIO.INPUT)
         # プルアップの設定
         wiringpi.pullUpDnControl(i, wiringpi.GPIO.PUD_UP)
         # コールバック:
         wiringpi.wiringPiISR(
             #    i, wiringpi.GPIO.INT_EDGE_RISING, self.callback_in_rising)
             i,
             wiringpi.GPIO.INT_EDGE_BOTH,
             self.callback_in_rising)
         #前回の値初期化
         self.__GpioPin_before.append(0)
         #長押し開始時刻初期化
         self.__nagaoshi__GpioPin_before.append(datetime.datetime.today())
Esempio n. 18
0
    def run(self):
        logger = logging.getLogger(__name__)
        logger.debug("Setting up Button {} on pin {}".format(
            self.topic, self.pin))

        wiringpi.wiringPiSetup()
        wiringpi.pinMode(self.pin, wiringpi.GPIO.INPUT)
        wiringpi.pullUpDnControl(self.pin,
                                 getattr(wiringpi.GPIO, self.pull_resistor))
        wiringpi.wiringPiISR(self.pin, getattr(wiringpi.GPIO, self.edge_type),
                             self._button_callback)

        # Force sending state info on MQTT Topic on startup
        self.pipe.send(
            [self.topic,
             self._readString(wiringpi.digitalRead(self.pin))])

        t = threading.Thread(target=self._queue_thread)
        t.setDaemon(True)
        t.start()

        while True:
            wiringpi.delay(1000)
Esempio n. 19
0
def init_gpio():
    """
    初始化gpio口
    :return:
    """
    # Set up the wiringpi object to use physical pin numbers
    wp.wiringPiSetupPhys()

    #
    wp.pinMode(INT_PIN, INPUT)
    # wp.digitalWrite(CS_PIN, HIGH)

    # 中断注册
    # print('INT: ')
    print(wp.wiringPiISR(INT_PIN, wp.INT_EDGE_FALLING, int_from_pca9535))
Esempio n. 20
0
	Popen("sudo rm /kiekje/*.jpg", shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
	Popen("sudo rm /kiekje/kiekjes.db", shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
	Popen("sudo reboot", shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)

triggerButton = 26
resetButton = 17

wiringpi.wiringPiSetupGpio()
wiringpi.pinMode(triggerButton, wiringpi.GPIO.INPUT)
wiringpi.pullUpDnControl(triggerButton, wiringpi.GPIO.PUD_UP)
takePicture.last_interrupt_time = 0


wiringpi.pinMode(resetButton, wiringpi.GPIO.INPUT)
wiringpi.pullUpDnControl(resetButton, wiringpi.GPIO.PUD_UP)
wiringpi.wiringPiISR(resetButton, wiringpi.GPIO.INT_EDGE_FALLING, reset)

check_call(["sudo", initAndJPGSizePath, '1600x1200' ])

buttonState = 1
lastButtonState = 1

while(True):
	for event in pygame.event.get():
		if(event.type is MOUSEBUTTONDOWN):
			pos = pygame.mouse.get_pos()
			print(pos)
			for b in buttons[screenMode]:
				if b.selected(pos): break
				
	if(screenMode == 0):
Esempio n. 21
0
import wiringpi

BUTTON1 = 4

# init wiringpi
wiringpi.wiringPiSetup()


# interrupt
# int wiringPiISR (int pin, int edgeType,  void (*function)(void));
def gpio_callback():
    print("GPIO_CALLBACK!")


wiringpi.pinMode(BUTTON1, wiringpi.GPIO.INPUT)
wiringpi.pullUpDnControl(BUTTON1, wiringpi.GPIO.PUD_UP)

wiringpi.wiringPiISR(BUTTON1, wiringpi.GPIO.INT_EDGE_BOTH, gpio_callback)

while True:
    wiringpi.delay(2000)
Esempio n. 22
0
 def onBothEdge(self, handler):
     wiringpi.wiringPiISR(self.pin, wiringpi.INT_EDGE_BOTH, handler)
Esempio n. 23
0
    print("reboot")
    cmd = 'sudo shutdown -r now'
    subprocess.call(cmd.split(" "))
    exit()

state = False
timekeeper = None
def switch_trigger():
    if check_chattering("switch") == False:
        return

    global state
    global timekeeper
    if state:
        diff = timekeeper()
        state = False
        print('pulled up: ', diff, 'sec')
        if 3 <= diff:
            shutdown()
        elif 1 <= diff:
            reboot()
    else:
        timekeeper = timer()
        state = True
        print('pulled down')


while True:
    pi.wiringPiISR(SW_PIN, pi.INT_EDGE_BOTH, switch_trigger)
    time.sleep(1000)
Esempio n. 24
0
def handle_pin_change(bttnPin,bttnIndex):
    # ***************
    wiringpi.delay(25)   #TODO: REMOVE - Once the circuit board is built, it will do hardware debouncing
    # ***************

    # Read Input
    value = wiringpi.digitalRead(bttnPin)
    print("BTTN{0} = {1}".format(bttnIndex, value))
    if value == wpi.HIGH:
        bttnSounds[bttnIndex].play()
    else:
    
    # Set lighting to match the button
    wiringpi.digitalWrite(bttnPin, value)


# Configure wiringpi
wiringpi.wiringPiSetup()    # This uses the wiringPi number scheme (If you don't know the numbering, just do a `gpio readall` in the cmdline for info)

# Configure all the INPUTS
wiringpi.pinMode(BTTN1, wpi.INPUT)
wiringpi.pinMode(BTTN2, wpi.INPUT)
wiringpi.pinMode(BTTN3, wpi.INPUT)
wiringpi.pinMode(BTTN4, wpi.INPUT)
wiringpi.pinMode(BTTN5, wpi.INPUT)
wiringpi.pinMode(BTTN6, wpi.INPUT)
wiringpi.pinMode(BTTN7, wpi.INPUT)
wiringpi.pinMode(BTTN8, wpi.INPUT)
wiringpi.pullUpDnControl(BTTN1, wpi.PUD_DOWN)
wiringpi.pullUpDnControl(BTTN2, wpi.PUD_DOWN)
wiringpi.pullUpDnControl(BTTN3, wpi.PUD_DOWN)
wiringpi.pullUpDnControl(BTTN4, wpi.PUD_DOWN)
wiringpi.pullUpDnControl(BTTN5, wpi.PUD_DOWN)
wiringpi.pullUpDnControl(BTTN6, wpi.PUD_DOWN)
wiringpi.pullUpDnControl(BTTN7, wpi.PUD_DOWN)
wiringpi.pullUpDnControl(BTTN8, wpi.PUD_DOWN)

# Configure all the Lighting OUTPUTS
wiringpi.pinMode(BTTN1_LIGHT, wpi.OUTPUT)
wiringpi.pinMode(BTTN2_LIGHT, wpi.OUTPUT)
wiringpi.pinMode(BTTN3_LIGHT, wpi.OUTPUT)
wiringpi.pinMode(BTTN4_LIGHT, wpi.OUTPUT)
wiringpi.pinMode(BTTN5_LIGHT, wpi.OUTPUT)
wiringpi.pinMode(BTTN6_LIGHT, wpi.OUTPUT)
wiringpi.pinMode(BTTN7_LIGHT, wpi.OUTPUT)
wiringpi.pinMode(BTTN8_LIGHT, wpi.OUTPUT)
wiringpi.digitalWrite(BTTN1_LIGHT, wpi.LOW)
wiringpi.digitalWrite(BTTN2_LIGHT, wpi.LOW)
wiringpi.digitalWrite(BTTN3_LIGHT, wpi.LOW)
wiringpi.digitalWrite(BTTN4_LIGHT, wpi.LOW)
wiringpi.digitalWrite(BTTN5_LIGHT, wpi.LOW)
wiringpi.digitalWrite(BTTN6_LIGHT, wpi.LOW)
wiringpi.digitalWrite(BTTN7_LIGHT, wpi.LOW)
wiringpi.digitalWrite(BTTN8_LIGHT, wpi.LOW)

# ***************
wiringpi.pinMode(TEST, wpi.OUTPUT)      #TODO: REMOVE - This is here so I can touch wires together to test the inputs.
# ***************

# Configure All ISRs for button press notification
wiringpi.wiringPiISR(BTTN2, wpi.INT_EDGE_BOTH, bttn_2_changed)
wiringpi.wiringPiISR(BTTN1, wpi.INT_EDGE_BOTH, bttn_1_changed)
wiringpi.wiringPiISR(BTTN3, wpi.INT_EDGE_BOTH, bttn_3_changed)
wiringpi.wiringPiISR(BTTN4, wpi.INT_EDGE_BOTH, bttn_4_changed)
wiringpi.wiringPiISR(BTTN5, wpi.INT_EDGE_BOTH, bttn_5_changed)
wiringpi.wiringPiISR(BTTN6, wpi.INT_EDGE_BOTH, bttn_6_changed)
wiringpi.wiringPiISR(BTTN7, wpi.INT_EDGE_BOTH, bttn_7_changed)
wiringpi.wiringPiISR(BTTN8, wpi.INT_EDGE_BOTH, bttn_8_changed)

#TODO: Game Logic/Selection. Below is just a way to stall the main thread from exiting
while True:
    wiringpi.delay(2000)
Esempio n. 25
0
BUTTON_B = 2


def button_a_callback():
    #    print "BTN A"
    wiringpi.digitalWrite(LED, 0)
    call("sudo reboot", shell=True)


def button_b_callback():
    #    print "BTN B"
    wiringpi.digitalWrite(LED, 0)
    call("sudo halt", shell=True)


print "Starting NES Interface"

wiringpi.wiringPiSetup()
wiringpi.pinMode(BUTTON_A, wiringpi.GPIO.INPUT)
wiringpi.pinMode(BUTTON_B, wiringpi.GPIO.INPUT)
wiringpi.pinMode(LED, wiringpi.GPIO.OUTPUT)
wiringpi.digitalWrite(LED, 1)

#wiringpi.pullUpDnControl(PIN_TO_SENSE, wiringpi.GPIO.PUD_UP)

wiringpi.wiringPiISR(BUTTON_A, wiringpi.GPIO.INT_EDGE_BOTH, button_a_callback)
wiringpi.wiringPiISR(BUTTON_B, wiringpi.GPIO.INT_EDGE_BOTH, button_b_callback)

while True:
    wiringpi.delay(2000)
Esempio n. 26
0

# sw1が押されたコールバック
def sw1_callback():
    if is_long_pushed(PIN_SW1_WHITE):
        print("reboot")
        os.system("sudo reboot")
    else:
        print("reboot cancel")


# sw2が押されたコールバック
def sw2_callback():
    if is_long_pushed(PIN_SW2_BLACK):
        print("shutdown")
        os.system("sudo poweroff")
    else:
        print("shutdown cancel")


if __name__ == '__main__':
    wp.wiringPiSetupGpio()
    wp.pinMode(20, 1)
    wp.pinMode(21, 1)
    wp.pinMode(25, 1)
    # 負論理なので立下りトリガ
    wp.wiringPiISR(PIN_SW1_WHITE, wp.GPIO.INT_EDGE_FALLING, sw1_callback)
    wp.wiringPiISR(PIN_SW2_BLACK, wp.GPIO.INT_EDGE_FALLING, sw2_callback)
    while True:
        wp.delay(250)
def rotaryClear():
    # GPIO.add_event_detect(RoSPin, GPIO.FALLING, callback=clear) # wait for falling
    wpi.wiringPiISR(pSW, wpi.INT_EDGE_FALLING, clear)
Esempio n. 28
0
def setup_wiringpi(args):
    import wiringpi
    wiringpi.wiringPiSetupGpio()
    wiringpi.pinMode(args.pinin, 0)
    wiringpi.pullUpDnControl(args.pinin, 1)
    wiringpi.wiringPiISR(args.pinin, wiringpi.INT_EDGE_RISING, callback_wiringpi)
Esempio n. 29
0
import wiringpi
PIN_TO_SENSE = 29


def gpio_callback():
    print("GPIO_CALLBACK!")
    value = wiringpi.digitalRead(PIN_TO_SENSE)
    print("value: " + str(value))


wiringpi.wiringPiSetup()
wiringpi.pinMode(PIN_TO_SENSE, wiringpi.GPIO.INPUT)
wiringpi.pullUpDnControl(PIN_TO_SENSE, wiringpi.GPIO.PUD_UP)

wiringpi.wiringPiISR(PIN_TO_SENSE, wiringpi.GPIO.INT_EDGE_BOTH, gpio_callback)

while True:
    wiringpi.delay(2000)
Esempio n. 30
0
		state = wiringpi.digitalRead(IO_PIN)
		if (state != switch_state):
			switch_state = state;
			msg = str(state) + MESSAGE_DELIM + str(time_now)
			print 'Switch interrupt: %s' % state
			print 'publishing to %s: %s' % (aio_switch_feedid, msg)
			client.publish(aio_switch_feedid, msg)
		last_ts = time_now


# can call wiringPiSetupSys() if we've previously exported GPIO pins
wiringpi.wiringPiSetupGpio()

# use external pullup
wiringpi.pinMode(IO_PIN, wiringpi.GPIO.INPUT)
wiringpi.wiringPiISR(IO_PIN, wiringpi.GPIO.INT_EDGE_BOTH, on_switch_interrupt)

def on_connect(aioClient):
    	# Once connected, hook into i/o events
    	aioClient.subscribe(aio_switch_feedid)

def on_message(aioClient, feed_id, msg):
	state = wiringpi.digitalRead(IO_PIN)
	print "%s: got switch msg: %s, current state is: %s" % (feed_id, msg, state) 

print 'Creating MQTTClient with userid %s, key: %s' % (aio_userid, aio_key)
client = MQTTClient(aio_userid, aio_key)

# Register callbacks
client.on_connect = on_connect
client.on_message = on_message
Esempio n. 31
0
import wiringpi

#PIN_TO_SENSE = 14
PIN_TO_SENSE = 4


def gpio_callback_rising():
    print("GPIO_CALLBACK_RISING!")


wiringpi.wiringPiSetupGpio()
wiringpi.pinMode(PIN_TO_SENSE, wiringpi.GPIO.INPUT)
wiringpi.pullUpDnControl(PIN_TO_SENSE, wiringpi.GPIO.PUD_DOWN)
wiringpi.wiringPiISR(PIN_TO_SENSE, wiringpi.GPIO.INT_EDGE_RISING,
                     gpio_callback_rising)

while True:
    wiringpi.delay(2000)
Esempio n. 32
0
def rotaryClear():
    piwiring.wiringPiISR(RoSWPin, piwiring.INT_EDGE_FALLING,
                         clear)  # wait for falling
Esempio n. 33
0
        state = wiringpi.digitalRead(IO_PIN)
        if (state != switch_state):
            switch_state = state
            msg = str(state) + MESSAGE_DELIM + str(time_now)
            print 'Switch interrupt: %s' % state
            print 'publishing to %s: %s' % (aio_switch_feedid, msg)
            client.publish(aio_switch_feedid, msg)
        last_ts = time_now


# can call wiringPiSetupSys() if we've previously exported GPIO pins
wiringpi.wiringPiSetupGpio()

# use external pullup
wiringpi.pinMode(IO_PIN, wiringpi.GPIO.INPUT)
wiringpi.wiringPiISR(IO_PIN, wiringpi.GPIO.INT_EDGE_BOTH, on_switch_interrupt)


def on_connect(aioClient):
    # Once connected, hook into i/o events
    aioClient.subscribe(aio_switch_feedid)


def on_message(aioClient, feed_id, msg):
    state = wiringpi.digitalRead(IO_PIN)
    print "%s: got switch msg: %s, current state is: %s" % (feed_id, msg,
                                                            state)


print 'Creating MQTTClient with userid %s, key: %s' % (aio_userid, aio_key)
client = MQTTClient(aio_userid, aio_key)
Esempio n. 34
0
import wiringpi as wpi
import time
pin = 18
wpi.wiringPiSetupGpio()
wpi.pinMode(pin, wpi.INPUT)


def isr():
    print wpi.digitalRead(pin)


wpi.wiringPiISR(pin, wpi.INT_EDGE_BOTH, isr)

while True:
    time.sleep(100)
Esempio n. 35
0
def rotaryButtonSetup():
    wpi.wiringPiISR(pSW, wpi.INT_EDGE_FALLING, softOff)  # wait for falling
Esempio n. 36
0
import wiringpi
PIN_TO_SENSE = 23

def gpio_callback():
    print "GPIO_CALLBACK!"

wiringpi.wiringPiSetupGpio()
wiringpi.pinMode(PIN_TO_SENSE, wiringpi.GPIO.INPUT)
wiringpi.pullUpDnControl(PIN_TO_SENSE, wiringpi.GPIO.PUD_UP)

wiringpi.wiringPiISR(PIN_TO_SENSE, wiringpi.GPIO.INT_EDGE_BOTH, gpio_callback)

while True:
    wiringpi.delay(2000)
Esempio n. 37
0
main_draw = True

repo = Repo('/home/pi/pigrammer')

version = next((tag for tag in repo.tags if tag.commit == repo.head.commit),
               "Unknown")

if is_online():
    repo.remotes.origin.fetch()
    logger.info('Pigrammer is online, checking for updates')
    lines = ['Checking for', 'updates']
    drawScreen(x, image, lines)
    time.sleep(1)
    update()
else:
    lines = [str(version)]
    drawScreen(x, image, lines)
    time.sleep(1)

signal.signal(signal.SIGINT, signal_handler)
wp.wiringPiISR(pin_button, wp.INT_EDGE_FALLING, debounce_handler)

print("Startig PiGrammer")
logger.info("Starting PiGrammer")

lines = ["Ready to flash"]
while True:
    if main_draw:
        drawScreen(x, image, lines)
        time.sleep(0.5)