10 years, 6 months ago.

How do you select between the different units?

I have been trying to use these libraries and specify metric units and not imperial.

How do I ask the print function to return a different units type?

Question relating to:

I was about to reply that the library seems incomplete and doesn't support metric units but then I noticed you've crated a fork and added them.

posted by Andy A 20 Jun 2014

Yeah it doesn't support metric. The thing I haven't done before is how to do you pass the enum variable to the function? the temperature code has the following print function const char* print(unitsType units = CELSIUS); where unitsType is an enum with the values CELSIUS and FARENHEIT and KELVIN but then when you call the function t.print(CELSIUS) doesn't work because CELSIUS is not a known variable, I tried putting it in "" and '' and that doesn't seem to work so how do you pass the variable to it?

Thanks

posted by Mark Irwin 20 Jun 2014

const char* print(unitsType units = CELSIUS) used to default to imperial and as a work around i changed the default to metric.

posted by Mark Irwin 20 Jun 2014

1 Answer

10 years, 5 months ago.

Not sure how it works on this compiler, but you usually just give the fully qualified name like this: Temperature.CELSIUS, since the unitsType is public.