__init__.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #! /usr/bin/python3
  2. # Copyright 2017 Digital
  3. #
  4. # This file is part of BeeWatch.
  5. #
  6. # BeeWatch is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # BeeWatch is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with BeeWatch. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. # Python Libraries
  20. import logging
  21. # import time
  22. import trio
  23. # My Libraries
  24. import digilib.pin
  25. log = logging.getLogger(__name__+"")
  26. lpin = logging.getLogger(__name__+".pin")
  27. # log = logging.getLogger(__name__+"")
  28. print("*"*20)
  29. print("USE TRIO WHEN CODING THE PIN STUFF")
  30. print("this message is printed by {}".format(__file__))
  31. print("*"*20)
  32. class LoadCell(digilib.pin.PinControllerBase):
  33. """interface for a single load cell"""
  34. pass
  35. class BeeWeighingScale(digilib.pin.PinAPIBase):
  36. """handles all load cells"""
  37. pass
  38. class PinAPIBee(digilib.pin.PinAPIBase):
  39. engine_left = None
  40. engine_right = None
  41. def __init__(self):
  42. super(PinAPIBee,self).__init__()
  43. self.engine_right = self.make_engine(4,17)
  44. self.engine_left = self.make_engine(27,22)
  45. def make_engine(self,*args):
  46. return digilib.pin.PCEngine(*args)
  47. def turn_left(self):
  48. right_on = self.engine_right.is_on
  49. right_speed = self.engine_right.speed
  50. left_on = self.engine_left.is_on
  51. left_speed = self.engine_left.speed
  52. self.engine_right.turn_on()
  53. self.engine_right.set_speed(1)
  54. self.engine_left.turn_on()
  55. self.engine_left.set_speed(1)
  56. trio.sleep(2)
  57. if not right_on:
  58. self.engine_right.turn_off()
  59. self.engine_right.set_speed(right_speed)
  60. if not left_on:
  61. self.engine_left.turn_off()
  62. self.engine_left.set_speed(left_speed)
  63. # set engines to previous values
  64. def turn_right(self):
  65. pass
  66. lpin.info("turning right is not implemented")
  67. # self.engine_left.stop()
  68. # self.engine_right.start()
  69. # set engines to previous values