Skip to content

Commit f3ca096

Browse files
committed
0.3.2 weight
1 parent efb3745 commit f3ca096

12 files changed

Lines changed: 80 additions & 22 deletions

File tree

libraries/weight/.github/workflows/arduino-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ jobs:
66
runs-on: ubuntu-latest
77
timeout-minutes: 5
88
steps:
9-
- uses: actions/checkout@v4
10-
- uses: arduino/arduino-lint-action@v1
9+
- uses: actions/checkout@v5
10+
- uses: arduino/arduino-lint-action@v2
1111
with:
1212
library-manager: update
1313
compliance: strict

libraries/weight/.github/workflows/arduino_test_runner.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
timeout-minutes: 20
99

1010
steps:
11-
- uses: actions/checkout@v4
11+
- uses: actions/checkout@v5
1212
- uses: ruby/setup-ruby@v1
1313
with:
1414
ruby-version: 2.6

libraries/weight/.github/workflows/jsoncheck.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ on:
55
paths:
66
- '**.json'
77
pull_request:
8+
paths:
9+
- '**.json'
810

911
jobs:
1012
test:
1113
runs-on: ubuntu-latest
1214
timeout-minutes: 5
1315
steps:
14-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v5
1517
- name: json-syntax-check
1618
uses: limitusus/json-syntax-check@v2
1719
with:

libraries/weight/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

88

9-
## [0.3.1] - 2023-11-23
9+
## [0.3.2] - 2025-08-27
10+
- update github actions
1011
- update readme.md
12+
- minor edits
1113

14+
## [0.3.1] - 2023-11-23
15+
- update readme.md
1216

1317
## [0.3.0] - 2023-08-29
1418
- rename class **weightConvertor** to **weightConverter**

libraries/weight/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020-2024 Rob Tillaart
3+
Copyright (c) 2020-2025 Rob Tillaart
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

libraries/weight/README.md

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Open for additions, including obscure weight metrics or
2222
weight related math functions and constants.
2323

2424

25-
#### Overview of conversions:
25+
### Overview of conversions:
2626

2727
```
2828
stone - lbs - ounce
@@ -34,7 +34,7 @@ weight related math functions and constants.
3434
```
3535

3636

37-
#### Related
37+
### Related
3838

3939
- https://github.com/RobTillaart/AtomicWeight
4040
- https://github.com/RobTillaart/VolumeConverter
@@ -55,14 +55,14 @@ Functions are straightforward.
5555
- **float ounce2gram(float ounce)**
5656
- **float gram2ounce(float gram)**
5757
- **float gram2kilo(float gram)**
58-
- **float kilo2gram( float kilo)**
58+
- **float kilo2gram(float kilo)**
5959
- **float lbs2ounce(float lbs)**
6060
- **float ounce2lbs(float ounce)**
6161
- **float stone2lbs(float stone)**
6262
- **float lbs2stone(float lbs)**
6363
- **float stone2kilo(float stone)**
6464
- **float kilo2stone(float kilo)**
65-
- **float US2metric(float stone, float lbs, float ounce)**
65+
- **float US2metric(float stone, float lbs, float ounce)** returns kg.
6666
- **float metric2US(float kilo, float &stone, float &lbs, float &ounce)**
6767

6868

@@ -89,17 +89,58 @@ Internal representation is the gram as it the ISO standard.
8989
Since version 0.3.0 the converter can also add different units.
9090

9191

92+
### Example
93+
94+
To convert from one less known format to another just takes two calls, example:
95+
96+
```cpp
97+
weightConverter wc;
98+
99+
wc.setStone(24.2);
100+
float x = wc.getRobie();
101+
```
102+
103+
If you need to convert a lot of data between two formats, it is also possible to
104+
pre-calculate a factor so the conversion is faster.
105+
On an UNO R3 the gain goes up to 20%.
106+
107+
108+
```cpp
109+
weightConverter wc;
110+
111+
wc.setGram(1); // any non zero value will work.
112+
float factor = wc.getRobie() / wc.getStone();
113+
sum = 0;
114+
for (int i = 0; i < 1000; i++)
115+
{
116+
sum += i * factor;
117+
}
118+
119+
```
120+
121+
or with the functions.
122+
123+
```cpp
124+
float grams2stoneFactor = lbs2stone(ounce2lbs(gram2ounce(1)));
125+
sum = 0;
126+
for (int i = 0; i < 1000; i++)
127+
{
128+
sum += i * factor;
129+
}
130+
```
131+
132+
92133
## Interface
93134

94135
```cpp
95136
#include "weight.h"
96137
```
97138

98-
#### Constructor
139+
### Constructor
99140

100141
- **weightConverter()**
101142

102-
#### Setters
143+
### Setters
103144

104145
- **void setKilogram(float value = 0)**
105146
- **void setGram(float value = 0)**
@@ -120,7 +161,7 @@ Since version 0.3.0 the converter can also add different units.
120161
- **void setGrain(float value = 0)**
121162
- **void setCarat(float value = 0)**
122163

123-
#### Adders
164+
### Adders
124165

125166
- **void addKilogram(float value = 0)**
126167
- **void addGram(float value = 0)**
@@ -141,7 +182,7 @@ Since version 0.3.0 the converter can also add different units.
141182
- **void addGrain(float value = 0)**
142183
- **void addCarat(float value = 0)**
143184

144-
#### Getters
185+
### Getters
145186

146187
- **float getKilogram()**
147188
- **float getGram()**

libraries/weight/examples/weightConverter_test/weightConverter_test.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// FILE: weightConverter_test.ino
33
// AUTHOR: Rob Tillaart
44
// PURPOSE: demo
5-
// DATE: 2022-12-05
5+
// URL: https://github.com/RobTillaart/weight
66

77

88
#include "weight.h"
@@ -13,7 +13,10 @@ const float accuracy = 0.0001;
1313
void setup()
1414
{
1515
Serial.begin(115200);
16+
Serial.println();
1617
Serial.println(__FILE__);
18+
Serial.print("WEIGHT_LIB_VERSION: ");
19+
Serial.println(WEIGHT_LIB_VERSION);
1720
Serial.println();
1821

1922
weightConverter WC;

libraries/weight/examples/weightPerformance/weightPerformance.ino

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// FILE: weightPerformance.ino
33
// AUTHOR: Rob Tillaart
44
// PURPOSE: demo
5-
// DATE: 2020-06-17
5+
// URL: https://github.com/RobTillaart/weight
66

77

88
#include "weight.h"
@@ -16,10 +16,14 @@ uint32_t start, stop;
1616
void setup()
1717
{
1818
Serial.begin(115200);
19+
Serial.println();
1920
Serial.println(__FILE__);
21+
Serial.print("WEIGHT_LIB_VERSION: ");
22+
Serial.println(WEIGHT_LIB_VERSION);
23+
Serial.println();
2024

2125
Serial.println("\nFUNCTION:\tTIME (us)");
22-
// measure_1();
26+
// measure_1();
2327
measure_2();
2428
}
2529

libraries/weight/examples/weightTest/weightTest.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// FILE: weightTest.ino
33
// AUTHOR: Rob Tillaart
44
// PURPOSE: demo
5-
// DATE: 2020-06-17
5+
// URL: https://github.com/RobTillaart/weight
66

77

88
#include "weight.h"
@@ -13,7 +13,11 @@ const float accuracy = 0.0001;
1313
void setup()
1414
{
1515
Serial.begin(115200);
16+
Serial.println();
1617
Serial.println(__FILE__);
18+
Serial.print("WEIGHT_LIB_VERSION: ");
19+
Serial.println(WEIGHT_LIB_VERSION);
20+
Serial.println();
1721
}
1822

1923

libraries/weight/library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/weight.git"
1717
},
18-
"version": "0.3.1",
18+
"version": "0.3.2",
1919
"license": "MIT",
2020
"frameworks": "*",
2121
"platforms": "*",

0 commit comments

Comments
 (0)