12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #! /usr/bin/python3
- # Copyright 2017 Digital
- #
- # This file is part of BeeWatch.
- #
- # BeeWatch is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # BeeWatch is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with BeeWatch. If not, see <http://www.gnu.org/licenses/>.
- #
- # Python Libraries
- import logging
- # import time
- import trio
- # My Libraries
- import digilib.pin
- log = logging.getLogger(__name__+"")
- lpin = logging.getLogger(__name__+".pin")
- # log = logging.getLogger(__name__+"")
- print("*"*20)
- print("USE TRIO WHEN CODING THE PIN STUFF")
- print("this message is printed by {}".format(__file__))
- print("*"*20)
- class LoadCell(digilib.pin.PinControllerBase):
- """interface for a single load cell"""
- pass
- class BeeWeighingScale(digilib.pin.PinAPIBase):
- """handles all load cells"""
- pass
- class PinAPIBee(digilib.pin.PinAPIBase):
- engine_left = None
- engine_right = None
- def __init__(self):
- super(PinAPIBee,self).__init__()
- self.engine_right = self.make_engine(4,17)
- self.engine_left = self.make_engine(27,22)
- def make_engine(self,*args):
- return digilib.pin.PCEngine(*args)
- def turn_left(self):
- right_on = self.engine_right.is_on
- right_speed = self.engine_right.speed
- left_on = self.engine_left.is_on
- left_speed = self.engine_left.speed
- self.engine_right.turn_on()
- self.engine_right.set_speed(1)
- self.engine_left.turn_on()
- self.engine_left.set_speed(1)
- trio.sleep(2)
- if not right_on:
- self.engine_right.turn_off()
- self.engine_right.set_speed(right_speed)
- if not left_on:
- self.engine_left.turn_off()
- self.engine_left.set_speed(left_speed)
- # set engines to previous values
- def turn_right(self):
- pass
- lpin.info("turning right is not implemented")
- # self.engine_left.stop()
- # self.engine_right.start()
- # set engines to previous values
|