Compare commits
2 commits
59daa25a91
...
10bdaee926
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10bdaee926 | ||
|
|
bb33920af9 |
3 changed files with 99 additions and 3 deletions
|
|
@ -204,7 +204,8 @@ class ILI9341:
|
||||||
if not 0 <= x < self.width or not 0 <= y < self.height:
|
if not 0 <= x < self.width or not 0 <= y < self.height:
|
||||||
return
|
return
|
||||||
self._writeblock(x, y, x, y, ustruct.pack(">H", color))
|
self._writeblock(x, y, x, y, ustruct.pack(">H", color))
|
||||||
|
def fill(self,color):
|
||||||
|
self.fill_rectangle(0,0,self.width,self.height,color=color)
|
||||||
def fill_rectangle(self, x, y, w, h, color=None):
|
def fill_rectangle(self, x, y, w, h, color=None):
|
||||||
x = min(self.width - 1, max(0, x))
|
x = min(self.width - 1, max(0, x))
|
||||||
y = min(self.height - 1, max(0, y))
|
y = min(self.height - 1, max(0, y))
|
||||||
|
|
@ -305,7 +306,8 @@ class ILI9341:
|
||||||
if written<len(text):
|
if written<len(text):
|
||||||
curx = self.chars(text[written:], curx,cury)
|
curx = self.chars(text[written:], curx,cury)
|
||||||
self._x = curx; self._y = cury
|
self._x = curx; self._y = cury
|
||||||
|
def show(self):
|
||||||
|
return
|
||||||
|
|
||||||
def print(self, text): #does word wrap, leaves self._x unchanged
|
def print(self, text): #does word wrap, leaves self._x unchanged
|
||||||
cury = self._y; curx = self._x
|
cury = self._y; curx = self._x
|
||||||
|
|
@ -325,3 +327,5 @@ class ILI9341:
|
||||||
curx = self.chars(word+' ', curx,cury)
|
curx = self.chars(word+' ', curx,cury)
|
||||||
curx = self._x; cury = self.next_line(cury,char_h)
|
curx = self._x; cury = self.next_line(cury,char_h)
|
||||||
self._y = cury
|
self._y = cury
|
||||||
|
def text(self,text):
|
||||||
|
self.print(text)
|
||||||
92
src/main.py
92
src/main.py
|
|
@ -13,6 +13,13 @@ import uasyncio
|
||||||
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
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
class EditMenu(Enum):
|
||||||
|
DEPOSIT = 1
|
||||||
|
COATING = 2
|
||||||
|
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)
|
||||||
|
|
@ -70,6 +77,26 @@ def splash():
|
||||||
def start_view(state, rotary):
|
def start_view(state, rotary):
|
||||||
|
|
||||||
display.set_pos(0,0)
|
display.set_pos(0,0)
|
||||||
|
<<<<<<< HEAD
|
||||||
|
text="Spin Coater"
|
||||||
|
display.print(text,size=2)
|
||||||
|
|
||||||
|
#display.set_font(tt14)
|
||||||
|
before = "> " if rotary.value() == 0 else " "
|
||||||
|
display.print(before + "Edit")
|
||||||
|
before = "> " if rotary.value() == 1 else " "
|
||||||
|
display.print(before + "Start")
|
||||||
|
#print(rotary.value())
|
||||||
|
|
||||||
|
def draw_edit_menu(state, rotary):
|
||||||
|
display.print("Deposit speed:")
|
||||||
|
display.print("{: >{w}} RPM".format(config["deposit_rpm"], w=5))
|
||||||
|
display.print("Coating speed:")
|
||||||
|
display.print("{: >{w}} RPM".format(config["coating_rpm"], w=5))
|
||||||
|
display.print("Coating time:")
|
||||||
|
display.print("{: >{w}} sec".format(config["coating_time"],w=2))
|
||||||
|
display.reset_pos()
|
||||||
|
=======
|
||||||
text="Spin Coater\n"
|
text="Spin Coater\n"
|
||||||
#display.set_font(tt14)
|
#display.set_font(tt14)
|
||||||
text += "> " if rotary.value() == 0 else " "
|
text += "> " if rotary.value() == 0 else " "
|
||||||
|
|
@ -87,22 +114,52 @@ def draw_edit_menu(state, rotary):
|
||||||
display.text("Coating time:", 0, 42, 1)
|
display.text("Coating time:", 0, 42, 1)
|
||||||
display.text("{: >{w}} sec".format(config["coating_time"], w=5), 56, 52, 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)
|
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)
|
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):
|
||||||
|
display.print("RPM:{: >{w}.0f}".format(rpm, w=5))
|
||||||
|
|
||||||
|
|
||||||
|
def deposit_view(state, rotary):
|
||||||
|
# display.fill_rect(0, 0, 127, 14, 1)
|
||||||
|
display.text("Deposit")
|
||||||
|
draw_rpm(state["rpm"])
|
||||||
|
display.text("Press to")
|
||||||
|
display.text("continue")
|
||||||
|
|
||||||
|
|
||||||
|
def coating_view(state, rotary):
|
||||||
|
# display.fill_rect()
|
||||||
|
display.text("Coating")
|
||||||
|
draw_rpm(state["rpm"])
|
||||||
|
display.text("{: >{w}} sec".format(state["timer"], w=4))
|
||||||
|
=======
|
||||||
display.text(">", 40, 54, 1)
|
display.text(">", 40, 54, 1)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -123,6 +180,7 @@ def coating_view(state, rotary):
|
||||||
display.text("Coating", 36, 3, 0)
|
display.text("Coating", 36, 3, 0)
|
||||||
draw_rpm(state["rpm"])
|
draw_rpm(state["rpm"])
|
||||||
display.text("{: >{w}} sec".format(state["timer"], w=4), 30, 48, 1)
|
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):
|
||||||
|
|
@ -160,7 +218,11 @@ 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
|
||||||
|
# display.show()
|
||||||
|
=======
|
||||||
display.show()
|
display.show()
|
||||||
|
>>>>>>> refs/remotes/origin/main
|
||||||
await uasyncio.sleep_ms(33)
|
await uasyncio.sleep_ms(33)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -300,6 +362,10 @@ 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -307,7 +373,12 @@ 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)
|
||||||
|
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>
|
||||||
|
|
@ -336,6 +407,10 @@ 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
|
||||||
|
=======
|
||||||
|
>>>>>>> refs/remotes/origin/main
|
||||||
tft.initr()
|
tft.initr()
|
||||||
tft.rgb(True)
|
tft.rgb(True)
|
||||||
#tftprinttest()
|
#tftprinttest()
|
||||||
|
|
@ -357,6 +432,22 @@ state = {
|
||||||
"timer": 0,
|
"timer": 0,
|
||||||
"rotary_val":-1
|
"rotary_val":-1
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
|
with open("config.json", "r") as f:
|
||||||
|
config = json.load(f)
|
||||||
|
#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())
|
||||||
|
|
||||||
|
=======
|
||||||
|
|
||||||
#display.erase()
|
#display.erase()
|
||||||
#display.set_pos(0,0)
|
#display.set_pos(0,0)
|
||||||
|
|
@ -369,6 +460,7 @@ splash()
|
||||||
# display.print(text)
|
# display.print(text)
|
||||||
event_loop = uasyncio.get_event_loop()
|
event_loop = uasyncio.get_event_loop()
|
||||||
event_loop.create_task(update_display())
|
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()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ class Rotary(object):
|
||||||
self._listener.remove(l)
|
self._listener.remove(l)
|
||||||
|
|
||||||
def _process_rotary_pins(self, pin):
|
def _process_rotary_pins(self, pin):
|
||||||
print(self._value)
|
#print(self._value)
|
||||||
old_value = self._value
|
old_value = self._value
|
||||||
clk_dt_pins = (self._hal_get_clk_value() <<
|
clk_dt_pins = (self._hal_get_clk_value() <<
|
||||||
1) | self._hal_get_dt_value()
|
1) | self._hal_get_dt_value()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue