epdconfig.py 2.3 KB

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