Multitasking ?
-
- Posts: 325
- Joined: Tue Jun 21, 2022 2:17 pm
- Location: South coast UK
- Has thanked: 173 times
- Been thanked: 104 times
Re: Multitasking ?
I have finally started using this new version of tempr$, which is excellent and allows much better updating. The routine is called once every three seconds, which is ample time for the conversions, and it is all non-blocking. I use the sensor id string to distinguish between them, e.g this is in the setup:
the disp_temp lines are a sub that writes to a tft display. To get the sensor id strings use tempr$(temp_pin), list the result and copy it into your code.
Code: [Local Link Removed for Guests]
ext_sensor_id$ = "28db49ec00000063"
hw_sensor_id$ = "28883c18291901ce"
ch_sensor_id$ = "288978c400000006"
ret_sensor_id$ = "289764c400000013"
temp_pin = 13 'all sensors on this pin
ret$ = tempr$(temp_pin,0) 'request all readings
Code: [Local Link Removed for Guests]
'===========
read_temps:
'===========
'read and display each temperature
local_ext_temp = val(tempr$(temp_pin,ext_sensor_id$))
flow_temp = val(tempr$(temp_pin,ch_sensor_id$) )
disp_temp c4,r3,flow_temp
ret_temp = val(tempr$(temp_pin,ret_sensor_id$))
disp_temp c4,r4,ret_temp
hw_temp = val(tempr$(temp_pin,hw_sensor_id$) )
disp_temp c4,r2,hw_temp
'ask for the next time
ret$ = tempr$(temp_pin,0) 'request all readings, also once in startup
return