aboutsummaryrefslogtreecommitdiffstats
path: root/lib/weather.lua
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-17 08:56:04 +0200
committerDanilo M. <danix@danix.xyz>2026-09-17 08:56:04 +0200
commit17692349e6b6ce3f6083b5d565dda9f3ca7dba22 (patch)
tree136bdba9785f1cdbf5ff33716f0a0360e96cad96 /lib/weather.lua
parenta249039f2de33d8cc8126d6dd62fbc1004193536 (diff)
downloadconky-theme-udt-17692349e6b6ce3f6083b5d565dda9f3ca7dba22.tar.gz
conky-theme-udt-17692349e6b6ce3f6083b5d565dda9f3ca7dba22.zip
docs: explain the Beaufort index arithmetic and why compass exists
Two comments, no behaviour change. `force - 1` reads as an off-by-one until you know the scale starts at 0 while ipairs starts at 1, so the loop index is already force + 1. Said plainly now, along with why the fall-through returns 12. compass() has no caller: the card draws arrow(). It is kept because it shares arrow()'s binning exactly, so testing both pins that shared logic from two angles, and switching the card to "S 9 km/h" becomes a one-word change. Without this note the next reader finds an unused function and has to reconstruct the reasoning. Raised by code review as the only two points worth acting on; no Critical or Important issues were found. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'lib/weather.lua')
-rw-r--r--lib/weather.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/weather.lua b/lib/weather.lua
index 6e2741a..ac1f4cf 100644
--- a/lib/weather.lua
+++ b/lib/weather.lua
@@ -71,6 +71,10 @@ end
-- Beaufort force from km/h. Upper bounds carried over from the polybar
-- script; a value equal to a bound stays in the lower force.
+--
+-- The scale starts at 0 and ipairs starts at 1, so force N's upper bound is
+-- BEAUFORT[N + 1] and the loop index is already N + 1. Hence `force - 1`
+-- below. The scale tops out at 12, which is why the fall-through returns it.
local BEAUFORT = { 1, 5, 11, 19, 28, 38, 49, 61, 74, 88, 102, 117 }
function M.beaufort(kmh)
@@ -84,6 +88,11 @@ end
-- Eight compass points. The half-step offset is what makes north straddle
-- zero: without it, 350 degrees would land in NW and 10 in NE, leaving north
-- with only half its arc.
+--
+-- Nothing calls compass() yet: the card draws arrow() instead. It is kept
+-- because it shares arrow()'s binning exactly, so testing both pins that
+-- shared logic from two angles, and swapping the card to read "S 9 km/h"
+-- instead of an arrow is then a one-word change rather than new code.
local POINTS = { 'N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW' }
function M.compass(deg)