diff --git a/libraries/Currency/CHANGELOG.md b/libraries/Currency/CHANGELOG.md index c1569ff7..f48990bb 100644 --- a/libraries/Currency/CHANGELOG.md +++ b/libraries/Currency/CHANGELOG.md @@ -6,11 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.1.8] - 2023-10-19 +- update readme.md + + ## [0.1.7] - 2022-10-30 - add changelog.md - add rp2040 to build-CI - ## [0.1.6] - 2022-04-15 - fix #5 split .h in .h and .cpp diff --git a/libraries/Currency/README.md b/libraries/Currency/README.md index f2e4d546..b6f499ac 100644 --- a/libraries/Currency/README.md +++ b/libraries/Currency/README.md @@ -1,21 +1,23 @@ [![Arduino CI](https://github.com/RobTillaart/currency/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci) -[![Arduino-lint](https://github.com/RobTillaart/Currency/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/Currency/actions/workflows/arduino-lint.yml) -[![JSON check](https://github.com/RobTillaart/Currency/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/Currency/actions/workflows/jsoncheck.yml) +[![Arduino-lint](https://github.com/RobTillaart/currency/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/currency/actions/workflows/arduino-lint.yml) +[![JSON check](https://github.com/RobTillaart/currency/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/currency/actions/workflows/jsoncheck.yml) +[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/currency.svg)](https://github.com/RobTillaart/currency/issues) + [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/currency/blob/master/LICENSE) [![GitHub release](https://img.shields.io/github/release/RobTillaart/currency.svg?maxAge=3600)](https://github.com/RobTillaart/currency/releases) +[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/currency.svg)](https://registry.platformio.org/libraries/robtillaart/currency) # Currency Arduino library to help formatting integers for printing as currency. -#### Warning: experimental - - ## Description +**Experimental** + The currency library contains a number of functions that help to print integers as currency. @@ -37,10 +39,17 @@ There is a relation with the printHelpers class - https://github.com/RobTillaart When this currency library has matured it might be merged with printHelpers. +#### Related + +- https://github.com/RobTillaart/printHelpers + ## Interface -The following functions are implemented: +```cpp +#include "currency.h" +``` +The following functions are implemented: ### Core function @@ -98,18 +107,31 @@ individual digits (div / mod 10). ## Future -#### must +#### Must + - update documentation. -#### should +#### Should + +#### Could -#### could - More wrapper functions? - test double parameters. - should decimals be a parameter too? - add BTC, USD, EUR, GBP, RUB, JPY, CNY, etc. (3+1 chars) - https://www.easymarkets.com/eu/learn-centre/discover-trading/currency-acronyms-and-abbreviations/ -#### won't +#### Won't + - currency conversion? - intern all in ??? + + +## Support + +If you appreciate my libraries, you can support the development and maintenance. +Improve the quality of the libraries by providing issues and Pull Requests, or +donate through PayPal or GitHub sponsors. + +Thank you, + diff --git a/libraries/Currency/currency.cpp b/libraries/Currency/currency.cpp index aa5f3f49..4a7aa7f0 100644 --- a/libraries/Currency/currency.cpp +++ b/libraries/Currency/currency.cpp @@ -1,11 +1,9 @@ // // FILE: currency.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.1.7 +// VERSION: 0.1.8 // PURPOSE: Currency library for Arduino // URL: https://github.com/RobTillaart/Currency -// -// HISTORY: see changelog.md #include "currency.h" @@ -20,11 +18,11 @@ char * currency(int32_t value, int decimals, char decimalSeparator, char thousan bool negative = v < 0; if (negative) v = -v; - int pos = -decimals; // decimal places + int pos = -decimals; // decimal places while ((pos < 1) || (v > 0)) { - // separators + // separators if ((pos == 0) && (decimals > 0) ) tmp[index++] = decimalSeparator; if ((pos > 0) && (pos % 3 == 0) ) tmp[index++] = thousandSeparator; pos++; @@ -37,7 +35,7 @@ char * currency(int32_t value, int decimals, char decimalSeparator, char thousan tmp[index++] = symbol; tmp[index] = '\0'; - // reverse string + // reverse string for (uint8_t i = 0, j = index - 1; i < index / 2; i++, j--) { char c = tmp[i]; @@ -57,7 +55,7 @@ char * currency64(int64_t value, int decimals, char decimalSeparator, char thous bool negative = v < 0; if (negative) v = -v; - int pos = -decimals; // decimal places + int pos = -decimals; // decimal places while ((pos < 1) || (v > 0)) { @@ -74,7 +72,7 @@ char * currency64(int64_t value, int decimals, char decimalSeparator, char thous tmp[index++] = symbol; tmp[index] = '\0'; - // reverse string + // reverse string for (uint8_t i = 0, j = index - 1; i < index / 2; i++, j--) { char c = tmp[i]; @@ -113,4 +111,4 @@ char * yenf(double value) { return currency64(round(value * 100), 2, '.', char * yuanf(double value) { return currency64(round(value * 100), 2, '.', ',', 'R'); } -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/libraries/Currency/currency.h b/libraries/Currency/currency.h index 6844f394..968b89b8 100644 --- a/libraries/Currency/currency.h +++ b/libraries/Currency/currency.h @@ -1,9 +1,8 @@ #pragma once - // // FILE: currency.h // AUTHOR: Rob Tillaart -// VERSION: 0.1.7 +// VERSION: 0.1.8 // PURPOSE: Currency library for Arduino // URL: https://github.com/RobTillaart/Currency @@ -11,7 +10,7 @@ #include "Arduino.h" -#define CURRENCY_VERSION (F("0.1.7")) +#define CURRENCY_VERSION (F("0.1.8")) // TODO @@ -55,5 +54,5 @@ char * yenf(double value); char * yuanf(double value); -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/libraries/Currency/library.json b/libraries/Currency/library.json index 40c77505..0a2dd2e3 100644 --- a/libraries/Currency/library.json +++ b/libraries/Currency/library.json @@ -15,9 +15,9 @@ "type": "git", "url": "https://github.com/RobTillaart/currency" }, - "version": "0.1.7", + "version": "0.1.8", "license": "MIT", - "frameworks": "arduino", + "frameworks": "*", "platforms": "*", "headers": "currency.h" } diff --git a/libraries/Currency/library.properties b/libraries/Currency/library.properties index bcb7eabf..cc79e608 100644 --- a/libraries/Currency/library.properties +++ b/libraries/Currency/library.properties @@ -1,5 +1,5 @@ name=currency -version=0.1.7 +version=0.1.8 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library to help formatting integers as currency e.g. $ 1.000.000,00.