Viewer. The viewer reads the temperature and communicates that to the user using the LCD. The viewer function is parametrized with the old temperature, which is 0 on the first call. The task it generates first reads the temperature from the DHT using the temperature task. This task reads the temperature continuously and emits it as an unstable task value. The >>*. combinator is used to only continue execution when the temperature is not the same as the old temperature. This makes sure the LCD and SDS are not continuously written. When the >>*. steps, the temp SDS is set and the value is written to the LCD. Finally a recursive call to itself is done with the new temperature so that it will continuously execute. fun λviewer=( ‹ λoldtemp temperature dht ‹ ‹ >>*. [IfValue (λt t !=. oldtemp) (setSds temp)] >>=.λntemp printAt lcd (lit 0) (lit 0) ntemp >>|. viewer ntemp) In
Appears in 1 contract
Sources: End User Agreement
Viewer. The viewer reads the temperature and communicates that to the user using the LCD. The viewer function is parametrized with the old temperature, which is 0 on the first first call. The task it generates first first reads the temperature from the DHT using the temperature task. This task reads the temperature continuously and emits it as an unstable task value. The >>*. combinator is used to only continue execution when the temperature is not the same as the old temperature. This makes sure the LCD and SDS are not continuously written. When the >>*. steps, the temp SDS is set and the value is written to the LCD. Finally a recursive call to itself is done with the new temperature so that it will continuously execute. fun λviewer=( ‹ ⭢ λoldtemp temperature dht ‹ ‹ ⭢ ⭢ >>*. [IfValue (λt t !=. oldtemp) (setSds temp)] >>=.λntemp printAt lcd (lit 0) (lit 0) ntemp >>|. viewer ntemp) In
Appears in 1 contract
Sources: End User Agreement