def main():
	
	gpio.setup(SW1, gpio.IN)
	gpio.setup(SW2, gpio.IN)
	gpio.setup(SW3, gpio.IN)


	while True:
		
		valueSW1 = gpio.read(SW1)
		valueSW2 = gpio.read(SW2)
		valueSW3 = gpio.read(SW3)

		if valueSW1 == 0:
			firebase.put('/' , "house1", {u'addr': addrSW1, u'id': idSW1, u'visible': "True", u'lat': latSW1, u'lng': lonSW1})
		else:
			pass
		
		if valueSW2 == 0:
			firebase.put('/' , "house2", {u'addr': addrSW2, u'id': idSW2, u'visible': "True", u'lat': latSW2, u'lng': lonSW2})
		else:
			pass
		
		if valueSW3 == 0:
			firebase.put('/' , "house1", {u'addr': addrSW1, u'id': idSW1, u'visible': "False", u'lat': latSW1, u'lng': lonSW1})
			firebase.put('/' , "house2", {u'addr': addrSW2, u'id': idSW2, u'visible': "False", u'lat': latSW2, u'lng': lonSW2})
		else:
			pass
def exchange(dOut):
    # Trade 1 byte between CPI and Arduino.

    global cpiState, ardState

    ardState = gpio.read(ARD)

    dIn = 0
    for i in range(BITS):

        gpio.write(DAT_OUT, (dOut >> i) % 2)

        gpio.write(CPI, cpiState)
        cpiState = not cpiState

        starTime = time.time()
        while(gpio.read(ARD) == ardState):
            time.sleep(0.0001)
            if starTime + TIMEOUT < time.time():
                return -1
        ardState = not ardState

        dIn += gpio.read(DAT_IN) << i

    gpio.write(CPI, cpiState)
    cpiState = not cpiState

    return dIn
Esempio n. 3
0
	def toggle(self):
		
		if gpio.read(57) == 0:
			gpio.set(57, 1)
		elif gpio.read(57) == 1:
			gpio.set(57, 0)
		else:
			pass
def main():

    gpio.setup(SW1, gpio.IN)
    gpio.setup(SW2, gpio.IN)
    gpio.setup(SW3, gpio.IN)

    while True:

        valueSW1 = gpio.read(SW1)
        valueSW2 = gpio.read(SW2)
        valueSW3 = gpio.read(SW3)

        if valueSW1 == 0:
            firebase.put(
                '/', "house1", {
                    u'addr': addrSW1,
                    u'id': idSW1,
                    u'visible': "True",
                    u'lat': latSW1,
                    u'lng': lonSW1
                })
        else:
            pass

        if valueSW2 == 0:
            firebase.put(
                '/', "house2", {
                    u'addr': addrSW2,
                    u'id': idSW2,
                    u'visible': "True",
                    u'lat': latSW2,
                    u'lng': lonSW2
                })
        else:
            pass

        if valueSW3 == 0:
            firebase.put(
                '/', "house1", {
                    u'addr': addrSW1,
                    u'id': idSW1,
                    u'visible': "False",
                    u'lat': latSW1,
                    u'lng': lonSW1
                })
            firebase.put(
                '/', "house2", {
                    u'addr': addrSW2,
                    u'id': idSW2,
                    u'visible': "False",
                    u'lat': latSW2,
                    u'lng': lonSW2
                })
        else:
            pass
Esempio n. 5
0
 def getGPIO(self):
     rospy.loginfo('start scan gpio...')
     xfm_last_status = gpio.read(XFM_WAKEUP_PIN)
     r = rospy.Rate(100)
     while not rospy.is_shutdown():
         xfm_now_status = gpio.read(XFM_WAKEUP_PIN)
         if xfm_last_status == 0 and xfm_now_status == 1:
             print "RISING!!"
             self.pushMsg()
         xfm_last_status = xfm_now_status
         r.sleep()
Esempio n. 6
0
def toggle(pin):

    if gpio.read(pin) == 0:
        gpio.setup(pin, gpio.OUT)
        gpio.set(pin, 1)
    elif gpio.read(pin) == 1:
        gpio.setup(pin, gpio.OUT)
        gpio.set(pin, 0)
    else:
        print('There was some sort of error, are you using the right pin?')
    print(gpio.read(pin))
Esempio n. 7
0
def led_status():
    """checks each led status, returns which LED currently high"""
    if gpio.read(out_zero) == 1:
        return 0
    elif gpio.read(out_one) == 1:
        return 1
    elif gpio.read(out_two) == 1:
        return 2
    elif gpio.read(out_three) == 1:
        return 3
    else:
        return 4  # all LEDs are low
Esempio n. 8
0
def button_led_check(led):
    """checks status of all buttons, and if the correct button has been pressed, LED turns off"""
    button_zero = gpio.read(in_zero)
    button_one = gpio.read(in_one)
    button_two = gpio.read(in_two)
    button_three = gpio.read(in_three)

    if led == 0 and button_zero == 1:
        gpio.output(out_zero, 0)
    elif led == 1 and button_one == 1:
        gpio.output(out_one, 0)
    elif led == 2 and button_two == 1:
        gpio.output(out_two, 0)
    elif led == 3 and button_three == 1:
        gpio.output(out_three, 0)
Esempio n. 9
0
def gates_sensor_handler(gpio):
    global bot
    if (c.DEVELOPER_COMPUTER != '64bit'):
        pin = int(gpio.getPin())
        new_state = gpio.read()
    else:
        pin = 45
        new_state = 1
    gate = -1
    for i in range(len(c.GPIOREAD_LIST)):
        if (pin == c.GPIOREAD_LIST[i]):
            gate = i
            break
    if (gate >= 0 and bot != None):
        subscribers = db.get_subscribers(gate)
        if (new_state == c.OPEN_GPIO):
            send_to_subscribers(
                bot, subscribers,
                "Informacion: Porton " + str(gate) + " fue abierto")
            Thread(target=timer_close_gate, args=(
                bot,
                gate,
            )).start()
        elif (new_state == c.CLOSED_GPIO):
            send_to_subscribers(
                bot, subscribers,
                "Informacion: Porton " + str(gate) + " fue cerrado")
        else:
            send_to_subscribers(
                bot, subscribers,
                "Informacion: Porton " + str(gate) + " estado desconocido")
    else:
        print(pin, new_state, gate)
        print("Error no encontro puerta")
    db.add_event(new_state, gate)
Esempio n. 10
0
def button_status():
    changed = True
    old_v = -1
    while True:  # this will never exit (unless there is an error, maybe?)
        v = read(95)
        changed = (old_v != v)
        yield (changed, v)
        old_v = v
Esempio n. 11
0
 def focusOut(self):
     if gpio.read(self.focuserRUN) == 0:
         gpio.set(self.focuserRUN, 1)
         gpio.set(self.focuserIN, 0)
         gpio.set(self.focuserOUT, 1)
         self.focus_out.setStyleSheet("background-color: lime")
         self.focus_in.setStyleSheet("background-color: None")
         self.focus_auto.setEnabled(False)
     else:
         if gpio.read(self.focuserOUT) == 1:
             gpio.set(self.focuserRUN, 0)
             gpio.set(self.focuserIN, 0)
             gpio.set(self.focuserOUT, 0)
             self.focus_in.setStyleSheet("background-color: None")
             self.focus_out.setStyleSheet("background-color: None")
             self.focus_auto.setEnabled(True)
         else:
             gpio.set(self.focuserIN, 0)
             gpio.set(self.focuserOUT, 1)
             self.focus_out.setStyleSheet("background-color: lime")
             self.focus_in.setStyleSheet("background-color: None")
Esempio n. 12
0
def updateIndicators(stop_event):
    blinker = 0
    while not stop_event.wait(0.1):
        v = read(button_switch)
        #print "button-switch", v
        if v:  ##disabled the blinker## and blinker<15:
            set(led_red, 0)
        else:
            set(led_red, 1)
        blinker = blinker + 1
        if blinker >= 20:
            blinker = 0
    print 'updateIndicators thread has terminated.'
Esempio n. 13
0
def gpioread():
    keys = []
    for writeport in range(80, 87):
        if writeport == 86:
            writeport = 136
        gpio.set(writeport, 1)
        time.sleep(0.002)
        key = 0
        for readport in range(135, 127, -1):
            key = (key << 1) + gpio.read(readport)
        key = ~((key ^ (key >> 1)) & 0x1f ^ (key >> 1)) & 0x7f
        keys.append(key)
        gpio.set(writeport, 0)
    return keys
def start_launch(launch_name, stdscr):
    stdscr.nodelay(1)
    gpio.setup(396, gpio.IN)
    uuid = roslaunch.rlutil.get_or_generate_uuid(None, True)
    roslaunch.configure_logging(uuid)
    launch = roslaunch.parent.ROSLaunchParent(uuid, [
        '/home/nvidia/catkin_ws/src/heron_software/src/launch/' + launch_name +
        '.launch'
    ])
    launch.start()  #Lance le launch
    while stdscr.getch() != 27 and gpio.read(
            396
    ) != 0:  #Attend que "Echap" ou le bouton d'arrêt d'urgence soit appuyé
        pass
    launch.shutdown()  #Arrête le launch
Esempio n. 15
0
 def run(self):
     while not gs.exit_signal:
         gs.button_1 = gpio.read(cf.GPIO_BUTTON_1)
         gs.button_2 = gpio.read(cf.GPIO_BUTTON_2)
         gs.button_3 = gpio.read(cf.GPIO_BUTTON_3)
         gs.button_4 = gpio.read(cf.GPIO_BUTTON_4)
         gs.button_ss1 = gpio.read(cf.GPIO_BUTTON_SS1)
         gs.button_ss2 = gpio.read(cf.GPIO_BUTTON_SS2)
         gpio.output(cf.GPIO_LED, gs.led_state)
         time.sleep(0.05)
     self.clean_up_gpio(None, None)
     print("Exiting from ButtonReader")
Esempio n. 16
0
 def read(self):
     state = gpio.read(self.pin)
     falling = False
     rising = False
     if self.previous_state and not state:
         falling = True
     if not self.previous_state and state:
         rising = True
     if self.edge == "RISING":
         if rising:
             self.callback()
     elif self.edge == "FALLING":
         if falling:
             self.callback()
     else:
         if rising or falling:
             self.callback()
     self.previous_state = state
Esempio n. 17
0
 def test_basic(self):
     mopen = mock_open(read_data='0')
     with patch(bins + '.open', mopen, create=True) as m:
         result = gpio.read(0)
     assertInitialized(self, m)
     self.assertEqual(result, 0)
Esempio n. 18
0
import gpio
import time

for i in range(5, 10):
    gpio.setup(i, 'in')

while 1:
    time.sleep(0.1)
    for i in range(5, 10):
        val = gpio.read(i)
        if val == 0:
            print "pin: %d" % i
Esempio n. 19
0
def check(sensor_id, db_id):
    value = gpio.read(int(sensor_id))
    if previous[sensor_id] != value:
        previous[sensor_id] = value
        payload = {"sensor_id": db_id, "value": value}
        getToken.postData("movement_reading", payload)
Esempio n. 20
0
 def poll_gpio(self, index):
     assert index in self.bus_gpio_list
     return gpio.read(self._gpio_pin_index[index - 1])
Esempio n. 21
0
 def test_basic(self):
     mopen = mock_open(read_data='0')
     with patch(bins + '.open', mopen, create=True) as m:
         result = gpio.read(0)
     assertInitialized(self, m)
     self.assertEqual(result, 0)
Esempio n. 22
0
    def __init__(self):
        try:
            #BELOW: list of status register names and the corresponding GPIO port address
            self.status_register={"DONE":1006,"P1V0_MGT_PGOOD":1005,"QDR_TERM_PGOOD":1004,"DDR3_TERM_PGOOD":1003,"P1V8_MGT_PGOOD":1002,"P1V2_PGOOD":1001,"P1V5_PGOOD":1000,"P1V8_PGOOD":999,"P2V0_PGOOD":998,"P1V0_PGOOD":997,"P5V0_PGOOD":996,"P3V3_PGOOD":995, "QSFP_MODULE_PRESENT_U20":994, "QSFP_MODULE_PRESENT_U13":993}
            self.status_names = self.status_register.keys()
            
            #BELOW: list of reset register names and the corresponding GPIO port address
            self.reset_register={"ZYNC_F_RST":1010,"ZYNC_FW_RST_N":1011,"RESETL0":1012,"RESETL1":1013,"V7_INIT_B":1014,"V7_PRG_ZY":1015}
            self.reset_names = self.reset_register.keys()
            """
            from firmware
            ZYNC_F_RST           <= reset_gpio_wo(0);
            ZYNC_FW_RST_N        <= reset_gpio_wo(1); -- active HIGH!!! signal
            RESETL0              <= NOT reset_gpio_wo(2); -- active low signal
            RESETL1              <= NOT reset_gpio_wo(3); -- active low signal
            V7_INIT_B            <= NOT reset_gpio_wo(4); -- active low signal
            V7_PRG_ZY            <= reset_gpio_wo(5);
            """
            
            #BELOW: list of control register names and the corresponding GPIO port address
            self.control_register={"FSEL_1_DE": 986, "FSEL_0_DE": 987, "F_CLK_SEL": 988, "QSFP_I2C_SEL0": 989, "LPMODE0": 990, "LPMODE1": 991, "P1V0_EN_ZYNC": 992}
            self.control_names = self.control_register.keys()
            self.control_register_local = {"FSEL_1_DE": 0, "FSEL_0_DE": 0, "F_CLK_SEL": 0, "QSFP_I2C_SEL0": 0, "LPMODE0": 0, "LPMODE1": 0, "P1V0_EN_ZYNC": 1}

            """
             -- *** Control Register bis assignments for register control ***
            FSEL_1_DE <= control_reg(0);
            FSEL_0_DE <= control_reg(1);  
            F_CLK_SEL <= control_reg(2);
            QSFP_I2C_SEL0 <= control_reg(3);
            LPMODE0 <= control_reg(4);
            MODPRSL0 <= control_reg(5);
            LPMODE1 <= control_reg(6);
            MODPRSL1 <= control_reg(7);
            P1V0_EN_ZYNC <= control_reg(8);
            
            """
            self.selected_flash = 1 # device 1,2,3 or 4
        #exception error handling needs further improvement
        except ValueError:
            print('Non-numeric input detected.')

        print("I got here")
        self.gpio_root = '/sys/class/gpio/'
        self.gpiopath = lambda pin: os.path.join(gpio_root, 'gpio{0}'.format(pin))
        self.RoMODE = 'r'
        self.RWMODE = 'r+'
        self.WMODE = 'w'

        # try: #setup the gpio registers
        #     self.gpio_setup()
        # except BaseException as e:
        #     print("Failed to do something: ", e)
        # finally:
        #     print("Closing all gpio instances")
        #     gpio.cleanup()
        try:
            for key,val in self.control_register.items():
                ppath = str(self.gpio_root + 'gpio' + str(val))
                value = open(str(ppath + '/value'), self.RWMODE)
                direction = open(str(ppath + '/direction'), self.RoMODE)
                gpio._open[val] = gpio.PinState(value=value, direction=direction)
            
            for key,val in self.status_register.items():
                ppath = str(self.gpio_root + 'gpio' + str(val))
                value = open(str(ppath + '/value'), self.RoMODE)
                direction = open(str(ppath + '/direction'), self.RoMODE)
                gpio._open[val] = gpio.PinState(value=value, direction=direction)
            
            for key,val in self.reset_register.items():
                ppath = str(self.gpio_root + 'gpio' + str(val))
                value = open(str(ppath + '/value'), self.RWMODE)
                direction = open(str(ppath + '/direction'), self.RoMODE)
                gpio._open[val] = gpio.PinState(value=value, direction=direction)
            
            print(gpio._open)
            print(gpio._open[990].value)

        except (BaseException) as e:
            response = {'error': 'Something happened: {}'.format(str(e))}

            
        
        print(gpio._open)


        try: #populate the parameter tree
            self.param_tree = ParameterTree({
                "status":{
                    "DONE":(lambda: gpio.read(self.status_register.get("DONE")), None),
                    "P1V0_MGT_PGOOD":(lambda: gpio.read(self.status_register.get("P1V0_MGT_PGOOD")), None),
                    "QDR_TERM_PGOOD":(lambda: gpio.read(self.status_register.get("QDR_TERM_PGOOD")), None),
                    "DDR3_TERM_PGOOD":(lambda: gpio.read(self.status_register.get("DDR3_TERM_PGOOD")), None),
                    "P1V8_MGT_PGOOD":(lambda: gpio.read(self.status_register.get("P1V8_MGT_PGOOD")), None),
                    "P1V2_PGOOD":(lambda: gpio.read(self.status_register.get("P1V2_PGOOD")), None),
                    "P1V5_PGOOD":(lambda: gpio.read(self.status_register.get("P1V5_PGOOD")), None),
                    "P1V8_PGOOD":(lambda: gpio.read(self.status_register.get("P1V8_PGOOD")), None),
                    "P2V0_PGOOD":(lambda: gpio.read(self.status_register.get("P2V0_PGOOD")), None),
                    "P1V0_PGOOD":(lambda: gpio.read(self.status_register.get("P1V0_PGOOD")), None),
                    "P5V0_PGOOD":(lambda: gpio.read(self.status_register.get("P5V0_PGOOD")), None),
                    "P3V3_PGOOD":(lambda: gpio.read(self.status_register.get("P3V3_PGOOD")), None),
                    "QSFP_MODULE_PRESENT_U20_BOTn":(lambda: gpio.read(self.status_register.get("QSFP_MODULE_PRESENT_U20")), None),
                    "QSFP_MODULE_PRESENT_U13_TOPn":(lambda: gpio.read(self.status_register.get("QSFP_MODULE_PRESENT_U13")), None),
                    
                },
                "reset":{
                    "ZYNC_F_RST": (None, self.ZYNC_F_RST_set),
                    "ZYNC_FW_RST_N": (None, self.ZYNC_FW_RST_N_set),
                    "RESETL0": (None, self.RESETL0_set),
                    "RESETL1": (None, self.RESETL1_set),
                    "V7_INIT_B": (None, self.V7_INIT_B_set),
                    "RE-PROGRAM_FPGA": (None, self.V7_PRG_ZY_set)
                },
                "control":{
                    "FIRMWARE_SELECT":(lambda: self.selected_flash, self.set_flash, {"description":"flash 1 = default firmware, flash 2 = test firmware, flash 3 = test firmware, flash 4 = FLASH PROGRAMMING FIRMWARE"}),
                    "FLASH_CLOCK_SELECT":(lambda: self.read_control_reg("F_CLK_SEL"), self.F_CLK_SEL_set, {"description":"FPGA (DEFAULT/NORMAL) = 0, QSPI (PROGRAMMING FIRMWARE) = 1"}),
                    "QSFP_I2C_SELECT":(lambda: self.read_control_reg("QSFP_I2C_SEL0"),self.QSFP_I2C_SEL0_set, {"description":"changes which I2C interface is ACTIVE, 0 = U20 BOTT, 1 = U13 TOP"}),
                    "QSFP_LOW_POWER_MODE_U20_BOT":(lambda: self.read_control_reg("LPMODE0"), self.LPMODE0_set, {"description":"puts the bottom QSFP device into low power mode"}),
                    "QSFP_LOW_POWER_MODE_U13_TOP":(lambda: self.read_control_reg("LPMODE1"), self.LPMODE1_set, {"description":"puts the top QSFP device into low power mode"}),
                    "P1V0_EN_ZYNC":(lambda: self.read_control_reg("P1V0_EN_ZYNC"), self.P1V0_EN_ZYNC_set)
                    
                }         
            })



        except ValueError: #excepts need revision to be meaningful
            print('Non-numeric input detected.')
Esempio n. 23
0
import gpio
import time

# Using Vitiral's gpio library (Access by Linux sysfs on L4T for Nvidia Jetson TX2)

# GPIO Declaration
bit0 = 388  #Pin 396: Pin 7 in Expansion Header J21

# GPIO Setup
gpio.setup(bit0, gpio.OUT)  #Pin 396: Pin 7 in Expansion Header J21 as OUTPUT

while True:
    value = gpio.read(bit0)
    if value:
        gpio.set(bit0, 0)
    else:
        gpio.set(bit0, 1)
    time.sleep(0.0)
Esempio n. 24
0
    for i in LEDS:
        IO.output(i, 0)
        time.sleep(0.001)
        IO.cleanup(i)


IO.setmode(IO.BCM)

RED = 26
YELLOW = 21
GREEN = 20
R1 = 13
R2 = 6
R3 = 12
Y1 = 7
Y2 = 8
Y3 = 11
Trigger = 14

LEDS = [26, 21, 20, 13, 6, 12, 7, 8, 11]

for i in LEDS:
    IO.setup(i, IO.OUT)
try:
    while True:
        IO.setup(Trigger, IO.IN)
        print(IO.read(Trigger))
except KeyboardInterrupt:
    RunEnd()
exit()
Esempio n. 25
0
import gpio


def toggle(pin):

    if gpio.read(pin) == 0:
        gpio.setup(pin, gpio.OUT)
        gpio.set(pin, 1)
    elif gpio.read(pin) == 1:
        gpio.setup(pin, gpio.OUT)
        gpio.set(pin, 0)
    else:
        print('There was some sort of error, are you using the right pin?')
    print(gpio.read(pin))


pinnum = raw_input("What pin are you looking for?\nHint: it's probably 57 ")
pinst = gpio.read(pinnum)
cmd = raw_input('Pin %s is %s, do you want to change it? (y/n) ' %
                (pinnum, pinst))

if cmd.lower() == 'y':
    toggle(pinnum)
    print('Pin %s was toggled' % pinnum)
elif cmd.lower() == 'n':
    pass
else:
    print("Something didn't work")
Esempio n. 26
0
def read_bits(bit, num_bits):
    read_bits = [0] * num_bits
    for i in range(0, num_bits):
        read_bits[i] = gpio.read(bit[i])
    print(read_bits[::-1])  # Inverse for readability ONLY for Debugging!
    # from readings of an off-the-shelf multimeter.
    if adc_reading >= 1015:
        return math.inf
    else:
        return max(0.0, -1.9312e6 / (adc_reading - 1022.75) - 2151.174)

def mapFunc(x, in_min, in_max, out_min, out_max):
    if in_min == in_max:
        return (out_min + out_max) / 2
    return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min

gpio.initialize(CPI, False)
gpio.initialize(ARD, True)
gpio.initialize(DAT_IN, True)
gpio.initialize(DAT_OUT, False)
ardState = gpio.read(ARD)
cpiState = True

new_reading = 0
readings = []
avg = 0
setting = 0
tol = 0

with open("/sys/devices/platform/backlight/backlight/backlight/brightness", "r") as f:
    bright = int(f.read())

vol_str = subprocess.run(
    "amixer get Master",
    shell=True,
    capture_output=True,
Esempio n. 28
0
print(
    'Frozen Python to test GPIO.\n Press board switches to change LED colour.\n'
)
import gpio
gpio.init()
gpio.output(gpio.red)
gpio.output(gpio.green)
gpio.output(gpio.blue)
gpio.input(gpio.sw1)
gpio.input(gpio.sw2)
gpio.up(gpio.red)
exit = 0
while exit == 0:
    switch1 = gpio.read(gpio.sw1)
    switch2 = gpio.read(gpio.sw2)
    if switch1 == 0 and switch2 == 0:
        exit = 1
    elif switch1 == 0:
        gpio.up(gpio.green)
        gpio.down(gpio.red)
        gpio.down(gpio.blue)
    elif switch2 == 0:
        gpio.up(gpio.blue)
        gpio.down(gpio.green)
        gpio.down(gpio.red)
    else:
        gpio.up(gpio.red)
        gpio.down(gpio.green)
        gpio.down(gpio.blue)
print('Blinking loop')
import time
Esempio n. 29
0
def main():
    #setup beaglebone perephials
    GPIO = gpio_factory("bbb")
    read(GPIO, "P9_12")
    SPI = spi_factory(0, 0, "bbb")

    #setup cc2500
    cc2500.reset(SPI)
    time.sleep(1)
    cc2500.init(SPI)
    time.sleep(1)
    cc2500.config(SPI)

    if len(sys.argv) < 2:
        print("Invalid argument. Follow these examples below")
        print("")
        print("Random schedule")
        print("'python3 main.py size min_random max_random'")
        print("")
        print("Periodic schedule")
        print("'python3 size period'")
        print("")
        print("File schedule")
        print("'python3 main.py file_name'")
        return

    ts_lookup = None
    is_periodic = False
    adjust_ids = None

    argv_len = len(sys.argv)
    if argv_len == 4:  #min random, max random, size
        size = int(sys.argv[1])
        r_min = int(sys.argv[2])
        r_max = int(sys.argv[3])
        if size > MAX_SCHEDULE_SIZE:
            print("adjusted size of schedule from", size, "to maximum size:",
                  MAX_SCHEDULE_SIZE)
            size = MAX_SCHEDULE_SIZE

        output_file_name = "ts.%d-%d-%d.dat" % (size, r_min, r_max)
        print(output_file_name)

        schedule, ts_lookup = generate_schedule(size, r_min, r_max)
        send_schedule(GPIO, SPI, schedule)

    elif argv_len == 3:  #period, size
        is_periodic = True
        size = int(sys.argv[1])
        period = int(sys.argv[2])
        output_file_name = "ts.%d-%d.dat" % (size, period)
        print(output_file_name)
        ts_lookup = send_periodic_schedule(GPIO, SPI, size, period)
        rec_counter_packets(GPIO, SPI, ts_lookup, output_file_name,
                            is_periodic, adjust_ids)
        return

    elif argv_len == 2:  #filename
        file_name = sys.argv[1]
        output_file_name = "ts.%s" % (file_name)
        print(output_file_name)

        schedule, ts_lookup = get_schedule(file_name)
        send_schedule(GPIO, SPI, schedule)

    else:
        print("No clue what this input is, wrong length")
        return

    adjust_ids = ids_adjust_packets(schedule)
    t0 = 2000
    wait_t0(GPIO, SPI, t0, adjust_ids)
    rec_counter_packets(GPIO, SPI, ts_lookup, output_file_name, is_periodic,
                        adjust_ids)
    return
Esempio n. 30
0
#!/usr/bin/python

import gpio
from gpio import read

print 'button=', read(95)
print 'led-G=', read(65)
print 'led-A=', read(90)
print 'led-R=', read(91)
Esempio n. 31
0
#poziom logów
gpio.log.setLevel(logging.INFO)

#zmienne stanów
state = 0
last_state = 0

#ustawienie pinów w stan wejścia/wyjścia
#gpio.setup(504, gpio.OUT) #504/505
gpio.setup(488, gpio.IN)

client = mqtt.Client()
client.connect("localhost", 1883, 60)

#nasłuchiwanie zmian
while (True):
    state = gpio.read(488)

    if state != last_state and state:
        client.publish("gpio/488", "1")
        #gpio.set(504,1)
        print("Włączanie diody")
    elif state != last_state and state == 0:
        client.publish("gpio/488", "0")
        #gpio.set(504,0)
        print("Wyłączanie diody")

    last_state = state

    time.sleep(0.5)
Esempio n. 32
0
import gpio

register = gpio.read(18)
print "Read: 0x%08X" % register

gpio.write(18, 0)