the public repo for the e-paper bulletin board. It's a bulletin board that syncs over scuttlebutt :)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.3 KiB

5 months ago
  1. # /*****************************************************************************
  2. # * | File : EPD_1in54.py
  3. # * | Author : Waveshare team
  4. # * | Function : Hardware underlying interface
  5. # * | Info :
  6. # *----------------
  7. # * | This version: V2.0
  8. # * | Date : 2018-11-01
  9. # * | Info :
  10. # * 1.Remove:
  11. # digital_write(self, pin, value)
  12. # digital_read(self, pin)
  13. # delay_ms(self, delaytime)
  14. # set_lut(self, lut)
  15. # self.lut = self.lut_full_update
  16. # ******************************************************************************/
  17. # Permission is hereby granted, free of charge, to any person obtaining a copy
  18. # of this software and associated documnetation files (the "Software"), to deal
  19. # in the Software without restriction, including without limitation the rights
  20. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  21. # copies of the Software, and to permit persons to whom the Software is
  22. # furished to do so, subject to the following conditions:
  23. #
  24. # The above copyright notice and this permission notice shall be included in
  25. # all copies or substantial portions of the Software.
  26. #
  27. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  28. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  29. # FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  30. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  31. # LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  32. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  33. # THE SOFTWARE.
  34. #
  35. import spidev
  36. import RPi.GPIO as GPIO
  37. import time
  38. # Pin definition
  39. RST_PIN = 17
  40. DC_PIN = 25
  41. CS_PIN = 8
  42. BUSY_PIN = 24
  43. # SPI device, bus = 0, device = 0
  44. SPI = spidev.SpiDev(0, 0)
  45. def digital_write(pin, value):
  46. GPIO.output(pin, value)
  47. def digital_read(pin):
  48. return GPIO.input(BUSY_PIN)
  49. def delay_ms(delaytime):
  50. time.sleep(delaytime / 1000.0)
  51. def spi_writebyte(data):
  52. SPI.writebytes(data)
  53. def module_init():
  54. GPIO.setmode(GPIO.BCM)
  55. GPIO.setwarnings(False)
  56. GPIO.setup(RST_PIN, GPIO.OUT)
  57. GPIO.setup(DC_PIN, GPIO.OUT)
  58. GPIO.setup(CS_PIN, GPIO.OUT)
  59. GPIO.setup(BUSY_PIN, GPIO.IN)
  60. SPI.max_speed_hz = 2000000
  61. SPI.mode = 0b00
  62. return 0;
  63. ### END OF FILE ###