mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.1.2 Currency
This commit is contained in:
parent
56e39e9588
commit
7c46024ef6
@ -2,6 +2,10 @@ compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
- uno
|
||||
- leonardo
|
||||
- due
|
||||
- zero
|
||||
# - due
|
||||
# - zero
|
||||
# - leonardo
|
||||
- m4
|
||||
- esp32
|
||||
# - esp8266
|
||||
# - mega2560
|
@ -4,10 +4,14 @@ name: Arduino CI
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
arduino_ci:
|
||||
runTest:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: Arduino-CI/action@master
|
||||
# Arduino-CI/action@v0.1.1
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.6
|
||||
- run: |
|
||||
gem install arduino_ci
|
||||
arduino_ci.rb
|
||||
|
@ -1,5 +1,7 @@
|
||||
|
||||
[![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)
|
||||
[![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)
|
||||
|
||||
@ -21,7 +23,10 @@ The currency functions assume you do the currency math in integer units.
|
||||
For dollars and euro's this would be cents. For numbers with more decimals
|
||||
it is a smaller unit.
|
||||
|
||||
Using integers makes addition, subtraction and multiplication exact.
|
||||
Using integers makes addition, subtraction and multiplication exact.
|
||||
|
||||
The library has experimental wrappers for float/double values.
|
||||
Not tested extensively yet.
|
||||
|
||||
Choosing int32_t as 'base' also means that there is a limit in terms
|
||||
of minimum and maximum values. When large amounts are needed one can
|
||||
@ -48,7 +53,8 @@ The following functions are implemented:
|
||||
- **char \* bitcoin(int32_t value)**
|
||||
- **char \* dollar(int32_t value)**
|
||||
- **char \* euro(int32_t value)**
|
||||
- **char \* roebel(int32_t value)**
|
||||
- **char \* pound(int32_t value)**
|
||||
- **char \* roubles(int32_t value)**
|
||||
- **char \* yen(int32_t value)**
|
||||
- **char \* yuan(int32_t value)**
|
||||
|
||||
@ -58,7 +64,8 @@ The following functions are implemented:
|
||||
- **char \* bitcoin64(int64_t value)**
|
||||
- **char \* dollar64(int64_t value)**
|
||||
- **char \* euro64(int64_t value)**
|
||||
- **char \* roebel64(int64_t value)**
|
||||
- **char \* pound64(int64_t value)**
|
||||
- **char \* roubles64(int64_t value)**
|
||||
- **char \* yen64(int64_t value)**
|
||||
- **char \* yuan64(int64_t value)**
|
||||
|
||||
@ -70,7 +77,8 @@ Even more experimental - not tested
|
||||
- **char \* bitcoinf(double value)**
|
||||
- **char \* dollarf(double value)**
|
||||
- **char \* eurof(double value)**
|
||||
- **char \* roebelf(double value)**
|
||||
- **char \* poundf(double value)**
|
||||
- **char \* roublesf(double value)**
|
||||
- **char \* yenf(double value)**
|
||||
- **char \* yuanf(double value)**
|
||||
|
||||
@ -79,6 +87,8 @@ Even more experimental - not tested
|
||||
|
||||
- More wrapper functions?
|
||||
- test double parameters.
|
||||
- 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/
|
||||
|
||||
|
||||
## Operation
|
||||
|
@ -3,19 +3,22 @@
|
||||
//
|
||||
// FILE: currency.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.1
|
||||
// VERSION: 0.1.2
|
||||
// PURPOSE: Currency library for Arduino
|
||||
// URL: https://github.com/RobTillaart/Currency
|
||||
|
||||
// HISTORY
|
||||
// 0.1.0 2021-02-27 initial version
|
||||
// 0.1.1 2021-05-27 fix library.properties
|
||||
// 0.1.2 2021-10-20 update build-CI + badges
|
||||
// added pound, renamed roubles
|
||||
//
|
||||
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
|
||||
#define CURRENCY_VERSION (F("0.1.1"))
|
||||
#define CURRENCY_VERSION (F("0.1.2"))
|
||||
|
||||
|
||||
// TODO
|
||||
@ -111,21 +114,24 @@ char * currency64(int64_t value, int decimals, char dsep, char tsep, char sym)
|
||||
char * bitcoin(int32_t value) { return currency(value, 6, '.', ',', 'B'); }
|
||||
char * dollar(int32_t value) { return currency(value, 2, '.', ',', '$'); }
|
||||
char * euro(int32_t value) { return currency(value, 2, ',', '.', 'E'); }
|
||||
char * roebel(int32_t value) { return currency(value, 2, ',', '.', 'P'); }
|
||||
char * pound(int32_t value) { return currency(value, 2, ',', '.', 'L'); }
|
||||
char * roubles(int32_t value) { return currency(value, 2, ',', '.', 'P'); }
|
||||
char * yen(int32_t value) { return currency(value, 2, '.', ',', 'Y'); }
|
||||
char * yuan(int32_t value) { return currency(value, 2, '.', ',', 'R'); }
|
||||
|
||||
char * bitcoin64(int64_t value) { return currency64(value, 6, '.', ',', 'B'); }
|
||||
char * dollar64(int64_t value) { return currency64(value, 2, '.', ',', '$'); }
|
||||
char * euro64(int64_t value) { return currency64(value, 2, ',', '.', 'E'); }
|
||||
char * roebel64(int64_t value) { return currency64(value, 2, ',', '.', 'P'); }
|
||||
char * pound64(int64_t value) { return currency64(value, 2, ',', '.', 'L'); }
|
||||
char * roubles64(int64_t value) { return currency64(value, 2, ',', '.', 'P'); }
|
||||
char * yen64(int64_t value) { return currency64(value, 2, '.', ',', 'Y'); }
|
||||
char * yuan64(int64_t value) { return currency64(value, 2, '.', ',', 'R'); }
|
||||
|
||||
char * bitcoinf(double value) { return currency64(round(value * 1000000), 6, '.', ',', 'B'); }
|
||||
char * dollarf(double value) { return currency64(round(value * 100), 2, '.', ',', '$'); }
|
||||
char * eurof(double value) { return currency64(round(value * 100), 2, ',', '.', 'E'); }
|
||||
char * roebelf(double value) { return currency64(round(value * 100), 2, ',', '.', 'P'); }
|
||||
char * poundf(double value) { return currency64(round(value * 100), 2, ',', '.', 'L'); }
|
||||
char * roublesf(double value) { return currency64(round(value * 100), 2, ',', '.', 'P'); }
|
||||
char * yenf(double value) { return currency64(round(value * 100), 2, '.', ',', 'Y'); }
|
||||
char * yuanf(double value) { return currency64(round(value * 100), 2, '.', ',', 'R'); }
|
||||
|
||||
|
@ -9,21 +9,21 @@ currency64 KEYWORD2
|
||||
bitcoin KEYWORD2
|
||||
dollar KEYWORD2
|
||||
euro KEYWORD2
|
||||
roebel KEYWORD2
|
||||
roubles KEYWORD2
|
||||
yen KEYWORD2
|
||||
yuan KEYWORD2
|
||||
|
||||
bitcoin64 KEYWORD2
|
||||
dollar64 KEYWORD2
|
||||
euro64 KEYWORD2
|
||||
roebel64 KEYWORD2
|
||||
roubles64 KEYWORD2
|
||||
yen64 KEYWORD2
|
||||
yuan64 KEYWORD2
|
||||
|
||||
bitcoinf KEYWORD2
|
||||
dollarf KEYWORD2
|
||||
eurof KEYWORD2
|
||||
roebelf KEYWORD2
|
||||
roublesf KEYWORD2
|
||||
yenf KEYWORD2
|
||||
yuanf KEYWORD2
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "currency",
|
||||
"keywords": "currency, bitcoin, dollar, euro, roebel, yen, yuan",
|
||||
"keywords": "currency, bitcoin, dollar, euro, roubles, yen, yuan",
|
||||
"description": "Arduino library to help formatting integers as currency e.g. $ 1.000.000,00. ",
|
||||
"authors":
|
||||
[
|
||||
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/currency"
|
||||
},
|
||||
"version": "0.1.1",
|
||||
"version": "0.1.2",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*"
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=currency
|
||||
version=0.1.1
|
||||
version=0.1.2
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library to help formatting integers as currency e.g. $ 1.000.000,00.
|
||||
|
Loading…
Reference in New Issue
Block a user