123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- """
- Author: Tobias Müller
- Date: 30.06.2023
- Version: 1.0
- Main File to run on the pico.
- """
- ############################## Modules ##############################
- from Libs.LCD_Shield import LCD
- from time import sleep_us
- from machine import Pin
- ############################## Global Variables ##############################
- Display = LCD()
- ############################## Main ##############################
- def main():
- """
- Main Program
- """
- ########################## Local Variables ############################
- button_up = Pin(6,Pin.IN,Pin.PULL_DOWN)
- button_down = Pin(7,Pin.IN,Pin.PULL_DOWN)
- button_right = Pin(8,Pin.IN,Pin.PULL_DOWN)
- button_left = Pin(9,Pin.IN,Pin.PULL_DOWN)
- led_green = Pin(16,Pin.OUT)
- led_red = Pin(17,Pin.OUT)
-
- ########################## Code ############################
- led_green.on()
- led_red.on()
- Display.lcd_line_mode = 3
- Display.print("Hochschule Anhalt")
- for _ in range(0,3):
- for brightness in range(0,105,5):
- Display.lcd_brightness = brightness
- sleep_us(25000)
- for brightness in range(0,105,5):
- Display.lcd_brightness = 100 - brightness
- sleep_us(20000)
- Display.clear()
- Display.print("LCD Shield testing:")
- for brightness in range(0,105,5):
- Display.lcd_brightness = brightness
- sleep_us(20000)
- sleep_us(2000000)
- while True:
- if button_up.value():
- Display.clear()
- Display.lcd_line_mode = 0
- Display.print("button", row=1)
- Display.print("up *", row=2)
- Display.print("* *", row=3, column=7)
- Display.print("*", row=4, column=8)
- led_red.off()
- sleep_us(300000)
- Display.clear(row=2, column=8)
- led_red.on()
- sleep_us(300000)
- elif button_down.value():
- Display.clear()
- Display.lcd_line_mode = 0
- Display.print("button down * * * *")
- led_green.off()
- sleep_us(300000)
- Display.clear(row=4)
- led_green.on()
- sleep_us(300000)
- elif button_left.value():
- Display.clear()
- Display.lcd_line_mode = 0
- Display.print("button", row=1)
- Display.print("left *", row=2)
- Display.print("* *", row=3, column=7)
- Display.print("*", row=4, column=8)
- led_green.off()
- led_red.on()
- sleep_us(300000)
- Display.clear(row=3, column=7)
- led_green.on()
- led_red.off()
- sleep_us(300000)
- elif button_right.value():
- Display.clear()
- Display.lcd_line_mode = 0
- Display.print("button\nright *\n * *\n *")
- led_green.off()
- led_red.off()
- sleep_us(300000)
- Display.clear(row=3, column=9)
- led_green.on()
- led_red.on()
- sleep_us(300000)
- else:
- Display.clear()
- Display.lcd_line_mode = 2
- led_red.on()
- led_green.on()
- Display.print("LCD Shield")
- Display.print("a button", row=3, column=2)
- for pattern in range(0,9):
- if pattern == 0:
- Display.print(" push ", row=2)
- elif pattern == 1:
- Display.print("> push <", row=2)
- elif pattern == 2:
- Display.print(">> push <<", row=2)
- elif pattern == 3:
- Display.print(">>>push<<<", row=2)
- elif pattern == 4:
- Display.print(" >>push<< ", row=2)
- elif pattern == 5:
- Display.print(" >push< ", row=2)
- elif pattern == 6:
- Display.print(" push ", row=2)
- else:
- Display.clear(row=2)
- sleep_us(100000)
-
- ############################## Run ##############################
- if __name__ == "__main__":
- main()
|