This page has no translation to Deutsch yet. The original English version is below. If you’d like to help, great! See how to translate a documentation page in the contribution guide.
Note This is a web-version of a tutorial chapter embedded right into the XOD IDE. To get a better learning experience we recommend to install the desktop IDE or start the browser-based IDE, and you’ll see the same tutorial there.

Units of Measure

Screenshot of 211-units-of-measure

The standard xod/units library contains a few nodes for converting some popular units. For example, Celsius to Fahrenheit, degrees to radians and so on.

One of these nodes (c-to-f) is already on the patch and the program shows temperature in Fahrenheit.

Exercise #

Let’s improve the program to see a temperature in Fahrenheit only when the button is pressed.

  1. Add if-else below button.
  2. Link PRS with COND.
  3. Link Tc with F.
  4. Link output from c-to-f with T.
  5. Link R with the second pin of concat.
  6. Upload the program.

Great! However, we still get a “C” on the LCD, even when the temperature converted to the Fahrenheit. Let’s fix it.

  1. Add one more if-else.
  2. Link PRS to the new COND pin.
  3. Bind "F" to the T pin, and "C" to the F pin.
  4. Link R with the latest pin of the concat node.
  5. Upload the program again.

👆 Remember the quotes #

As was mentioned, the if-else node can work with numbers and strings depending on the incoming value type. The "F" and "C" values you bind have to be put in quotes so that XOD knows what data type do you mean.

See the generic nodes guide for better understanding.

Found a typo or mistake? Want to improve the text? Edit this page on GitHub and open a pull request. If you have a complex proposal or you want to discuss the content, feel free to start a new thread on XOD forum.