mend
This commit is contained in:
parent
7791c55969
commit
5f9e718f86
6 changed files with 177 additions and 62 deletions
60
src/main.py
60
src/main.py
|
|
@ -87,6 +87,7 @@ def fafo():
|
|||
bgr = f.read(3)
|
||||
tft._pushcolor(TFTColor(bgr[2],bgr[1],bgr[0]))
|
||||
time.sleep(5)
|
||||
tft.fill(TFT.BLACK)
|
||||
def tftprinttest():
|
||||
tft.fill(TFT.BLACK)
|
||||
v = 30
|
||||
|
|
@ -132,6 +133,7 @@ def start_view(state, rotary):
|
|||
#print(rotary.value())
|
||||
|
||||
def draw_edit_menu(state, rotary):
|
||||
tft.fill(TFT.BLACK)
|
||||
display.print("Deposit speed:")
|
||||
display.print("{: >{w}} RPM".format(config["deposit_rpm"], w=5))
|
||||
display.print("Coating speed:")
|
||||
|
|
@ -160,7 +162,6 @@ def draw_rpm(rpm):
|
|||
|
||||
|
||||
def deposit_view(state, rotary):
|
||||
# display.fill_rect(0, 0, 127, 14, 1)
|
||||
display.print("Deposit")
|
||||
draw_rpm(state["rpm"])
|
||||
display.print("Press to")
|
||||
|
|
@ -176,6 +177,7 @@ def coating_view(state, rotary):
|
|||
|
||||
#def decode_ESC_telemetry(data, motor_poles=14):
|
||||
# if len(data) > 10:
|
||||
# display.fill_rect(0, 0, 127, 14, 1)
|
||||
# # use latest telemetry
|
||||
# data = data[-10:]
|
||||
#
|
||||
|
|
@ -190,13 +192,13 @@ def coating_view(state, rotary):
|
|||
# erpm = int((data[7] << 8) | data[8]) * 100
|
||||
# rpm = erpm / (motor_poles / 2)
|
||||
# crc = data[9]
|
||||
#
|
||||
# print(" Temp (C):", temperature)
|
||||
# print(" Voltage (V):", voltage)
|
||||
# print(" Current (A):", current)
|
||||
# print("Consumption (mAh):", consumption)
|
||||
# print(" Erpm:", erpm)
|
||||
# print(" RPM:", rpm)
|
||||
#
|
||||
# print(" CRC:", crc)
|
||||
# print()
|
||||
#
|
||||
|
|
@ -207,7 +209,6 @@ async def update_display():
|
|||
global state
|
||||
global rotary
|
||||
while True:
|
||||
display.print("LOLOLOL")
|
||||
state["view"](state, rotary)
|
||||
await uasyncio.sleep_ms(200)
|
||||
|
||||
|
|
@ -263,7 +264,7 @@ def timer_callback(f):
|
|||
def kill_me(f):
|
||||
state["target_rpm"] = 0
|
||||
|
||||
def update_motor_pwm():
|
||||
async def update_motor_pwm():
|
||||
global timer3
|
||||
global current_rpm
|
||||
pwm = PWM(Pin(26))
|
||||
|
|
@ -279,30 +280,14 @@ def update_motor_pwm():
|
|||
pwm.freq(50)
|
||||
|
||||
timer3.init(mode=Timer.PERIODIC, period=100, callback=timer_callback)
|
||||
pwm.duty_ns(1055*10**3)
|
||||
time.sleep(1)
|
||||
|
||||
print((current_rpm*60)/COILS)
|
||||
pwm.duty_ns(1055*10**3)
|
||||
|
||||
#pwm.duty_ns(1200*10**3)
|
||||
#global rpm_counter
|
||||
#rpm_counter= 0
|
||||
#time.sleep(10)
|
||||
|
||||
# time.sleep(10) # keep low signal to arm
|
||||
# # for i in range(1060,1800):
|
||||
# # pwm.duty_u16(i*3)
|
||||
# # time.sleep(1)
|
||||
# pwm.duty_ns(1070*10**3)
|
||||
# pwm.duty_u16(1700)
|
||||
# time.sleep(200)
|
||||
pwm.duty_ns(1060*10**3)
|
||||
state["target_rpm"] = 5000
|
||||
timer2.init(mode=Timer.PERIODIC, period=10000, callback=kill_me)
|
||||
|
||||
time.sleep(3)
|
||||
print((current_rpm*60)/COILS)
|
||||
state["target_rpm"] = 4000
|
||||
coating_time = config["coating_time"]*1000
|
||||
timer2.init(mode=Timer.PERIODIC, period=coating_time, callback=kill_me)
|
||||
|
||||
while(True):
|
||||
|
||||
print(f'target RPM:{state["target_rpm"]}')
|
||||
rpm_pid.setpoint = state["target_rpm"]
|
||||
|
||||
|
|
@ -323,15 +308,14 @@ def update_motor_pwm():
|
|||
if state["target_rpm"] == 0:
|
||||
print("Killing Coater!")
|
||||
throttle = 0
|
||||
rpm_pid.reset()
|
||||
#pwm.duty_ns(1800*10**3)
|
||||
#time.sleep(3)
|
||||
#return
|
||||
print(throttle)
|
||||
|
||||
if throttle !=0:
|
||||
new_duty = 1060+(int(660*throttle))
|
||||
# print(throttle)
|
||||
new_duty = 1055+(int(665*throttle))
|
||||
print(new_duty)
|
||||
pwm.duty_ns(new_duty*10**3)
|
||||
else:
|
||||
print("KILLED!")
|
||||
new_duty = 1055
|
||||
pwm.duty_ns(new_duty*10**3)
|
||||
timer2.deinit()
|
||||
|
|
@ -392,7 +376,6 @@ def on_button_press(p):
|
|||
if state["view"] == edit_coating_rpm_view:
|
||||
state["view"] = edit_coating_time_view
|
||||
rotary.set(
|
||||
max_val=1000,
|
||||
min_val=0,
|
||||
max_val=9999,
|
||||
range_mode=RotaryIRQ.RANGE_BOUNDED,
|
||||
|
|
@ -521,14 +504,15 @@ tft.fill(TFT.BLACK)
|
|||
|
||||
# splash()
|
||||
fafo()
|
||||
tft.fill(TFT.BLACK)
|
||||
# for ff in fonts:
|
||||
# display.set_font(ff)
|
||||
# display.print(text)
|
||||
update_motor_pwm()
|
||||
#update_motor_pwm()
|
||||
event_loop = uasyncio.get_event_loop()
|
||||
# event_loop.create_task(update_display())
|
||||
|
||||
# #event_loop.create_task(update_motor_pwm())
|
||||
# event_loop.run_forever()
|
||||
event_loop.create_task(update_display())
|
||||
update_display()
|
||||
#event_loop.create_task(update_motor_pwm())
|
||||
#event_loop.run_forever()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue