Skip to content

Commit c18b6e9

Browse files
committed
0.1.1 AngleConvertor
1 parent 1b628ab commit c18b6e9

File tree

12 files changed

+126
-20
lines changed

12 files changed

+126
-20
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
lint:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
9+
- uses: actions/checkout@v3
1010
- uses: arduino/arduino-lint-action@v1
1111
with:
1212
library-manager: update

libraries/AngleConvertor/.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
runs-on: ubuntu-latest
99

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

libraries/AngleConvertor/.github/workflows/jsoncheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
test:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
1414
- name: json-syntax-check
1515
uses: limitusus/json-syntax-check@v1
1616
with:

libraries/AngleConvertor/AngleConvertor.h

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// FILE: AngleConvertor.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.1.0
5+
// VERSION: 0.1.1
66
// DATE: 2022-12-01
77
// PURPOSE: angle conversion class
88
// URL: https://github.com/RobTillaart/AngleConvertor
@@ -11,7 +11,7 @@
1111
#include "Arduino.h"
1212

1313

14-
#define ANGLECONVERTOR_LIB_VERSION (F("0.1.0"))
14+
#define ANGLECONVERTOR_LIB_VERSION (F("0.1.1"))
1515

1616

1717
/////////////////////////////////////////////////////////////
@@ -34,7 +34,7 @@ class AngleConvertor
3434
void setHexacontade(float value = 0) { _v = value * (M_PI / 30.0); };
3535
void setHourAngle(float value = 0) { _v = value * (M_PI / 12.0); };
3636
void setMilliTurn(float value = 0) { _v = value * (M_PI / 500.0); };
37-
37+
3838
void setMinuteTime(float value = 0) { _v = value * (M_PI / 720.0); };
3939
void setOctant(float value = 0) { _v = value * (M_PI / 4.0); };
4040
void setPechus(float value = 0) { _v = value * (M_PI / 90.0); }; // assumes 2°
@@ -58,7 +58,7 @@ class AngleConvertor
5858
float getHexacontade() { return _v * (30.0 / M_PI); };
5959
float getHourAngle() { return _v * (12.0 / M_PI); };
6060
float getMilliTurn() { return _v * (500.0 / M_PI); };
61-
61+
6262
float getMinuteTime() { return _v * (720.0 / M_PI); };
6363
float getOctant() { return _v * (4.0 / M_PI); };
6464
float getPechus() { return _v * (90.0 / M_PI); }; // assumes 2°
@@ -71,8 +71,24 @@ class AngleConvertor
7171
float getTurn() { return _v * (0.5 / M_PI); };
7272

7373

74+
// WINDROSE
75+
//
76+
char * windrose()
77+
{
78+
return windrose(_v * (180.0 / M_PI));
79+
}
80+
81+
char * windrose(float degrees)
82+
{
83+
uint8_t idx = (degrees + 11.25) * 0.044444444444444; // 1.0 / 22.5
84+
return _wr2[idx];
85+
}
86+
7487
private:
75-
float _v; // internal use radians.
88+
float _v; // internal use radians.
89+
char _wr2[17][4] = {
90+
"N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW", "N"};
91+
7692
};
7793

7894

libraries/AngleConvertor/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88

99

10+
## [0.1.1] - 2023-01-23
11+
- update GitHub actions
12+
- update license 2023
13+
- update readme
14+
- add windrose() (2x)
15+
- add example
16+
17+
1018
## [0.1.0] - 2022-12-01
1119
- initial version
1220

libraries/AngleConvertor/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) 2022-2022 Rob Tillaart
3+
Copyright (c) 2022-2023 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/AngleConvertor/README.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,27 @@ AngleConvertor is an Arduino class to convert an angle from and to less known fo
4343
| Turn | 1 |
4444

4545

46-
#### Related to
46+
#### Related
47+
48+
- https://github.com/RobTillaart/AngleConvertor
4749
- https://github.com/RobTillaart/AverageAngle
4850
- https://github.com/RobTillaart/Angle
4951
- https://github.com/RobTillaart/runningAngle
5052

5153

5254
## Interface
5355

56+
```cpp
57+
#include "AngleConvertor.h"
58+
```
59+
60+
5461
#### Constructor
5562

5663
- **AngleConvertor()** create an AngleConvertor, default value is zero.
5764

5865

59-
#### setters
66+
#### Setters
6067

6168
- **void setDegrees(float value = 0)**
6269
- **void setRadians(float value = 0)**
@@ -80,7 +87,7 @@ AngleConvertor is an Arduino class to convert an angle from and to less known fo
8087
- **void setTurn(float value = 0)**
8188

8289

83-
#### getters
90+
#### Getters
8491

8592
- **float getDegrees()**
8693
- **float getRadians()**
@@ -103,6 +110,18 @@ AngleConvertor is an Arduino class to convert an angle from and to less known fo
103110
- **float getSign()**
104111
- **float getTurn()**
105112

113+
#### WindRose
114+
115+
116+
From: https://forum.arduino.cc/t/function-optimization-wind-direction-open-for-ideas/92493/10
117+
118+
Converts an angle in degrees to a char array like "WSW".
119+
0 and 360 degrees is considered North.
120+
121+
- **char \* windrose()** converter version.
122+
- **char \* windrose(float degrees)** stand alone version.
123+
degrees should be between 0 and 360, as function does no normalization.
124+
106125

107126
## Operation
108127

@@ -111,16 +130,17 @@ See examples.
111130

112131
## Future
113132

114-
#### must
133+
#### Must
134+
115135
- improve documentation
116136

117-
#### should
137+
#### Should
118138

119139

120-
#### could
140+
#### Could
141+
121142
- add dedicated functions == faster (on request only).
122143
- add more conversions
123144
- integrate with **Angle class** ?
124145
- printing can be a lot of work
125146

126-
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//
2+
// FILE: AngleConverter_windrose.ino
3+
// AUTHOR: Rob Tillaart
4+
// PURPOSE: demo sketch to test angleConvertor class
5+
// DATE: 2022-12-01
6+
// URL: https://github.com/RobTillaart/AngleConvertor
7+
//
8+
9+
10+
#include "AngleConvertor.h"
11+
12+
AngleConvertor conv;
13+
14+
uint32_t start, stop;
15+
16+
17+
void setup()
18+
{
19+
Serial.begin(115200);
20+
Serial.println(__FILE__);
21+
Serial.print("lib version: ");
22+
Serial.println(ANGLECONVERTOR_LIB_VERSION);
23+
Serial.println();
24+
25+
26+
for (int angle = 0; angle <= 360; angle += 5)
27+
{
28+
Serial.print(angle);
29+
Serial.print("\t");
30+
Serial.print(conv.windrose(angle));
31+
Serial.println();
32+
}
33+
Serial.println();
34+
delay(100);
35+
36+
start = micros();
37+
conv.setDegrees(127.876);
38+
char * p = conv.windrose();
39+
stop = micros();
40+
41+
Serial.print("WINDROSE TIME: \t");
42+
Serial.println(stop - start);
43+
Serial.print("WINDROSE DIR: \t");
44+
Serial.println(p);
45+
46+
Serial.println("\nDone...");
47+
}
48+
49+
50+
void loop()
51+
{
52+
}
53+
54+
55+
// -- END OF FILE --

libraries/AngleConvertor/keywords.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ getSextant KEYWORD2
5353
getSign KEYWORD2
5454
getTurn KEYWORD2
5555

56+
# Windrose
57+
58+
windrose KEYWORD2
59+
5660

5761
# Constants (LITERAL1)
5862
ANGLECONVERTOR_LIB_VERSION LITERAL1

libraries/AngleConvertor/library.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "AngleConvertor",
3-
"keywords": "Angle,convert,degrees,radians",
3+
"keywords": "Angle,convert,degrees,radians,windrose",
44
"description": "Library to convert between different less known angle formats.",
55
"authors":
66
[
@@ -15,7 +15,7 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/AngleConvertor.git"
1717
},
18-
"version": "0.1.0",
18+
"version": "0.1.1",
1919
"license": "MIT",
2020
"frameworks": "arduino",
2121
"platforms": "*",

libraries/AngleConvertor/library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name=AngleConvertor
2-
version=0.1.0
2+
version=0.1.1
33
author=Rob Tillaart <[email protected]>
44
maintainer=Rob Tillaart <[email protected]>
55
sentence=Library to convert between different less known angle formats.
6-
paragraph=
6+
paragraph=degrees,radians,gradians,windrose
77
category=Data Processing
88
url=https://github.com/RobTillaart/AngleConvertor
99
architectures=*

libraries/AngleConvertor/test/unit_test_001.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ unittest_setup()
4242
fprintf(stderr, "ANGLECONVERTOR_LIB_VERSION: %s\n", (char *) ANGLECONVERTOR_LIB_VERSION);
4343
}
4444

45+
4546
unittest_teardown()
4647
{
4748
}
@@ -115,4 +116,6 @@ unittest(test_conversions)
115116

116117
unittest_main()
117118

119+
118120
// -- END OF FILE --
121+

0 commit comments

Comments
 (0)