lcd.py 1.5 KB

123456789101112131415161718192021222324252627
  1. #
  2. # Copyright (c) 2006-2019, RT-Thread Development Team
  3. #
  4. # SPDX-License-Identifier: MIT License
  5. #
  6. # Change Logs:
  7. # Date Author Notes
  8. # 2019-06-13 SummerGift first version
  9. #
  10. from machine import LCD # Import the LCD class from machine
  11. lcd = LCD() # Create a LCD object
  12. lcd.light(False) # Close the backlight
  13. lcd.light(True) # Open the backlight
  14. lcd.fill(lcd.BLACK) # Fill the entire LCD with black
  15. lcd.fill(lcd.RED) # Fill the entire LCD with red
  16. lcd.fill(lcd.GRAY) # Fill the entire LCD with gray
  17. lcd.fill(lcd.WHITE) # Fill the entire LCD with white
  18. lcd.pixel(50, 50, lcd.BLUE) # fills the pixels in the (50,50) position with blue
  19. lcd.text("hello RT-Thread", 0, 0, 16) # prints the string at 16 font size at position (0, 0)
  20. lcd.text("hello RT-Thread", 0, 16, 24) # prints the string at 24 font size at position (0, 16)
  21. lcd.text("hello RT-Thread", 0, 48, 32) # prints the string at 32 font size at position (0, 48)
  22. lcd.line(0, 50, 239, 50) # Draw a line starting at (0,50) and ending at (239,50)
  23. lcd.line(0, 50, 239, 50) # Draw a line starting at (0,50) and ending at (239,50)
  24. lcd.rectangle(100, 100, 200, 200) # Draw a rectangle with the top left corner (100,100) and the bottom right corner (200,200)
  25. lcd.circle(150, 150, 80) # Draw a circle with a radius of 80 at the center (150,150)