Ejemplo n.º 1
0
    def start(self):
        # If there's no board, load one
        if not self.arduino:
            self.load_arduino()

        # Initialize iterator and pin (board communication)
        self.want_to_abort = False
        it = pyfirmata.util.Iterator(self.arduino)
        it.start()
        a_pin = self.arduino.analog[self.pin]
        a_pin.enable_reporting()
        # Allow board time to settle
        time.sleep(0.1)

        while True:
            value = a_pin.read()

            self.count += 1
            self.ind.append( self.count )
            self.result.append(value)

            pv.update()
            time.sleep(self.rate)
     
            if self.want_to_abort: 
                # Shutdown pin and board
                a_pin.disable_reporting()
                self.arduino.exit()
                self.arduino = None
                break
Ejemplo n.º 2
0
 def do_it(self):
     if self.op == 'add':
         self.result = operator.add(self.first, self.second)
     elif self.op == 'subtract':
         self.result = operator.sub(self.first, self.second)
     
     print('{0} {1} {2} = {3}'.format(self.first, self.op, self.second, self.result))
     pv.update()
Ejemplo n.º 3
0
    def do_it(self):
        if self.op == 'add':
            self.result = operator.add(self.first, self.second)
        elif self.op == 'subtract':
            self.result = operator.sub(self.first, self.second)

        print('{0} {1} {2} = {3}'.format(self.first, self.op, self.second,
                                         self.result))
        pv.update()
Ejemplo n.º 4
0
    def start(self):
        self.want_to_abort = False

        while True:
            self.count += 1
            self.ind.append(self.count)
            self.result.append(np.random.randn(1))

            pv.update()

            time.sleep(0.1)
            if self.want_to_abort: break
Ejemplo n.º 5
0
    def do_it(self):
        if self.op == 'add':
            res = operator.add(self.first, self.second)
        elif self.op == 'subtract':
            res = operator.sub(self.first, self.second)

        self.count += 1
        self.ind.append(self.count)
        self.result.append(res)

        print('{0} {1} {2} = {3}'.format(self.first, self.op, self.second, res))
        pv.update()
Ejemplo n.º 6
0
    def do_it(self):
        if self.op == 'add':
            res = operator.add(self.first, self.second)
        elif self.op == 'subtract':
            res = operator.sub(self.first, self.second)

        self.count += 1
        self.ind.append(self.count)
        self.result.append(res)

        print('{0} {1} {2} = {3}'.format(self.first, self.op, self.second,
                                         res))
        pv.update()