def blink_led(self,
               times=1,
               on_seconds=0.1,
               off_seconds=0.1,
               forever=False):
     led.blink_on_board_led(times=times,
                            forever=forever,
                            on_seconds=on_seconds,
                            off_seconds=off_seconds)
Exemple #2
0
    def setup_wifi():
        def wait_for_wifi():
            import network

            sta_if = network.WLAN(network.STA_IF)
            if not sta_if.isconnected():
                print('connecting to network...')
                sta_if.active(True)
                # sta_if.connect(SSID, PASSWORD)
                while not sta_if.isconnected():
                    pass
            print('Network configuration:', sta_if.ifconfig())

        wait_for_wifi()

        import led
        led.blink_on_board_led(times=2)
    def fire(self, ):
        led.blink_on_board_led(times=1, on_seconds=0.1, off_seconds=0.1)

        self.log('{0} fires.'.format(self.name))
        self.setOutputActive()

        # kick down-stream neurons
        connections = self.getConnections()

        for connection in connections.keys():
            # send message to kick other neurons
            message = {
                'receiver': connection,
                'message_type': 'function',
                'function': 'kick',
                'kwargs': {
                    'neuron_id': self.name
                }
            }
            self.request(message)
# coding: utf-8


def wait_for_wifi():
    import network

    sta_if = network.WLAN(network.STA_IF)
    if not sta_if.isconnected():
        print('connecting to network...')
        sta_if.active(True)
        # sta_if.connect(SSID, PASSWORD)
        # sta_if.connect('SSID', '')
        while not sta_if.isconnected():
            pass
    print('Network configuration:', sta_if.ifconfig())


wait_for_wifi()

import led
led.blink_on_board_led(times=2)

import node
node.main()