mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.1.13 Angle
This commit is contained in:
parent
3ced6ab10e
commit
86307cd8cb
@ -1,3 +1,18 @@
|
||||
platforms:
|
||||
rpipico:
|
||||
board: rp2040:rp2040:rpipico
|
||||
package: rp2040:rp2040
|
||||
gcc:
|
||||
features:
|
||||
defines:
|
||||
- ARDUINO_ARCH_RP2040
|
||||
warnings:
|
||||
flags:
|
||||
|
||||
packages:
|
||||
rp2040:rp2040:
|
||||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
|
||||
|
||||
compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
@ -7,5 +22,7 @@ compile:
|
||||
# - leonardo
|
||||
- m4
|
||||
- esp32
|
||||
# - esp8266
|
||||
- esp8266
|
||||
# - mega2560
|
||||
- rpipico
|
||||
|
||||
|
@ -1,26 +1,12 @@
|
||||
//
|
||||
// FILE: Angle.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.12
|
||||
// VERSION: 0.1.13
|
||||
// PURPOSE: library for Angle math for Arduino
|
||||
// URL: https://github.com/RobTillaart/Angle
|
||||
// http://forum.arduino.cc/index.php?topic=339402
|
||||
//
|
||||
// HISTORY
|
||||
// 0.1.00 initial version
|
||||
// 0.1.01 clean up a bit
|
||||
// 0.1.02 added toRadians() + fix compare()
|
||||
// 0.1.03 added URL, fromRadians [TEST]
|
||||
// 0.1.04 changed thousands in tenthousands, string constructor
|
||||
// 0.1.05 added AngleFormat proxy added 03/03/15 by Christoper Andrews.
|
||||
// 0.1.06 fixed bug negative values.
|
||||
// 0.1.7 2020-03-26 refactor #pragma once
|
||||
// 0.1.8 2020-05-27 update library.json
|
||||
// 0.1.9 2020-12-10 Arduino CI
|
||||
// 0.1.10 2021-01-16 readme.md + minor refactor
|
||||
// 0.1.11 2021-10-17 update build-CI,
|
||||
// 0.1.12 2021-12-12 update library.json, license, minor edits
|
||||
|
||||
// HISTORY: see changelog.md
|
||||
|
||||
|
||||
#include "Angle.h"
|
||||
@ -38,7 +24,7 @@ size_t AngleFormat::printTo(Print& p) const
|
||||
}
|
||||
|
||||
|
||||
Angle::Angle(int dd, int mm, int ss, int tt) // TODO optimize
|
||||
Angle::Angle(int dd, int mm, int ss, int tt)
|
||||
{
|
||||
neg = false;
|
||||
d = dd;
|
||||
@ -52,9 +38,11 @@ Angle::Angle(int dd, int mm, int ss, int tt) // TODO optimize
|
||||
if (m < 0) { m = -m; neg = true; }
|
||||
if (s < 0) { s = -s; neg = true; }
|
||||
if (t < 0) { t = -t; neg = true; }
|
||||
// modulo might be faster
|
||||
while (t >= 10000) { s++; t -= 10000; }
|
||||
while (s >= 60) { m++; s -= 60; }
|
||||
while (m >= 60) { d++; m -= 60; }
|
||||
// check special case 0
|
||||
if (d == 0 && m == 0 && s == 0 && t == 0) neg = false;
|
||||
}
|
||||
|
||||
@ -79,6 +67,8 @@ Angle::Angle(const double alpha)
|
||||
p = p / 10000UL;
|
||||
s = p % 60UL;
|
||||
m = p / 60UL;
|
||||
// check special case 0
|
||||
if (d == 0 && m == 0 && s == 0 && t == 0) neg = false;
|
||||
}
|
||||
|
||||
|
||||
@ -133,6 +123,8 @@ Angle::Angle(const char * str)
|
||||
yy = yy / 10000UL;
|
||||
s = yy % 60;
|
||||
m = yy / 60;
|
||||
// check special case 0
|
||||
if (d == 0 && m == 0 && s == 0 && t == 0) neg = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: Angle.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.12
|
||||
// VERSION: 0.1.13
|
||||
// PURPOSE: angle library for Arduino
|
||||
// HISTORY: See angle.cpp
|
||||
//
|
||||
@ -15,7 +15,7 @@
|
||||
#include "Printable.h"
|
||||
|
||||
|
||||
#define ANGLE_LIB_VERSION (F("0.1.12"))
|
||||
#define ANGLE_LIB_VERSION (F("0.1.13"))
|
||||
|
||||
|
||||
class Angle;
|
||||
|
61
libraries/Angle/CHANGELOG.md
Normal file
61
libraries/Angle/CHANGELOG.md
Normal file
@ -0,0 +1,61 @@
|
||||
# Change Log Angle
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [0.1.13] - 2022-10-12
|
||||
- Add RP2040 support to build-CI
|
||||
- Add CHANGELOG.md
|
||||
- minor change unit test
|
||||
- minor edits (comments)
|
||||
- Add zero tests to two constructors (zero is not negative)
|
||||
|
||||
## [0.1.12] - 2021-12-12
|
||||
- update library.json
|
||||
- update license
|
||||
- minor edits
|
||||
|
||||
## [0.1.11] - 2021-10-17
|
||||
- update build-CI
|
||||
|
||||
## [0.1.10] - 2021-01-16
|
||||
- update readme.md
|
||||
- minor refactor
|
||||
|
||||
## [0.1.9] - 2020-12-10
|
||||
- Add build Arduino CI
|
||||
|
||||
## [0.1.8] - 2020-05-27
|
||||
- update library.json
|
||||
|
||||
## [0.1.7] - 2020-03-26
|
||||
- refactor #pragma once
|
||||
|
||||
## [0.1.06]
|
||||
- fixed bug negative values
|
||||
|
||||
## [0.1.05] 2015-03-03
|
||||
- added AngleFormat
|
||||
- proxy added 03/03/15 by Christoper Andrews
|
||||
|
||||
## [0.1.04]
|
||||
- changed thousands in tenthousands
|
||||
- add string constructor
|
||||
|
||||
## [0.1.03]
|
||||
- added URL
|
||||
- fromRadians (test)
|
||||
|
||||
## [0.1.02]
|
||||
- added toRadians()
|
||||
- fix compare()
|
||||
|
||||
## [0.1.01]
|
||||
- clean up a bit
|
||||
|
||||
## [0.1.00]
|
||||
- initial version
|
||||
|
@ -80,5 +80,10 @@ bugs. Especially the constructor does not check input so use it carefully.
|
||||
- improve documentation
|
||||
- test more
|
||||
- optimize code where possible
|
||||
- performance sketch
|
||||
- improve code quality
|
||||
- fix TODO in code
|
||||
- use better variable names in code
|
||||
- move all code to .cpp
|
||||
|
||||
|
||||
|
@ -11,6 +11,7 @@ degree KEYWORD2
|
||||
minute KEYWORD2
|
||||
second KEYWORD2
|
||||
tenthousand KEYWORD2
|
||||
|
||||
toDouble KEYWORD2
|
||||
toRadians KEYWORD2
|
||||
fromRadians KEYWORD2
|
||||
|
@ -20,7 +20,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/Angle.git"
|
||||
},
|
||||
"version": "0.1.12",
|
||||
"version": "0.1.13",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*",
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=Angle
|
||||
version=0.1.12
|
||||
version=0.1.13
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Library to convert between floating point angle to minutes hours representation.
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
unittest_setup()
|
||||
{
|
||||
fprintf(stderr, "ANGLE_LIB_VERSION: %s\n", (char *) ANGLE_LIB_VERSION);
|
||||
}
|
||||
|
||||
unittest_teardown()
|
||||
@ -48,8 +49,6 @@ unittest_teardown()
|
||||
|
||||
unittest(test_constructors)
|
||||
{
|
||||
fprintf(stderr, "ANGLE_LIB_VERSION: %s\n", (char *) ANGLE_LIB_VERSION);
|
||||
|
||||
Angle a(1, 2, 3, 4);
|
||||
Angle b(-45, 30);
|
||||
Angle n(0);
|
||||
@ -87,6 +86,7 @@ unittest(test_constructors)
|
||||
assertEqual(0, s.tenthousand());
|
||||
}
|
||||
|
||||
|
||||
unittest(test_toDouble)
|
||||
{
|
||||
Angle a(1, 2, 3, 4);
|
||||
@ -108,6 +108,7 @@ unittest(test_toDouble)
|
||||
assertMoreOrEqual(38, fs);
|
||||
}
|
||||
|
||||
|
||||
unittest(test_Radians)
|
||||
{
|
||||
Angle a(1, 2, 3, 4);
|
||||
|
Loading…
Reference in New Issue
Block a user