Skip to content

Commit 16f1886

Browse files
committed
Update MoonPhase, MoonRise and SunRise librairies from https://github.com/signetica
1 parent 5614bb5 commit 16f1886

14 files changed

Lines changed: 224 additions & 160 deletions

File tree

‎qml/ScreenSettings.qml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,22 @@ Loader {
14771477
}
14781478
}
14791479

1480+
Text { // legend_sunandmoon
1481+
anchors.left: parent.left
1482+
anchors.leftMargin: contentColumn.paddingLeft + contentColumn.padText
1483+
anchors.right: parent.right
1484+
anchors.rightMargin: contentColumn.paddingRight + Theme.componentMargin
1485+
1486+
topPadding: -12
1487+
bottomPadding: 12
1488+
1489+
text: qsTr("Gives you sunset / sunrise time at your location.")
1490+
textFormat: Text.StyledText
1491+
wrapMode: Text.WordWrap
1492+
color: Theme.colorSubText
1493+
font.pixelSize: Theme.fontSizeContentSmall
1494+
}
1495+
14801496
////////
14811497

14821498
Item {

‎thirdparty/SunAndMoon/CMakeLists.txt‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
cmake_minimum_required(VERSION 3.20)
2+
13
project(SunAndMoon LANGUAGES CXX)
24

35
set(CMAKE_CXX_STANDARD 17)
6+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
47
set(CMAKE_AUTOMOC ON)
8+
set(CMAKE_AUTORCC ON)
9+
10+
find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml)
511

612
################################################################################
713

814
# Generic dependencies
9-
set(CORE_COMPONENTS Core Gui Qml)
10-
find_package(Qt6 REQUIRED COMPONENTS ${CORE_COMPONENTS})
11-
12-
1315
set(CORE_LIBRARIES Qt::Core)
1416

1517
# Generic sources
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Copyright 2007 Stephen R. Schmitt
1+
Copyright 2007 Stephen R. Schmitt
22
Subsequent work Copyright 2020 Cyrus Rahman
33
You may use or modify this source code in any way you find useful, provided
4-
that you agree that the author(s) have no warranty, obligations or liability.
5-
You must determine the suitability of this source code for your use.
4+
that you agree that the author(s) have no warranty, obligations or liability. You
5+
must determine the suitability of this source code for your use.
66

77
Redistributions of this source code must retain this copyright notice.

‎thirdparty/SunAndMoon/MoonPhase/MoonPhase.cpp‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,25 @@
99
// by Cyrus Rahman, this work is subject to Stephen Schmitt's copyright:
1010
//
1111
// Copyright 2004 Stephen R. Schmitt
12-
// Subsequent work Copyright 2020 Cyrus Rahman
12+
// Subsequent work Copyright 2020-2026 Cyrus Rahman
1313
// You may use or modify this source code in any way you find useful, provided
14-
// that you agree that the author(s) have no warranty, obligations or liability.
15-
// You must determine the suitability of this source code for your use.
16-
17-
#include "MoonPhase.h"
14+
// that you agree that the author(s) have no warranty, obligations or liability. You
15+
// must determine the suitability of this source code for your use.
1816

1917
#include <math.h>
18+
#include "MoonPhase.h"
2019

2120
// Names of lunar phases
2221
static const char *phaseNames[] = {"New", "Evening Crescent", "First Quarter",
23-
"Waxing Gibbous", "Full", "Waning Gibbous",
24-
"Last Quarter", "Morning Crescent"};
22+
"Waxing Gibbous", "Full", "Waning Gibbous",
23+
"Last Quarter", "Morning Crescent"};
2524
// Names of Zodiac constellations
2625
static const char *zodiacNames[] = {"Pisces", "Aries", "Taurus", "Gemini", "Cancer",
27-
"Leo", "Virgo", "Libra", "Scorpio", "Sagittarius",
28-
"Capricorn", "Aquarius"};
26+
"Leo", "Virgo", "Libra", "Scorpio", "Sagittarius",
27+
"Capricorn", "Aquarius"};
2928
// Ecliptic angles of Zodiac constellations
3029
static const float zodiacAngles[] = {33.18, 51.16, 93.44, 119.48, 135.30, 173.34,
31-
224.17, 242.57, 271.26, 302.49, 311.72, 348.58};
30+
224.17, 242.57, 271.26, 302.49, 311.72, 348.58};
3231

3332
// Constructor initialization.
3433
MoonPhase::MoonPhase() {
@@ -39,7 +38,8 @@ MoonPhase::MoonPhase() {
3938
distance = 0;
4039
latitude = 0;
4140
longitude = 0;
42-
phaseName = zodiacName = "";
41+
phaseName = phaseNames[0];
42+
zodiacName = zodiacNames[0];
4343
}
4444

4545
// Determine the Moon Phase and orbital positions for the specified time.
@@ -62,8 +62,8 @@ MoonPhase::calculate(time_t t) {
6262
double distancePhase = (jDate - MOON_DISTANCE_OFFSET) / MOON_DISTANCE_PERIOD;
6363
distancePhase -= floor(distancePhase);
6464
distance = 60.4 - 3.3 * cos(2 * M_PI * distancePhase)
65-
- 0.6 * cos(2 * 2 * M_PI * phase - 2 * M_PI * distancePhase)
66-
- 0.5 * cos(2 * 2 * M_PI * phase);
65+
- 0.6 * cos(2 * 2 * M_PI * phase - 2 * M_PI * distancePhase)
66+
- 0.5 * cos(2 * 2 * M_PI * phase);
6767

6868
// Calculate ecliptic latitude from nodal (draconic) phase.
6969
double latPhase = (jDate - MOON_LATITUDE_OFFSET) / MOON_LATITUDE_PERIOD;
@@ -74,15 +74,15 @@ MoonPhase::calculate(time_t t) {
7474
double longPhase = (jDate - MOON_LONGITUDE_OFFSET) / MOON_LONGITUDE_PERIOD;
7575
longPhase -= floor(longPhase);
7676
longitude = 360 * longPhase
77-
+ 6.3 * sin(2 * M_PI * distancePhase)
78-
+ 1.3 * sin(2 * 2 * M_PI * phase - 2 * M_PI * distancePhase)
79-
+ 0.7 * sin(2 * 2 * M_PI * phase);
77+
+ 6.3 * sin(2 * M_PI * distancePhase)
78+
+ 1.3 * sin(2 * 2 * M_PI * phase - 2 * M_PI * distancePhase)
79+
+ 0.7 * sin(2 * 2 * M_PI * phase);
8080
if (longitude > 360)
8181
longitude -= 360;
8282

8383
// Select the Zodiac name.
8484
zodiacName = zodiacNames[0];
85-
for (unsigned i = 0; i < sizeof(zodiacAngles) / sizeof(float); i++) {
85+
for (int i = 0; i < sizeof(zodiacAngles) / sizeof(float); i++) {
8686
if (longitude < zodiacAngles[i]) {
8787
zodiacName = zodiacNames[i];
8888
break;

‎thirdparty/SunAndMoon/MoonPhase/MoonPhase.h‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44
#include <time.h>
55

66
#define MOON_SYNODIC_PERIOD 29.530588853 // Period of moon cycle in days.
7-
#define MOON_SYNODIC_OFFSET 2451550.26 // Reference cycle offset in days.
7+
#define MOON_SYNODIC_OFFSET 2451550.26 // Reference cycle offset in days.
88
#define MOON_DISTANCE_PERIOD 27.55454988 // Period of distance oscillation
99
#define MOON_DISTANCE_OFFSET 2451562.2
1010
#define MOON_LATITUDE_PERIOD 27.212220817 // Latitude oscillation
11-
#define MOON_LATITUDE_OFFSET 2451565.2
11+
#define MOON_LATITUDE_OFFSET 2451565.2
1212
#define MOON_LONGITUDE_PERIOD 27.321582241 // Longitude oscillation
13-
#define MOON_LONGITUDE_OFFSET 2451555.8
13+
#define MOON_LONGITUDE_OFFSET 2451555.8
1414

1515
class MoonPhase {
1616
public:
1717
double jDate;
18-
double phase; // 0 - 1, 0.5 = full
19-
double age; // Age in days of current cycle
20-
double fraction; // Fraction of illuminated disk
21-
double distance; // Moon distance in earth radii
22-
double latitude; // Moon ecliptic latitude
23-
double longitude; // Moon ecliptic longitude
18+
double phase; // 0 - 1, 0.5 = full
19+
double age; // Age in days of current cycle
20+
double fraction; // Fraction of illuminated disk
21+
double distance; // Moon distance in earth radii
22+
double latitude; // Moon ecliptic latitude
23+
double longitude; // Moon ecliptic longitude
2424
const char *phaseName; // New, Full, etc.
2525
const char *zodiacName; // Constellation
2626

@@ -30,5 +30,4 @@ class MoonPhase {
3030
private:
3131
double julianDate(time_t);
3232
};
33-
3433
#endif

‎thirdparty/SunAndMoon/MoonPhase/README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Arduino processors) there is a version of the software included in
1818
this distribution (MoonPhaseFXP, for Floating X Precision) that avoids exceeding the
1919
available precision.
2020

21-
To paraphrase the original author Bradley E Schaefer:
21+
To paraphrase the original author Bradley E. Schaefer:
2222

2323
I can only think of one application where lunar phase is needed to a
2424
hundredth of a day, whereas nearly all applications are happy to have
@@ -33,12 +33,12 @@ To paraphrase the original author Bradley E Schaefer:
3333

3434
This software was originally adapted to javascript by Stephen R. Schmitt
3535
from a BASIC program from the 'Astronomical Computing' column of Sky & Telescope,
36-
April 1994, page 84, written by Bradley E. Schaefer.
36+
April 1994, page 86, written by Bradley E. Schaefer.
3737

3838
## Usage
3939

4040
To use the MoonPhase library, include MoonPhase.h
41-
41+
4242
#include <MoonPhase.h>
4343
#include <MoonPhaseFXP.h> // (for 4-byte double precision)
4444

@@ -50,7 +50,7 @@ To use the MoonPhase library, include MoonPhase.h
5050
mp.calculate(time_t time); // (for 4-byte double precision)
5151

5252
### Arguments
53-
time: // The time of the desired the moon phase and position, in UTC
53+
time: // The time of the desired moon phase and position, in UTC
5454
// seconds from the Unix epoch (January 1, 1970).
5555

5656
// As the moon phase changes slowly and precision within a few
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Copyright 2007 Stephen R. Schmitt
1+
Copyright 2007 Stephen R. Schmitt
22
Subsequent work Copyright 2020 Cyrus Rahman
33
You may use or modify this source code in any way you find useful, provided
4-
that you agree that the author(s) have no warranty, obligations or liability.
5-
You must determine the suitability of this source code for your use.
4+
that you agree that the author(s) have no warranty, obligations or liability. You
5+
must determine the suitability of this source code for your use.
66

77
Redistributions of this source code must retain this copyright notice.

0 commit comments

Comments
 (0)