Commit Graph

64 Commits (bcbca9e0650d8a1a2dfc092c7561faa08169a3c8)

Author SHA1 Message Date
Kenny Levinsen bcbca9e065 Use illuminant D for the majority of temperatures
D65, the natural whitepoint that wlsunset assumes, is defined on
illuminant D, which simulates daylight with atmospheric effects.
However, we used planckian locus for all values under 6500 K, which
meant that there was a significant jump in color - specifically, a
sudden reduction in green and blue - as we started reducing the color
temperature.

Instead, we purely use illuminant D down to 4000 K where it is well
defined. Below 4000 K, illuminant D starts unintentionally approaching
the planckian locus, before finally breaking completely at 2000 K. We
extend the boundary of illuminant D to 2500 K and perform a
sine-smoothed transition to planckian locus from 4000 K to 2500 K to
extend the range of wlsunset down to 1667 K, where planckian locus ends
and we finally give up.

The end-result is a smooth transition along all valid temperature
values, with no sudden jumps as we had before. However, we do end up
with slightly greener/bluer colors than earlier. We'll have to see how
that holds up.
2020-11-11 16:40:37 +01:00
Kenny Levinsen 49ad3ce7a8 meson: Disable implicit-fallthrough
Clang cannot decide how it wishes to handle implicit-fallthrough, with
different solutions across different versions, which presents a problem
on FreeBSD where several majors of clang remain relevant.

Disable implicit-fallthrough until clang has figured out what it wants
to do in life.
2020-11-09 21:50:21 +01:00
Kenny Levinsen 22589b8f1f ci: Add FreeBSD to CI 2020-11-09 17:11:37 +01:00
Jan Beich ec0c1614af meson: explicitly depend on libwayland for includes
On BSDs base compiler doesn't search packages by default, making it
easy for vendors to depend only on base system.

FAILED: wlsunset.p/main.c.o
cc -Iwlsunset.p -I. -I.. -Xclang -fcolor-diagnostics -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -Werror -std=c11 -g -Wundef -Wunused -Wlogical-op -Wmissing-include-dirs -Wold-style-definition -Wpointer-arith -Wstrict-prototypes -Wimplicit-fallthrough -Wmissing-prototypes -Wno-unknown-warning-option -Wno-unused-command-line-argument -Wvla -Wl,--exclude-libs=ALL -D_USE_MATH_DEFINES -D_XOPEN_SOURCE=700 -MD -MQ wlsunset.p/main.c.o -MF wlsunset.p/main.c.o.d -o wlsunset.p/main.c.o -c ../main.c
../main.c:14:10: fatal error: 'wayland-client-protocol.h' file not found
 #include <wayland-client-protocol.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
2020-11-09 15:13:08 +01:00
Kenny Levinsen 33c64bc929 man: Remove reference to missing features 2020-10-31 01:57:31 +01:00
Rohan Kumar fa2bd44253 Add manpage 2020-10-27 10:10:09 +01:00
Kenny Levinsen 0569fb45bd Option cleanup 2020-10-21 01:41:49 +02:00
Kenny Levinsen 0da97df89e Use clock_gettime for all time requests 2020-10-21 00:49:35 +02:00
Kenny Levinsen 0703fbcc0e Minor line length reduction 2020-10-21 00:41:50 +02:00
Kenny Levinsen b9f0b8e3c0 Move longitude time correction out of calc_sun
calc_sun reported sun trajectory in seconds since the start of a UTC
day, as they would occur for the specified UTC day. The caller would
then add the UTC timestamp for the start of a UTC day to these numbers.
This lead to complications, as e.g. a sunrise in China would be a
negative value, as it occurred in the last UTC day.

Futhermore, the start of a UTC day was used to signal the need for new
sun calculations. This would lead to recalculations to possibly occur
after its results were needed, such as after sunrise when the target
longitude deviated significantly from the prime meridian.

To fix this, we apply longitude time correction to the start of day
calculation. This way recalculation will occur on the start of the
longitude local day, close midnight for the observer.

We also remove the longitude time correction from calc_sun, so that it
simply returning the number of seconds since the start of the local day
of the observer. The caller then adds the start of the longitude local
day to get the final numbers.
2020-10-19 14:18:28 +02:00
Kenny Levinsen b43cd9f343 Sort sun and wayland code 2020-10-19 00:39:38 +02:00
Kenny Levinsen 1da4343e31 Remove manual duration for now 2020-10-19 00:37:47 +02:00
Kenny Levinsen 5c497febb7 Do not use -1 for sun calc error 2020-10-19 00:37:02 +02:00
Kenny Levinsen c7c8dad01d Self-pipe timer signal handling 2020-10-18 22:41:22 +02:00
Kenny Levinsen f66842c020 Split up main a bit 2020-10-18 01:19:47 +02:00
Kenny Levinsen fdcdb04023 Remove clamp from color_math.h 2020-10-18 00:45:36 +02:00
Kenny Levinsen 75b0a71d99 Simplify speedrun code a bit 2020-10-18 00:36:52 +02:00
Kenny Levinsen e14e8efcf3 Gracefully handle midnight sun/polar night
The sun trajectory calculation previously emitted garbage if midnight
sun or polar night phenomena was in effect. To fix this, the calculation
is overhauled to report if the computation failed, and if so, which
specific phenomena was the cause.

Timing recalulation uses this information to change out of the normal
state that uses the four sun position timings, into a static state where
wlsunset simply waits a day at a time for a normal sun trajectory
pattern to be restored. In this state, a fixedc high/low temperature is
set as appropriate for the phenomena.

A transition phase replicating the previous day's sunrise is used to
smooth out entry into a midnight sun, which would otherwise cause a
jarring instant-daylight setting.
2020-10-18 00:36:52 +02:00
Kenny Levinsen 7bd167e9d3 Split state from config, cleanup 2020-10-14 17:57:34 +02:00
Kenny Levinsen 67896358cf Precalculate animation step timings 2020-10-14 15:50:25 +02:00
Kenny Levinsen 9922bdeeef Cleanup dawn-overflowing deadline 2020-10-07 22:02:02 +02:00
Kenny Levinsen 3186967e1d Simplify state management 2020-10-07 21:55:46 +02:00
Kenny Levinsen 7c22eade9a Change twilight interval to -3 to 6 2020-10-04 19:51:25 +02:00
Kenny Levinsen 601e15080e Perform absolute sleeps 2020-10-04 19:49:45 +02:00
Kenny Levinsen 1dfefe2b51 Update temperature log 2020-10-04 15:33:00 +02:00
Kenny Levinsen cb294e1735 Prefix registry log output 2020-10-04 15:31:17 +02:00
Kenny Levinsen 46b9010b76 Warn about speedrun mode 2020-10-04 15:30:58 +02:00
Kenny Levinsen 83d90d2bea Calculate dawn and dusk times 2020-10-04 15:30:45 +02:00
Kenny Levinsen ddbb8f9912 Rename states to dawn, day, dusk and night 2020-10-04 15:26:47 +02:00
Kenny Levinsen caba0d8dcc Clean up gamma_control on failure 2020-10-04 15:24:54 +02:00
Kenny Levinsen f8269d8754 Improve speedrun time, increase to x1000 time 2020-10-04 15:23:49 +02:00
Kenny Levinsen 55bd086b51 Better log output 2020-10-04 01:03:23 +02:00
Kenny Levinsen 01779f7349 Break out of poll on signal 2020-10-04 00:56:51 +02:00
Kenny Levinsen daf27a5f11 Free output on removal, log add/remove 2020-10-04 00:56:17 +02:00
Kenny Levinsen 5761b05c1b Use wlsunset in anonymous file template 2020-10-04 00:55:25 +02:00
Kenny Levinsen 0128fb535f Check for zero-value in recalc_stops 2020-09-27 16:08:56 +02:00
Kenny Levinsen a74f7fd44f Allow direct high-to-low state transition 2020-09-26 19:37:52 +02:00
Kenny Levinsen 25ab690fa9 Recalculate next day immediately after sunset 2020-09-26 19:30:21 +02:00
Kenny Levinsen 39b211da95 Start high-to-low animation before sunset
Low-to-high animation runs from sunrise to sunrise+duration. However,
high-to-low animation ran from sunset to sunset+duration.

Run high-to-low animation at sunset-duration to sunset.
2020-09-26 19:27:48 +02:00
Kenny Levinsen 07f2f1d3ce Only print hour/min/sec during speedrun 2020-09-20 17:53:50 +02:00
Kenny Levinsen 3353efc0ae Silence erroneous uninitialized value warning
The compiler is confused by the circular switch, and thinks that temp
might become uniniitalized. This is clearly false, as it is set at all
switch breaks.

Silence the warning by explicitly initializing it to zero.
2020-09-20 17:29:56 +02:00
Kenny Levinsen f2f11dada2 Add SPEEDRUN mode, improve sleep timing
Add a SPEEDRUN define which, if set, will run wlsunset at 200x
super-realtime to aid testing.

Sleep timing calculations were approximated and often off. These have
been adjusted from testing using the SPEEDRUN feature.
2020-09-20 17:26:27 +02:00
Kenny Levinsen 20a40d450b Error if high/low temp is identical 2020-09-20 17:25:38 +02:00
Kenny Levinsen 81d87e3c47 readme: Add IRC and mailing list note 2020-09-20 03:54:16 +02:00
Kenny Levinsen 9df941cfd1 Allow complete state fallthrough 2020-09-20 03:52:32 +02:00
Kenny Levinsen 940cf08226 Account when forcing high/low state 2020-09-20 03:50:47 +02:00
Kenny Levinsen 71f0f904e2 Increase animation resolution 2020-09-20 03:49:42 +02:00
Kenny Levinsen c7e004c65b Handle sun times ahead of wallclock 2020-09-20 03:49:27 +02:00
Kenny Levinsen ef117f0a1f Typo in calculation message 2020-09-15 11:59:58 +02:00
Kenny Levinsen efa5b63ebd readme: Fix xkcd ref 2020-09-14 11:20:23 +02:00