From 871eb7d0a98776c6edc144ba76c9453b33b23117 Mon Sep 17 00:00:00 2001 From: rob tillaart Date: Mon, 27 Dec 2021 20:50:10 +0100 Subject: [PATCH] 0.1.2 relativity --- libraries/relativity/.arduino-ci.yml | 6 +++- .../.github/workflows/arduino_test_runner.yml | 10 ++++-- libraries/relativity/LICENSE | 2 +- libraries/relativity/README.md | 34 +++++++++++-------- .../examples/gamma_table/gamma_table.ino | 4 ++- .../examples/gravity_demo/gravity_demo.ino | 3 +- .../relativity_demo/relativity_demo.ino | 3 +- libraries/relativity/library.json | 5 +-- libraries/relativity/library.properties | 2 +- libraries/relativity/relativity.h | 10 +++--- libraries/relativity/test/unit_test_001.cpp | 3 +- 11 files changed, 50 insertions(+), 32 deletions(-) diff --git a/libraries/relativity/.arduino-ci.yml b/libraries/relativity/.arduino-ci.yml index ff5659b9..3e496624 100644 --- a/libraries/relativity/.arduino-ci.yml +++ b/libraries/relativity/.arduino-ci.yml @@ -2,6 +2,10 @@ compile: # Choosing to run compilation tests on 2 different Arduino platforms platforms: - uno - - leonardo - due - zero + - leonardo + - m4 + - esp32 + - esp8266 + - mega2560 diff --git a/libraries/relativity/.github/workflows/arduino_test_runner.yml b/libraries/relativity/.github/workflows/arduino_test_runner.yml index 476456bb..096b975b 100644 --- a/libraries/relativity/.github/workflows/arduino_test_runner.yml +++ b/libraries/relativity/.github/workflows/arduino_test_runner.yml @@ -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 diff --git a/libraries/relativity/LICENSE b/libraries/relativity/LICENSE index a8b455d0..5777550e 100644 --- a/libraries/relativity/LICENSE +++ b/libraries/relativity/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021-2021 Rob Tillaart +Copyright (c) 2021-2022 Rob Tillaart Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/libraries/relativity/README.md b/libraries/relativity/README.md index 4aef09a9..735f8d57 100644 --- a/libraries/relativity/README.md +++ b/libraries/relativity/README.md @@ -1,5 +1,7 @@ [![Arduino CI](https://github.com/RobTillaart/relativity/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci) +[![Arduino-lint](https://github.com/RobTillaart/relativity/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/relativity/actions/workflows/arduino-lint.yml) +[![JSON check](https://github.com/RobTillaart/relativity/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/relativity/actions/workflows/jsoncheck.yml) [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/relativity/blob/master/LICENSE) [![GitHub release](https://img.shields.io/github/release/RobTillaart/relativity.svg?maxAge=3600)](https://github.com/RobTillaart/relativity/releases) @@ -11,18 +13,19 @@ Arduino library with relativity functions. ## Description -This experimental library implements a number of functions that give indication of the time dilation etc due to relativistic speed. +This experimental library implements a number of functions that give an +indication of the time dilation etcetera due to relativistic speed. -Goal: Educational purposes or when one puts a cubesat into space :) +Goal: Educational purposes or when one puts a cube-sat into space :) ## Interface -- **relativity()** constructor -- **double getC()** returns speed of light -- **double getG()** returns gravitational constant -- **double factor(double speed)** returns sqrt(1-v2/c2) -- **double gamma(double speed)** returns 1/sqrt(1-v2/c2) +- **relativity()** constructor. +- **double getC()** returns speed of light. +- **double getG()** returns gravitational constant. +- **double factor(double speed)** returns sqrt(1-v2/c2). +- **double gamma(double speed)** returns 1/sqrt(1-v2/c2). - **double relativeTime(double time, double speed)** returns the relative time for given time and speed. - **double relativeLength(double length, double speed)** returns the relative length for given length and speed. - **double relativeMass(double mass, double speed)** returns the relative mass for given mass and speed. @@ -31,11 +34,12 @@ Goal: Educational purposes or when one puts a cubesat into space :) ### Caching variants -These functions are the same however the math to calculate a given factor and gamma is done only once and cached. So these function will perform a bit better, especially if floating point is slow. +These functions are the same however the math to calculate a given factor and gamma is done only once and cached. +So these functions will perform a bit better, especially if floating point is slow. -- **void setSpeed(double speed = 0)** set the speed once and calculate the factor and gamma to minimize math for next functions. Think caching. +- **void setSpeed(double speed = 0)** set the speed and calculate the factor and gamma to minimize math for next functions. - **double getSpeed()** returns speed set. -- **double getFactor()** returns factor for speed set +- **double getFactor()** returns factor for speed set. - **double getGamma()** returns gamma for speed set. - **double relativeTime(double time)** returns the relative time for speed set with **setSpeed()**. - **double relativeLength(double length)** returns the relative length for speed set. @@ -46,12 +50,13 @@ These functions are the same however the math to calculate a given factor and ga ### Gravity effects - **double gravitationalTime(double time, double speed)** returns time dilation due to gravitational effects. -- **double diameterEarth(uint8_t longitude = 45)** calculates the diameter of the Earth given it is not a nice circle but more an ellipse, flatter on the poles and thicker on the equator. -Longitude is in (absolute) degrees. +- **double diameterEarth(double longitude = 45)** calculates the diameter of the Earth given it is not a nice +circle but more an ellipse, flatter on the poles and thicker on the equator. +Longitude is in degrees -90 .. 90. - **double getPlanetMass(uint8_t n)** returns planet mass in **kg** -where param n: 0 = Sun, 1 = Mercury etc +where parameter n: 0 = Sun, 1 = Mercury etc. - **double getPlanetRadius(uint8_t n)** returns planet radius in **km** -where param n: 0 = Sun, 1 = Mercury etc +where parameter n: 0 = Sun, 1 = Mercury etc. ## Operations @@ -64,6 +69,5 @@ See examples for typical usage. - test test test test - add more functions - fix some overflow conditions. - - add moons? - add caching version of mass / radius; diff --git a/libraries/relativity/examples/gamma_table/gamma_table.ino b/libraries/relativity/examples/gamma_table/gamma_table.ino index 0cf28a59..f6b8bcf3 100644 --- a/libraries/relativity/examples/gamma_table/gamma_table.ino +++ b/libraries/relativity/examples/gamma_table/gamma_table.ino @@ -1,7 +1,6 @@ // // FILE: gamma_table.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.0 // PURPOSE: test formulas // DATE: 2021-05-29 // URL: https://github.com/RobTillaart/relativity @@ -14,6 +13,7 @@ uint32_t start, stop; relativity R; + void setup() { Serial.begin(115200); @@ -46,4 +46,6 @@ void loop() { } + // -- END OF FILE -- + diff --git a/libraries/relativity/examples/gravity_demo/gravity_demo.ino b/libraries/relativity/examples/gravity_demo/gravity_demo.ino index aa34466d..a343a41a 100644 --- a/libraries/relativity/examples/gravity_demo/gravity_demo.ino +++ b/libraries/relativity/examples/gravity_demo/gravity_demo.ino @@ -1,7 +1,6 @@ // // FILE: gravity_demo.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.0 // PURPOSE: test formulas // DATE: 2021-05-29 // URL: https://github.com/RobTillaart/relativity @@ -35,4 +34,6 @@ void loop() { } + // -- END OF FILE -- + diff --git a/libraries/relativity/examples/relativity_demo/relativity_demo.ino b/libraries/relativity/examples/relativity_demo/relativity_demo.ino index 85e0fa4c..d8beb302 100644 --- a/libraries/relativity/examples/relativity_demo/relativity_demo.ino +++ b/libraries/relativity/examples/relativity_demo/relativity_demo.ino @@ -1,7 +1,6 @@ // // FILE: relativity_demo.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.0 // PURPOSE: test formulas // DATE: 2021-05-29 // URL: https://github.com/RobTillaart/relativity @@ -48,4 +47,6 @@ void loop() { } + // -- END OF FILE -- + diff --git a/libraries/relativity/library.json b/libraries/relativity/library.json index 1649e26b..927c7f78 100644 --- a/libraries/relativity/library.json +++ b/libraries/relativity/library.json @@ -15,8 +15,9 @@ "type": "git", "url": "https://github.com/RobTillaart/relativity.git" }, - "version": "0.1.1", + "version": "0.1.2", "license": "MIT", "frameworks": "*", - "platforms": "*" + "platforms": "*", + "headers": "relativity.h" } diff --git a/libraries/relativity/library.properties b/libraries/relativity/library.properties index 2b311867..f16d8940 100644 --- a/libraries/relativity/library.properties +++ b/libraries/relativity/library.properties @@ -1,5 +1,5 @@ name=relativity -version=0.1.1 +version=0.1.2 author=Rob Tillaart maintainer=Rob Tillaart sentence=library with relativity functions. diff --git a/libraries/relativity/relativity.h b/libraries/relativity/relativity.h index b18718da..724b8ff8 100644 --- a/libraries/relativity/relativity.h +++ b/libraries/relativity/relativity.h @@ -2,19 +2,20 @@ // // FILE: relativity.h // AUTHOR: Rob Tillaart -// VERSION: 0.1.1 +// VERSION: 0.1.2 // PURPOSE: Collection relativity formulas // URL: https://github.com/RobTillaart/relativity // // HISTORY: // 0.1.0 2021-05-29 initial version // 0.1.1 2021-06-02 fix in tests +// 0.1.2 2021-12-27 update library.json, readme, license, minor edits #include "Arduino.h" -#define RELATIVITY_LIB_VERSION (F("0.1.1")) +#define RELATIVITY_LIB_VERSION (F("0.1.2")) class relativity @@ -122,7 +123,7 @@ public: } // returns radius in km. - double radiusEarth(uint8_t longitude = 45) // 0..90 + double radiusEarth(double longitude = 45) // 0..90 { // https://www.youtube.com/watch?v=hYMvJum9_Do @ 8:00 // radius polar: 6357 km @@ -130,7 +131,7 @@ public: // difference: 21 km double radians = longitude * (PI / 180.0); - // approx of the graph in youtube with a cosine + // approx of the graph in YouTube with a cosine return 6367.5 + 10.5 * cos(radians * 2); } @@ -194,3 +195,4 @@ private: // -- END OF FILE -- + diff --git a/libraries/relativity/test/unit_test_001.cpp b/libraries/relativity/test/unit_test_001.cpp index 0d4cb251..6571e0e7 100644 --- a/libraries/relativity/test/unit_test_001.cpp +++ b/libraries/relativity/test/unit_test_001.cpp @@ -37,6 +37,7 @@ unittest_setup() { + fprintf(stderr, "RELATIVITY_LIB_VERSION: %s\n", (char*) RELATIVITY_LIB_VERSION); } @@ -47,8 +48,6 @@ unittest_teardown() unittest(test_constructor) { - fprintf(stderr, "VERSION: %s\n", RELATIVITY_LIB_VERSION); - relativity R; // test constants