mirror of
https://github.com/eclipse/upm.git
synced 2025-07-02 09:51:14 +03:00
python_examples: Reformatted, self-checking, executable
* Moved body of each python example to main. This allows for basic load module testing for CI * General cleanup of python modules (crlf/tabs/prints/etc) * Chmod'ed to 755 to allow running examples without specifying the python interpreter * Added ctest for loading python2/3 modules * Added jniclasscode pragma for java swig interface files. * Updated check_examplenames.py module to check all languages vs. a cxx example name * Added tests for checking python module and test loading * Added 'make test' to travis-ci run (run ctests) * Print a more meaningful message when not building cxx docs into python modules * Updated check_clean.py to only check java wrapper files * ENABLED ctests for UPM * Deleted using_carrays.py python example - this is covered by other examples Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
92
examples/python/ili9341.py
Normal file → Executable file
92
examples/python/ili9341.py
Normal file → Executable file
@ -24,52 +24,56 @@
|
||||
import time
|
||||
import pyupm_ili9341 as ili9341
|
||||
|
||||
# Pins (Edison)
|
||||
# CS_LCD GP44 (MRAA 31)
|
||||
# CS_SD GP43 (MRAA 38) unused
|
||||
# DC GP12 (MRAA 20)
|
||||
# RESEST GP13 (MRAA 14)
|
||||
lcd = ili9341.ILI9341(31, 38, 20, 14)
|
||||
def main():
|
||||
# Pins (Edison)
|
||||
# CS_LCD GP44 (MRAA 31)
|
||||
# CS_SD GP43 (MRAA 38) unused
|
||||
# DC GP12 (MRAA 20)
|
||||
# RESEST GP13 (MRAA 14)
|
||||
lcd = ili9341.ILI9341(31, 38, 20, 14)
|
||||
|
||||
# Fill the screen with a solid color
|
||||
lcd.fillScreen(lcd.color565(0, 40, 16))
|
||||
# Fill the screen with a solid color
|
||||
lcd.fillScreen(lcd.color565(0, 40, 16))
|
||||
|
||||
# Draw some shapes
|
||||
lcd.drawFastVLine(10, 10, 100, ili9341.ILI9341_RED)
|
||||
lcd.drawFastHLine(20, 10, 50, ili9341.ILI9341_CYAN)
|
||||
lcd.drawLine(160, 30, 200, 60, ili9341.ILI9341_GREEN)
|
||||
lcd.fillRect(20, 30, 75, 60, ili9341.ILI9341_ORANGE)
|
||||
lcd.drawCircle(70, 50, 20, ili9341.ILI9341_PURPLE)
|
||||
lcd.fillCircle(120, 50, 20, ili9341.ILI9341_PURPLE)
|
||||
lcd.drawTriangle(50, 100, 10, 140, 90, 140, ili9341.ILI9341_YELLOW)
|
||||
lcd.fillTriangle(150, 100, 110, 140, 190, 140, ili9341.ILI9341_YELLOW)
|
||||
lcd.drawRoundRect(20, 150, 50, 30, 10, ili9341.ILI9341_RED)
|
||||
lcd.drawRoundRect(130, 150, 50, 30, 10, ili9341.ILI9341_RED)
|
||||
lcd.fillRoundRect(75, 150, 50, 30, 10, ili9341.ILI9341_RED)
|
||||
# Draw some shapes
|
||||
lcd.drawFastVLine(10, 10, 100, ili9341.ILI9341_RED)
|
||||
lcd.drawFastHLine(20, 10, 50, ili9341.ILI9341_CYAN)
|
||||
lcd.drawLine(160, 30, 200, 60, ili9341.ILI9341_GREEN)
|
||||
lcd.fillRect(20, 30, 75, 60, ili9341.ILI9341_ORANGE)
|
||||
lcd.drawCircle(70, 50, 20, ili9341.ILI9341_PURPLE)
|
||||
lcd.fillCircle(120, 50, 20, ili9341.ILI9341_PURPLE)
|
||||
lcd.drawTriangle(50, 100, 10, 140, 90, 140, ili9341.ILI9341_YELLOW)
|
||||
lcd.fillTriangle(150, 100, 110, 140, 190, 140, ili9341.ILI9341_YELLOW)
|
||||
lcd.drawRoundRect(20, 150, 50, 30, 10, ili9341.ILI9341_RED)
|
||||
lcd.drawRoundRect(130, 150, 50, 30, 10, ili9341.ILI9341_RED)
|
||||
lcd.fillRoundRect(75, 150, 50, 30, 10, ili9341.ILI9341_RED)
|
||||
|
||||
# Write some text
|
||||
lcd.setCursor(0, 200)
|
||||
lcd.setTextColor(ili9341.ILI9341_LIGHTGREY)
|
||||
lcd.setTextWrap(True)
|
||||
lcd.setTextSize(1)
|
||||
lcd._print("Text 1\n")
|
||||
lcd.setTextSize(2)
|
||||
lcd._print("Text 2\n")
|
||||
lcd.setTextSize(3)
|
||||
lcd._print("Text 3\n")
|
||||
lcd.setTextSize(4)
|
||||
lcd._print("Text 4\n")
|
||||
# Write some text
|
||||
lcd.setCursor(0, 200)
|
||||
lcd.setTextColor(ili9341.ILI9341_LIGHTGREY)
|
||||
lcd.setTextWrap(True)
|
||||
lcd.setTextSize(1)
|
||||
lcd._print("Text 1\n")
|
||||
lcd.setTextSize(2)
|
||||
lcd._print("Text 2\n")
|
||||
lcd.setTextSize(3)
|
||||
lcd._print("Text 3\n")
|
||||
lcd.setTextSize(4)
|
||||
lcd._print("Text 4\n")
|
||||
|
||||
# Test screen rotation
|
||||
for r in range(0, 4):
|
||||
lcd.setRotation(r)
|
||||
lcd.fillRect(0, 0, 5, 5, ili9341.ILI9341_WHITE)
|
||||
time.sleep(1)
|
||||
|
||||
# Invert colors, wait, then revert back
|
||||
lcd.invertDisplay(True)
|
||||
time.sleep(2)
|
||||
lcd.invertDisplay(False)
|
||||
# Test screen rotation
|
||||
for r in range(0, 4):
|
||||
lcd.setRotation(r)
|
||||
lcd.fillRect(0, 0, 5, 5, ili9341.ILI9341_WHITE)
|
||||
time.sleep(1)
|
||||
|
||||
# Don't forget to free up that memory!
|
||||
del lcd
|
||||
# Invert colors, wait, then revert back
|
||||
lcd.invertDisplay(True)
|
||||
time.sleep(2)
|
||||
lcd.invertDisplay(False)
|
||||
|
||||
# Don't forget to free up that memory!
|
||||
del lcd
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Reference in New Issue
Block a user