|
|
@@ -53,7 +53,7 @@ class HeatPower():
|
|
|
# self.sw_pin.duty(180)
|
|
|
self.status = 0
|
|
|
self.duty = 0.0
|
|
|
- self.duty_percent(0.7)
|
|
|
+ self.off()
|
|
|
|
|
|
def duty_percent(self, percent):
|
|
|
if percent > 1:
|
|
|
@@ -88,10 +88,13 @@ class HeatPower():
|
|
|
def ajust_power(self, wt, ct):
|
|
|
if not self.status:
|
|
|
return
|
|
|
- if wt > 88 or ct > 45:
|
|
|
+ if wt > 88:
|
|
|
step = (88-wt)/100
|
|
|
self.ajust_duty(step)
|
|
|
# print('wt:', wt, "step:", step)
|
|
|
+ elif ct > 45:
|
|
|
+ step = (45-ct)/100
|
|
|
+ self.ajust_duty(step)
|
|
|
else:
|
|
|
step = (42-ct)/100
|
|
|
# print('ct:', ct, "step:", step)
|
|
|
@@ -107,17 +110,21 @@ async def cal_ntc():
|
|
|
center_ntc.cal_temperature()
|
|
|
await uasyncio.sleep_ms(200)
|
|
|
|
|
|
+
|
|
|
async def sensor():
|
|
|
uasyncio.create_task(cal_ntc())
|
|
|
- heat.on()
|
|
|
+ cnt = 0
|
|
|
while True:
|
|
|
+ cnt += 1
|
|
|
+ if cnt > 10:
|
|
|
+ cnt = 0
|
|
|
+ print("wire_temp:", wire_temp, "\tcenter_temp:", center_temp, '\tduty:', heat.duty)
|
|
|
+ gc.collect()
|
|
|
wire_temp = wire_ntc.get_temperature()
|
|
|
center_temp = center_ntc.get_temperature()
|
|
|
- print("wire_temp:", wire_temp, "\tcenter_temp:", center_temp, '\tduty:', heat.duty)
|
|
|
- heat.ajust_power(wire_temp, center_temp)
|
|
|
+ heat.ajust_power(wire_ntc.get_temperature(), center_ntc.get_temperature())
|
|
|
# 主动垃圾回收是个好习惯,如果没有经常开辟内存,可不用
|
|
|
- gc.collect()
|
|
|
- await uasyncio.sleep_ms(3000)
|
|
|
+ await uasyncio.sleep_ms(300)
|
|
|
|
|
|
|
|
|
|