Added tests.py (just a file of me testing the functionality of the library)
This commit is contained in:
		
							
								
								
									
										52
									
								
								tests.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								tests.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,52 @@ | |||||||
|  | from lcdMenu import lcdMenu | ||||||
|  | import config | ||||||
|  | from config import LCD | ||||||
|  |  | ||||||
|  | """ | ||||||
|  | # testing different icon styles | ||||||
|  | LCD.custom_char(0, bytearray([0x00,0x04,0x04,0x04,0x15,0x0E,0x04,0x00]))  # arrow down (variant 1) | ||||||
|  | LCD.custom_char(1, bytearray([0x00,0x04,0x04,0x04,0x15,0x0A,0x04,0x00]))  # arrow down (variant 2) | ||||||
|  | LCD.custom_char(2, bytearray([0x00,0x00,0x00,0x00,0x11,0x0A,0x04,0x00]))  # arrow down (variant 3) | ||||||
|  | LCD.custom_char(3, bytearray([0x00,0x04,0x0E,0x15,0x04,0x04,0x04,0x00]))  # arrow up   (variant 1) | ||||||
|  | LCD.custom_char(4, bytearray([0x00,0x04,0x0A,0x15,0x04,0x04,0x04,0x00]))  # arrow up   (variant 2) | ||||||
|  | LCD.custom_char(5, bytearray([0x00,0x04,0x0A,0x11,0x00,0x00,0x00,0x00]))  # arrow up   (variant 3) | ||||||
|  | LCD.putstr(chr(0)+" "+chr(1)+" "+chr(2)+" "+chr(3)+" "+chr(4)+" "+chr(5)+"   <>") | ||||||
|  | """ | ||||||
|  |  | ||||||
|  | #LCD.putstr("<<<<<<<<>>>>>>>>< some tst itm >") | ||||||
|  | #LCD.putstr("<<<<<<<  >>>>>>>< some tst itm >") | ||||||
|  | #LCD.putstr("<              >< some tst itm >") | ||||||
|  | LCD.putstr("[ ------------ ]< some tst itm >") | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def some_print(): | ||||||
|  |     print("some_print() executed!") | ||||||
|  | def another_callback(): | ||||||
|  |     print("another_callback() executed") | ||||||
|  | def third(): | ||||||
|  |     print("third") | ||||||
|  |     return True | ||||||
|  | menuItems = [("some_print", some_print), | ||||||
|  |              ("another_entry", another_callback), | ||||||
|  |              ("third item", third)] | ||||||
|  | lm = lcdMenu(config.LCD, | ||||||
|  |              {"next_btn": config.BTN_1, "ok_btn": config.BTN_2}, | ||||||
|  |              menuItems, | ||||||
|  |              scroll_direction=True, cycle=True, | ||||||
|  |              hide_menu_name=False) | ||||||
|  |  | ||||||
|  | print(lm.current_selection) | ||||||
|  | lm.next_selection() | ||||||
|  | print(lm.current_selection) | ||||||
|  | lm.next_selection() | ||||||
|  | print(lm.current_selection) | ||||||
|  | lm.next_selection() | ||||||
|  | print(lm.current_selection) | ||||||
|  | print("--------") | ||||||
|  | print(lm.current_selection) | ||||||
|  | lm.previous_selection() | ||||||
|  | print(lm.current_selection) | ||||||
|  | lm.previous_selection() | ||||||
|  | print(lm.current_selection) | ||||||
|  | lm.previous_selection() | ||||||
|  | print(lm.current_selection) | ||||||
		Reference in New Issue
	
	Block a user