Skip to content

Commit 7c46024

Browse files
committed
0.1.2 Currency
1 parent 56e39e9 commit 7c46024

File tree

7 files changed

+45
-21
lines changed

7 files changed

+45
-21
lines changed

libraries/Currency/.arduino-ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ compile:
22
# Choosing to run compilation tests on 2 different Arduino platforms
33
platforms:
44
- uno
5-
- leonardo
6-
- due
7-
- zero
5+
# - due
6+
# - zero
7+
# - leonardo
8+
- m4
9+
- esp32
10+
# - esp8266
11+
# - mega2560

libraries/Currency/.github/workflows/arduino_test_runner.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ name: Arduino CI
44
on: [push, pull_request]
55

66
jobs:
7-
arduino_ci:
7+
runTest:
88
runs-on: ubuntu-latest
99

1010
steps:
1111
- uses: actions/checkout@v2
12-
- uses: Arduino-CI/action@master
13-
# Arduino-CI/[email protected]
12+
- uses: ruby/setup-ruby@v1
13+
with:
14+
ruby-version: 2.6
15+
- run: |
16+
gem install arduino_ci
17+
arduino_ci.rb

libraries/Currency/README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

22
[![Arduino CI](https://github.com/RobTillaart/currency/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
3+
[![Arduino-lint](https://github.com/RobTillaart/Currency/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/Currency/actions/workflows/arduino-lint.yml)
4+
[![JSON check](https://github.com/RobTillaart/Currency/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/Currency/actions/workflows/jsoncheck.yml)
35
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/currency/blob/master/LICENSE)
46
[![GitHub release](https://img.shields.io/github/release/RobTillaart/currency.svg?maxAge=3600)](https://github.com/RobTillaart/currency/releases)
57

@@ -21,7 +23,10 @@ The currency functions assume you do the currency math in integer units.
2123
For dollars and euro's this would be cents. For numbers with more decimals
2224
it is a smaller unit.
2325

24-
Using integers makes addition, subtraction and multiplication exact.
26+
Using integers makes addition, subtraction and multiplication exact.
27+
28+
The library has experimental wrappers for float/double values.
29+
Not tested extensively yet.
2530

2631
Choosing int32_t as 'base' also means that there is a limit in terms
2732
of minimum and maximum values. When large amounts are needed one can
@@ -48,7 +53,8 @@ The following functions are implemented:
4853
- **char \* bitcoin(int32_t value)**
4954
- **char \* dollar(int32_t value)**
5055
- **char \* euro(int32_t value)**
51-
- **char \* roebel(int32_t value)**
56+
- **char \* pound(int32_t value)**
57+
- **char \* roubles(int32_t value)**
5258
- **char \* yen(int32_t value)**
5359
- **char \* yuan(int32_t value)**
5460

@@ -58,7 +64,8 @@ The following functions are implemented:
5864
- **char \* bitcoin64(int64_t value)**
5965
- **char \* dollar64(int64_t value)**
6066
- **char \* euro64(int64_t value)**
61-
- **char \* roebel64(int64_t value)**
67+
- **char \* pound64(int64_t value)**
68+
- **char \* roubles64(int64_t value)**
6269
- **char \* yen64(int64_t value)**
6370
- **char \* yuan64(int64_t value)**
6471

@@ -70,7 +77,8 @@ Even more experimental - not tested
7077
- **char \* bitcoinf(double value)**
7178
- **char \* dollarf(double value)**
7279
- **char \* eurof(double value)**
73-
- **char \* roebelf(double value)**
80+
- **char \* poundf(double value)**
81+
- **char \* roublesf(double value)**
7482
- **char \* yenf(double value)**
7583
- **char \* yuanf(double value)**
7684

@@ -79,6 +87,8 @@ Even more experimental - not tested
7987

8088
- More wrapper functions?
8189
- test double parameters.
90+
- add BTC, USD, EUR, GBP, RUB, JPY, CNY, etc. (3+1 chars)
91+
- https://www.easymarkets.com/eu/learn-centre/discover-trading/currency-acronyms-and-abbreviations/
8292

8393

8494
## Operation

libraries/Currency/currency.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@
33
//
44
// FILE: currency.h
55
// AUTHOR: Rob Tillaart
6-
// VERSION: 0.1.1
6+
// VERSION: 0.1.2
77
// PURPOSE: Currency library for Arduino
88
// URL: https://github.com/RobTillaart/Currency
99

1010
// HISTORY
1111
// 0.1.0 2021-02-27 initial version
1212
// 0.1.1 2021-05-27 fix library.properties
13+
// 0.1.2 2021-10-20 update build-CI + badges
14+
// added pound, renamed roubles
15+
//
1316

1417

1518
#include "Arduino.h"
1619

1720

18-
#define CURRENCY_VERSION (F("0.1.1"))
21+
#define CURRENCY_VERSION (F("0.1.2"))
1922

2023

2124
// TODO
@@ -111,21 +114,24 @@ char * currency64(int64_t value, int decimals, char dsep, char tsep, char sym)
111114
char * bitcoin(int32_t value) { return currency(value, 6, '.', ',', 'B'); }
112115
char * dollar(int32_t value) { return currency(value, 2, '.', ',', '$'); }
113116
char * euro(int32_t value) { return currency(value, 2, ',', '.', 'E'); }
114-
char * roebel(int32_t value) { return currency(value, 2, ',', '.', 'P'); }
117+
char * pound(int32_t value) { return currency(value, 2, ',', '.', 'L'); }
118+
char * roubles(int32_t value) { return currency(value, 2, ',', '.', 'P'); }
115119
char * yen(int32_t value) { return currency(value, 2, '.', ',', 'Y'); }
116120
char * yuan(int32_t value) { return currency(value, 2, '.', ',', 'R'); }
117121

118122
char * bitcoin64(int64_t value) { return currency64(value, 6, '.', ',', 'B'); }
119123
char * dollar64(int64_t value) { return currency64(value, 2, '.', ',', '$'); }
120124
char * euro64(int64_t value) { return currency64(value, 2, ',', '.', 'E'); }
121-
char * roebel64(int64_t value) { return currency64(value, 2, ',', '.', 'P'); }
125+
char * pound64(int64_t value) { return currency64(value, 2, ',', '.', 'L'); }
126+
char * roubles64(int64_t value) { return currency64(value, 2, ',', '.', 'P'); }
122127
char * yen64(int64_t value) { return currency64(value, 2, '.', ',', 'Y'); }
123128
char * yuan64(int64_t value) { return currency64(value, 2, '.', ',', 'R'); }
124129

125130
char * bitcoinf(double value) { return currency64(round(value * 1000000), 6, '.', ',', 'B'); }
126131
char * dollarf(double value) { return currency64(round(value * 100), 2, '.', ',', '$'); }
127132
char * eurof(double value) { return currency64(round(value * 100), 2, ',', '.', 'E'); }
128-
char * roebelf(double value) { return currency64(round(value * 100), 2, ',', '.', 'P'); }
133+
char * poundf(double value) { return currency64(round(value * 100), 2, ',', '.', 'L'); }
134+
char * roublesf(double value) { return currency64(round(value * 100), 2, ',', '.', 'P'); }
129135
char * yenf(double value) { return currency64(round(value * 100), 2, '.', ',', 'Y'); }
130136
char * yuanf(double value) { return currency64(round(value * 100), 2, '.', ',', 'R'); }
131137

libraries/Currency/keywords.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ currency64 KEYWORD2
99
bitcoin KEYWORD2
1010
dollar KEYWORD2
1111
euro KEYWORD2
12-
roebel KEYWORD2
12+
roubles KEYWORD2
1313
yen KEYWORD2
1414
yuan KEYWORD2
1515

1616
bitcoin64 KEYWORD2
1717
dollar64 KEYWORD2
1818
euro64 KEYWORD2
19-
roebel64 KEYWORD2
19+
roubles64 KEYWORD2
2020
yen64 KEYWORD2
2121
yuan64 KEYWORD2
2222

2323
bitcoinf KEYWORD2
2424
dollarf KEYWORD2
2525
eurof KEYWORD2
26-
roebelf KEYWORD2
26+
roublesf KEYWORD2
2727
yenf KEYWORD2
2828
yuanf KEYWORD2
2929

libraries/Currency/library.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "currency",
3-
"keywords": "currency, bitcoin, dollar, euro, roebel, yen, yuan",
3+
"keywords": "currency, bitcoin, dollar, euro, roubles, yen, yuan",
44
"description": "Arduino library to help formatting integers as currency e.g. $ 1.000.000,00. ",
55
"authors":
66
[
@@ -15,7 +15,7 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/currency"
1717
},
18-
"version": "0.1.1",
18+
"version": "0.1.2",
1919
"license": "MIT",
2020
"frameworks": "arduino",
2121
"platforms": "*"

libraries/Currency/library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=currency
2-
version=0.1.1
2+
version=0.1.2
33
author=Rob Tillaart <[email protected]>
44
maintainer=Rob Tillaart <[email protected]>
55
sentence=Arduino library to help formatting integers as currency e.g. $ 1.000.000,00.

0 commit comments

Comments
 (0)