|
| 1 | + |
| 2 | +[](https://github.com/marketplace/actions/arduino_ci) |
| 3 | +[](https://github.com/RobTillaart/VolumeConverter/actions/workflows/arduino-lint.yml) |
| 4 | +[](https://github.com/RobTillaart/VolumeConverter/actions/workflows/jsoncheck.yml) |
| 5 | +[](https://github.com/RobTillaart/VolumeConverter/issues) |
| 6 | + |
| 7 | +[](https://github.com/RobTillaart/VolumeConverter/blob/master/LICENSE) |
| 8 | +[](https://github.com/RobTillaart/VolumeConverter/releases) |
| 9 | +[](https://registry.platformio.org/libraries/robtillaart/VolumeConverter) |
| 10 | + |
| 11 | + |
| 12 | +# VolumeConverter |
| 13 | + |
| 14 | +Arduino library to convert volume units. |
| 15 | + |
| 16 | + |
| 17 | +## Description |
| 18 | + |
| 19 | +VolumeConverter is a library containing a VolumeConverter class. |
| 20 | + |
| 21 | +It consists of setters to set a certain volume in one of the |
| 22 | +many supported units. Internally it is converted to liters. |
| 23 | +Then the user can use a getter to get the volume in one of the |
| 24 | +supported units. |
| 25 | + |
| 26 | +Besides conversion the class also allows one to add different |
| 27 | +units and convert them. |
| 28 | + |
| 29 | +The purpose of the library is conversion and can be used for |
| 30 | +educational programs too. |
| 31 | + |
| 32 | +The library is open for additions, including obscure volume metrics |
| 33 | +and volume related math functions and constants. |
| 34 | +Also good examples (e.g. educational) are welcome. |
| 35 | + |
| 36 | + |
| 37 | +#### Accuracy |
| 38 | + |
| 39 | +As the library uses floats the accuracy is limited especially |
| 40 | +if one tries to add or convert the extremes of the scales. |
| 41 | +E.g. Long tons to teaspoons will loose significant digits. |
| 42 | + |
| 43 | + |
| 44 | +## Interface |
| 45 | + |
| 46 | + |
| 47 | +```cpp |
| 48 | +#include "VolumeConverter.h" |
| 49 | +``` |
| 50 | + |
| 51 | +Internal representation is the liter as it the ISO standard. |
| 52 | + |
| 53 | +## Interface |
| 54 | + |
| 55 | + |
| 56 | +#### Constructor |
| 57 | + |
| 58 | +- **VolumeConverter()** sets the internal value to 0. |
| 59 | + |
| 60 | +#### Setters |
| 61 | + |
| 62 | +- **void setLiters(float value = 0)** |
| 63 | +- **void setMilliLiters(float value = 0)** |
| 64 | +- **void setCubicMeters(float value = 0)** |
| 65 | +- **void setLongTons(float value = 0)** |
| 66 | +- **void setShortTons(float value = 0)** |
| 67 | +- **void setBarrels(float value = 0)** |
| 68 | +- **void setGallons(float value = 0)** |
| 69 | +- **void setQuarts(float value = 0)** |
| 70 | +- **void setPints(float value = 0)** |
| 71 | +- **void setCups(float value = 0)** |
| 72 | +- **void setFluidOunces(float value = 0)** |
| 73 | +- **void setTableSpoons(float value = 0)** |
| 74 | +- **void setTeaSpoons(float value = 0)** |
| 75 | + |
| 76 | +#### Adders |
| 77 | + |
| 78 | +- **void addLiters(float value = 0)** |
| 79 | +- **void addMilliLiters(float value = 0)** |
| 80 | +- **void addCubicMeters(float value = 0)** |
| 81 | +- **void addLongTons(float value = 0)** |
| 82 | +- **void addShortTons(float value = 0)** |
| 83 | +- **void addBarrels(float value = 0)** |
| 84 | +- **void addGallons(float value = 0)** |
| 85 | +- **void addQuarts(float value = 0)** |
| 86 | +- **void addPints(float value = 0)** |
| 87 | +- **void addCups(float value = 0)** |
| 88 | +- **void addFluidOunces(float value = 0)** |
| 89 | +- **void addTableSpoons(float value = 0)** |
| 90 | +- **void addTeaSpoons(float value = 0)** |
| 91 | + |
| 92 | +#### getters |
| 93 | + |
| 94 | +- **float getLiters()** |
| 95 | +- **float getMilliLiters()** |
| 96 | +- **float getCubicMeters()** |
| 97 | +- **float getLongTons()** |
| 98 | +- **float getShortTons()** |
| 99 | +- **float getBarrels()** |
| 100 | +- **float getGallons()** |
| 101 | +- **float getQuarts()** |
| 102 | +- **float getPints()** |
| 103 | +- **float getCups()** |
| 104 | +- **float getFluidOunces()** |
| 105 | +- **float getTableSpoons()** |
| 106 | +- **float getTeaSpoons()** |
| 107 | + |
| 108 | + |
| 109 | +## Future |
| 110 | + |
| 111 | +#### Must |
| 112 | + |
| 113 | +- improve documentation |
| 114 | + |
| 115 | +#### Should |
| 116 | + |
| 117 | +- consider using double instead of float. |
| 118 | + |
| 119 | +#### Could |
| 120 | + |
| 121 | +- add more unit tests |
| 122 | +- add more examples |
| 123 | + |
| 124 | +#### won't (unless) |
| 125 | + |
| 126 | + |
| 127 | +## Support |
| 128 | + |
| 129 | +If you appreciate my libraries, you can support the development and maintenance. |
| 130 | +Improve the quality of the libraries by providing issues and Pull Requests, or |
| 131 | +donate through PayPal or GitHub sponsors. |
| 132 | + |
| 133 | +Thank you, |
| 134 | + |
| 135 | + |
0 commit comments