bug fixing...
This commit is contained in:
		
							parent
							
								
									10bdaee926
								
							
						
					
					
						commit
						137a385707
					
				
					 2 changed files with 41 additions and 120 deletions
				
			
		|  | @ -125,7 +125,9 @@ class TFT(object) : | ||||||
| 
 | 
 | ||||||
|   def size( self ) : |   def size( self ) : | ||||||
|     return self._size |     return self._size | ||||||
| 
 |   def reset_pos(self): | ||||||
|  |     self.x = 0 | ||||||
|  |     self.y = 0 | ||||||
| #   @micropython.native | #   @micropython.native | ||||||
|   def on( self, aTF = True ) : |   def on( self, aTF = True ) : | ||||||
|     '''Turn display on or off.''' |     '''Turn display on or off.''' | ||||||
|  |  | ||||||
							
								
								
									
										157
									
								
								src/main.py
									
										
									
									
									
								
							
							
						
						
									
										157
									
								
								src/main.py
									
										
									
									
									
								
							|  | @ -10,16 +10,18 @@ import tt14 | ||||||
| import tt24 | import tt24 | ||||||
| import tt32 | import tt32 | ||||||
| import uasyncio | import uasyncio | ||||||
|  | import time | ||||||
|  | import math | ||||||
| from rotary_irq_esp import RotaryIRQ | from rotary_irq_esp import RotaryIRQ | ||||||
| fonts = [glcdfont,tt14,tt24,tt32] | fonts = [glcdfont,tt14,tt24,tt32] | ||||||
| from sysfont import sysfont | from sysfont import sysfont | ||||||
| import json | import json | ||||||
| from enum import Enum | # from enum import Enum | ||||||
| 
 | 
 | ||||||
| class EditMenu(Enum): | # class EditMenu(Enum): | ||||||
|     DEPOSIT = 1 | #     DEPOSIT = 1 | ||||||
|     COATING = 2 | #     COATING = 2 | ||||||
|     TIME = 3 | #     TIME = 3 | ||||||
| def splash(): | def splash(): | ||||||
|     # display.fill(0) |     # display.fill(0) | ||||||
|     # display.fill_rect(0, 0, 32, 32, 1) |     # display.fill_rect(0, 0, 32, 32, 1) | ||||||
|  | @ -43,41 +45,40 @@ def splash(): | ||||||
| 
 | 
 | ||||||
|     # #display.show() |     # #display.show() | ||||||
| 
 | 
 | ||||||
| # def tftprinttest(): | def tftprinttest(): | ||||||
| #     tft.fill(TFT.BLACK); |     tft.fill(TFT.BLACK) | ||||||
| #     v = 30 |     v = 30 | ||||||
| #     tft.text((0, v), "Hello World!", TFT.RED, sysfont, 1, nowrap=True) |     tft.text((0, v), "Hello World!", TFT.RED, sysfont, 1, nowrap=True) | ||||||
| #     v += sysfont["Height"] |     v += sysfont["Height"] | ||||||
| #     tft.text((0, v), "Hello World!", TFT.YELLOW, sysfont, 2, nowrap=True) |     tft.text((0, v), "Hello World!", TFT.YELLOW, sysfont, 2, nowrap=True) | ||||||
| #     v += sysfont["Height"] * 2 |     v += sysfont["Height"] * 2 | ||||||
| #     tft.text((0, v), "Hello World!", TFT.GREEN, sysfont, 3, nowrap=True) |     tft.text((0, v), "Hello World!", TFT.GREEN, sysfont, 3, nowrap=True) | ||||||
| #     v += sysfont["Height"] * 3 |     v += sysfont["Height"] * 3 | ||||||
| #     tft.text((0, v), str(1234.567), TFT.BLUE, sysfont, 4, nowrap=True) |     tft.text((0, v), str(1234.567), TFT.BLUE, sysfont, 4, nowrap=True) | ||||||
| #     time.sleep_ms(1500) |     time.sleep_ms(100) | ||||||
| #     tft.fill(TFT.BLACK); |     tft.fill(TFT.BLACK) | ||||||
| #     v = 0 |     v = 0 | ||||||
| #     tft.text((0, v), "Hello World!", TFT.RED, sysfont) |     tft.text((0, v), "Hello World!", TFT.RED, sysfont) | ||||||
| #     v += sysfont["Height"] |     v += sysfont["Height"] | ||||||
| #     tft.text((0, v), str(math.pi), TFT.GREEN, sysfont) |     tft.text((0, v), str(math.pi), TFT.GREEN, sysfont) | ||||||
| #     v += sysfont["Height"] |     v += sysfont["Height"] | ||||||
| #     tft.text((0, v), " Want pi?", TFT.GREEN, sysfont) |     tft.text((0, v), " Want pi?", TFT.GREEN, sysfont) | ||||||
| #     v += sysfont["Height"] * 2 |     v += sysfont["Height"] * 2 | ||||||
| #     tft.text((0, v), hex(8675309), TFT.GREEN, sysfont) |     tft.text((0, v), hex(8675309), TFT.GREEN, sysfont) | ||||||
| #     v += sysfont["Height"] |     v += sysfont["Height"] | ||||||
| #     tft.text((0, v), " Print HEX!", TFT.GREEN, sysfont) |     tft.text((0, v), " Print HEX!", TFT.GREEN, sysfont) | ||||||
| #     v += sysfont["Height"] * 2 |     v += sysfont["Height"] * 2 | ||||||
| #     tft.text((0, v), "Sketch has been", TFT.WHITE, sysfont) |     tft.text((0, v), "Sketch has been", TFT.WHITE, sysfont) | ||||||
| #     v += sysfont["Height"] |     v += sysfont["Height"] | ||||||
| #     tft.text((0, v), "running for: ", TFT.WHITE, sysfont) |     tft.text((0, v), "running for: ", TFT.WHITE, sysfont) | ||||||
| #     v += sysfont["Height"] |     v += sysfont["Height"] | ||||||
| #     tft.text((0, v), str(time.ticks_ms() / 1000), TFT.PURPLE, sysfont) |     tft.text((0, v), str(time.ticks_ms() / 1000), TFT.PURPLE, sysfont) | ||||||
| #     v += sysfont["Height"] |     v += sysfont["Height"] | ||||||
| #     tft.text((0, v), " seconds.", TFT.WHITE, sysfont) |     tft.text((0, v), " seconds.", TFT.WHITE, sysfont) | ||||||
| 
 | 
 | ||||||
| def start_view(state, rotary): | def start_view(state, rotary): | ||||||
|      |      | ||||||
|     display.set_pos(0,0) |     display.set_pos(0,0) | ||||||
| <<<<<<< HEAD |  | ||||||
|     text="Spin Coater" |     text="Spin Coater" | ||||||
|     display.print(text,size=2) |     display.print(text,size=2) | ||||||
| 
 | 
 | ||||||
|  | @ -96,50 +97,20 @@ def draw_edit_menu(state, rotary): | ||||||
|     display.print("Coating time:") |     display.print("Coating time:") | ||||||
|     display.print("{: >{w}} sec".format(config["coating_time"],w=2)) |     display.print("{: >{w}} sec".format(config["coating_time"],w=2)) | ||||||
|     display.reset_pos() |     display.reset_pos() | ||||||
| ======= |  | ||||||
|     text="Spin Coater\n" |  | ||||||
|     #display.set_font(tt14) |  | ||||||
|     text += "> " if rotary.value() == 0 else "     " |  | ||||||
|     text+="Edit\n" |  | ||||||
|     text+= "> " if rotary.value() == 1 else "     " |  | ||||||
|     text+= "Start\n" |  | ||||||
|     display.print(text) |  | ||||||
|     #print(rotary.value()) |  | ||||||
| 
 |  | ||||||
| def draw_edit_menu(state, rotary): |  | ||||||
|     display.text("Deposit speed:", 0, 0, 1) |  | ||||||
|     display.text("{: >{w}} RPM".format(config["deposit_rpm"], w=5), 56, 10, 1) |  | ||||||
|     display.text("Coating speed:", 0, 21, 1) |  | ||||||
|     display.text("{: >{w}} RPM".format(config["coating_rpm"], w=5), 56, 31, 1) |  | ||||||
|     display.text("Coating time:", 0, 42, 1) |  | ||||||
|     display.text("{: >{w}} sec".format(config["coating_time"], w=5), 56, 52, 1) |  | ||||||
| 
 |  | ||||||
| >>>>>>> refs/remotes/origin/main |  | ||||||
| 
 | 
 | ||||||
| def edit_deposit_view(state, rotary): | def edit_deposit_view(state, rotary): | ||||||
|     config["deposit_rpm"] = rotary.value() * 100 |     config["deposit_rpm"] = rotary.value() * 100 | ||||||
|     draw_edit_menu(state, rotary) |     draw_edit_menu(state, rotary) | ||||||
| <<<<<<< HEAD |  | ||||||
| ======= |  | ||||||
|     display.text(">", 40, 10, 1) |  | ||||||
| >>>>>>> refs/remotes/origin/main |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def edit_coating_rpm_view(state, rotary): | def edit_coating_rpm_view(state, rotary): | ||||||
|     config["coating_rpm"] = rotary.value() * 100 |     config["coating_rpm"] = rotary.value() * 100 | ||||||
| <<<<<<< HEAD |  | ||||||
| 
 |  | ||||||
|     draw_edit_menu(state, rotary) |     draw_edit_menu(state, rotary) | ||||||
| ======= |  | ||||||
|     draw_edit_menu(state, rotary) |  | ||||||
|     display.text(">", 40, 32, 1) |  | ||||||
| >>>>>>> refs/remotes/origin/main |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def edit_coating_time_view(state, rotary): | def edit_coating_time_view(state, rotary): | ||||||
|     config["coating_time"] = rotary.value() |     config["coating_time"] = rotary.value() | ||||||
|     draw_edit_menu(state, rotary) |     draw_edit_menu(state, rotary) | ||||||
| <<<<<<< HEAD |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def draw_rpm(rpm): | def draw_rpm(rpm): | ||||||
|  | @ -159,28 +130,6 @@ def coating_view(state, rotary): | ||||||
|     display.text("Coating") |     display.text("Coating") | ||||||
|     draw_rpm(state["rpm"]) |     draw_rpm(state["rpm"]) | ||||||
|     display.text("{: >{w}} sec".format(state["timer"], w=4)) |     display.text("{: >{w}} sec".format(state["timer"], w=4)) | ||||||
| ======= |  | ||||||
|     display.text(">", 40, 54, 1) |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| def draw_rpm(rpm): |  | ||||||
|     display.text("RPM:{: >{w}.0f}".format(rpm, w=5), 30, 27, 1) |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| def deposit_view(state, rotary): |  | ||||||
|     display.fill_rect(0, 0, 127, 14, 1) |  | ||||||
|     display.text("Deposit", 36, 3, 0) |  | ||||||
|     draw_rpm(state["rpm"]) |  | ||||||
|     display.text("Press to", 32, 42, 1) |  | ||||||
|     display.text("continue", 32, 52, 1) |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| def coating_view(state, rotary): |  | ||||||
|     display.fill_rect(0, 0, 127, 14, 1) |  | ||||||
|     display.text("Coating", 36, 3, 0) |  | ||||||
|     draw_rpm(state["rpm"]) |  | ||||||
|     display.text("{: >{w}} sec".format(state["timer"], w=4), 30, 48, 1) |  | ||||||
| >>>>>>> refs/remotes/origin/main |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def decode_ESC_telemetry(data, motor_poles=14): | def decode_ESC_telemetry(data, motor_poles=14): | ||||||
|  | @ -218,12 +167,7 @@ async def update_display(): | ||||||
|     while True: |     while True: | ||||||
|         display.fill(color565(0,0,0)) |         display.fill(color565(0,0,0)) | ||||||
|         state["view"](state, rotary) |         state["view"](state, rotary) | ||||||
| <<<<<<< HEAD |         await uasyncio.sleep_ms(200) | ||||||
|         # display.show() |  | ||||||
| ======= |  | ||||||
|         display.show() |  | ||||||
| >>>>>>> refs/remotes/origin/main |  | ||||||
|         await uasyncio.sleep_ms(33) |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| async def update_motor(): | async def update_motor(): | ||||||
|  | @ -362,10 +306,6 @@ def save_config(): | ||||||
|     global config |     global config | ||||||
|     with open("config.json", "w") as f: |     with open("config.json", "w") as f: | ||||||
|         json.dump(config, f) |         json.dump(config, f) | ||||||
| <<<<<<< HEAD |  | ||||||
| 
 |  | ||||||
| ======= |  | ||||||
| >>>>>>> refs/remotes/origin/main |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -373,12 +313,9 @@ text = 'Now is the time for all good men to come to the aid of the party.' | ||||||
| 
 | 
 | ||||||
| power = Pin(m5stack.TFT_LED_PIN, Pin.OUT) | power = Pin(m5stack.TFT_LED_PIN, Pin.OUT) | ||||||
| power.value(1) | power.value(1) | ||||||
| <<<<<<< HEAD |  | ||||||
| timer1 = Timer(1) | timer1 = Timer(1) | ||||||
| timer2 = Timer(2) | timer2 = Timer(2) | ||||||
| ======= |  | ||||||
| 
 | 
 | ||||||
| >>>>>>> refs/remotes/origin/main |  | ||||||
| # No need to change the software. It's just a matter of different names.. Use this translation: | # No need to change the software. It's just a matter of different names.. Use this translation: | ||||||
| 
 | 
 | ||||||
| # SDO(MISO)	<not used> | # SDO(MISO)	<not used> | ||||||
|  | @ -407,10 +344,7 @@ spi = SPI( | ||||||
| #     h=128, | #     h=128, | ||||||
| #     r=5) | #     r=5) | ||||||
| tft = TFT(spi,m5stack.TFT_DC_PIN,m5stack.TFT_RST_PIN,m5stack.TFT_CS_PIN) | tft = TFT(spi,m5stack.TFT_DC_PIN,m5stack.TFT_RST_PIN,m5stack.TFT_CS_PIN) | ||||||
| <<<<<<< HEAD |  | ||||||
| display = tft | display = tft | ||||||
| ======= |  | ||||||
| >>>>>>> refs/remotes/origin/main |  | ||||||
| tft.initr() | tft.initr() | ||||||
| tft.rgb(True) | tft.rgb(True) | ||||||
| #tftprinttest() | #tftprinttest() | ||||||
|  | @ -432,7 +366,6 @@ state = { | ||||||
|     "timer": 0, |     "timer": 0, | ||||||
|     "rotary_val":-1 |     "rotary_val":-1 | ||||||
| } | } | ||||||
| <<<<<<< HEAD |  | ||||||
| with open("config.json", "r") as f: | with open("config.json", "r") as f: | ||||||
|     config = json.load(f) |     config = json.load(f) | ||||||
| #display.erase() | #display.erase() | ||||||
|  | @ -447,20 +380,6 @@ splash() | ||||||
| event_loop = uasyncio.get_event_loop() | event_loop = uasyncio.get_event_loop() | ||||||
| event_loop.create_task(update_display()) | event_loop.create_task(update_display()) | ||||||
| 
 | 
 | ||||||
| ======= |  | ||||||
| 
 |  | ||||||
| #display.erase() |  | ||||||
| #display.set_pos(0,0) |  | ||||||
| #display.set_font(tt32) |  | ||||||
| tft.fill(TFT.BLACK) |  | ||||||
| 
 |  | ||||||
| splash() |  | ||||||
| # for ff in fonts: |  | ||||||
| #     display.set_font(ff) |  | ||||||
| #     display.print(text) |  | ||||||
| event_loop = uasyncio.get_event_loop() |  | ||||||
| event_loop.create_task(update_display()) |  | ||||||
| >>>>>>> refs/remotes/origin/main |  | ||||||
| #event_loop.create_task(update_motor()) | #event_loop.create_task(update_motor()) | ||||||
| event_loop.run_forever() | event_loop.run_forever() | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Robert Schauklies
						Robert Schauklies