From 723481395dece030131b82f840e74505f22d40ee Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Fri, 4 Dec 2026 17:09:01 +0100 Subject: [PATCH 01/13] Docs site: README links into docs/ lead to the page again, not to a 404 Changelog: - Co-Authored-By: Claude Opus 5.5 --- .github/docs-site.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/docs-site.sh b/.github/docs-site.sh index 87a645e13..29007d6b5 100644 --- a/.github/docs-site.sh +++ b/.github/docs-site.sh @@ -33,12 +33,15 @@ rm -f "$stage/docs/docs.md" # how to build upstream's site, not for readers # README of the fork: "## O tomto forku" .. "## About this fork" = Czech, # from there to "## About MeshCore" = English. One heading level up, links -# into docs/ made site-relative, any other repo path absolute. +# into docs/ made site-relative, any other repo path absolute. The docs/ +# links are marked (@) before the absolute rewrite and unmarked after it, +# otherwise that rewrite caught them too (src/branch/main/power.md, a 404). readme_part() { sed -n "/^## $1/,/^## $2/p" README.md | sed '$d' | sed -E 's/^#(#+) /\1 /' | - sed -E 's#\]\((\./)?docs/([^)]+)\)#](\2)#g' | - sed -E "s#\\]\\((\\./)?([a-zA-Z][^):]*)\\)#](${src//#/\\#}/\\2)#g" + sed -E 's#\]\((\./)?docs/([^)]+)\)#](@\2)#g' | + sed -E "s#\\]\\((\\./)?([a-zA-Z][^):]*)\\)#](${src//#/\\#}/\\2)#g" | + sed -E 's#\]\(@#](#g' } readme_part 'About this fork' 'About MeshCore' >"$stage/docs/index.md" readme_part 'O tomto forku' 'About this fork' >"$stage/docs/cs.md" From ae0e80cde7559cb64fdda9d9229016b5bfd81867 Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Fri, 4 Dec 2026 17:09:13 +0100 Subject: [PATCH 02/13] Docs: power calculator -- board, firmware, settings, traffic and battery to average current and autonomy Changelog: - Co-Authored-By: Claude Opus 5.5 --- README.md | 4 + docs/_js/power-calculator.js | 406 +++++++++++++++++++++++++++++++++++ docs/_stylesheets/tth.css | 15 ++ docs/power-calculator.md | 49 +++++ docs/power-data.json | 258 ++++++++++++++++++++++ docs/power.md | 5 + mkdocs.tth.yml | 6 + 7 files changed, 743 insertions(+) create mode 100644 docs/_js/power-calculator.js create mode 100644 docs/power-calculator.md create mode 100644 docs/power-data.json diff --git a/README.md b/README.md index 8cc660050..039978d04 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,8 @@ Každá úspora proti upstreamu s naměřeným proudem a vlivem na příjem je v tabulce: [docs/power.md](docs/power.md#summary-every-option-against-stock-firmware). Změřeno proti upstreamu na stejné desce (XIAO, 3,3 V): náš repeater **6,87 mA**, upstream v1.19.0, jak ho dostanete, **10,13 mA** (−32 %; [protokol](docs/measurements/2026-12-04-stock-vs-tth/protocol.md)). +Kolik to dá pro váš uzel (deska, firmware, nastavení, provoz, baterie, panel): +[kalkulačka spotřeby](docs/power-calculator.md#cs). * GPS duty cycle (`gps duty`), i na T1000-E, kde nebyl: přijímač běží jen kolem synchronizace hodin (jednou denně, po neúspěšném okně znovu za 6 h). @@ -540,6 +542,8 @@ Every saving against upstream, with the measured current and its effect on reception, is in one table: [docs/power.md](docs/power.md#summary-every-option-against-stock-firmware). Measured against upstream on the same board (XIAO, 3.3 V): our repeater **6.87 mA**, upstream v1.19.0 as shipped **10.13 mA** (−32 %; [protocol](docs/measurements/2026-12-04-stock-vs-tth/protocol.md)). +What that means for your node (board, firmware, settings, traffic, battery, +panel): [power calculator](docs/power-calculator.md). * GPS duty cycle (`gps duty`), also on the T1000-E, which had none: the receiver runs only around a clock sync (once a day, after a window without diff --git a/docs/_js/power-calculator.js b/docs/_js/power-calculator.js new file mode 100644 index 000000000..fb6daf980 --- /dev/null +++ b/docs/_js/power-calculator.js @@ -0,0 +1,406 @@ +/* Power calculator of the docs site (docs/power-calculator.md, issue #48). + Plain JS, no framework, no build step. Loaded on every page through + extra_javascript in mkdocs.tth.yml; does nothing unless the page has +
. Every number comes from docs/power-data.json, this file + holds only the method (baseline + deltas + LoRa airtime) and the UI text. */ +(function () { + 'use strict'; + var script = document.currentScript; + + var T = { + en: { + title: 'Inputs', node: 'Node', settings: 'Settings', traffic: 'Traffic (estimate)', + battery: 'Battery and solar', result: 'Result', values: 'All values of the data file', + board: 'board', firmware: 'firmware', + powersaving: 'powersaving (MCU sleep)', rxps: 'radio.rxps (RX duty cycle)', + rxgain: 'radio.rxgain (boosted RX gain)', ble: 'BLE', gps: 'GPS', + rx_per_h: 'received packets / h', tx_per_h: 'transmitted packets / h (incl. forwarded)', + payload: 'packet length (bytes)', sf: 'SF', bw: 'BW (kHz)', cr: 'CR (4/x)', + preamble: 'preamble (symbols)', tx_dbm: 'TX power (dBm)', + tx_ma: 'TX current at that power (mA) - ESTIMATE', rx_extra: 'extra current while receiving (mA) - ESTIMATE', + mah: 'battery capacity (mAh)', usable_pct: 'usable capacity (%)', voltage: 'battery voltage (V)', + panel_w: 'solar panel (W, 0 = none)', sun_h: 'full-sun hours per day', charge_eff_pct: 'charging efficiency (%) - ESTIMATE', + measured: 'measured', estimate: 'ESTIMATE', unavailable: 'not in this firmware', + base: 'whole node', borrowed: 'taken from', fwoffset: 'firmware difference measured on', + nofwoffset: 'no measurement of this firmware on this board: the baseline of another firmware is used as is', + txline: 'transmitting', rxline: 'receiving', airtime: 'airtime of one packet', + avg: 'average current', perday: 'per day', autonomy: 'autonomy without sun', + days: 'days', solar: 'solar gain per day', balance: 'daily balance', + positive: 'the battery charges on such days', emptyin: 'battery empty in', + cost: 'reception cost', range: 'range', voltnote: 'currents of the measurement rig at', + battnote: 'Battery figures assume the node draws the same current from the cell (linear regulator).', + src: 'source', kind: 'kind', option: 'option', value: 'value', date: 'date', + loadfail: 'Could not load power-data.json: ', lang: 'Česky' + }, + cs: { + title: 'Vstupy', node: 'Uzel', settings: 'Nastavení', traffic: 'Provoz (odhad)', + battery: 'Baterie a solár', result: 'Výsledek', values: 'Všechny hodnoty datového souboru', + board: 'deska', firmware: 'firmware', + powersaving: 'powersaving (spánek MCU)', rxps: 'radio.rxps (střídání příjmu)', + rxgain: 'radio.rxgain (zesílený příjem)', ble: 'BLE', gps: 'GPS', + rx_per_h: 'přijatých paketů / h', tx_per_h: 'odvysílaných paketů / h (vč. přeposlaných)', + payload: 'délka paketu (bajty)', sf: 'SF', bw: 'BW (kHz)', cr: 'CR (4/x)', + preamble: 'preambule (symboly)', tx_dbm: 'vysílací výkon (dBm)', + tx_ma: 'proud při vysílání (mA) - ODHAD', rx_extra: 'proud navíc při příjmu (mA) - ODHAD', + mah: 'kapacita baterie (mAh)', usable_pct: 'využitelná kapacita (%)', voltage: 'napětí baterie (V)', + panel_w: 'solární panel (W, 0 = žádný)', sun_h: 'hodin plného slunce za den', charge_eff_pct: 'účinnost nabíjení (%) - ODHAD', + measured: 'změřeno', estimate: 'ODHAD', unavailable: 'tento firmware nemá', + base: 'celý uzel', borrowed: 'převzato z', fwoffset: 'rozdíl firmwarů změřený na', + nofwoffset: 'tento firmware na této desce změřený není: použit základ jiného firmwaru tak, jak je', + txline: 'vysílání', rxline: 'příjem', airtime: 'doba vysílání jednoho paketu', + avg: 'průměrný proud', perday: 'za den', autonomy: 'výdrž bez slunce', + days: 'dní', solar: 'zisk ze soláru za den', balance: 'denní bilance', + positive: 'v takové dny se baterie nabíjí', emptyin: 'baterie prázdná za', + cost: 'cena v příjmu', range: 'rozsah', voltnote: 'proudy měřicí sestavy při', + battnote: 'Výpočet baterie předpokládá, že uzel bere z článku stejný proud (lineární regulátor).', + src: 'zdroj', kind: 'druh', option: 'volba', value: 'hodnota', date: 'datum', + loadfail: 'Nepodařilo se načíst power-data.json: ', lang: 'English' + } + }; + + function el(tag, attrs, kids) { + var e = document.createElement(tag); + Object.keys(attrs || {}).forEach(function (k) { + if (k === 'text') e.textContent = attrs[k]; + else e.setAttribute(k, attrs[k]); + }); + (kids || []).forEach(function (c) { + if (c != null) e.appendChild(typeof c === 'string' ? document.createTextNode(c) : c); + }); + return e; + } + + function start() { + var root = document.getElementById('pcalc'); + if (!root || !script) return; + var base = new URL('../', script.src); // the script lives in /_js/ + fetch(new URL('power-data.json', base)) + .then(function (r) { + if (!r.ok) throw new Error('HTTP ' + r.status); + return r.json(); + }) + .then(function (d) { new Calc(root, d, base); }) + .catch(function (e) { root.textContent = T.en.loadfail + e.message; }); + } + + function Calc(root, d, base) { + this.root = root; + this.d = d; + this.base = base; + var h = location.hash.replace('#', ''); + this.lang = h === 'cs' || h === 'en' ? h : + (navigator.language || '').slice(0, 2) === 'cs' ? 'cs' : 'en'; + var td = d.traffic.defaults, b = d.battery; + this.s = { + board: d.boards[0].id, firmware: d.firmwares[0].id, + rx_per_h: td.rx_per_h, tx_per_h: td.tx_per_h, payload: td.payload, + sf: td.sf, bw: td.bw, cr: td.cr, preamble: td.preamble, tx_dbm: td.tx_dbm, + rx_extra: d.traffic.rx_extra.value, + mah: b.mah, usable_pct: b.usable_pct, voltage: b.voltage, + panel_w: b.panel_w, sun_h: b.sun_h, charge_eff_pct: b.charge_eff_pct + }; + this.s.tx_ma = this.txCurrent(this.s.tx_dbm); + this.applyDefaults(); + this.build(); + } + + var P = Calc.prototype; + + P.t = function (k) { return T[this.lang][k] || k; }; + P.n = function (o) { return o[this.lang] || o.en; }; // localized name of a data object + P.fmt = function (x, dec) { + var s = x.toFixed(dec == null ? 2 : dec); + return this.lang === 'cs' ? s.replace('.', ',') : s; + }; + P.board = function () { var s = this.s; return this.d.boards.filter(function (b) { return b.id === s.board; })[0]; }; + P.fw = function () { var s = this.s; return this.d.firmwares.filter(function (f) { return f.id === s.firmware; })[0]; }; + P.available = function (opt) { + if (opt === 'gps' && !this.board().gps) return false; + return this.fw().options.indexOf(opt) >= 0; + }; + + // board defaults, then what the firmware ships with; options it lacks are pinned off + P.applyDefaults = function () { + var self = this, def = Object.assign({}, this.board().defaults, this.fw().defaults); + Object.keys(this.d.settings).forEach(function (k) { + var vals = self.d.settings[k]; + if (!self.available(k)) self.s[k] = vals.indexOf('off') >= 0 ? 'off' : vals[0]; + else if (def[k] != null) self.s[k] = def[k]; + else if (vals.indexOf(self.s[k]) < 0) self.s[k] = vals[0]; + }); + }; + + // radio current in TX, linear between the points of the data file + P.txCurrent = function (dbm) { + var pts = this.d.traffic.tx_current.points.slice().sort(function (a, b) { return a.dbm - b.dbm; }); + if (dbm <= pts[0].dbm) return pts[0].value; + for (var i = 1; i < pts.length; i++) { + if (dbm <= pts[i].dbm) { + var a = pts[i - 1], b = pts[i]; + return Math.round(a.value + (b.value - a.value) * (dbm - a.dbm) / (b.dbm - a.dbm)); + } + } + return pts[pts.length - 1].value; + }; + + // LoRa time on air, Semtech SX1262 datasheet / AN1200.13: explicit header, CRC on + P.airtime = function () { + var s = this.s, sf = +s.sf, bw = +s.bw * 1000, cr = +s.cr - 4; + var tsym = Math.pow(2, sf) / bw; + var de = tsym > 0.016 ? 1 : 0; + var num = 8 * s.payload - 4 * sf + 28 + 16; + var nPay = 8 + Math.max(Math.ceil(num / (4 * (sf - 2 * de))) * (cr + 4), 0); + return (+s.preamble + 4.25) * tsym + nPay * tsym; + }; + + P.range = function (v) { return Array.isArray(v) ? [Math.min(v[0], v[1]), Math.max(v[0], v[1])] : [v, v]; }; + + P.pickBaseline = function () { + var s = this.s, keys = Object.keys(this.d.settings); + var rows = this.d.values.filter(function (v) { return v.kind === 'baseline' && v.board === s.board; }); + var same = rows.filter(function (v) { return v.firmware === s.firmware; }); + var pool = same.length ? same : rows; + function diff(v) { return keys.filter(function (k) { return v.settings[k] !== s[k]; }).length; } + pool.sort(function (a, b) { + return diff(a) - diff(b) || (b.measured - a.measured) || (a.firmware === 'tth' ? -1 : 1); + }); + return { row: pool[0], borrowed: !same.length }; + }; + + // delta rows of one option between two values, best match first: + // same board and firmware, same board, any board + P.findDelta = function (opt, from, to) { + var s = this.s, best = null; + this.d.values.forEach(function (v) { + if (v.kind !== 'delta' || v.option !== opt) return; + var sign = v.from === from && v.to === to ? 1 : v.from === to && v.to === from ? -1 : 0; + if (!sign) return; + var fwOk = v.firmware === '*' || v.firmware === s.firmware; + var rank = (v.board === s.board ? 0 : 2) + (fwOk ? 0 : 1); + if (!best || rank < best.rank) best = { row: v, sign: sign, rank: rank }; + }); + return best; + }; + + P.compute = function () { + var self = this, s = this.s, d = this.d, lines = []; + var pb = this.pickBaseline(), b = pb.row; + var u = b.uncertainty || 0, bmeas = b.measured && !pb.borrowed; + var bnote = b.firmware !== s.firmware ? this.t('borrowed') + ' ' + this.n(this.fwById(b.firmware)) : null; + lines.push({ label: this.t('base') + ' (' + this.settingsText(b) + ')', lo: b.value - u, hi: b.value + u, + approx: b.approx, measured: bmeas, row: b, note: bnote || (b['note_' + this.lang] || b.note_en) }); + + if (pb.borrowed) { // offset between the two firmwares, measured on another board + var off = this.fwOffset(b); + if (off) lines.push({ label: this.t('fwoffset') + ' ' + this.n(this.boardById(off.board)), lo: off.value, hi: off.value, measured: false, row: off.row }); + else lines.push({ label: this.t('nofwoffset'), lo: 0, hi: 0, measured: false, row: null, nonum: true }); + } + + Object.keys(d.settings).forEach(function (k) { + var from = b.settings[k], to = s[k]; + if (from === to || from == null) return; + var path = [], dd = self.findDelta(k, from, to); + if (dd) path.push(dd); + else d.settings[k].some(function (mid) { // one step through an intermediate value + var a = self.findDelta(k, from, mid), c = a && self.findDelta(k, mid, to); + if (a && c) { path.push(a, c); return true; } + return false; + }); + if (!path.length) { + lines.push({ label: k + ': ' + from + ' → ' + to, nonum: true, measured: false, row: null, lo: 0, hi: 0, note: '?' }); + return; + } + path.forEach(function (p) { + var r = self.range(p.row.value).map(function (x) { return x * p.sign; }); + var meas = p.row.measured && p.rank === 0; + var note = p.rank ? self.t('borrowed') + ' ' + self.n(self.boardById(p.row.board)) + + (p.row.firmware !== '*' ? ' / ' + self.n(self.fwById(p.row.firmware)) : '') : null; + lines.push({ label: k + ': ' + (p.sign > 0 ? p.row.from + ' → ' + p.row.to : p.row.to + ' → ' + p.row.from), + lo: Math.min(r[0], r[1]), hi: Math.max(r[0], r[1]), approx: p.row.approx, measured: meas, row: p.row, + note: note || (p.row['note_' + self.lang] || p.row.note_en), cost: self.cost(k, to) }); + }); + }); + + var at = this.airtime(); + var tx = s.tx_per_h * at / 3600 * s.tx_ma, rx = s.rx_per_h * at / 3600 * s.rx_extra; + lines.push({ label: this.t('txline') + ' (' + s.tx_per_h + '/h × ' + this.fmt(at * 1000, 0) + ' ms × ' + s.tx_ma + ' mA)', lo: tx, hi: tx, measured: false, row: null }); + lines.push({ label: this.t('rxline') + ' (' + s.rx_per_h + '/h × ' + this.fmt(at * 1000, 0) + ' ms × ' + s.rx_extra + ' mA)', lo: rx, hi: rx, measured: false, row: null }); + + var lo = 0, hi = 0, allMeas = true; + lines.forEach(function (l) { lo += l.lo; hi += l.hi; if (!l.measured) allMeas = false; }); + return { lines: lines, lo: lo, hi: hi, allMeasured: allMeas, airtime: at, voltage: b.voltage }; + }; + + P.fwById = function (id) { return this.d.firmwares.filter(function (f) { return f.id === id; })[0] || { en: id }; }; + P.boardById = function (id) { return this.d.boards.filter(function (f) { return f.id === id; })[0] || { en: id }; }; + P.settingsText = function (row) { + var self = this; + return Object.keys(row.settings).filter(function (k) { + return k !== 'gps' || self.board().gps; + }).map(function (k) { return k + ' ' + row.settings[k]; }).join(', '); + }; + + // (chosen firmware) - (baseline's firmware) with identical settings on another board + P.fwOffset = function (b) { + var s = this.s, vals = this.d.values, found = null; + vals.forEach(function (a) { + if (found || a.kind !== 'baseline' || a.firmware !== s.firmware || a.board === b.board) return; + vals.forEach(function (c) { + if (found || c.kind !== 'baseline' || c.board !== a.board || c.firmware !== b.firmware) return; + if (JSON.stringify(a.settings) === JSON.stringify(c.settings)) found = { board: a.board, value: a.value - c.value, row: a }; + }); + }); + return found; + }; + + P.cost = function (opt, to) { + return this.d.values.filter(function (v) { return v.kind === 'reception' && v.option === opt && v.to === to; })[0]; + }; + + P.srcLink = function (key) { + var src = this.d.sources[key]; + if (!src) return document.createTextNode(key || ''); + if (!src.url) return document.createTextNode(this.n(src)); + var parts = src.url.split('#'), p = parts[0]; + // mkdocs directory URLs: power.md -> power/, a/index.md -> a/ + p = p.replace(/(^|\/)index\.md$/, '$1').replace(/\.md$/, '/'); + var href = new URL(p, this.base).href + (parts[1] ? '#' + parts[1] : ''); + return el('a', { href: href, text: this.n(src) }); + }; + + P.badge = function (m) { + return el('span', { 'class': m ? 'pc-m' : 'pc-e', text: m ? this.t('measured') : this.t('estimate') }); + }; + + P.build = function () { + var self = this, s = this.s, d = this.d; + this.root.textContent = ''; + var langBtn = el('button', { type: 'button', 'class': 'pc-lang', text: this.t('lang') }); + langBtn.addEventListener('click', function () { self.lang = self.lang === 'cs' ? 'en' : 'cs'; self.build(); }); + this.root.appendChild(langBtn); + + function sel(key, opts, disabled) { + var e = el('select', { name: key }); + opts.forEach(function (o) { + var op = el('option', { value: o.v, text: o.t }); + if (String(s[key]) === String(o.v)) op.selected = true; + e.appendChild(op); + }); + if (disabled) e.disabled = true; + return e; + } + function num(key, step) { return el('input', { type: 'number', name: key, value: s[key], step: step || 'any', min: key === 'tx_dbm' ? '-9' : '0' }); } + function row(key, input, extra) { + return el('div', { 'class': 'pc-row' }, [el('label', { text: self.t(key) }), input, extra || null]); + } + + var form = el('form', { 'class': 'pc-form' }); + form.appendChild(el('h3', { text: this.t('node') })); + form.appendChild(row('board', sel('board', d.boards.map(function (b) { return { v: b.id, t: self.n(b) }; })))); + form.appendChild(row('firmware', sel('firmware', d.firmwares.map(function (f) { return { v: f.id, t: self.n(f) }; })))); + form.appendChild(el('h3', { text: this.t('settings') })); + Object.keys(d.settings).forEach(function (k) { + if (k === 'gps' && !self.board().gps) return; + var on = self.available(k); + var c = self.cost(k, s[k]); + var extra = !on ? el('span', { 'class': 'pc-note', text: self.t('unavailable') }) : + c ? el('span', { 'class': 'pc-cost' }, [self.t('cost') + ': ' + self.n(c) + ' ', self.badge(c.measured)]) : null; + form.appendChild(row(k, sel(k, d.settings[k].map(function (v) { return { v: v, t: v }; }), !on), extra)); + }); + form.appendChild(el('h3', { text: this.t('traffic') })); + ['rx_per_h', 'tx_per_h', 'payload'].forEach(function (k) { form.appendChild(row(k, num(k, 1))); }); + form.appendChild(row('sf', sel('sf', [7, 8, 9, 10, 11, 12].map(function (v) { return { v: v, t: v }; })))); + form.appendChild(row('bw', sel('bw', [62.5, 125, 250].map(function (v) { return { v: v, t: v }; })))); + form.appendChild(row('cr', sel('cr', [5, 6, 7, 8].map(function (v) { return { v: v, t: '4/' + v }; })))); + form.appendChild(row('preamble', num('preamble', 1))); + form.appendChild(row('tx_dbm', num('tx_dbm', 1))); + form.appendChild(row('tx_ma', num('tx_ma'), this.badge(false))); + form.appendChild(row('rx_extra', num('rx_extra'), this.badge(false))); + form.appendChild(el('h3', { text: this.t('battery') })); + ['mah', 'usable_pct', 'voltage', 'panel_w', 'sun_h', 'charge_eff_pct'].forEach(function (k) { form.appendChild(row(k, num(k))); }); + + form.addEventListener('input', function (ev) { + var t = ev.target, k = t.name; + if (!k) return; + var v = t.tagName === 'SELECT' && isNaN(+t.value) ? t.value : +t.value; + if (t.type === 'number' && t.value === '') return; + s[k] = v; + if (k === 'tx_dbm') s.tx_ma = self.txCurrent(v); + if (k === 'board' || k === 'firmware') self.applyDefaults(); + if (t.tagName === 'SELECT' || k === 'tx_dbm') self.build(); // dependent fields + else self.render(); + }); + form.addEventListener('submit', function (ev) { ev.preventDefault(); }); + + this.out = el('div', { 'class': 'pc-out' }); + this.root.appendChild(el('div', { 'class': 'pc-grid' }, [ + el('div', {}, [el('h2', { text: this.t('title') }), form]), + el('div', {}, [el('h2', { text: this.t('result') }), this.out]) + ])); + this.table = el('div', { 'class': 'pc-values' }); + this.root.appendChild(el('details', {}, [el('summary', { text: this.t('values') }), this.table])); + this.renderValues(); + this.render(); + }; + + P.render = function () { + var self = this, s = this.s, r = this.compute(), out = this.out; + out.textContent = ''; + var tb = el('tbody'); + r.lines.forEach(function (l) { + var val = l.nonum ? '' : (l.approx ? '~' : '') + (l.lo === l.hi ? self.fmt(l.lo) : self.fmt(l.lo) + ' … ' + self.fmt(l.hi)) + ' mA'; + var info = [self.badge(l.measured)]; + if (l.row && l.row.source) info.push(' ', self.srcLink(l.row.source)); + if (l.row && l.row.date) info.push(' (' + l.row.date + ')'); + if (l.note) info.push(el('div', { 'class': 'pc-note', text: l.note })); + if (l.cost) info.push(el('div', { 'class': 'pc-cost' }, [self.t('cost') + ': ' + self.n(l.cost) + ' ', self.badge(l.cost.measured)])); + tb.appendChild(el('tr', {}, [el('td', { text: l.label }), el('td', { 'class': 'pc-num', text: val }), el('td', {}, info)])); + }); + out.appendChild(el('table', { 'class': 'pc-lines' }, [tb])); + + var mid = (r.lo + r.hi) / 2, perDay = mid * 24, usable = s.mah * s.usable_pct / 100; + function kv(k, v, m) { + return el('tr', {}, [el('th', { text: k }), el('td', { 'class': 'pc-num', text: v }), el('td', {}, [m === undefined ? self.badge(r.allMeasured) : m])]); + } + var rng = r.lo === r.hi ? '' : ' (' + self.fmt(r.lo) + ' … ' + self.fmt(r.hi) + ')'; + var rows = [ + kv(this.t('avg'), this.fmt(mid) + ' mA' + rng), + kv(this.t('perday'), this.fmt(perDay, 0) + ' mAh'), + kv(this.t('autonomy'), this.fmt(usable / perDay, 1) + ' ' + this.t('days')) + ]; + if (s.panel_w > 0) { + var gain = s.panel_w * s.sun_h * (s.charge_eff_pct / 100) / s.voltage * 1000; + var bal = gain - perDay; + rows.push(kv(this.t('solar'), this.fmt(gain, 0) + ' mAh', this.badge(false))); + rows.push(kv(this.t('balance'), (bal >= 0 ? '+' : '') + this.fmt(bal, 0) + ' mAh', el('span', {}, [this.badge(false), ' ', + bal >= 0 ? this.t('positive') : this.t('emptyin') + ' ' + this.fmt(usable / -bal, 1) + ' ' + this.t('days')]))); + } + out.appendChild(el('table', { 'class': 'pc-sum' }, [el('tbody', {}, rows)])); + out.appendChild(el('p', { 'class': 'pc-note', text: this.t('airtime') + ': ' + this.fmt(r.airtime * 1000, 0) + ' ms. ' + + this.t('voltnote') + ' ' + this.fmt(r.voltage, 2) + ' V. ' + this.t('battnote') })); + }; + + P.renderValues = function () { + var self = this, d = this.d; + var head = el('tr', {}, ['kind', 'board', 'firmware', 'option', 'value', 'date', '', 'src'].map(function (k) { + return el('th', { text: k === 'kind' || k === 'board' || k === 'firmware' || k === 'option' || k === 'value' || k === 'date' || k === 'src' ? self.t(k) : '' }); + })); + var body = el('tbody'); + d.values.forEach(function (v) { + var what = v.kind === 'baseline' ? self.settingsAll(v) : v.option ? v.option + ': ' + (v.from ? v.from + ' → ' : '') + (v.to || '') : ''; + if (v.kind === 'reception' || v.kind === 'info') what += (what ? ' - ' : '') + self.n(v); + var val = v.value == null ? '' : (v.approx ? '~' : '') + (Array.isArray(v.value) ? self.fmt(v.value[0]) + ' … ' + self.fmt(v.value[1]) : self.fmt(v.value)) + + (v.uncertainty ? ' ± ' + self.fmt(v.uncertainty) : '') + ' ' + (v.unit || '') + (v.voltage ? ' @ ' + self.fmt(v.voltage, 2) + ' V' : ''); + body.appendChild(el('tr', {}, [ + el('td', { text: v.kind }), el('td', { text: v.board || '' }), el('td', { text: v.firmware || '' }), + el('td', { text: what }), el('td', { 'class': 'pc-num', text: val }), el('td', { text: v.date || '' }), + el('td', {}, [self.badge(v.measured)]), el('td', {}, [self.srcLink(v.source)]) + ])); + }); + this.table.appendChild(el('table', {}, [el('thead', {}, [head]), body])); + }; + P.settingsAll = function (v) { return Object.keys(v.settings).map(function (k) { return k + ' ' + v.settings[k]; }).join(', '); }; + + if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start); + else start(); +})(); diff --git a/docs/_stylesheets/tth.css b/docs/_stylesheets/tth.css index 0a049724e..e8fdf7261 100644 --- a/docs/_stylesheets/tth.css +++ b/docs/_stylesheets/tth.css @@ -34,3 +34,18 @@ .admonition.important > .admonition-title { color: var(--primary-color); } + +/* power calculator (power-calculator.md) */ +.pc-grid { display: grid; grid-template-columns: minmax(18em, 28em) 1fr; gap: 2em; } +@media (max-width: 60em) { .pc-grid { grid-template-columns: 1fr; } } +.pc-row { display: grid; grid-template-columns: 14em 1fr; gap: 0.2em 0.6em; align-items: center; margin: 0.15em 0; } +.pc-row > span { grid-column: 2; font-size: 0.85em; } +.pc-row select, .pc-row input { width: 100%; } +.pc-num { text-align: right; white-space: nowrap; } +.pc-m, .pc-e { font-size: 0.8em; padding: 0 0.3em; border: 1px solid; } +.pc-m { color: var(--primary-color); } +.pc-e { color: #e5a50a; } +.pc-cost { color: #e5a50a; font-size: 0.85em; } +.pc-note { font-size: 0.85em; opacity: 0.8; } +.pc-lang { float: right; } +.pc-values { overflow-x: auto; } diff --git a/docs/power-calculator.md b/docs/power-calculator.md new file mode 100644 index 000000000..779e3f728 --- /dev/null +++ b/docs/power-calculator.md @@ -0,0 +1,49 @@ +# Power calculator / Kalkulačka spotřeby + +Pick a board, firmware, settings, traffic and battery; the page adds up the +expected average current, energy per day and autonomy. Every line says whether +its number was **measured** or is an **estimate**, and where it comes from. +Česky: tlačítko „Česky" na stránce (odkaz s `#cs` ji otevře rovnou česky). + +
+ +> [!NOTE] +> The page is interactive on the docs site, +> https://tth-pub.pages.rfa.cz/meshcore-tth/power-calculator/ (a repository +> browser shows only this text). + +## How it computes + +- **Baseline:** the measured whole-node current of the chosen board and + firmware whose settings are closest to yours (no traffic, radio in RX). +- **Options:** for every setting that differs from that baseline, the paired + A/B delta from [power.md](power.md#summary-every-option-against-stock-firmware). + A delta measured on another board or firmware is used, but shown as an + estimate ("taken from ..."). +- **Traffic:** LoRa time on air with the Semtech formula (explicit header, + CRC on) for the packet length, SF, BW, CR and preamble; transmissions cost + the TX current at the set power, receptions an extra current while the packet + is being received. Both currents are **estimates** you can overwrite: the + TX one is interpolated from the SX1262 datasheet (14 dBm 45 mA, 22 dBm + 118 mA), below 14 dBm a guess. The baseline already contains the radio in RX. +- **Battery:** usable mAh / (average mA × 24 h). The node is assumed to draw + the same current from the cell (linear regulator); the absolute currents + belong to the measurement rig (XIAO at 3.26 V on its 3V3 pin, P1-Pro on the + 5 V USB side). +- **Solar:** panel W × full-sun hours × charging efficiency / battery voltage. + +**rxps is not free.** `radio.rxps balanced` and `max` save about 2 mA but lose +13-28 % of weak packets (SNR −2..−8) against none without it (bench +4. 12. 2026, [details](power.md#rx-duty-cycle-rxps)); the page shows that cost +next to the option. Use it only where packets arrive strong, never on a mast. + +## Data + +All numbers live in one file, +[`power-data.json`](https://git.rfa.cz/tth-pub/meshcore-tth/src/branch/main/docs/power-data.json): +each value with board, value, unit, date, source and `measured`. A new +measurement (the planned overnight re-measurement of every option on the same +rig) is a new row there, without touching the page; the whole table is also at +the bottom of the calculator. diff --git a/docs/power-data.json b/docs/power-data.json new file mode 100644 index 000000000..fb5ed51bb --- /dev/null +++ b/docs/power-data.json @@ -0,0 +1,258 @@ +{ + "_comment": [ + "Data of the power calculator (docs/power-calculator.md). The ONE place for", + "its numbers: the page reads this file, the JS holds no value. Every row of", + "`values` carries board, value, unit, date, source and measured; a new", + "measurement is a new row (or an edited one), no code change.", + "kind baseline: whole-node current of a board + firmware with the given", + "settings, no traffic. kind delta: change of current when `option` goes", + "from `from` to `to` on that board/firmware ('*' = not tied to a firmware);", + "value is a number or [min, max]. kind reception: what an option costs in", + "reception, shown next to it. kind info: shown in the table only.", + "Settings start at the board's defaults, then the firmware's (as shipped).", + "The calculator picks the baseline whose settings are closest to the chosen", + "ones and adds the deltas of the rest; a delta borrowed from another board", + "or firmware is shown as an estimate." + ], + "schema": 1, + "sources": { + "protocol-2026-12-04": { + "url": "measurements/2026-12-04-stock-vs-tth/protocol.md", + "en": "measurement protocol 4. 12. 2026 (stock vs this fork, k = 2)", + "cs": "protokol měření 4. 12. 2026 (upstream vs tento fork, k = 2)" + }, + "bench-2026-12-04-czech": { + "url": "measurements/2026-12-04-stock-vs-tth/protocol.md", + "en": "bench 4. 12. 2026 (cells C and C2), protocol update pending", + "cs": "lavice 4. 12. 2026 (buňky C a C2), doplnění protokolu čeká" + }, + "power-summary": { + "url": "power.md#summary-every-option-against-stock-firmware", + "en": "docs/power.md, summary table", + "cs": "docs/power.md, souhrnná tabulka" + }, + "power-rxps": { + "url": "power.md#rx-duty-cycle-rxps", + "en": "docs/power.md, RX duty cycle (bench 4. 12. 2026, #46)", + "cs": "docs/power.md, RX duty cycle (lavice 4. 12. 2026, #46)" + }, + "power-gps": { + "url": "power.md#gps-is-the-whole-game", + "en": "docs/power.md, GPS", + "cs": "docs/power.md, GPS" + }, + "power-ble": { + "url": "power.md#ble-two-defaults-that-were-quietly-expensive", + "en": "docs/power.md, BLE", + "cs": "docs/power.md, BLE" + }, + "power-nrf52": { + "url": "power.md#nrf52-sleep-and-peripheral-fixes", + "en": "docs/power.md, nRF52 fixes", + "cs": "docs/power.md, opravy nRF52" + }, + "sx1262-datasheet": { + "url": "", + "en": "SX1262 datasheet (Semtech), not measured", + "cs": "datasheet SX1262 (Semtech), neměřeno" + }, + "estimate": { + "url": "", + "en": "rough estimate, not measured", + "cs": "hrubý odhad, neměřeno" + } + }, + "boards": [ + { + "id": "xiao", + "en": "XIAO nRF52840 + Wio-SX1262 (fed on 3V3)", + "cs": "XIAO nRF52840 + Wio-SX1262 (napájené na 3V3)", + "gps": false, + "defaults": { "ble": "off", "gps": "off" } + }, + { + "id": "p1pro", + "en": "SenseCAP Solar P1-Pro (nRF52840 + SX1262 + L76K GPS)", + "cs": "SenseCAP Solar P1-Pro (nRF52840 + SX1262 + GPS L76K)", + "gps": true, + "defaults": { "ble": "on", "gps": "duty" } + } + ], + "firmwares": [ + { + "id": "tth", + "en": "this fork (meshcore-tth public release)", + "cs": "tento fork (veřejný release meshcore-tth)", + "options": ["powersaving", "rxps", "rxgain", "ble", "gps"], + "defaults": { "powersaving": "on", "rxps": "off", "rxgain": "on" } + }, + { + "id": "stock", + "en": "upstream MeshCore v1.19.0", + "cs": "upstream MeshCore v1.19.0", + "options": ["powersaving", "rxgain", "ble", "gps"], + "defaults": { "powersaving": "off", "rxps": "off", "rxgain": "on" } + }, + { + "id": "czech", + "en": "MeshCore Czech v1.19.0.01", + "cs": "MeshCore Czech v1.19.0.01", + "options": ["powersaving", "rxps", "rxgain", "ble", "gps"], + "defaults": { "powersaving": "on", "rxps": "balanced", "rxgain": "on" } + } + ], + "settings": { + "powersaving": ["on", "off"], + "rxps": ["off", "balanced", "max"], + "rxgain": ["on", "off"], + "ble": ["off", "on"], + "gps": ["off", "duty", "on"] + }, + "values": [ + { + "kind": "baseline", "board": "xiao", "firmware": "tth", + "settings": { "powersaving": "on", "rxps": "off", "rxgain": "on", "ble": "off", "gps": "off" }, + "value": 6.87, "uncertainty": 0.08, "unit": "mA", "voltage": 3.26, + "date": "2026-12-04", "source": "protocol-2026-12-04", "measured": true + }, + { + "kind": "baseline", "board": "xiao", "firmware": "stock", + "settings": { "powersaving": "on", "rxps": "off", "rxgain": "on", "ble": "off", "gps": "off" }, + "value": 7.27, "uncertainty": 0.09, "unit": "mA", "voltage": 3.26, + "date": "2026-12-04", "source": "protocol-2026-12-04", "measured": true + }, + { + "kind": "baseline", "board": "xiao", "firmware": "stock", + "settings": { "powersaving": "off", "rxps": "off", "rxgain": "on", "ble": "off", "gps": "off" }, + "value": 10.13, "uncertainty": 0.12, "unit": "mA", "voltage": 3.26, + "date": "2026-12-04", "source": "protocol-2026-12-04", "measured": true + }, + { + "kind": "baseline", "board": "xiao", "firmware": "czech", + "settings": { "powersaving": "on", "rxps": "off", "rxgain": "on", "ble": "off", "gps": "off" }, + "value": 7.35, "unit": "mA", "voltage": 3.26, + "date": "2026-12-04", "source": "bench-2026-12-04-czech", "measured": true + }, + { + "kind": "baseline", "board": "xiao", "firmware": "czech", + "settings": { "powersaving": "on", "rxps": "balanced", "rxgain": "on", "ble": "off", "gps": "off" }, + "value": 5.45, "approx": true, "unit": "mA", "voltage": 3.26, + "date": "2026-12-04", "source": "bench-2026-12-04-czech", "measured": true + }, + { + "kind": "baseline", "board": "p1pro", "firmware": "tth", + "settings": { "powersaving": "on", "rxps": "off", "rxgain": "on", "ble": "on", "gps": "duty" }, + "value": 24, "approx": true, "unit": "mA", "voltage": 5.0, + "note_en": "mast configuration, 5 V USB side, charged cell", + "note_cs": "konfigurace stožáru, strana 5 V USB, nabitý článek", + "date": "2026-08", "source": "power-summary", "measured": true + }, + + { + "kind": "delta", "option": "powersaving", "from": "off", "to": "on", + "board": "xiao", "firmware": "stock", + "value": -2.86, "unit": "mA", "date": "2026-12-04", + "source": "protocol-2026-12-04", "measured": true + }, + { + "kind": "delta", "option": "powersaving", "from": "off", "to": "on", + "board": "xiao", "firmware": "tth", + "value": -2.7, "unit": "mA", "date": "2026-11", + "source": "power-summary", "measured": true + }, + { + "kind": "delta", "option": "rxps", "from": "off", "to": "balanced", + "board": "xiao", "firmware": "tth", + "value": [-2.0, -1.8], "unit": "mA", "date": "2026-11", + "source": "power-rxps", "measured": true + }, + { + "kind": "delta", "option": "rxps", "from": "off", "to": "max", + "board": "xiao", "firmware": "tth", + "value": [-2.5, -2.3], "unit": "mA", "date": "2026-11", + "source": "power-rxps", "measured": true + }, + { + "kind": "delta", "option": "rxgain", "from": "on", "to": "off", + "board": "xiao", "firmware": "tth", + "value": [-0.51, -0.45], "unit": "mA", "date": "2026-11", + "source": "power-nrf52", "measured": true + }, + { + "kind": "delta", "option": "ble", "from": "on", "to": "off", + "board": "p1pro", "firmware": "tth", + "value": -1, "approx": true, "unit": "mA", "date": "2026-08", + "source": "power-ble", "measured": true + }, + { + "kind": "delta", "option": "gps", "from": "duty", "to": "on", + "board": "p1pro", "firmware": "*", + "value": [42, 45], "unit": "mA", "date": "2026-08", + "note_en": "receiver 46 mA continuous; gps duty saves 42-45 mA of it", + "note_cs": "přijímač 46 mA trvale; gps duty z toho ušetří 42-45 mA", + "source": "power-gps", "measured": true + }, + { + "kind": "delta", "option": "gps", "from": "duty", "to": "off", + "board": "p1pro", "firmware": "*", + "value": [-4, -1], "unit": "mA", "date": "2026-08", + "note_en": "derived: 46 mA minus the 42-45 mA duty saves", + "note_cs": "dopočteno: 46 mA minus 42-45 mA, které ušetří duty", + "source": "power-gps", "measured": false + }, + + { + "kind": "reception", "option": "rxps", "to": "balanced", + "en": "loses 13-28 % of weak packets (SNR -2..-8) against 0 % without rxps; strong signal 0 lost. Not for a mast.", + "cs": "ztratí 13-28 % slabých paketů (SNR -2..-8) proti 0 % bez rxps; silný signál 0 ztrát. Ne na stožár.", + "date": "2026-12-04", "source": "power-rxps", "measured": true + }, + { + "kind": "reception", "option": "rxps", "to": "max", + "en": "as balanced or worse: 13-28 % of weak packets lost; on a live mast -16 % received. Not for a mast.", + "cs": "jako balanced nebo hůř: ztráta 13-28 % slabých paketů; na ostrém stožáru -16 % přijatých. Ne na stožár.", + "date": "2026-12-04", "source": "power-rxps", "measured": true + }, + { + "kind": "reception", "option": "rxgain", "to": "off", + "en": "costs ~1-3 dB of sensitivity (datasheet, not measured).", + "cs": "stojí ~1-3 dB citlivosti (datasheet, neměřeno).", + "source": "sx1262-datasheet", "measured": false + }, + + { + "kind": "info", "option": "dcdc", "board": "xiao", "firmware": "tth", + "en": "DC/DC regulator off (all firmwares have it on)", + "cs": "DC/DC regulátor vypnutý (všechny firmwary ho mají zapnutý)", + "value": 0.6, "unit": "mA", "voltage": 3.3, "date": "2026-11", + "source": "power-nrf52", "measured": true + } + ], + "traffic": { + "_comment": "Defaults of the traffic inputs and the current the radio adds while it transmits/receives. All of it is an ESTIMATE the reader can overwrite on the page.", + "defaults": { + "rx_per_h": 120, "tx_per_h": 60, "payload": 60, + "sf": 7, "bw": 62.5, "cr": 5, "preamble": 16, "tx_dbm": 22 + }, + "rx_extra": { + "value": 3, "unit": "mA", "measured": false, "source": "estimate", + "en": "extra current while a packet is being received (radio held in RX, MCU awake)", + "cs": "proud navíc po dobu příjmu paketu (rádio drženo v RX, MCU vzhůru)" + }, + "tx_current": { + "_comment": "radio current in TX by output power; the page interpolates linearly in dBm. 14 and 22 dBm are datasheet figures, the rest a guess.", + "unit": "mA", "voltage": 3.3, + "points": [ + { "dbm": -9, "value": 15, "measured": false, "source": "estimate" }, + { "dbm": 0, "value": 20, "measured": false, "source": "estimate" }, + { "dbm": 14, "value": 45, "measured": false, "source": "sx1262-datasheet" }, + { "dbm": 22, "value": 118, "measured": false, "source": "sx1262-datasheet" } + ] + } + }, + "battery": { + "_comment": "defaults of the battery and solar inputs; efficiency and voltage are assumptions", + "mah": 3000, "usable_pct": 80, "voltage": 3.7, + "panel_w": 0, "sun_h": 2, "charge_eff_pct": 70 + } +} diff --git a/docs/power.md b/docs/power.md index 1a5383957..089426225 100644 --- a/docs/power.md +++ b/docs/power.md @@ -15,6 +15,11 @@ release. Current is the paired delta of switching the option on (negative = saves). Reception is what another board counted on the bench, or the live mesh where it says so. +What it adds up to for your node (board, firmware, settings, traffic, battery, +panel): the [power calculator](power-calculator.md), which reads its numbers +from [`power-data.json`](power-data.json) -- update that file together with +this table. + | option | stock | here | current | reception / transmission | details | |---|---|---|---|---|---| | GPS `gps duty` (receiver powered only around a daily clock sync) | continuous (`gps on`) or `gps period` | `gps duty` on mast builds | **−42 to −45 mA** of 46 (P1-Pro) | no effect on the radio | [GPS](#gps-is-the-whole-game) | diff --git a/mkdocs.tth.yml b/mkdocs.tth.yml index 4c85e5cc6..304f471be 100644 --- a/mkdocs.tth.yml +++ b/mkdocs.tth.yml @@ -23,6 +23,11 @@ theme: extra_css: - _stylesheets/tth.css +# the power calculator (power-calculator.md, data power-data.json); the +# script does nothing on a page without
+extra_javascript: + - _js/power-calculator.js + plugins: - search @@ -46,6 +51,7 @@ nav: - Console commands: tth-commands.md - Firmware update by the admin (OTA): ota.md - Power saving: power.md + - Power calculator: power-calculator.md - Budka as a sensor: budka-sensor.md - BLE/LoRa coexistence: ble-lora-coexistence.md - MeshCore (upstream): From d23beff8acc54784fd212f2eea899d0369bb3a17 Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Fri, 4 Dec 2026 17:18:26 +0100 Subject: [PATCH 03/13] Docs: power calculator gets a simple view -- result on top, the rest under Advanced Changelog: - Co-Authored-By: Claude Opus 5.5 --- docs/_js/power-calculator.js | 501 ++++++++++++++++++++++------------- docs/_stylesheets/tth.css | 89 ++++++- docs/power-calculator.md | 54 ++-- docs/power-data.json | 15 +- 4 files changed, 430 insertions(+), 229 deletions(-) diff --git a/docs/_js/power-calculator.js b/docs/_js/power-calculator.js index fb6daf980..e6a381aa3 100644 --- a/docs/_js/power-calculator.js +++ b/docs/_js/power-calculator.js @@ -2,59 +2,63 @@ Plain JS, no framework, no build step. Loaded on every page through extra_javascript in mkdocs.tth.yml; does nothing unless the page has
. Every number comes from docs/power-data.json, this file - holds only the method (baseline + deltas + LoRa airtime) and the UI text. */ + holds only the method (baseline + deltas + LoRa airtime) and the UI text. + UI: a simple view (what an operator knows), one "Advanced" section for the + rest, the result on top (sticky right column on a wide screen). */ (function () { 'use strict'; var script = document.currentScript; var T = { en: { - title: 'Inputs', node: 'Node', settings: 'Settings', traffic: 'Traffic (estimate)', - battery: 'Battery and solar', result: 'Result', values: 'All values of the data file', - board: 'board', firmware: 'firmware', - powersaving: 'powersaving (MCU sleep)', rxps: 'radio.rxps (RX duty cycle)', - rxgain: 'radio.rxgain (boosted RX gain)', ble: 'BLE', gps: 'GPS', - rx_per_h: 'received packets / h', tx_per_h: 'transmitted packets / h (incl. forwarded)', + node: 'Node', settings: 'Settings', traffic: 'Traffic', battery: 'Battery', + advanced: 'Advanced', breakdown: 'Breakdown', values: 'All values of the data file', + board: 'Board', firmware: 'Firmware', + powersaving: 'powersaving', rxps: 'radio.rxps', rxgain: 'radio.rxgain', ble: 'BLE', gps: 'GPS', + mah: 'Battery (mAh)', panel_w: 'Solar panel (W)', panel_hint: '0 = no panel', + rx_override: 'received packets / h', tx_override: 'transmitted packets / h', + override_hint: 'empty = the preset (quiet 30/10, normal 120/60, busy 600/300 RX/TX per hour)', payload: 'packet length (bytes)', sf: 'SF', bw: 'BW (kHz)', cr: 'CR (4/x)', preamble: 'preamble (symbols)', tx_dbm: 'TX power (dBm)', - tx_ma: 'TX current at that power (mA) - ESTIMATE', rx_extra: 'extra current while receiving (mA) - ESTIMATE', - mah: 'battery capacity (mAh)', usable_pct: 'usable capacity (%)', voltage: 'battery voltage (V)', - panel_w: 'solar panel (W, 0 = none)', sun_h: 'full-sun hours per day', charge_eff_pct: 'charging efficiency (%) - ESTIMATE', - measured: 'measured', estimate: 'ESTIMATE', unavailable: 'not in this firmware', + tx_ma: 'TX current (mA), estimate', rx_extra: 'extra current while receiving (mA), estimate', + usable_pct: 'usable capacity (%)', voltage: 'battery voltage (V)', + sun_h: 'full-sun hours per day', charge_eff_pct: 'charging efficiency (%), estimate', + unavailable: 'not in this firmware', + avg: 'average current', autonomy: 'autonomy', days: 'days', perday: 'per day', + indefinitely: 'indefinitely', balance: 'daily balance', nosun: 'without sun', + measured: 'measured', estimate: 'estimate', + part_node: 'node', part_tx: 'TX', part_rx: 'RX', base: 'whole node', borrowed: 'taken from', fwoffset: 'firmware difference measured on', - nofwoffset: 'no measurement of this firmware on this board: the baseline of another firmware is used as is', - txline: 'transmitting', rxline: 'receiving', airtime: 'airtime of one packet', - avg: 'average current', perday: 'per day', autonomy: 'autonomy without sun', - days: 'days', solar: 'solar gain per day', balance: 'daily balance', - positive: 'the battery charges on such days', emptyin: 'battery empty in', - cost: 'reception cost', range: 'range', voltnote: 'currents of the measurement rig at', - battnote: 'Battery figures assume the node draws the same current from the cell (linear regulator).', - src: 'source', kind: 'kind', option: 'option', value: 'value', date: 'date', - loadfail: 'Could not load power-data.json: ', lang: 'Česky' + nofwoffset: 'this firmware is not measured on this board: another firmware\'s baseline is used as is', + txline: 'transmitting', rxline: 'receiving', solar: 'solar gain per day', + details: 'details', src: 'source', kind: 'kind', option: 'option', value: 'value', date: 'date', + foot: 'Airtime of one packet {a} ms. Currents of the measurement rig at {v} V; the node is assumed to draw the same from the cell.', + loadfail: 'Could not load power-data.json: ' }, cs: { - title: 'Vstupy', node: 'Uzel', settings: 'Nastavení', traffic: 'Provoz (odhad)', - battery: 'Baterie a solár', result: 'Výsledek', values: 'Všechny hodnoty datového souboru', - board: 'deska', firmware: 'firmware', - powersaving: 'powersaving (spánek MCU)', rxps: 'radio.rxps (střídání příjmu)', - rxgain: 'radio.rxgain (zesílený příjem)', ble: 'BLE', gps: 'GPS', - rx_per_h: 'přijatých paketů / h', tx_per_h: 'odvysílaných paketů / h (vč. přeposlaných)', + node: 'Uzel', settings: 'Nastavení', traffic: 'Provoz', battery: 'Baterie', + advanced: 'Pokročilé', breakdown: 'Rozpis', values: 'Všechny hodnoty datového souboru', + board: 'Deska', firmware: 'Firmware', + powersaving: 'powersaving', rxps: 'radio.rxps', rxgain: 'radio.rxgain', ble: 'BLE', gps: 'GPS', + mah: 'Baterie (mAh)', panel_w: 'Solární panel (W)', panel_hint: '0 = bez panelu', + rx_override: 'přijatých paketů / h', tx_override: 'odvysílaných paketů / h', + override_hint: 'prázdné = předvolba (klidný 30/10, běžný 120/60, rušný 600/300 RX/TX za hodinu)', payload: 'délka paketu (bajty)', sf: 'SF', bw: 'BW (kHz)', cr: 'CR (4/x)', preamble: 'preambule (symboly)', tx_dbm: 'vysílací výkon (dBm)', - tx_ma: 'proud při vysílání (mA) - ODHAD', rx_extra: 'proud navíc při příjmu (mA) - ODHAD', - mah: 'kapacita baterie (mAh)', usable_pct: 'využitelná kapacita (%)', voltage: 'napětí baterie (V)', - panel_w: 'solární panel (W, 0 = žádný)', sun_h: 'hodin plného slunce za den', charge_eff_pct: 'účinnost nabíjení (%) - ODHAD', - measured: 'změřeno', estimate: 'ODHAD', unavailable: 'tento firmware nemá', + tx_ma: 'proud při vysílání (mA), odhad', rx_extra: 'proud navíc při příjmu (mA), odhad', + usable_pct: 'využitelná kapacita (%)', voltage: 'napětí baterie (V)', + sun_h: 'hodin plného slunce za den', charge_eff_pct: 'účinnost nabíjení (%), odhad', + unavailable: 'tento firmware nemá', + avg: 'průměrný proud', autonomy: 'výdrž', days: 'dní', perday: 'za den', + indefinitely: 'nekonečno', balance: 'denní bilance', nosun: 'bez slunce', + measured: 'změřeno', estimate: 'odhad', + part_node: 'uzel', part_tx: 'TX', part_rx: 'RX', base: 'celý uzel', borrowed: 'převzato z', fwoffset: 'rozdíl firmwarů změřený na', nofwoffset: 'tento firmware na této desce změřený není: použit základ jiného firmwaru tak, jak je', - txline: 'vysílání', rxline: 'příjem', airtime: 'doba vysílání jednoho paketu', - avg: 'průměrný proud', perday: 'za den', autonomy: 'výdrž bez slunce', - days: 'dní', solar: 'zisk ze soláru za den', balance: 'denní bilance', - positive: 'v takové dny se baterie nabíjí', emptyin: 'baterie prázdná za', - cost: 'cena v příjmu', range: 'rozsah', voltnote: 'proudy měřicí sestavy při', - battnote: 'Výpočet baterie předpokládá, že uzel bere z článku stejný proud (lineární regulátor).', - src: 'zdroj', kind: 'druh', option: 'volba', value: 'hodnota', date: 'datum', - loadfail: 'Nepodařilo se načíst power-data.json: ', lang: 'English' + txline: 'vysílání', rxline: 'příjem', solar: 'zisk ze soláru za den', + details: 'podrobnosti', src: 'zdroj', kind: 'druh', option: 'volba', value: 'hodnota', date: 'datum', + foot: 'Vysílání jednoho paketu trvá {a} ms. Proudy měřicí sestavy při {v} V; předpokládá se, že uzel bere z článku stejný proud.', + loadfail: 'Nepodařilo se načíst power-data.json: ' } }; @@ -62,7 +66,7 @@ var e = document.createElement(tag); Object.keys(attrs || {}).forEach(function (k) { if (k === 'text') e.textContent = attrs[k]; - else e.setAttribute(k, attrs[k]); + else if (attrs[k] !== false && attrs[k] != null) e.setAttribute(k, attrs[k]); }); (kids || []).forEach(function (c) { if (c != null) e.appendChild(typeof c === 'string' ? document.createTextNode(c) : c); @@ -87,13 +91,14 @@ this.root = root; this.d = d; this.base = base; + this.open = {}; var h = location.hash.replace('#', ''); this.lang = h === 'cs' || h === 'en' ? h : (navigator.language || '').slice(0, 2) === 'cs' ? 'cs' : 'en'; var td = d.traffic.defaults, b = d.battery; this.s = { board: d.boards[0].id, firmware: d.firmwares[0].id, - rx_per_h: td.rx_per_h, tx_per_h: td.tx_per_h, payload: td.payload, + preset: td.preset, rx_override: '', tx_override: '', payload: td.payload, sf: td.sf, bw: td.bw, cr: td.cr, preamble: td.preamble, tx_dbm: td.tx_dbm, rx_extra: d.traffic.rx_extra.value, mah: b.mah, usable_pct: b.usable_pct, voltage: b.voltage, @@ -114,6 +119,8 @@ }; P.board = function () { var s = this.s; return this.d.boards.filter(function (b) { return b.id === s.board; })[0]; }; P.fw = function () { var s = this.s; return this.d.firmwares.filter(function (f) { return f.id === s.firmware; })[0]; }; + P.fwById = function (id) { return this.d.firmwares.filter(function (f) { return f.id === id; })[0] || { en: id }; }; + P.boardById = function (id) { return this.d.boards.filter(function (f) { return f.id === id; })[0] || { en: id }; }; P.available = function (opt) { if (opt === 'gps' && !this.board().gps) return false; return this.fw().options.indexOf(opt) >= 0; @@ -153,6 +160,15 @@ return (+s.preamble + 4.25) * tsym + nPay * tsym; }; + // packets per hour: the explicit numbers of the advanced section, else the preset + P.traffic = function () { + var s = this.s, p = this.d.traffic.presets.filter(function (x) { return x.id === s.preset; })[0]; + return { + rx: s.rx_override === '' ? p.rx_per_h : +s.rx_override, + tx: s.tx_override === '' ? p.tx_per_h : +s.tx_override + }; + }; + P.range = function (v) { return Array.isArray(v) ? [Math.min(v[0], v[1]), Math.max(v[0], v[1])] : [v, v]; }; P.pickBaseline = function () { @@ -182,64 +198,6 @@ return best; }; - P.compute = function () { - var self = this, s = this.s, d = this.d, lines = []; - var pb = this.pickBaseline(), b = pb.row; - var u = b.uncertainty || 0, bmeas = b.measured && !pb.borrowed; - var bnote = b.firmware !== s.firmware ? this.t('borrowed') + ' ' + this.n(this.fwById(b.firmware)) : null; - lines.push({ label: this.t('base') + ' (' + this.settingsText(b) + ')', lo: b.value - u, hi: b.value + u, - approx: b.approx, measured: bmeas, row: b, note: bnote || (b['note_' + this.lang] || b.note_en) }); - - if (pb.borrowed) { // offset between the two firmwares, measured on another board - var off = this.fwOffset(b); - if (off) lines.push({ label: this.t('fwoffset') + ' ' + this.n(this.boardById(off.board)), lo: off.value, hi: off.value, measured: false, row: off.row }); - else lines.push({ label: this.t('nofwoffset'), lo: 0, hi: 0, measured: false, row: null, nonum: true }); - } - - Object.keys(d.settings).forEach(function (k) { - var from = b.settings[k], to = s[k]; - if (from === to || from == null) return; - var path = [], dd = self.findDelta(k, from, to); - if (dd) path.push(dd); - else d.settings[k].some(function (mid) { // one step through an intermediate value - var a = self.findDelta(k, from, mid), c = a && self.findDelta(k, mid, to); - if (a && c) { path.push(a, c); return true; } - return false; - }); - if (!path.length) { - lines.push({ label: k + ': ' + from + ' → ' + to, nonum: true, measured: false, row: null, lo: 0, hi: 0, note: '?' }); - return; - } - path.forEach(function (p) { - var r = self.range(p.row.value).map(function (x) { return x * p.sign; }); - var meas = p.row.measured && p.rank === 0; - var note = p.rank ? self.t('borrowed') + ' ' + self.n(self.boardById(p.row.board)) + - (p.row.firmware !== '*' ? ' / ' + self.n(self.fwById(p.row.firmware)) : '') : null; - lines.push({ label: k + ': ' + (p.sign > 0 ? p.row.from + ' → ' + p.row.to : p.row.to + ' → ' + p.row.from), - lo: Math.min(r[0], r[1]), hi: Math.max(r[0], r[1]), approx: p.row.approx, measured: meas, row: p.row, - note: note || (p.row['note_' + self.lang] || p.row.note_en), cost: self.cost(k, to) }); - }); - }); - - var at = this.airtime(); - var tx = s.tx_per_h * at / 3600 * s.tx_ma, rx = s.rx_per_h * at / 3600 * s.rx_extra; - lines.push({ label: this.t('txline') + ' (' + s.tx_per_h + '/h × ' + this.fmt(at * 1000, 0) + ' ms × ' + s.tx_ma + ' mA)', lo: tx, hi: tx, measured: false, row: null }); - lines.push({ label: this.t('rxline') + ' (' + s.rx_per_h + '/h × ' + this.fmt(at * 1000, 0) + ' ms × ' + s.rx_extra + ' mA)', lo: rx, hi: rx, measured: false, row: null }); - - var lo = 0, hi = 0, allMeas = true; - lines.forEach(function (l) { lo += l.lo; hi += l.hi; if (!l.measured) allMeas = false; }); - return { lines: lines, lo: lo, hi: hi, allMeasured: allMeas, airtime: at, voltage: b.voltage }; - }; - - P.fwById = function (id) { return this.d.firmwares.filter(function (f) { return f.id === id; })[0] || { en: id }; }; - P.boardById = function (id) { return this.d.boards.filter(function (f) { return f.id === id; })[0] || { en: id }; }; - P.settingsText = function (row) { - var self = this; - return Object.keys(row.settings).filter(function (k) { - return k !== 'gps' || self.board().gps; - }).map(function (k) { return k + ' ' + row.settings[k]; }).join(', '); - }; - // (chosen firmware) - (baseline's firmware) with identical settings on another board P.fwOffset = function (b) { var s = this.s, vals = this.d.values, found = null; @@ -257,6 +215,68 @@ return this.d.values.filter(function (v) { return v.kind === 'reception' && v.option === opt && v.to === to; })[0]; }; + P.settingsText = function (row) { + var self = this; + return Object.keys(row.settings).filter(function (k) { + return k !== 'gps' || self.board().gps; + }).map(function (k) { return k + ' ' + row.settings[k]; }).join(', '); + }; + + // lines of the breakdown; part = node | tx | rx (the bar), lo/hi in mA + P.compute = function () { + var self = this, s = this.s, d = this.d, lines = []; + var pb = this.pickBaseline(), b = pb.row; + var u = b.uncertainty || 0, bmeas = b.measured && !pb.borrowed; + var bnote = b.firmware !== s.firmware ? this.t('borrowed') + ' ' + this.n(this.fwById(b.firmware)) : null; + lines.push({ part: 'node', label: this.t('base') + ' (' + this.settingsText(b) + ')', lo: b.value - u, hi: b.value + u, + approx: b.approx, measured: bmeas, row: b, note: bnote || (b['note_' + this.lang] || b.note_en) }); + + if (pb.borrowed) { // offset between the two firmwares, measured on another board + var off = this.fwOffset(b); + if (off) lines.push({ part: 'node', label: this.t('fwoffset') + ' ' + this.n(this.boardById(off.board)), lo: off.value, hi: off.value, measured: false, row: off.row }); + else lines.push({ part: 'node', label: this.t('nofwoffset'), lo: 0, hi: 0, measured: false, row: null, nonum: true }); + } + + Object.keys(d.settings).forEach(function (k) { + var from = b.settings[k], to = s[k]; + if (from === to || from == null) return; + var path = [], dd = self.findDelta(k, from, to); + if (dd) path.push(dd); + else d.settings[k].some(function (mid) { // one step through an intermediate value + var a = self.findDelta(k, from, mid), c = a && self.findDelta(k, mid, to); + if (a && c) { path.push(a, c); return true; } + return false; + }); + if (!path.length) { + lines.push({ part: 'node', label: k + ': ' + from + ' → ' + to, nonum: true, measured: false, row: null, lo: 0, hi: 0, note: '?' }); + return; + } + path.forEach(function (p) { + var r = self.range(p.row.value).map(function (x) { return x * p.sign; }); + var meas = p.row.measured && p.rank === 0; + var note = p.rank ? self.t('borrowed') + ' ' + self.n(self.boardById(p.row.board)) + + (p.row.firmware !== '*' ? ' / ' + self.n(self.fwById(p.row.firmware)) : '') : null; + lines.push({ part: 'node', label: k + ': ' + (p.sign > 0 ? p.row.from + ' → ' + p.row.to : p.row.to + ' → ' + p.row.from), + lo: Math.min(r[0], r[1]), hi: Math.max(r[0], r[1]), approx: p.row.approx, measured: meas, row: p.row, + note: note || (p.row['note_' + self.lang] || p.row.note_en) }); + }); + }); + + var at = this.airtime(), tr = this.traffic(); + var tx = tr.tx * at / 3600 * s.tx_ma, rx = tr.rx * at / 3600 * s.rx_extra; + var ms = this.fmt(at * 1000, 0); + lines.push({ part: 'tx', label: this.t('txline') + ' (' + tr.tx + '/h × ' + ms + ' ms × ' + s.tx_ma + ' mA)', lo: tx, hi: tx, measured: false, row: null }); + lines.push({ part: 'rx', label: this.t('rxline') + ' (' + tr.rx + '/h × ' + ms + ' ms × ' + s.rx_extra + ' mA)', lo: rx, hi: rx, measured: false, row: null }); + + var r = { lines: lines, lo: 0, hi: 0, meas: 0, est: 0, parts: { node: 0, tx: 0, rx: 0 }, airtime: at, voltage: b.voltage }; + lines.forEach(function (l) { + var mid = (l.lo + l.hi) / 2; + r.lo += l.lo; r.hi += l.hi; r.parts[l.part] += mid; + if (l.measured) r.meas += mid; else r.est += mid; + }); + return r; + }; + P.srcLink = function (key) { var src = this.d.sources[key]; if (!src) return document.createTextNode(key || ''); @@ -272,122 +292,242 @@ return el('span', { 'class': m ? 'pc-m' : 'pc-e', text: m ? this.t('measured') : this.t('estimate') }); }; + // ---- UI ---- + + // segmented buttons; disabled = the option does not exist in this firmware + P.seg = function (key, opts, disabled) { + var s = this.s; + return el('div', { 'class': 'pc-seg', role: 'group', 'aria-label': this.t(key) }, opts.map(function (o) { + return el('button', { type: 'button', 'data-k': key, 'data-v': o.v, 'aria-pressed': String(s[key]) === String(o.v) ? 'true' : 'false', + disabled: disabled ? 'disabled' : false, text: o.t }); + })); + }; + + P.field = function (label, input, hint) { + return el('div', { 'class': 'pc-field' }, [el('label', { 'class': 'pc-label', text: label }), input, + hint ? el('div', { 'class': 'pc-hint' }, [hint]) : null]); + }; + + P.num = function (key, opts) { + opts = opts || {}; + return el('input', { type: 'number', name: key, value: this.s[key], step: opts.step || 'any', + min: opts.min != null ? opts.min : '0', placeholder: opts.ph || false, inputmode: 'decimal' }); + }; + + P.select = function (key, opts) { + var s = this.s, e = el('select', { name: key }); + opts.forEach(function (o) { + var op = el('option', { value: o.v, text: o.t }); + if (String(s[key]) === String(o.v)) op.selected = true; + e.appendChild(op); + }); + return e; + }; + + // reception cost of a setting, as one warning line with its source + P.warn = function (key, small) { + var c = this.cost(key, this.s[key]); + if (!c) return null; + var link = this.srcLink(c.source); + if (link.tagName === 'A') { link.textContent = this.t('details'); link.title = this.n(c); } + return el('div', { 'class': small ? 'pc-warn pc-small' : 'pc-warn', role: 'note' }, + ['⚠ ' + (c['short_' + this.lang] || this.n(c)) + ' · ', link]); + }; + + P.settingRow = function (k, small) { + var on = this.available(k); + var hint = on ? this.warn(k, small) : el('div', { 'class': 'pc-hint', text: this.t('unavailable') }); + return el('div', { 'class': 'pc-field' }, [el('span', { 'class': 'pc-label', text: this.t(k) }), + this.seg(k, this.d.settings[k].map(function (v) { return { v: v, t: v }; }), !on), hint]); + }; + P.build = function () { var self = this, s = this.s, d = this.d; + var focus = document.activeElement && this.root.contains(document.activeElement) ? + document.activeElement.getAttribute('data-k') + '=' + document.activeElement.getAttribute('data-v') : null; this.root.textContent = ''; - var langBtn = el('button', { type: 'button', 'class': 'pc-lang', text: this.t('lang') }); - langBtn.addEventListener('click', function () { self.lang = self.lang === 'cs' ? 'en' : 'cs'; self.build(); }); - this.root.appendChild(langBtn); - function sel(key, opts, disabled) { - var e = el('select', { name: key }); - opts.forEach(function (o) { - var op = el('option', { value: o.v, text: o.t }); - if (String(s[key]) === String(o.v)) op.selected = true; - e.appendChild(op); - }); - if (disabled) e.disabled = true; - return e; - } - function num(key, step) { return el('input', { type: 'number', name: key, value: s[key], step: step || 'any', min: key === 'tx_dbm' ? '-9' : '0' }); } - function row(key, input, extra) { - return el('div', { 'class': 'pc-row' }, [el('label', { text: self.t(key) }), input, extra || null]); - } + var langSeg = el('div', { 'class': 'pc-seg pc-lang', role: 'group', 'aria-label': 'language' }, [['cs', 'CZ'], ['en', 'EN']].map(function (l) { + return el('button', { type: 'button', 'data-lang': l[0], 'aria-pressed': self.lang === l[0] ? 'true' : 'false', text: l[1] }); + })); + // simple view var form = el('form', { 'class': 'pc-form' }); - form.appendChild(el('h3', { text: this.t('node') })); - form.appendChild(row('board', sel('board', d.boards.map(function (b) { return { v: b.id, t: self.n(b) }; })))); - form.appendChild(row('firmware', sel('firmware', d.firmwares.map(function (f) { return { v: f.id, t: self.n(f) }; })))); - form.appendChild(el('h3', { text: this.t('settings') })); - Object.keys(d.settings).forEach(function (k) { + form.appendChild(el('div', { 'class': 'pc-two pc-sel' }, [ + this.field(this.t('board'), this.select('board', d.boards.map(function (b) { return { v: b.id, t: self.n(b) }; }))), + this.field(this.t('firmware'), this.select('firmware', d.firmwares.map(function (f) { return { v: f.id, t: self.n(f) }; }))) + ])); + var sets = el('div', { 'class': 'pc-sets' }); + ['powersaving', 'rxps', 'ble', 'gps'].forEach(function (k) { if (k === 'gps' && !self.board().gps) return; - var on = self.available(k); - var c = self.cost(k, s[k]); - var extra = !on ? el('span', { 'class': 'pc-note', text: self.t('unavailable') }) : - c ? el('span', { 'class': 'pc-cost' }, [self.t('cost') + ': ' + self.n(c) + ' ', self.badge(c.measured)]) : null; - form.appendChild(row(k, sel(k, d.settings[k].map(function (v) { return { v: v, t: v }; }), !on), extra)); + sets.appendChild(self.settingRow(k)); }); - form.appendChild(el('h3', { text: this.t('traffic') })); - ['rx_per_h', 'tx_per_h', 'payload'].forEach(function (k) { form.appendChild(row(k, num(k, 1))); }); - form.appendChild(row('sf', sel('sf', [7, 8, 9, 10, 11, 12].map(function (v) { return { v: v, t: v }; })))); - form.appendChild(row('bw', sel('bw', [62.5, 125, 250].map(function (v) { return { v: v, t: v }; })))); - form.appendChild(row('cr', sel('cr', [5, 6, 7, 8].map(function (v) { return { v: v, t: '4/' + v }; })))); - form.appendChild(row('preamble', num('preamble', 1))); - form.appendChild(row('tx_dbm', num('tx_dbm', 1))); - form.appendChild(row('tx_ma', num('tx_ma'), this.badge(false))); - form.appendChild(row('rx_extra', num('rx_extra'), this.badge(false))); - form.appendChild(el('h3', { text: this.t('battery') })); - ['mah', 'usable_pct', 'voltage', 'panel_w', 'sun_h', 'charge_eff_pct'].forEach(function (k) { form.appendChild(row(k, num(k))); }); + form.appendChild(sets); + var presetDis = s.rx_override !== '' && s.tx_override !== ''; + form.appendChild(el('div', { 'class': 'pc-field' }, [el('span', { 'class': 'pc-label', text: this.t('traffic') }), + this.seg('preset', d.traffic.presets.map(function (p) { return { v: p.id, t: self.n(p) }; }), presetDis)])); + form.appendChild(el('div', { 'class': 'pc-two' }, [ + this.field(this.t('mah'), this.num('mah', { step: 100 })), + this.field(this.t('panel_w'), this.num('panel_w', { step: 0.5 }), this.t('panel_hint')) + ])); + + // advanced + var adv = el('details', { 'class': 'pc-adv', 'data-open': 'adv' }); + if (this.open.adv) adv.open = true; + adv.appendChild(el('summary', { text: this.t('advanced') })); + adv.appendChild(this.settingRow('rxgain', true)); + var grid = el('div', { 'class': 'pc-grid3' }); + grid.appendChild(this.field(this.t('rx_override'), this.num('rx_override', { step: 1, ph: String(this.traffic().rx) }))); + grid.appendChild(this.field(this.t('tx_override'), this.num('tx_override', { step: 1, ph: String(this.traffic().tx) }))); + grid.appendChild(this.field(this.t('payload'), this.num('payload', { step: 1 }))); + grid.appendChild(this.field(this.t('sf'), this.select('sf', [7, 8, 9, 10, 11, 12].map(function (v) { return { v: v, t: v }; })))); + grid.appendChild(this.field(this.t('bw'), this.select('bw', [62.5, 125, 250].map(function (v) { return { v: v, t: v }; })))); + grid.appendChild(this.field(this.t('cr'), this.select('cr', [5, 6, 7, 8].map(function (v) { return { v: v, t: '4/' + v }; })))); + grid.appendChild(this.field(this.t('preamble'), this.num('preamble', { step: 1 }))); + grid.appendChild(this.field(this.t('tx_dbm'), this.num('tx_dbm', { step: 1, min: '-9' }))); + grid.appendChild(this.field(this.t('tx_ma'), this.num('tx_ma'))); + grid.appendChild(this.field(this.t('rx_extra'), this.num('rx_extra'))); + grid.appendChild(this.field(this.t('usable_pct'), this.num('usable_pct', { step: 5 }))); + grid.appendChild(this.field(this.t('voltage'), this.num('voltage', { step: 0.1 }))); + grid.appendChild(this.field(this.t('sun_h'), this.num('sun_h', { step: 0.5 }))); + grid.appendChild(this.field(this.t('charge_eff_pct'), this.num('charge_eff_pct', { step: 5 }))); + adv.appendChild(grid); + adv.appendChild(el('p', { 'class': 'pc-hint', text: this.t('override_hint') })); + form.appendChild(adv); form.addEventListener('input', function (ev) { var t = ev.target, k = t.name; if (!k) return; - var v = t.tagName === 'SELECT' && isNaN(+t.value) ? t.value : +t.value; - if (t.type === 'number' && t.value === '') return; - s[k] = v; - if (k === 'tx_dbm') s.tx_ma = self.txCurrent(v); - if (k === 'board' || k === 'firmware') self.applyDefaults(); - if (t.tagName === 'SELECT' || k === 'tx_dbm') self.build(); // dependent fields - else self.render(); + if (t.tagName === 'SELECT') { + s[k] = isNaN(+t.value) ? t.value : +t.value; + if (k === 'board' || k === 'firmware') self.applyDefaults(); + self.build(); + return; + } + if (t.value === '') { + if (k === 'rx_override' || k === 'tx_override') s[k] = ''; + else return; + } else s[k] = +t.value; + if (k === 'tx_dbm') { + s.tx_ma = self.txCurrent(s[k]); + self.root.querySelector('[name=tx_ma]').value = s.tx_ma; + } + self.render(); }); form.addEventListener('submit', function (ev) { ev.preventDefault(); }); - this.out = el('div', { 'class': 'pc-out' }); - this.root.appendChild(el('div', { 'class': 'pc-grid' }, [ - el('div', {}, [el('h2', { text: this.t('title') }), form]), - el('div', {}, [el('h2', { text: this.t('result') }), this.out]) + this.out = el('div', { 'class': 'pc-result', 'aria-live': 'polite' }); + this.root.appendChild(el('div', { 'class': 'pc-card' }, [ + el('div', { 'class': 'pc-head' }, [el('strong', { text: this.lang === 'cs' ? 'Kalkulačka spotřeby' : 'Power calculator' }), langSeg]), + el('div', { 'class': 'pc-layout' }, [this.out, form]) ])); - this.table = el('div', { 'class': 'pc-values' }); - this.root.appendChild(el('details', {}, [el('summary', { text: this.t('values') }), this.table])); - this.renderValues(); + + var vals = el('details', { 'class': 'pc-values', 'data-open': 'values' }, [el('summary', { text: this.t('values') })]); + if (this.open.values) vals.open = true; + // at the end of the page when it has a place for it, else under the card + var vbox = document.getElementById('pcalc-values') || this.root; + if (vbox !== this.root) vbox.textContent = ''; + vbox.appendChild(vals); + this.renderValues(vals); + + this.root.addEventListener('click', this.onClick || (this.onClick = function (ev) { + var b = ev.target.closest('button'); + if (!b || !self.root.contains(b)) return; + if (b.hasAttribute('data-lang')) { self.lang = b.getAttribute('data-lang'); self.build(); return; } + var k = b.getAttribute('data-k'); + if (!k) return; + var v = b.getAttribute('data-v'); + s[k] = isNaN(+v) ? v : +v; + self.build(); + })); + this.onToggle = this.onToggle || function (ev) { + var k = ev.target.getAttribute && ev.target.getAttribute('data-open'); + if (k) self.open[k] = ev.target.open; + }; + this.root.addEventListener('toggle', this.onToggle, true); + vbox.addEventListener('toggle', this.onToggle, true); + this.render(); + if (focus) { + var f = this.root.querySelector('[data-k="' + focus.split('=')[0] + '"][data-v="' + focus.split('=')[1] + '"]'); + if (f) f.focus(); + } }; P.render = function () { var self = this, s = this.s, r = this.compute(), out = this.out; out.textContent = ''; + var mid = (r.lo + r.hi) / 2, perDay = mid * 24, usable = s.mah * s.usable_pct / 100; + + // the two big numbers + var rng = r.hi - r.lo > 0.005 ? this.fmt(r.lo) + ' … ' + this.fmt(r.hi) + ' mA' : ''; + var autoBig, autoSub; + if (s.panel_w > 0) { + var gain = s.panel_w * s.sun_h * (s.charge_eff_pct / 100) / s.voltage * 1000, bal = gain - perDay; + var balTxt = this.t('balance') + ' ' + (bal >= 0 ? '+' : '−') + this.fmt(Math.abs(bal), 0) + ' mAh'; + if (bal >= 0) { autoBig = '∞'; autoSub = this.t('indefinitely') + ' · ' + balTxt; } + else { autoBig = this.fmt(usable / -bal, 1); autoSub = this.t('days') + ' · ' + balTxt; } + autoSub += ' · ' + this.t('nosun') + ' ' + this.fmt(usable / perDay, 1) + ' ' + this.t('days'); + } else { + autoBig = this.fmt(usable / perDay, 1); + autoSub = this.t('days') + ' · ' + this.fmt(perDay, 0) + ' mAh ' + this.t('perday'); + } + out.appendChild(el('div', { 'class': 'pc-big' }, [ + el('div', {}, [el('div', { 'class': 'pc-label', text: this.t('avg') }), + el('div', { 'class': 'pc-bignum' }, [this.fmt(mid, mid >= 10 ? 1 : 2), el('span', { 'class': 'pc-unit', text: ' mA' })]), + el('div', { 'class': 'pc-sub', text: rng || ' ' })]), + el('div', {}, [el('div', { 'class': 'pc-label', text: this.t('autonomy') }), + el('div', { 'class': 'pc-bignum', text: autoBig }), + el('div', { 'class': 'pc-sub', text: autoSub })]) + ])); + + // split node / TX / RX + var tot = r.parts.node + r.parts.tx + r.parts.rx || 1, bar = el('div', { 'class': 'pc-bar', role: 'img', + 'aria-label': ['node', 'tx', 'rx'].map(function (p) { return self.t('part_' + p) + ' ' + self.fmt(r.parts[p]) + ' mA'; }).join(', ') }); + var legend = el('div', { 'class': 'pc-legend' }); + ['node', 'tx', 'rx'].forEach(function (p) { + var w = Math.max(0, r.parts[p]) / tot * 100; + bar.appendChild(el('span', { 'class': 'pc-b-' + p, style: 'width:' + w.toFixed(2) + '%' })); + legend.appendChild(el('span', {}, [el('i', { 'class': 'pc-b-' + p }), self.t('part_' + p) + ' ' + self.fmt(r.parts[p]) + ' mA'])); + }); + out.appendChild(bar); + out.appendChild(legend); + out.appendChild(el('div', { 'class': 'pc-me' }, [ + el('span', { 'class': 'pc-m-t', text: this.t('measured') + ': ' + this.fmt(r.meas) + ' mA' }), ' · ', + el('span', { 'class': 'pc-e-t', text: this.t('estimate') + ': ' + this.fmt(r.est) + ' mA' })])); + + // breakdown + var det = el('details', { 'class': 'pc-bd', 'data-open': 'bd' }, [el('summary', { text: this.t('breakdown') })]); + if (this.open.bd) det.open = true; var tb = el('tbody'); r.lines.forEach(function (l) { var val = l.nonum ? '' : (l.approx ? '~' : '') + (l.lo === l.hi ? self.fmt(l.lo) : self.fmt(l.lo) + ' … ' + self.fmt(l.hi)) + ' mA'; - var info = [self.badge(l.measured)]; - if (l.row && l.row.source) info.push(' ', self.srcLink(l.row.source)); - if (l.row && l.row.date) info.push(' (' + l.row.date + ')'); - if (l.note) info.push(el('div', { 'class': 'pc-note', text: l.note })); - if (l.cost) info.push(el('div', { 'class': 'pc-cost' }, [self.t('cost') + ': ' + self.n(l.cost) + ' ', self.badge(l.cost.measured)])); - tb.appendChild(el('tr', {}, [el('td', { text: l.label }), el('td', { 'class': 'pc-num', text: val }), el('td', {}, info)])); + var info = [l.label, ' ', self.badge(l.measured)]; + var sub = []; + if (l.row && l.row.source) sub.push(self.srcLink(l.row.source)); + if (l.row && l.row.date) sub.push(' (' + l.row.date + ')'); + if (l.note) sub.push(' · ' + l.note); + if (sub.length) info.push(el('div', { 'class': 'pc-hint' }, sub)); + tb.appendChild(el('tr', {}, [el('td', {}, info), el('td', { 'class': 'pc-num', text: val })])); }); - out.appendChild(el('table', { 'class': 'pc-lines' }, [tb])); - - var mid = (r.lo + r.hi) / 2, perDay = mid * 24, usable = s.mah * s.usable_pct / 100; - function kv(k, v, m) { - return el('tr', {}, [el('th', { text: k }), el('td', { 'class': 'pc-num', text: v }), el('td', {}, [m === undefined ? self.badge(r.allMeasured) : m])]); - } - var rng = r.lo === r.hi ? '' : ' (' + self.fmt(r.lo) + ' … ' + self.fmt(r.hi) + ')'; - var rows = [ - kv(this.t('avg'), this.fmt(mid) + ' mA' + rng), - kv(this.t('perday'), this.fmt(perDay, 0) + ' mAh'), - kv(this.t('autonomy'), this.fmt(usable / perDay, 1) + ' ' + this.t('days')) - ]; if (s.panel_w > 0) { - var gain = s.panel_w * s.sun_h * (s.charge_eff_pct / 100) / s.voltage * 1000; - var bal = gain - perDay; - rows.push(kv(this.t('solar'), this.fmt(gain, 0) + ' mAh', this.badge(false))); - rows.push(kv(this.t('balance'), (bal >= 0 ? '+' : '') + this.fmt(bal, 0) + ' mAh', el('span', {}, [this.badge(false), ' ', - bal >= 0 ? this.t('positive') : this.t('emptyin') + ' ' + this.fmt(usable / -bal, 1) + ' ' + this.t('days')]))); + var g = s.panel_w * s.sun_h * (s.charge_eff_pct / 100) / s.voltage * 1000; + tb.appendChild(el('tr', {}, [el('td', {}, [this.t('solar') + ' ', this.badge(false)]), el('td', { 'class': 'pc-num', text: this.fmt(g, 0) + ' mAh' })])); } - out.appendChild(el('table', { 'class': 'pc-sum' }, [el('tbody', {}, rows)])); - out.appendChild(el('p', { 'class': 'pc-note', text: this.t('airtime') + ': ' + this.fmt(r.airtime * 1000, 0) + ' ms. ' + - this.t('voltnote') + ' ' + this.fmt(r.voltage, 2) + ' V. ' + this.t('battnote') })); + det.appendChild(el('table', { 'class': 'pc-lines' }, [tb])); + det.appendChild(el('p', { 'class': 'pc-hint', text: this.t('foot').replace('{a}', this.fmt(r.airtime * 1000, 0)).replace('{v}', this.fmt(r.voltage, 2)) })); + out.appendChild(det); }; - P.renderValues = function () { + P.renderValues = function (box) { var self = this, d = this.d; var head = el('tr', {}, ['kind', 'board', 'firmware', 'option', 'value', 'date', '', 'src'].map(function (k) { - return el('th', { text: k === 'kind' || k === 'board' || k === 'firmware' || k === 'option' || k === 'value' || k === 'date' || k === 'src' ? self.t(k) : '' }); + return el('th', { text: k ? self.t(k) : '' }); })); var body = el('tbody'); d.values.forEach(function (v) { - var what = v.kind === 'baseline' ? self.settingsAll(v) : v.option ? v.option + ': ' + (v.from ? v.from + ' → ' : '') + (v.to || '') : ''; + var what = v.kind === 'baseline' ? Object.keys(v.settings).map(function (k) { return k + ' ' + v.settings[k]; }).join(', ') : + v.option ? v.option + ': ' + (v.from ? v.from + ' → ' : '') + (v.to || '') : ''; if (v.kind === 'reception' || v.kind === 'info') what += (what ? ' - ' : '') + self.n(v); var val = v.value == null ? '' : (v.approx ? '~' : '') + (Array.isArray(v.value) ? self.fmt(v.value[0]) + ' … ' + self.fmt(v.value[1]) : self.fmt(v.value)) + (v.uncertainty ? ' ± ' + self.fmt(v.uncertainty) : '') + ' ' + (v.unit || '') + (v.voltage ? ' @ ' + self.fmt(v.voltage, 2) + ' V' : ''); @@ -397,9 +537,8 @@ el('td', {}, [self.badge(v.measured)]), el('td', {}, [self.srcLink(v.source)]) ])); }); - this.table.appendChild(el('table', {}, [el('thead', {}, [head]), body])); + box.appendChild(el('div', { 'class': 'pc-scroll' }, [el('table', {}, [el('thead', {}, [head]), body])])); }; - P.settingsAll = function (v) { return Object.keys(v.settings).map(function (k) { return k + ' ' + v.settings[k]; }).join(', '); }; if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start); else start(); diff --git a/docs/_stylesheets/tth.css b/docs/_stylesheets/tth.css index e8fdf7261..38d401512 100644 --- a/docs/_stylesheets/tth.css +++ b/docs/_stylesheets/tth.css @@ -35,17 +35,78 @@ color: var(--primary-color); } -/* power calculator (power-calculator.md) */ -.pc-grid { display: grid; grid-template-columns: minmax(18em, 28em) 1fr; gap: 2em; } -@media (max-width: 60em) { .pc-grid { grid-template-columns: 1fr; } } -.pc-row { display: grid; grid-template-columns: 14em 1fr; gap: 0.2em 0.6em; align-items: center; margin: 0.15em 0; } -.pc-row > span { grid-column: 2; font-size: 0.85em; } -.pc-row select, .pc-row input { width: 100%; } -.pc-num { text-align: right; white-space: nowrap; } -.pc-m, .pc-e { font-size: 0.8em; padding: 0 0.3em; border: 1px solid; } -.pc-m { color: var(--primary-color); } -.pc-e { color: #e5a50a; } -.pc-cost { color: #e5a50a; font-size: 0.85em; } -.pc-note { font-size: 0.85em; opacity: 0.8; } -.pc-lang { float: right; } -.pc-values { overflow-x: auto; } +/* power calculator (power-calculator.md, docs/_js/power-calculator.js): a + card of its own inside the theme, proportional labels, monospace numbers */ +.pc-card { + font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; + border: 1px solid #333; border-radius: 10px; background: #0b0b0b; + padding: 1rem 1.25rem 1.25rem; margin: 1.5rem 0; line-height: 1.45; +} +.pc-card table, .pc-card td, .pc-card th { border: 0; } +.pc-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; + margin-bottom: 0.75rem; font-size: 1.05rem; } +.pc-layout { display: grid; grid-template-columns: 1fr; gap: 1.5rem; } +@media (min-width: 52em) { + .pc-layout { grid-template-columns: minmax(0, 1fr) minmax(19rem, 24rem); align-items: start; } + .pc-result { order: 2; position: sticky; top: 1rem; } +} +.pc-form { display: flex; flex-direction: column; gap: 1rem; } +.pc-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 1rem; } +.pc-sel { grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); } +.pc-sets { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; } +.pc-grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0.75rem 1rem; margin-top: 0.75rem; } +.pc-field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; } +.pc-label { font-size: 0.85rem; color: #b8bcc4; } +.pc-card input { font-family: ui-monospace, monospace; } +.pc-card select { font-family: inherit; } +.pc-card select, .pc-card input { + font-size: 0.95rem; width: 100%; box-sizing: border-box; + background: #151515; color: #e8e9ed; border: 1px solid #3a3a3a; border-radius: 6px; padding: 0.4rem 0.5rem; +} +.pc-card select:focus, .pc-card input:focus, .pc-seg button:focus-visible { + outline: 2px solid var(--primary-color); outline-offset: 1px; +} +.pc-seg { display: flex; flex-wrap: nowrap; max-width: 100%; border: 1px solid #3a3a3a; border-radius: 6px; overflow: hidden; width: fit-content; } +.pc-seg button { + font: inherit; font-size: 0.9rem; background: transparent; color: #e8e9ed; border: 0; + border-right: 1px solid #3a3a3a; padding: 0.35rem 0.8rem; cursor: pointer; margin: 0; border-radius: 0; + flex: 1 1 auto; white-space: nowrap; +} +@media (max-width: 30em) { .pc-seg button { font-size: 0.85rem; padding: 0.35rem 0.55rem; } .pc-card { padding: 0.8rem; } } +.pc-seg button:last-child { border-right: 0; } +.pc-seg button:hover:not(:disabled) { background: #1d2a22; } +.pc-seg button[aria-pressed="true"] { background: var(--primary-color); color: #000; font-weight: 600; } +.pc-seg button:disabled { color: #6b6f76; cursor: not-allowed; } +.pc-lang button { font-size: 0.8rem; padding: 0.15rem 0.55rem; } +.pc-warn { color: #f0b429; font-size: 0.85rem; } +.pc-warn.pc-small { font-size: 0.8rem; } +.pc-warn a, .pc-hint a { color: inherit; text-decoration: underline; } +.pc-hint { font-size: 0.8rem; color: #9da1a8; } +.pc-adv > summary, .pc-bd > summary, .pc-values > summary { cursor: pointer; color: #b8bcc4; } +.pc-adv { border-top: 1px solid #262626; padding-top: 0.75rem; } +.pc-adv[open] > .pc-field { margin-top: 0.75rem; } +.pc-result { background: #111; border: 1px solid #262626; border-radius: 8px; padding: 1rem; } +.pc-big { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; } +.pc-bignum { font-family: ui-monospace, monospace; font-size: 2.2rem; line-height: 1.1; font-weight: 700; + color: var(--primary-color); } +.pc-unit { font-size: 1rem; font-weight: 400; color: #b8bcc4; } +.pc-sub { font-size: 0.8rem; color: #9da1a8; min-height: 1.2em; } +.pc-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: #222; margin: 1rem 0 0.4rem; } +.pc-bar span { display: block; height: 100%; } +.pc-b-node { background: #5fd38d; } +.pc-b-tx { background: #e5a50a; } +.pc-b-rx { background: #62a0ea; } +.pc-legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; font-size: 0.8rem; color: #b8bcc4; } +.pc-legend i { display: inline-block; width: 0.7em; height: 0.7em; border-radius: 2px; margin-right: 0.35em; } +.pc-me { margin-top: 0.6rem; font-size: 0.85rem; } +.pc-m-t { color: #5fd38d; } +.pc-e-t { color: #f0b429; } +.pc-bd { margin-top: 0.8rem; font-size: 0.85rem; } +.pc-lines { width: 100%; margin-top: 0.5rem; } +.pc-lines td { padding: 0.25rem 0.3rem; vertical-align: top; } +.pc-num { text-align: right; white-space: nowrap; font-family: ui-monospace, monospace; } +.pc-m, .pc-e { font-size: 0.7rem; padding: 0 0.3em; border: 1px solid; border-radius: 3px; } +.pc-m { color: #5fd38d; } +.pc-e { color: #f0b429; } +.pc-values { margin: 1rem 0; } +.pc-scroll { overflow-x: auto; font-size: 0.85rem; } diff --git a/docs/power-calculator.md b/docs/power-calculator.md index 779e3f728..8d0191399 100644 --- a/docs/power-calculator.md +++ b/docs/power-calculator.md @@ -1,12 +1,10 @@ # Power calculator / Kalkulačka spotřeby -Pick a board, firmware, settings, traffic and battery; the page adds up the -expected average current, energy per day and autonomy. Every line says whether -its number was **measured** or is an **estimate**, and where it comes from. -Česky: tlačítko „Česky" na stránce (odkaz s `#cs` ji otevře rovnou česky). +Pick your board, firmware and settings; the calculator shows the expected +average current and how long a battery lasts. Česky: přepínač „CZ" v kartě. -
## How it computes -- **Baseline:** the measured whole-node current of the chosen board and - firmware whose settings are closest to yours (no traffic, radio in RX). -- **Options:** for every setting that differs from that baseline, the paired - A/B delta from [power.md](power.md#summary-every-option-against-stock-firmware). - A delta measured on another board or firmware is used, but shown as an - estimate ("taken from ..."). -- **Traffic:** LoRa time on air with the Semtech formula (explicit header, - CRC on) for the packet length, SF, BW, CR and preamble; transmissions cost - the TX current at the set power, receptions an extra current while the packet - is being received. Both currents are **estimates** you can overwrite: the - TX one is interpolated from the SX1262 datasheet (14 dBm 45 mA, 22 dBm - 118 mA), below 14 dBm a guess. The baseline already contains the radio in RX. -- **Battery:** usable mAh / (average mA × 24 h). The node is assumed to draw - the same current from the cell (linear regulator); the absolute currents - belong to the measurement rig (XIAO at 3.26 V on its 3V3 pin, P1-Pro on the - 5 V USB side). -- **Solar:** panel W × full-sun hours × charging efficiency / battery voltage. +- **Node:** the measured whole-node current of the board and firmware closest + to your settings, plus the measured + [delta](power.md#summary-every-option-against-stock-firmware) of each setting + that differs. A number borrowed from another board or firmware counts as an + estimate; the result says how much of the total is measured. +- **Traffic:** packets × LoRa time on air (Semtech formula) × radio current. + The presets are 30/10, 120/60 and 600/300 received/transmitted packets per + hour; exact numbers, packet length, modulation and the (estimated) TX and RX + currents are under *Advanced*. +- **Battery:** usable mAh / (mA × 24 h); with a panel, W × sun hours × + efficiency / battery voltage per day. -**rxps is not free.** `radio.rxps balanced` and `max` save about 2 mA but lose -13-28 % of weak packets (SNR −2..−8) against none without it (bench -4. 12. 2026, [details](power.md#rx-duty-cycle-rxps)); the page shows that cost -next to the option. Use it only where packets arrive strong, never on a mast. +**rxps is not free:** it saves about 2 mA but loses 13-28 % of weak packets +([details](power.md#rx-duty-cycle-rxps)). Never on a mast. ## Data All numbers live in one file, -[`power-data.json`](https://git.rfa.cz/tth-pub/meshcore-tth/src/branch/main/docs/power-data.json): -each value with board, value, unit, date, source and `measured`. A new -measurement (the planned overnight re-measurement of every option on the same -rig) is a new row there, without touching the page; the whole table is also at -the bottom of the calculator. +[`power-data.json`](https://git.rfa.cz/tth-pub/meshcore-tth/src/branch/main/docs/power-data.json), +each with board, date, source and whether it was measured; new measurements +are new rows there. + +
diff --git a/docs/power-data.json b/docs/power-data.json index fb5ed51bb..5c067a396 100644 --- a/docs/power-data.json +++ b/docs/power-data.json @@ -8,7 +8,7 @@ "settings, no traffic. kind delta: change of current when `option` goes", "from `from` to `to` on that board/firmware ('*' = not tied to a firmware);", "value is a number or [min, max]. kind reception: what an option costs in", - "reception, shown next to it. kind info: shown in the table only.", + "reception, shown next to it (short_*: the one-line warning). kind info: shown in the table only.", "Settings start at the board's defaults, then the firmware's (as shipped).", "The calculator picks the baseline whose settings are closest to the chosen", "ones and adds the deltas of the rest; a delta borrowed from another board", @@ -203,18 +203,24 @@ { "kind": "reception", "option": "rxps", "to": "balanced", + "short_en": "loses 13-28 % of weak packets; not for a mast", + "short_cs": "ztratí 13-28 % slabých paketů; ne na stožár", "en": "loses 13-28 % of weak packets (SNR -2..-8) against 0 % without rxps; strong signal 0 lost. Not for a mast.", "cs": "ztratí 13-28 % slabých paketů (SNR -2..-8) proti 0 % bez rxps; silný signál 0 ztrát. Ne na stožár.", "date": "2026-12-04", "source": "power-rxps", "measured": true }, { "kind": "reception", "option": "rxps", "to": "max", + "short_en": "loses 13-28 % of weak packets or more; not for a mast", + "short_cs": "ztratí 13-28 % slabých paketů i víc; ne na stožár", "en": "as balanced or worse: 13-28 % of weak packets lost; on a live mast -16 % received. Not for a mast.", "cs": "jako balanced nebo hůř: ztráta 13-28 % slabých paketů; na ostrém stožáru -16 % přijatých. Ne na stožár.", "date": "2026-12-04", "source": "power-rxps", "measured": true }, { "kind": "reception", "option": "rxgain", "to": "off", + "short_en": "~1-3 dB less sensitive (datasheet, not measured)", + "short_cs": "citlivost o ~1-3 dB horší (datasheet, neměřeno)", "en": "costs ~1-3 dB of sensitivity (datasheet, not measured).", "cs": "stojí ~1-3 dB citlivosti (datasheet, neměřeno).", "source": "sx1262-datasheet", "measured": false @@ -230,8 +236,13 @@ ], "traffic": { "_comment": "Defaults of the traffic inputs and the current the radio adds while it transmits/receives. All of it is an ESTIMATE the reader can overwrite on the page.", + "presets": [ + { "id": "quiet", "en": "quiet node", "cs": "klidný uzel", "rx_per_h": 30, "tx_per_h": 10 }, + { "id": "normal", "en": "normal node", "cs": "běžný uzel", "rx_per_h": 120, "tx_per_h": 60 }, + { "id": "busy", "en": "busy node", "cs": "rušný uzel", "rx_per_h": 600, "tx_per_h": 300 } + ], "defaults": { - "rx_per_h": 120, "tx_per_h": 60, "payload": 60, + "preset": "normal", "payload": 60, "sf": 7, "bw": 62.5, "cr": 5, "preamble": 16, "tx_dbm": 22 }, "rx_extra": { From 6a1d87679d9dcbbd3e4b5efdc78d88cc79efe8f7 Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Fri, 4 Dec 2026 17:29:25 +0100 Subject: [PATCH 04/13] Docs: power calculator -- solar by month (December first), board battery/panel, I2C sensors Changelog: - Co-Authored-By: Claude Opus 5.5 --- docs/_js/power-calculator.js | 117 ++++++++++++++++++++++++++++------- docs/_stylesheets/tth.css | 19 ++++++ docs/power-calculator.md | 16 ++++- docs/power-data.json | 93 ++++++++++++++++++++++++++-- 4 files changed, 216 insertions(+), 29 deletions(-) diff --git a/docs/_js/power-calculator.js b/docs/_js/power-calculator.js index e6a381aa3..3fa31ef1f 100644 --- a/docs/_js/power-calculator.js +++ b/docs/_js/power-calculator.js @@ -22,10 +22,14 @@ preamble: 'preamble (symbols)', tx_dbm: 'TX power (dBm)', tx_ma: 'TX current (mA), estimate', rx_extra: 'extra current while receiving (mA), estimate', usable_pct: 'usable capacity (%)', voltage: 'battery voltage (V)', - sun_h: 'full-sun hours per day', charge_eff_pct: 'charging efficiency (%), estimate', + charge_eff_pct: 'charging efficiency (%), estimate', month: 'Month', orient: 'Panel faces', + sensors: 'I2C sensors', sensors_hint: 'datasheet estimate for how this firmware reads them', + covers: 'panel covers it', emptyafter: 'battery empty after {n} days in {m} (starting full)', + night: 'the battery does not carry the {h} h night of {m}: it lasts {x} h', + nightshort: 'but not through the night', monthbal: 'balance per month (mAh/day)', bal_in: 'balance in', perdayu: 'mAh/day', unavailable: 'not in this firmware', avg: 'average current', autonomy: 'autonomy', days: 'days', perday: 'per day', - indefinitely: 'indefinitely', balance: 'daily balance', nosun: 'without sun', + balance: 'daily balance', nosun: 'without sun', sensorline: 'I2C sensor', measured: 'measured', estimate: 'estimate', part_node: 'node', part_tx: 'TX', part_rx: 'RX', base: 'whole node', borrowed: 'taken from', fwoffset: 'firmware difference measured on', @@ -47,10 +51,14 @@ preamble: 'preambule (symboly)', tx_dbm: 'vysílací výkon (dBm)', tx_ma: 'proud při vysílání (mA), odhad', rx_extra: 'proud navíc při příjmu (mA), odhad', usable_pct: 'využitelná kapacita (%)', voltage: 'napětí baterie (V)', - sun_h: 'hodin plného slunce za den', charge_eff_pct: 'účinnost nabíjení (%), odhad', + charge_eff_pct: 'účinnost nabíjení (%), odhad', month: 'Měsíc', orient: 'Panel míří na', + sensors: 'Čidla na I2C', sensors_hint: 'odhad z datasheetu podle toho, jak je tento firmware čte', + covers: 'panel stačí', emptyafter: 'baterie prázdná po {n} dnech, měsíc {m} (z plné)', + night: 'baterie neutáhne {h} h noci (měsíc {m}): vydrží {x} h', + nightshort: 'ale noc nevydrží', monthbal: 'bilance po měsících (mAh/den)', bal_in: 'bilance, měsíc', perdayu: 'mAh/den', unavailable: 'tento firmware nemá', avg: 'průměrný proud', autonomy: 'výdrž', days: 'dní', perday: 'za den', - indefinitely: 'nekonečno', balance: 'denní bilance', nosun: 'bez slunce', + balance: 'denní bilance', nosun: 'bez slunce', sensorline: 'čidlo na I2C', measured: 'změřeno', estimate: 'odhad', part_node: 'uzel', part_tx: 'TX', part_rx: 'RX', base: 'celý uzel', borrowed: 'převzato z', fwoffset: 'rozdíl firmwarů změřený na', @@ -102,10 +110,11 @@ sf: td.sf, bw: td.bw, cr: td.cr, preamble: td.preamble, tx_dbm: td.tx_dbm, rx_extra: d.traffic.rx_extra.value, mah: b.mah, usable_pct: b.usable_pct, voltage: b.voltage, - panel_w: b.panel_w, sun_h: b.sun_h, charge_eff_pct: b.charge_eff_pct + panel_w: b.panel_w, charge_eff_pct: b.charge_eff_pct, + month: d.solar.default_month, orient: d.solar.orientation[0].id, sensors: {} }; this.s.tx_ma = this.txCurrent(this.s.tx_dbm); - this.applyDefaults(); + this.applyDefaults(true); this.build(); } @@ -127,8 +136,12 @@ }; // board defaults, then what the firmware ships with; options it lacks are pinned off - P.applyDefaults = function () { + // boardChanged: also the battery and panel the board ships with + P.applyDefaults = function (boardChanged) { var self = this, def = Object.assign({}, this.board().defaults, this.fw().defaults); + if (boardChanged) ['mah', 'panel_w'].forEach(function (k) { + self.s[k] = def[k] != null ? def[k] : self.d.battery[k]; + }); Object.keys(this.d.settings).forEach(function (k) { var vals = self.d.settings[k]; if (!self.available(k)) self.s[k] = vals.indexOf('off') >= 0 ? 'off' : vals[0]; @@ -169,18 +182,30 @@ }; }; + // solar gain in mAh per day in month m (1..12) + P.solarGain = function (m) { + var s = this.s, so = this.d.solar; + var f = so.orientation.filter(function (o) { return o.id === s.orient; })[0].factor; + return s.panel_w * so.sun_h[m - 1] * f * (s.charge_eff_pct / 100) / s.voltage * 1000; + }; + P.monthName = function (m) { + return new Date(2026, m - 1, 15).toLocaleString(this.lang === 'cs' ? 'cs-CZ' : 'en-GB', { month: 'long' }); + }; + P.range = function (v) { return Array.isArray(v) ? [Math.min(v[0], v[1]), Math.max(v[0], v[1])] : [v, v]; }; P.pickBaseline = function () { var s = this.s, keys = Object.keys(this.d.settings); - var rows = this.d.values.filter(function (v) { return v.kind === 'baseline' && v.board === s.board; }); + var bid = s.board, like = this.board().like; + var rows = this.d.values.filter(function (v) { return v.kind === 'baseline' && v.board === bid; }); + if (!rows.length && like) rows = this.d.values.filter(function (v) { return v.kind === 'baseline' && v.board === like; }); var same = rows.filter(function (v) { return v.firmware === s.firmware; }); var pool = same.length ? same : rows; function diff(v) { return keys.filter(function (k) { return v.settings[k] !== s[k]; }).length; } pool.sort(function (a, b) { return diff(a) - diff(b) || (b.measured - a.measured) || (a.firmware === 'tth' ? -1 : 1); }); - return { row: pool[0], borrowed: !same.length }; + return { row: pool[0], borrowed: !same.length, boardBorrowed: pool[0].board !== bid }; }; // delta rows of one option between two values, best match first: @@ -226,8 +251,9 @@ P.compute = function () { var self = this, s = this.s, d = this.d, lines = []; var pb = this.pickBaseline(), b = pb.row; - var u = b.uncertainty || 0, bmeas = b.measured && !pb.borrowed; - var bnote = b.firmware !== s.firmware ? this.t('borrowed') + ' ' + this.n(this.fwById(b.firmware)) : null; + var u = b.uncertainty || 0, bmeas = b.measured && !pb.borrowed && !pb.boardBorrowed; + var bnote = pb.boardBorrowed ? this.t('borrowed') + ' ' + this.n(this.boardById(b.board)) : + b.firmware !== s.firmware ? this.t('borrowed') + ' ' + this.n(this.fwById(b.firmware)) : null; lines.push({ part: 'node', label: this.t('base') + ' (' + this.settingsText(b) + ')', lo: b.value - u, hi: b.value + u, approx: b.approx, measured: bmeas, row: b, note: bnote || (b['note_' + this.lang] || b.note_en) }); @@ -262,6 +288,13 @@ }); }); + d.sensors.list.forEach(function (x) { + if (!s.sensors[x.id]) return; + var v = x[s.firmware] != null ? x[s.firmware] : x['*']; + lines.push({ part: 'node', label: self.t('sensorline') + ': ' + x.name, lo: v, hi: v, measured: false, + row: { source: d.sensors.source }, note: x.how }); + }); + var at = this.airtime(), tr = this.traffic(); var tx = tr.tx * at / 3600 * s.tx_ma, rx = tr.rx * at / 3600 * s.rx_extra; var ms = this.fmt(at * 1000, 0); @@ -370,6 +403,20 @@ this.field(this.t('mah'), this.num('mah', { step: 100 })), this.field(this.t('panel_w'), this.num('panel_w', { step: 0.5 }), this.t('panel_hint')) ])); + var months = []; + for (var m = 1; m <= 12; m++) months.push({ v: m, t: this.monthName(m) }); + form.appendChild(el('div', { 'class': 'pc-two pc-sel' }, [ + this.field(this.t('month'), this.select('month', months)), + el('div', { 'class': 'pc-field' }, [el('span', { 'class': 'pc-label', text: this.t('orient') }), + this.seg('orient', d.solar.orientation.map(function (o) { return { v: o.id, t: self.n(o) }; }))]) + ])); + var chips = el('div', { 'class': 'pc-chips' }, d.sensors.list.map(function (x) { + var cb = el('input', { type: 'checkbox', 'data-sensor': x.id }); + cb.checked = !!s.sensors[x.id]; + return el('label', { 'class': 'pc-chip', title: x.how }, [cb, x.name]); + })); + form.appendChild(el('div', { 'class': 'pc-field' }, [el('span', { 'class': 'pc-label', text: this.t('sensors') }), chips, + el('div', { 'class': 'pc-hint' }, [this.t('sensors_hint') + ' ', this.badge(false)])])); // advanced var adv = el('details', { 'class': 'pc-adv', 'data-open': 'adv' }); @@ -389,7 +436,6 @@ grid.appendChild(this.field(this.t('rx_extra'), this.num('rx_extra'))); grid.appendChild(this.field(this.t('usable_pct'), this.num('usable_pct', { step: 5 }))); grid.appendChild(this.field(this.t('voltage'), this.num('voltage', { step: 0.1 }))); - grid.appendChild(this.field(this.t('sun_h'), this.num('sun_h', { step: 0.5 }))); grid.appendChild(this.field(this.t('charge_eff_pct'), this.num('charge_eff_pct', { step: 5 }))); adv.appendChild(grid); adv.appendChild(el('p', { 'class': 'pc-hint', text: this.t('override_hint') })); @@ -397,10 +443,11 @@ form.addEventListener('input', function (ev) { var t = ev.target, k = t.name; + if (t.hasAttribute('data-sensor')) { s.sensors[t.getAttribute('data-sensor')] = t.checked; self.render(); return; } if (!k) return; if (t.tagName === 'SELECT') { s[k] = isNaN(+t.value) ? t.value : +t.value; - if (k === 'board' || k === 'firmware') self.applyDefaults(); + if (k === 'board' || k === 'firmware') self.applyDefaults(k === 'board'); self.build(); return; } @@ -461,13 +508,27 @@ // the two big numbers var rng = r.hi - r.lo > 0.005 ? this.fmt(r.lo) + ' … ' + this.fmt(r.hi) + ' mA' : ''; - var autoBig, autoSub; + var autoBig, autoSub, autoLabel = this.t('autonomy'), warnNight = null, strip = null, autoBad = false; if (s.panel_w > 0) { - var gain = s.panel_w * s.sun_h * (s.charge_eff_pct / 100) / s.voltage * 1000, bal = gain - perDay; - var balTxt = this.t('balance') + ' ' + (bal >= 0 ? '+' : '−') + this.fmt(Math.abs(bal), 0) + ' mAh'; - if (bal >= 0) { autoBig = '∞'; autoSub = this.t('indefinitely') + ' · ' + balTxt; } - else { autoBig = this.fmt(usable / -bal, 1); autoSub = this.t('days') + ' · ' + balTxt; } - autoSub += ' · ' + this.t('nosun') + ' ' + this.fmt(usable / perDay, 1) + ' ' + this.t('days'); + var mn = this.monthName(s.month), bal = this.solarGain(s.month) - perDay; + autoLabel = this.t('bal_in') + ' ' + mn; + autoBig = (bal >= 0 ? '+' : '−') + this.fmt(Math.abs(bal), 0); + autoBad = bal < 0; + autoSub = this.t('perdayu') + ' · ' + (bal >= 0 ? this.t('covers') : + this.t('emptyafter').replace('{n}', this.fmt(usable / -bal, 1)).replace('{m}', mn)) + + ' · ' + this.t('nosun') + ' ' + this.fmt(usable / perDay, 1) + ' ' + this.t('days'); + strip = el('div', { 'class': 'pc-strip' }); + for (var m = 1; m <= 12; m++) { + var bm = this.solarGain(m) - perDay, ab = Math.abs(bm); + var txt = (bm >= 0 ? '+' : '−') + (ab >= 1000 ? this.fmt(ab / 1000, 1) + 'k' : this.fmt(ab, 0)); + strip.appendChild(el('span', { 'class': (bm < 0 ? 'pc-neg' : 'pc-pos') + (m === +s.month ? ' pc-cur' : ''), + title: this.monthName(m) + ': ' + txt + ' ' + this.t('perdayu') }, [ + el('b', { text: this.monthName(m).slice(0, 3) }), el('span', { text: txt })])); + } + // the cell must carry the night of that month (said only when it does not) + var nh = this.d.solar.night_h[s.month - 1], lasts = usable / mid; + if (lasts < nh) warnNight = this.t('night').replace('{h}', this.fmt(nh, 0)).replace('{m}', mn).replace('{x}', this.fmt(lasts, 1)); + if (warnNight) { autoBad = true; autoSub = autoSub.replace(this.t('covers'), '⚠ ' + this.t('nightshort')); } } else { autoBig = this.fmt(usable / perDay, 1); autoSub = this.t('days') + ' · ' + this.fmt(perDay, 0) + ' mAh ' + this.t('perday'); @@ -476,11 +537,21 @@ el('div', {}, [el('div', { 'class': 'pc-label', text: this.t('avg') }), el('div', { 'class': 'pc-bignum' }, [this.fmt(mid, mid >= 10 ? 1 : 2), el('span', { 'class': 'pc-unit', text: ' mA' })]), el('div', { 'class': 'pc-sub', text: rng || ' ' })]), - el('div', {}, [el('div', { 'class': 'pc-label', text: this.t('autonomy') }), - el('div', { 'class': 'pc-bignum', text: autoBig }), + el('div', {}, [el('div', { 'class': 'pc-label', text: autoLabel }), + el('div', { 'class': 'pc-bignum' + (autoBad ? ' pc-bad' : ''), text: autoBig }), el('div', { 'class': 'pc-sub', text: autoSub })]) ])); + if (strip) { + var so = this.d.solar; + out.appendChild(el('div', { 'class': 'pc-label pc-strip-t', text: this.t('monthbal') })); + out.appendChild(strip); + out.appendChild(el('div', { 'class': 'pc-hint' }, [this.badge(false), ' ', this.srcLink(so.source)])); + // the model is optimistic for a real mast: say what one of ours did + out.appendChild(el('div', { 'class': 'pc-hint' }, ['⚠ ' + so['field_note_' + this.lang] + ' · ', this.srcLink(so.field_source)])); + } + if (warnNight) out.appendChild(el('div', { 'class': 'pc-warn', text: '⚠ ' + warnNight })); + // split node / TX / RX var tot = r.parts.node + r.parts.tx + r.parts.rx || 1, bar = el('div', { 'class': 'pc-bar', role: 'img', 'aria-label': ['node', 'tx', 'rx'].map(function (p) { return self.t('part_' + p) + ' ' + self.fmt(r.parts[p]) + ' mA'; }).join(', ') }); @@ -511,8 +582,8 @@ tb.appendChild(el('tr', {}, [el('td', {}, info), el('td', { 'class': 'pc-num', text: val })])); }); if (s.panel_w > 0) { - var g = s.panel_w * s.sun_h * (s.charge_eff_pct / 100) / s.voltage * 1000; - tb.appendChild(el('tr', {}, [el('td', {}, [this.t('solar') + ' ', this.badge(false)]), el('td', { 'class': 'pc-num', text: this.fmt(g, 0) + ' mAh' })])); + var g = this.solarGain(s.month); + tb.appendChild(el('tr', {}, [el('td', {}, [this.t('solar') + ' (' + this.monthName(s.month) + ') ', this.badge(false)]), el('td', { 'class': 'pc-num', text: this.fmt(g, 0) + ' mAh' })])); } det.appendChild(el('table', { 'class': 'pc-lines' }, [tb])); det.appendChild(el('p', { 'class': 'pc-hint', text: this.t('foot').replace('{a}', this.fmt(r.airtime * 1000, 0)).replace('{v}', this.fmt(r.voltage, 2)) })); diff --git a/docs/_stylesheets/tth.css b/docs/_stylesheets/tth.css index 38d401512..ce905cfac 100644 --- a/docs/_stylesheets/tth.css +++ b/docs/_stylesheets/tth.css @@ -110,3 +110,22 @@ .pc-e { color: #f0b429; } .pc-values { margin: 1rem 0; } .pc-scroll { overflow-x: auto; font-size: 0.85rem; } +.pc-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; } +.pc-chip { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.8rem; padding: 0.15rem 0.5rem; + border: 1px solid #3a3a3a; border-radius: 999px; cursor: pointer; } +.pc-chip input { width: auto; margin: 0; accent-color: var(--primary-color); } +.pc-chip:has(input:checked) { border-color: var(--primary-color); color: var(--primary-color); } +.pc-strip-t { margin-top: 0.9rem; } +.pc-strip { display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; margin-top: 0.3rem; } +.pc-strip > span { display: flex; flex-direction: column; align-items: center; padding: 0.15rem 0; + border-radius: 3px; font-family: ui-monospace, monospace; font-size: 0.62rem; line-height: 1.25; } +.pc-strip b { font-family: system-ui, sans-serif; font-weight: 400; color: #b8bcc4; } +.pc-pos { background: #12301f; color: #8fe0b0; } +.pc-neg { background: #3a1414; color: #ff9b9b; } +.pc-cur { outline: 2px solid #e8e9ed; outline-offset: -1px; } +.pc-lines { table-layout: fixed; } +.pc-lines td:last-child { width: 6.5em; white-space: normal; } +.pc-bignum.pc-bad { color: #ff8a8a; } +.pc-layout > *, .pc-card { min-width: 0; } +.pc-strip { grid-template-columns: repeat(12, minmax(0, 1fr)); } +@media (max-width: 30em) { .pc-strip { grid-template-columns: repeat(6, minmax(0, 1fr)); } } diff --git a/docs/power-calculator.md b/docs/power-calculator.md index 8d0191399..4d809c5b0 100644 --- a/docs/power-calculator.md +++ b/docs/power-calculator.md @@ -23,8 +23,20 @@ power.md.
The presets are 30/10, 120/60 and 600/300 received/transmitted packets per hour; exact numbers, packet length, modulation and the (estimated) TX and RX currents are under *Advanced*. -- **Battery:** usable mAh / (mA × 24 h); with a panel, W × sun hours × - efficiency / battery voltage per day. +- **I2C sensors:** what the chip draws between reads (telemetry is read only + when asked), from its datasheet. This fork puts every sensor to sleep between + reads; upstream leaves the INA219/226/260/3221 converting (0.3-0.7 mA each) + and a BMP280 in normal mode. Estimates; only the idle bus itself was measured. +- **Battery:** usable mAh / (mA × 24 h). A board's choice fills in what it + ships with (SenseCAP Solar P1-Pro: 4× 18650, 13 400 mAh, 5 W panel). +- **Solar:** W × equivalent full-sun hours of the chosen **month** × orientation + × charging efficiency / battery voltage. Sun hours are PVGIS monthly means + for Prague at the optimal tilt (December 1.5 h, June 5.6 h a day); the + calculator opens on December, the worst month, and shows the balance of all + twelve. East/west is taken as 60 %, heavy shade 30 % (estimates). How much + that matters: one of our masts (remote-mast, panel facing east) lost ~50 mV a day + from mid-November with consumption unchanged + ([details](power.md#a-mast-that-runs-flat-bootlock-and-cutoff)). **rxps is not free:** it saves about 2 mA but loses 13-28 % of weak packets ([details](power.md#rx-duty-cycle-rxps)). Never on a mast. diff --git a/docs/power-data.json b/docs/power-data.json index 5c067a396..256b1577d 100644 --- a/docs/power-data.json +++ b/docs/power-data.json @@ -56,6 +56,26 @@ "en": "SX1262 datasheet (Semtech), not measured", "cs": "datasheet SX1262 (Semtech), neměřeno" }, + "seeed-wiki": { + "url": "https://wiki.seeedstudio.com/meshtastic_solar_node/", + "en": "Seeed wiki, SenseCAP Solar Node: 5 W panel, P1-Pro 4x 18650 NMC 3350 mAh", + "cs": "Seeed wiki, SenseCAP Solar Node: panel 5 W, P1-Pro 4x 18650 NMC 3350 mAh" + }, + "pvgis": { + "url": "https://re.jrc.ec.europa.eu/pvg_tools/en/", + "en": "PVGIS, Prague, optimal tilt, monthly mean - estimate", + "cs": "PVGIS, Praha, optimální sklon, měsíční průměr - odhad" + }, + "power-flat": { + "url": "power.md#a-mast-that-runs-flat-bootlock-and-cutoff", + "en": "docs/power.md, a mast that runs flat", + "cs": "docs/power.md, stožár, který se vybije" + }, + "sensor-code": { + "url": "", + "en": "src/helpers/sensors/EnvironmentSensorManager.cpp + datasheet, not measured", + "cs": "src/helpers/sensors/EnvironmentSensorManager.cpp + datasheet, neměřeno" + }, "estimate": { "url": "", "en": "rough estimate, not measured", @@ -68,14 +88,25 @@ "en": "XIAO nRF52840 + Wio-SX1262 (fed on 3V3)", "cs": "XIAO nRF52840 + Wio-SX1262 (napájené na 3V3)", "gps": false, - "defaults": { "ble": "off", "gps": "off" } + "defaults": { "ble": "off", "gps": "off", "mah": 3000, "panel_w": 0 } }, { "id": "p1pro", "en": "SenseCAP Solar P1-Pro (nRF52840 + SX1262 + L76K GPS)", "cs": "SenseCAP Solar P1-Pro (nRF52840 + SX1262 + GPS L76K)", "gps": true, - "defaults": { "ble": "on", "gps": "duty" } + "defaults": { "ble": "on", "gps": "duty", "mah": 13400, "panel_w": 5 }, + "defaults_source": "seeed-wiki" + }, + { + "id": "p1", + "en": "SenseCAP Solar P1 (no GPS, own 4x 18650)", + "cs": "SenseCAP Solar P1 (bez GPS, vlastní 4x 18650)", + "gps": false, + "like": "p1pro", + "_comment": "not measured: the P1-Pro without its GPS receiver, every number borrowed from the P1-Pro (an estimate); ships without cells", + "defaults": { "ble": "on", "gps": "off", "mah": 13400, "panel_w": 5 }, + "defaults_source": "seeed-wiki" } ], "firmwares": [ @@ -262,8 +293,62 @@ } }, "battery": { - "_comment": "defaults of the battery and solar inputs; efficiency and voltage are assumptions", + "_comment": "defaults of the battery inputs (a board's defaults win); efficiency and voltage are assumptions", "mah": 3000, "usable_pct": 80, "voltage": 3.7, - "panel_w": 0, "sun_h": 2, "charge_eff_pct": 70 + "panel_w": 0, "charge_eff_pct": 70 + }, + "solar": { + "_comment": [ + "Equivalent full-sun hours per day (kWh/m2/day on the panel), by month, for a fixed", + "panel at the optimal tilt (38 deg, south) in Prague (50.08 N 14.42 E): PVGIS v5.2", + "MRcalc, H(i_opt)_m, mean of 2010-2020, divided by the days of the month (queried", + "4. 12. 2026). An ESTIMATE for a node: irradiation on the plane, before the losses", + "of the charger and cell (charge_eff_pct) and of a worse orientation (orientation).", + "night_h: hours without sun on the 15th of the month at 50 N (rounded), for the", + "check that the cell carries the night. default_month 12 = the worst month." + ], + "source": "pvgis", "measured": false, "default_month": 12, + "sun_h": [1.48, 2.57, 3.88, 5.13, 5.14, 5.57, 5.58, 5.29, 4.33, 2.88, 1.72, 1.47], + "night_h": [15.6, 14.2, 12.3, 10.4, 8.7, 7.8, 8.2, 9.7, 11.5, 13.4, 15.1, 16.1], + "orientation": [ + { "id": "south", "en": "south", "cs": "jih", "factor": 1.0 }, + { "id": "eastwest", "en": "east / west", "cs": "východ / západ", "factor": 0.6 }, + { "id": "shade", "en": "heavy shade", "cs": "silný stín", "factor": 0.3 } + ], + "orientation_source": "estimate", + "field_note_en": "one of our masts (remote-mast, panel facing east) lost ~50 mV a day from mid-November with consumption unchanged", + "field_note_cs": "jeden z našich stožárů (remote-mast, panel na východ) ztrácel od poloviny listopadu ~50 mV denně při nezměněné spotřebě", + "field_source": "power-flat" + }, + "sensors": { + "_comment": [ + "I2C sensors this firmware probes (src/helpers/sensors/EnvironmentSensorManager.cpp,", + "only builds with ENV_INCLUDE_*). Telemetry is read only when someone asks, so the", + "average is the chip's current between reads; a read itself (a few ms, rarely) is", + "left out. This fork puts every chip to sleep after init and triggers one", + "conversion per read; upstream (v1.19.0) leaves INA219/INA226/INA260/INA3221", + "converting continuously, BMP280 in normal mode and SHTC3 idle. A row with", + "firmware 'tth' is this fork, '*' every other firmware (MeshCore Czech assumed", + "to be upstream here). All values are datasheet ESTIMATES, nothing measured; the", + "bench measured only an idle I2C bus (TWIM, Wire.end()): +-0.00 mA, 3. 12. 2026.", + "Not listed: VL53L0X, BMP085, RAK12035 (not looked at)." + ], + "unit": "mA", "source": "sensor-code", "measured": false, + "list": [ + { "id": "aht20", "name": "AHT10/AHT20", "tth": 0.00025, "*": 0.00025, "how": "sleep 0.25 uA between reads" }, + { "id": "bme280", "name": "BME280", "tth": 0.0001, "*": 0.0001, "how": "forced mode, sleep 0.1 uA" }, + { "id": "bmp280", "name": "BMP280", "tth": 0.0001, "*": 0.65, "how": "here forced (sleep 0.1 uA); upstream normal mode, 1 ms standby: converting almost all the time" }, + { "id": "bmp3xx", "name": "BMP388/390", "tth": 0.002, "*": 0.002, "how": "forced reads, sleep ~2 uA" }, + { "id": "bme680", "name": "BME680", "tth": 0.00015, "*": 0.00015, "how": "performReading per query, sleep 0.15 uA (heater only during a read)" }, + { "id": "bme680bsec", "name": "BME680 + BSEC", "tth": 0.9, "*": 0.9, "how": "BSEC low-power mode: gas heater every 3 s, all the time" }, + { "id": "shtc3", "name": "SHTC3", "tth": 0.0003, "*": 0.045, "how": "here asleep after init (0.3 uA); upstream idle until the first read (45 uA)" }, + { "id": "sht4x", "name": "SHT4x", "tth": 0.0004, "*": 0.0004, "how": "idle 0.4 uA between single-shot reads" }, + { "id": "lps22hb", "name": "LPS22HB", "tth": 0.001, "*": 0.001, "how": "one-shot, power-down 1 uA" }, + { "id": "ina219", "name": "INA219", "tth": 0.006, "*": 0.7, "how": "here power-down 6 uA; upstream continuous ~0.7 mA" }, + { "id": "ina226", "name": "INA226", "tth": 0.002, "*": 0.33, "how": "here shutdown <=2 uA; upstream continuous ~0.33 mA" }, + { "id": "ina260", "name": "INA260", "tth": 0.002, "*": 0.31, "how": "here shutdown <=2 uA; upstream continuous ~0.31 mA" }, + { "id": "ina3221", "name": "INA3221", "tth": 0.002, "*": 0.35, "how": "here power-down ~2 uA; upstream continuous ~0.35 mA" }, + { "id": "mlx90614", "name": "MLX90614", "tth": 1.3, "*": 1.3, "how": "no sleep in the driver, ~1.3 mA" } + ] } } From fc974459780f4824af1806d40be6a301b298560e Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Fri, 4 Dec 2026 17:34:12 +0100 Subject: [PATCH 05/13] Docs: power calculator result drops the estimate and mast notes, month strip in two rows Changelog: - Co-Authored-By: Claude Opus 5.5 --- docs/_js/power-calculator.js | 4 ---- docs/_stylesheets/tth.css | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/_js/power-calculator.js b/docs/_js/power-calculator.js index 3fa31ef1f..49893cf30 100644 --- a/docs/_js/power-calculator.js +++ b/docs/_js/power-calculator.js @@ -543,12 +543,8 @@ ])); if (strip) { - var so = this.d.solar; out.appendChild(el('div', { 'class': 'pc-label pc-strip-t', text: this.t('monthbal') })); out.appendChild(strip); - out.appendChild(el('div', { 'class': 'pc-hint' }, [this.badge(false), ' ', this.srcLink(so.source)])); - // the model is optimistic for a real mast: say what one of ours did - out.appendChild(el('div', { 'class': 'pc-hint' }, ['⚠ ' + so['field_note_' + this.lang] + ' · ', this.srcLink(so.field_source)])); } if (warnNight) out.appendChild(el('div', { 'class': 'pc-warn', text: '⚠ ' + warnNight })); diff --git a/docs/_stylesheets/tth.css b/docs/_stylesheets/tth.css index ce905cfac..ddb212647 100644 --- a/docs/_stylesheets/tth.css +++ b/docs/_stylesheets/tth.css @@ -116,7 +116,7 @@ .pc-chip input { width: auto; margin: 0; accent-color: var(--primary-color); } .pc-chip:has(input:checked) { border-color: var(--primary-color); color: var(--primary-color); } .pc-strip-t { margin-top: 0.9rem; } -.pc-strip { display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; margin-top: 0.3rem; } +.pc-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 2px; margin-top: 0.3rem; } .pc-strip > span { display: flex; flex-direction: column; align-items: center; padding: 0.15rem 0; border-radius: 3px; font-family: ui-monospace, monospace; font-size: 0.62rem; line-height: 1.25; } .pc-strip b { font-family: system-ui, sans-serif; font-weight: 400; color: #b8bcc4; } @@ -127,5 +127,5 @@ .pc-lines td:last-child { width: 6.5em; white-space: normal; } .pc-bignum.pc-bad { color: #ff8a8a; } .pc-layout > *, .pc-card { min-width: 0; } -.pc-strip { grid-template-columns: repeat(12, minmax(0, 1fr)); } +.pc-strip { grid-template-columns: repeat(6, minmax(0, 1fr)); } @media (max-width: 30em) { .pc-strip { grid-template-columns: repeat(6, minmax(0, 1fr)); } } From 049fca56de8f48ccf091ed44fabd083625befa32 Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Fri, 4 Dec 2026 17:37:12 +0100 Subject: [PATCH 06/13] Docs: power calculator -- sensors collapsed, the rxps note says what it costs without alarm Changelog: - Co-Authored-By: Claude Opus 5.5 --- docs/_js/power-calculator.js | 14 ++++++++++---- docs/power-calculator.md | 5 +++-- docs/power-data.json | 8 ++++---- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/docs/_js/power-calculator.js b/docs/_js/power-calculator.js index 49893cf30..d0502527a 100644 --- a/docs/_js/power-calculator.js +++ b/docs/_js/power-calculator.js @@ -363,8 +363,8 @@ if (!c) return null; var link = this.srcLink(c.source); if (link.tagName === 'A') { link.textContent = this.t('details'); link.title = this.n(c); } - return el('div', { 'class': small ? 'pc-warn pc-small' : 'pc-warn', role: 'note' }, - ['⚠ ' + (c['short_' + this.lang] || this.n(c)) + ' · ', link]); + return el('div', { 'class': 'pc-hint', role: 'note' }, + [(c['short_' + this.lang] || this.n(c)) + ' · ', link]); }; P.settingRow = function (k, small) { @@ -415,8 +415,14 @@ cb.checked = !!s.sensors[x.id]; return el('label', { 'class': 'pc-chip', title: x.how }, [cb, x.name]); })); - form.appendChild(el('div', { 'class': 'pc-field' }, [el('span', { 'class': 'pc-label', text: this.t('sensors') }), chips, - el('div', { 'class': 'pc-hint' }, [this.t('sensors_hint') + ' ', this.badge(false)])])); + // collapsed: a dozen chips would take half the page; the summary says how many are picked + var nSel = d.sensors.list.filter(function (x) { return s.sensors[x.id]; }).length; + var sens = el('details', { 'class': 'pc-adv pc-sens', 'data-open': 'sens' }); + if (this.open.sens) sens.open = true; + sens.appendChild(el('summary', { text: this.t('sensors') + (nSel ? ' (' + nSel + ')' : '') })); + sens.appendChild(chips); + sens.appendChild(el('div', { 'class': 'pc-hint' }, [this.t('sensors_hint') + ' ', this.badge(false)])); + form.appendChild(sens); // advanced var adv = el('details', { 'class': 'pc-adv', 'data-open': 'adv' }); diff --git a/docs/power-calculator.md b/docs/power-calculator.md index 4d809c5b0..18c0cb184 100644 --- a/docs/power-calculator.md +++ b/docs/power-calculator.md @@ -38,8 +38,9 @@ power.md.
from mid-November with consumption unchanged ([details](power.md#a-mast-that-runs-flat-bootlock-and-cutoff)). -**rxps is not free:** it saves about 2 mA but loses 13-28 % of weak packets -([details](power.md#rx-duty-cycle-rxps)). Never on a mast. +**rxps:** saves about 2 mA and hears fewer weak packets (13-28 % below 0 dB +SNR, [details](power.md#rx-duty-cycle-rxps)). With other repeaters around that +cover the same area it hardly matters; it does where the node is the only path. ## Data diff --git a/docs/power-data.json b/docs/power-data.json index 256b1577d..fc06c7630 100644 --- a/docs/power-data.json +++ b/docs/power-data.json @@ -234,16 +234,16 @@ { "kind": "reception", "option": "rxps", "to": "balanced", - "short_en": "loses 13-28 % of weak packets; not for a mast", - "short_cs": "ztratí 13-28 % slabých paketů; ne na stožár", + "short_en": "hears fewer weak packets (13-28 % below 0 dB SNR); matters only where this node is the one path", + "short_cs": "slabé pakety zachytí hůř (13-28 % pod 0 dB SNR); vadí jen tam, kde je uzel jediná cesta", "en": "loses 13-28 % of weak packets (SNR -2..-8) against 0 % without rxps; strong signal 0 lost. Not for a mast.", "cs": "ztratí 13-28 % slabých paketů (SNR -2..-8) proti 0 % bez rxps; silný signál 0 ztrát. Ne na stožár.", "date": "2026-12-04", "source": "power-rxps", "measured": true }, { "kind": "reception", "option": "rxps", "to": "max", - "short_en": "loses 13-28 % of weak packets or more; not for a mast", - "short_cs": "ztratí 13-28 % slabých paketů i víc; ne na stožár", + "short_en": "hears fewer weak packets (13-28 % below 0 dB SNR, max a bit more); matters only where this node is the one path", + "short_cs": "slabé pakety zachytí hůř (13-28 % pod 0 dB SNR, max o něco víc); vadí jen tam, kde je uzel jediná cesta", "en": "as balanced or worse: 13-28 % of weak packets lost; on a live mast -16 % received. Not for a mast.", "cs": "jako balanced nebo hůř: ztráta 13-28 % slabých paketů; na ostrém stožáru -16 % přijatých. Ne na stožár.", "date": "2026-12-04", "source": "power-rxps", "measured": true From 410206c464a4b0cc8bd9d12b397db14146a298e8 Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Fri, 4 Dec 2026 17:46:21 +0100 Subject: [PATCH 07/13] Docs: power calculator -- charger type, chemistry, cold, days without sun, other calculators Changelog: - Co-Authored-By: Claude Opus 5.5 --- docs/_js/power-calculator.js | 87 +++++++++++++++++++++++++++++++----- docs/_stylesheets/tth.css | 1 + docs/power-calculator.md | 35 +++++++++++++-- docs/power-data.json | 57 ++++++++++++++++++++--- 4 files changed, 160 insertions(+), 20 deletions(-) diff --git a/docs/_js/power-calculator.js b/docs/_js/power-calculator.js index d0502527a..de34ee1d8 100644 --- a/docs/_js/power-calculator.js +++ b/docs/_js/power-calculator.js @@ -23,6 +23,11 @@ tx_ma: 'TX current (mA), estimate', rx_extra: 'extra current while receiving (mA), estimate', usable_pct: 'usable capacity (%)', voltage: 'battery voltage (V)', charge_eff_pct: 'charging efficiency (%), estimate', month: 'Month', orient: 'Panel faces', + charger: 'charger', chem: 'battery chemistry', dark_days: 'days without sun', + dark_ok: '{d} days without sun: the battery carries them ({p} % left)', + dark_bad: '{d} days without sun: the battery lasts only {n}', + recover: 'refilled in {n} days of this month\'s balance', norecover: 'this month\'s balance does not refill it', + coldcap: 'capacity −{p} % in the cold ({t} °C)', sensors: 'I2C sensors', sensors_hint: 'datasheet estimate for how this firmware reads them', covers: 'panel covers it', emptyafter: 'battery empty after {n} days in {m} (starting full)', night: 'the battery does not carry the {h} h night of {m}: it lasts {x} h', @@ -52,6 +57,11 @@ tx_ma: 'proud při vysílání (mA), odhad', rx_extra: 'proud navíc při příjmu (mA), odhad', usable_pct: 'využitelná kapacita (%)', voltage: 'napětí baterie (V)', charge_eff_pct: 'účinnost nabíjení (%), odhad', month: 'Měsíc', orient: 'Panel míří na', + charger: 'nabíječ', chem: 'chemie článku', dark_days: 'dny bez slunce', + dark_ok: 'po {d} dnech bez slunce zbude v baterii {p} %', + dark_bad: 'bez slunce vydrží baterie jen {n} (zadáno {d})', + recover: 'dobije se za {n} dní bilance tohoto měsíce', norecover: 'bilance tohoto měsíce ji nedobije', + coldcap: 'kapacita −{p} % zimou ({t} °C)', sensors: 'Čidla na I2C', sensors_hint: 'odhad z datasheetu podle toho, jak je tento firmware čte', covers: 'panel stačí', emptyafter: 'baterie prázdná po {n} dnech, měsíc {m} (z plné)', night: 'baterie neutáhne {h} h noci (měsíc {m}): vydrží {x} h', @@ -111,7 +121,8 @@ rx_extra: d.traffic.rx_extra.value, mah: b.mah, usable_pct: b.usable_pct, voltage: b.voltage, panel_w: b.panel_w, charge_eff_pct: b.charge_eff_pct, - month: d.solar.default_month, orient: d.solar.orientation[0].id, sensors: {} + month: d.solar.default_month, orient: d.solar.orientation[0].id, sensors: {}, + charger: d.solar.chargers[0].id, chem: d.solar.chemistries[0].id, dark_days: d.solar.dark_days }; this.s.tx_ma = this.txCurrent(this.s.tx_dbm); this.applyDefaults(true); @@ -139,9 +150,13 @@ // boardChanged: also the battery and panel the board ships with P.applyDefaults = function (boardChanged) { var self = this, def = Object.assign({}, this.board().defaults, this.fw().defaults); - if (boardChanged) ['mah', 'panel_w'].forEach(function (k) { - self.s[k] = def[k] != null ? def[k] : self.d.battery[k]; - }); + if (boardChanged) { + ['mah', 'panel_w'].forEach(function (k) { + self.s[k] = def[k] != null ? def[k] : self.d.battery[k]; + }); + if (def.charger) this.setCharger(def.charger); + if (def.chem) this.setChem(def.chem); + } Object.keys(this.d.settings).forEach(function (k) { var vals = self.d.settings[k]; if (!self.available(k)) self.s[k] = vals.indexOf('off') >= 0 ? 'off' : vals[0]; @@ -182,10 +197,38 @@ }; }; + // a charger / chemistry preset sets the numbers it stands for (still overridable) + P.setCharger = function (id) { + var c = this.d.solar.chargers.filter(function (x) { return x.id === id; })[0]; + if (c) { this.s.charger = id; this.s.charge_eff_pct = c.eff_pct; } + }; + P.setChem = function (id) { + var c = this.d.solar.chemistries.filter(function (x) { return x.id === id; })[0]; + if (c) { this.s.chem = id; this.s.usable_pct = c.usable_pct; this.s.voltage = c.voltage; } + }; + // capacity lost to cold in month m, % (linear between the points of the data file) + P.coldLoss = function (m) { + var t = this.d.solar.temp_c[m - 1]; + var pts = this.d.solar.cold_derate.slice().sort(function (a, b) { return a.t - b.t; }); + if (t <= pts[0].t) return pts[0].loss_pct; + for (var i = 1; i < pts.length; i++) { + if (t <= pts[i].t) { + var a = pts[i - 1], b = pts[i]; + return a.loss_pct + (b.loss_pct - a.loss_pct) * (t - a.t) / (b.t - a.t); + } + } + return pts[pts.length - 1].loss_pct; + }; + P.usableAt = function (m) { + var s = this.s; + return s.mah * s.usable_pct / 100 * (1 - this.coldLoss(m) / 100); + }; + // solar gain in mAh per day in month m (1..12) P.solarGain = function (m) { var s = this.s, so = this.d.solar; - var f = so.orientation.filter(function (o) { return o.id === s.orient; })[0].factor; + var o = so.orientation.filter(function (x) { return x.id === s.orient; })[0]; + var f = o.factor_month ? o.factor_month[m - 1] : o.factor; return s.panel_w * so.sun_h[m - 1] * f * (s.charge_eff_pct / 100) / s.voltage * 1000; }; P.monthName = function (m) { @@ -405,11 +448,13 @@ ])); var months = []; for (var m = 1; m <= 12; m++) months.push({ v: m, t: this.monthName(m) }); - form.appendChild(el('div', { 'class': 'pc-two pc-sel' }, [ + form.appendChild(el('div', { 'class': 'pc-two' }, [ this.field(this.t('month'), this.select('month', months)), - el('div', { 'class': 'pc-field' }, [el('span', { 'class': 'pc-label', text: this.t('orient') }), - this.seg('orient', d.solar.orientation.map(function (o) { return { v: o.id, t: self.n(o) }; }))]) + this.field(this.t('dark_days'), this.num('dark_days', { step: 1 })) ])); + // four orientations need the full width + form.appendChild(el('div', { 'class': 'pc-field' }, [el('span', { 'class': 'pc-label', text: this.t('orient') }), + this.seg('orient', d.solar.orientation.map(function (o) { return { v: o.id, t: self.n(o) }; }))])); var chips = el('div', { 'class': 'pc-chips' }, d.sensors.list.map(function (x) { var cb = el('input', { type: 'checkbox', 'data-sensor': x.id }); cb.checked = !!s.sensors[x.id]; @@ -440,8 +485,10 @@ grid.appendChild(this.field(this.t('tx_dbm'), this.num('tx_dbm', { step: 1, min: '-9' }))); grid.appendChild(this.field(this.t('tx_ma'), this.num('tx_ma'))); grid.appendChild(this.field(this.t('rx_extra'), this.num('rx_extra'))); + grid.appendChild(this.field(this.t('chem'), this.select('chem', d.solar.chemistries.map(function (c) { return { v: c.id, t: self.n(c) }; })))); grid.appendChild(this.field(this.t('usable_pct'), this.num('usable_pct', { step: 5 }))); grid.appendChild(this.field(this.t('voltage'), this.num('voltage', { step: 0.1 }))); + grid.appendChild(this.field(this.t('charger'), this.select('charger', d.solar.chargers.map(function (c) { return { v: c.id, t: self.n(c) + ' ' + c.eff_pct + ' %' }; })))); grid.appendChild(this.field(this.t('charge_eff_pct'), this.num('charge_eff_pct', { step: 5 }))); adv.appendChild(grid); adv.appendChild(el('p', { 'class': 'pc-hint', text: this.t('override_hint') })); @@ -454,6 +501,8 @@ if (t.tagName === 'SELECT') { s[k] = isNaN(+t.value) ? t.value : +t.value; if (k === 'board' || k === 'firmware') self.applyDefaults(k === 'board'); + if (k === 'charger') self.setCharger(t.value); + if (k === 'chem') self.setChem(t.value); self.build(); return; } @@ -510,11 +559,13 @@ P.render = function () { var self = this, s = this.s, r = this.compute(), out = this.out; out.textContent = ''; - var mid = (r.lo + r.hi) / 2, perDay = mid * 24, usable = s.mah * s.usable_pct / 100; + var mid = (r.lo + r.hi) / 2, perDay = mid * 24, usable = this.usableAt(s.month); + var so = this.d.solar, tmon = so.temp_c[s.month - 1], cold = this.coldLoss(s.month), notes = []; + if (cold > 0.5) notes.push(this.t('coldcap').replace('{p}', this.fmt(cold, 0)).replace('{t}', this.fmt(tmon, 1))); // the two big numbers var rng = r.hi - r.lo > 0.005 ? this.fmt(r.lo) + ' … ' + this.fmt(r.hi) + ' mA' : ''; - var autoBig, autoSub, autoLabel = this.t('autonomy'), warnNight = null, strip = null, autoBad = false; + var autoBig, autoSub, autoLabel = this.t('autonomy'), warnNight = null, strip = null, autoBad = false, darkLine = null; if (s.panel_w > 0) { var mn = this.monthName(s.month), bal = this.solarGain(s.month) - perDay; autoLabel = this.t('bal_in') + ' ' + mn; @@ -535,6 +586,19 @@ var nh = this.d.solar.night_h[s.month - 1], lasts = usable / mid; if (lasts < nh) warnNight = this.t('night').replace('{h}', this.fmt(nh, 0)).replace('{m}', mn).replace('{x}', this.fmt(lasts, 1)); if (warnNight) { autoBad = true; autoSub = autoSub.replace(this.t('covers'), '⚠ ' + this.t('nightshort')); } + // a dark streak from full, then how long this month's surplus takes to refill it + var dd = +s.dark_days || 0; + if (dd > 0) { + var need = dd * perDay; + if (need <= usable) { + var dl = this.t('dark_ok').replace('{d}', dd).replace('{p}', this.fmt((usable - need) / usable * 100, 0)); + dl += ' · ' + (bal > 0 ? this.t('recover').replace('{n}', this.fmt(need / bal, 1)) : this.t('norecover')); + darkLine = el('div', { 'class': 'pc-hint', text: dl }); + } else { + darkLine = el('div', { 'class': 'pc-warn', text: this.t('dark_bad').replace('{d}', dd) + .replace('{n}', this.fmt(usable / perDay, 1) + ' ' + this.t('days')) }); + } + } } else { autoBig = this.fmt(usable / perDay, 1); autoSub = this.t('days') + ' · ' + this.fmt(perDay, 0) + ' mAh ' + this.t('perday'); @@ -552,7 +616,10 @@ out.appendChild(el('div', { 'class': 'pc-label pc-strip-t', text: this.t('monthbal') })); out.appendChild(strip); } + if (darkLine) out.appendChild(darkLine); if (warnNight) out.appendChild(el('div', { 'class': 'pc-warn', text: '⚠ ' + warnNight })); + if (tmon < 0) notes.push(so['cold_note_' + this.lang]); + notes.forEach(function (n) { out.appendChild(el('div', { 'class': 'pc-hint', text: n })); }); // split node / TX / RX var tot = r.parts.node + r.parts.tx + r.parts.rx || 1, bar = el('div', { 'class': 'pc-bar', role: 'img', diff --git a/docs/_stylesheets/tth.css b/docs/_stylesheets/tth.css index ddb212647..11a3188d4 100644 --- a/docs/_stylesheets/tth.css +++ b/docs/_stylesheets/tth.css @@ -129,3 +129,4 @@ .pc-layout > *, .pc-card { min-width: 0; } .pc-strip { grid-template-columns: repeat(6, minmax(0, 1fr)); } @media (max-width: 30em) { .pc-strip { grid-template-columns: repeat(6, minmax(0, 1fr)); } } +.pc-seg { flex-wrap: wrap; } diff --git a/docs/power-calculator.md b/docs/power-calculator.md index 18c0cb184..bfa35ab9a 100644 --- a/docs/power-calculator.md +++ b/docs/power-calculator.md @@ -28,12 +28,21 @@ power.md.
reads; upstream leaves the INA219/226/260/3221 converting (0.3-0.7 mA each) and a BMP280 in normal mode. Estimates; only the idle bus itself was measured. - **Battery:** usable mAh / (mA × 24 h). A board's choice fills in what it - ships with (SenseCAP Solar P1-Pro: 4× 18650, 13 400 mAh, 5 W panel). + ships with (SenseCAP Solar P1-Pro: 4× 18650, 13 400 mAh, 5 W panel). The + chemistry sets the usable share (Li-ion/NMC 80 %, LiFePO4 90 %), and the + month's mean temperature (Czech uplands) takes off what the cold costs + (~20 % at 0 °C, ~40 % at −20 °C after EastMesh; estimates). +- **Days without sun:** whether the battery, full at the start, carries that + many dark days (default 4; Voltaic recommends at least 4, EastMesh 3-5), and + how many days of the month's surplus it takes to refill it afterwards. - **Solar:** W × equivalent full-sun hours of the chosen **month** × orientation - × charging efficiency / battery voltage. Sun hours are PVGIS monthly means + × charging efficiency / battery voltage. The efficiency comes from the + charger type (D-Central's presets: MPPT 70 %, PWM 55 %, linear 50 %; the + SenseCAP Solar and the XIAO charge linearly). Sun hours are PVGIS monthly means for Prague at the optimal tilt (December 1.5 h, June 5.6 h a day); the calculator opens on December, the worst month, and shows the balance of all - twelve. East/west is taken as 60 %, heavy shade 30 % (estimates). How much + twelve. East/west is taken as 60 %, heavy shade 30 %, a flat panel that +snow covers 20-30 % in winter (estimates). How much that matters: one of our masts (remote-mast, panel facing east) lost ~50 mV a day from mid-November with consumption unchanged ([details](power.md#a-mast-that-runs-flat-bootlock-and-cutoff)). @@ -42,6 +51,26 @@ power.md. SNR, [details](power.md#rx-duty-cycle-rxps)). With other repeaters around that cover the same area it hardly matters; it does where the node is the only path. +## Other calculators and guides / Jiné kalkulačky a návody + +- [D-Central Off-Grid Solar Node Planner](https://d-central.tech/solar-node-planner/) + -- interactive, Meshtastic/LoRa, sized for a Canadian winter. +- [Voltaic Systems off-grid sizing](https://voltaicsystems.com/sizing/) -- + interactive, generic IoT; aims at a power ratio of at least 1.5. +- [EastMesh wiki: Power & Solar](https://wiki.eastmesh.au/power/overview/) -- + a MeshCore community guide. +- [SDRstore: European winter battery and panel sizing](https://www.sdrstore.eu/solar-meshtastic-lilygo-european-winter-battery-panel-sizing/) + -- a worked example with a commissioning checklist. +- [Meshtastic: measure power consumption](https://meshtastic.org/docs/hardware/solar-powered/measure-power-consumption/) + -- how to measure your own node. +- [PVGIS (EU JRC)](https://re.jrc.ec.europa.eu/pvg_tools/en/) -- the sun + where your node actually stands. + +What this one adds: the per-option deltas measured on our bench, firmware +against firmware, and what an option costs in reception. +Co přidává tahle: rozdíly jednotlivých voleb změřené na naší lavici, srovnání +firmwarů a cenu voleb v příjmu. + ## Data All numbers live in one file, diff --git a/docs/power-data.json b/docs/power-data.json index fc06c7630..15ce650a9 100644 --- a/docs/power-data.json +++ b/docs/power-data.json @@ -58,8 +58,23 @@ }, "seeed-wiki": { "url": "https://wiki.seeedstudio.com/meshtastic_solar_node/", - "en": "Seeed wiki, SenseCAP Solar Node: 5 W panel, P1-Pro 4x 18650 NMC 3350 mAh", - "cs": "Seeed wiki, SenseCAP Solar Node: panel 5 W, P1-Pro 4x 18650 NMC 3350 mAh" + "en": "Seeed wiki, SenseCAP Solar Node: 5 W panel, P1-Pro 4x 18650 NMC 3350 mAh, linear charger CN3165", + "cs": "Seeed wiki, SenseCAP Solar Node: panel 5 W, P1-Pro 4x 18650 NMC 3350 mAh, lineární nabíječ CN3165" + }, + "dcentral": { + "url": "https://d-central.tech/solar-node-planner/", + "en": "D-Central Off-Grid Solar Node Planner (presets), estimate", + "cs": "D-Central Off-Grid Solar Node Planner (předvolby), odhad" + }, + "eastmesh": { + "url": "https://wiki.eastmesh.au/power/overview/", + "en": "EastMesh wiki, Power & Solar, estimate", + "cs": "EastMesh wiki, Power & Solar, odhad" + }, + "voltaic": { + "url": "https://voltaicsystems.com/sizing/", + "en": "Voltaic Systems off-grid sizing", + "cs": "Voltaic Systems, dimenzování off-grid" }, "pvgis": { "url": "https://re.jrc.ec.europa.eu/pvg_tools/en/", @@ -88,14 +103,15 @@ "en": "XIAO nRF52840 + Wio-SX1262 (fed on 3V3)", "cs": "XIAO nRF52840 + Wio-SX1262 (napájené na 3V3)", "gps": false, - "defaults": { "ble": "off", "gps": "off", "mah": 3000, "panel_w": 0 } + "defaults": { "ble": "off", "gps": "off", "mah": 3000, "panel_w": 0, "charger": "linear", "chem": "liion" }, + "_charger": "XIAO nRF52840 charges its cell with an on-board linear charger (BQ25101)" }, { "id": "p1pro", "en": "SenseCAP Solar P1-Pro (nRF52840 + SX1262 + L76K GPS)", "cs": "SenseCAP Solar P1-Pro (nRF52840 + SX1262 + GPS L76K)", "gps": true, - "defaults": { "ble": "on", "gps": "duty", "mah": 13400, "panel_w": 5 }, + "defaults": { "ble": "on", "gps": "duty", "mah": 13400, "panel_w": 5, "charger": "linear", "chem": "liion" }, "defaults_source": "seeed-wiki" }, { @@ -105,7 +121,7 @@ "gps": false, "like": "p1pro", "_comment": "not measured: the P1-Pro without its GPS receiver, every number borrowed from the P1-Pro (an estimate); ships without cells", - "defaults": { "ble": "on", "gps": "off", "mah": 13400, "panel_w": 5 }, + "defaults": { "ble": "on", "gps": "off", "mah": 13400, "panel_w": 5, "charger": "linear", "chem": "liion" }, "defaults_source": "seeed-wiki" } ], @@ -295,7 +311,7 @@ "battery": { "_comment": "defaults of the battery inputs (a board's defaults win); efficiency and voltage are assumptions", "mah": 3000, "usable_pct": 80, "voltage": 3.7, - "panel_w": 0, "charge_eff_pct": 70 + "panel_w": 0, "charge_eff_pct": 50 }, "solar": { "_comment": [ @@ -313,9 +329,36 @@ "orientation": [ { "id": "south", "en": "south", "cs": "jih", "factor": 1.0 }, { "id": "eastwest", "en": "east / west", "cs": "východ / západ", "factor": 0.6 }, - { "id": "shade", "en": "heavy shade", "cs": "silný stín", "factor": 0.3 } + { "id": "shade", "en": "heavy shade", "cs": "silný stín", "factor": 0.3 }, + { "id": "flat", "en": "flat / snow-prone", "cs": "plochý / pod sněhem", + "factor_month": [0.2, 0.3, 0.7, 0.9, 0.95, 0.95, 0.95, 0.95, 0.85, 0.7, 0.4, 0.2], + "_comment": "a flat panel under snow makes nothing (D-Central); winter 0-40 % taken as 20-30 %, summer near the optimal tilt; estimate", + "source": "dcentral" } ], "orientation_source": "estimate", + "chargers": [ + { "id": "mppt", "en": "MPPT", "cs": "MPPT", "eff_pct": 70 }, + { "id": "pwm", "en": "PWM", "cs": "PWM", "eff_pct": 55 }, + { "id": "linear", "en": "linear (CN3165, XIAO)", "cs": "lineární (CN3165, XIAO)", "eff_pct": 50 }, + { "id": "bench", "en": "optimistic / bench", "cs": "optimistický / lavice", "eff_pct": 80 } + ], + "chargers_source": "dcentral", + "chemistries": [ + { "id": "liion", "en": "Li-ion / NMC", "cs": "Li-ion / NMC", "usable_pct": 80, "voltage": 3.7 }, + { "id": "lifepo4", "en": "LiFePO4", "cs": "LiFePO4", "usable_pct": 90, "voltage": 3.2 } + ], + "_chemistries": "lead-acid left out: a 12 V battery needs a converter the node does not have", + "chemistries_source": "eastmesh", + "temp_c": [-3, -2, 1, 6, 11, 14, 16, 15.5, 11.5, 7, 2, -1.5], + "_temp_c": "monthly mean air temperature, Czech uplands ~600 m (rounded climate normals), estimate", + "cold_derate": [ { "t": 10, "loss_pct": 0 }, { "t": 0, "loss_pct": 20 }, { "t": -20, "loss_pct": 40 } ], + "_cold_derate": "capacity lost to cold, interpolated in temp_c (EastMesh: ~20 % at 0 C, ~40 % at -20 C), estimate", + "cold_source": "eastmesh", + "cold_note_en": "Li-ion must not be charged below 0 °C; the SenseCAP charger stops via an NTC (threshold about −10 °C, not verified)", + "cold_note_cs": "Li-ion se pod 0 °C nesmí nabíjet; SenseCAP to hlídá NTC na nabíječi (práh kolem −10 °C, neověřeno)", + "dark_days": 4, + "_dark_days": "days without sun the battery should carry: Voltaic recommends >= 4, EastMesh 3-5", + "dark_days_source": "voltaic", "field_note_en": "one of our masts (remote-mast, panel facing east) lost ~50 mV a day from mid-November with consumption unchanged", "field_note_cs": "jeden z našich stožárů (remote-mast, panel na východ) ztrácel od poloviny listopadu ~50 mV denně při nezměněné spotřebě", "field_source": "power-flat" From fd6b10db74c3cbae1fa808092dc4698db9063017 Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Fri, 4 Dec 2026 17:50:04 +0100 Subject: [PATCH 08/13] Docs: power calculator keeps to its model, no notes about our own masts Changelog: - Co-Authored-By: Claude Opus 5.5 --- docs/power-calculator.md | 5 +---- docs/power-data.json | 10 +--------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/docs/power-calculator.md b/docs/power-calculator.md index bfa35ab9a..91d946ad9 100644 --- a/docs/power-calculator.md +++ b/docs/power-calculator.md @@ -42,10 +42,7 @@ power.md. for Prague at the optimal tilt (December 1.5 h, June 5.6 h a day); the calculator opens on December, the worst month, and shows the balance of all twelve. East/west is taken as 60 %, heavy shade 30 %, a flat panel that -snow covers 20-30 % in winter (estimates). How much - that matters: one of our masts (remote-mast, panel facing east) lost ~50 mV a day - from mid-November with consumption unchanged - ([details](power.md#a-mast-that-runs-flat-bootlock-and-cutoff)). +snow covers 20-30 % in winter (estimates). **rxps:** saves about 2 mA and hears fewer weak packets (13-28 % below 0 dB SNR, [details](power.md#rx-duty-cycle-rxps)). With other repeaters around that diff --git a/docs/power-data.json b/docs/power-data.json index 15ce650a9..a25591dce 100644 --- a/docs/power-data.json +++ b/docs/power-data.json @@ -81,11 +81,6 @@ "en": "PVGIS, Prague, optimal tilt, monthly mean - estimate", "cs": "PVGIS, Praha, optimální sklon, měsíční průměr - odhad" }, - "power-flat": { - "url": "power.md#a-mast-that-runs-flat-bootlock-and-cutoff", - "en": "docs/power.md, a mast that runs flat", - "cs": "docs/power.md, stožár, který se vybije" - }, "sensor-code": { "url": "", "en": "src/helpers/sensors/EnvironmentSensorManager.cpp + datasheet, not measured", @@ -358,10 +353,7 @@ "cold_note_cs": "Li-ion se pod 0 °C nesmí nabíjet; SenseCAP to hlídá NTC na nabíječi (práh kolem −10 °C, neověřeno)", "dark_days": 4, "_dark_days": "days without sun the battery should carry: Voltaic recommends >= 4, EastMesh 3-5", - "dark_days_source": "voltaic", - "field_note_en": "one of our masts (remote-mast, panel facing east) lost ~50 mV a day from mid-November with consumption unchanged", - "field_note_cs": "jeden z našich stožárů (remote-mast, panel na východ) ztrácel od poloviny listopadu ~50 mV denně při nezměněné spotřebě", - "field_source": "power-flat" + "dark_days_source": "voltaic" }, "sensors": { "_comment": [ From 3244806de2fceaf2ea6d28168abfffe51bc19da8 Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Fri, 4 Dec 2026 17:51:52 +0100 Subject: [PATCH 09/13] Docs: power calculator scales the solar yield to what a real installation delivers (45 %) Changelog: - Co-Authored-By: Claude Opus 5.5 --- docs/_js/power-calculator.js | 9 +++++---- docs/power-calculator.md | 4 +++- docs/power-data.json | 4 +++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/_js/power-calculator.js b/docs/_js/power-calculator.js index de34ee1d8..cc68fafef 100644 --- a/docs/_js/power-calculator.js +++ b/docs/_js/power-calculator.js @@ -22,7 +22,7 @@ preamble: 'preamble (symbols)', tx_dbm: 'TX power (dBm)', tx_ma: 'TX current (mA), estimate', rx_extra: 'extra current while receiving (mA), estimate', usable_pct: 'usable capacity (%)', voltage: 'battery voltage (V)', - charge_eff_pct: 'charging efficiency (%), estimate', month: 'Month', orient: 'Panel faces', + charge_eff_pct: 'charging efficiency (%), estimate', site_pct: 'real installation (% of the model)', month: 'Month', orient: 'Panel faces', charger: 'charger', chem: 'battery chemistry', dark_days: 'days without sun', dark_ok: '{d} days without sun: the battery carries them ({p} % left)', dark_bad: '{d} days without sun: the battery lasts only {n}', @@ -56,7 +56,7 @@ preamble: 'preambule (symboly)', tx_dbm: 'vysílací výkon (dBm)', tx_ma: 'proud při vysílání (mA), odhad', rx_extra: 'proud navíc při příjmu (mA), odhad', usable_pct: 'využitelná kapacita (%)', voltage: 'napětí baterie (V)', - charge_eff_pct: 'účinnost nabíjení (%), odhad', month: 'Měsíc', orient: 'Panel míří na', + charge_eff_pct: 'účinnost nabíjení (%), odhad', site_pct: 'reálná instalace (% modelu)', month: 'Měsíc', orient: 'Panel míří na', charger: 'nabíječ', chem: 'chemie článku', dark_days: 'dny bez slunce', dark_ok: 'po {d} dnech bez slunce zbude v baterii {p} %', dark_bad: 'bez slunce vydrží baterie jen {n} (zadáno {d})', @@ -120,7 +120,7 @@ sf: td.sf, bw: td.bw, cr: td.cr, preamble: td.preamble, tx_dbm: td.tx_dbm, rx_extra: d.traffic.rx_extra.value, mah: b.mah, usable_pct: b.usable_pct, voltage: b.voltage, - panel_w: b.panel_w, charge_eff_pct: b.charge_eff_pct, + panel_w: b.panel_w, charge_eff_pct: b.charge_eff_pct, site_pct: d.battery.site_pct, month: d.solar.default_month, orient: d.solar.orientation[0].id, sensors: {}, charger: d.solar.chargers[0].id, chem: d.solar.chemistries[0].id, dark_days: d.solar.dark_days }; @@ -229,7 +229,7 @@ var s = this.s, so = this.d.solar; var o = so.orientation.filter(function (x) { return x.id === s.orient; })[0]; var f = o.factor_month ? o.factor_month[m - 1] : o.factor; - return s.panel_w * so.sun_h[m - 1] * f * (s.charge_eff_pct / 100) / s.voltage * 1000; + return s.panel_w * so.sun_h[m - 1] * f * (s.charge_eff_pct / 100) * (s.site_pct / 100) / s.voltage * 1000; }; P.monthName = function (m) { return new Date(2026, m - 1, 15).toLocaleString(this.lang === 'cs' ? 'cs-CZ' : 'en-GB', { month: 'long' }); @@ -490,6 +490,7 @@ grid.appendChild(this.field(this.t('voltage'), this.num('voltage', { step: 0.1 }))); grid.appendChild(this.field(this.t('charger'), this.select('charger', d.solar.chargers.map(function (c) { return { v: c.id, t: self.n(c) + ' ' + c.eff_pct + ' %' }; })))); grid.appendChild(this.field(this.t('charge_eff_pct'), this.num('charge_eff_pct', { step: 5 }))); + grid.appendChild(this.field(this.t('site_pct'), this.num('site_pct', { step: 5 }))); adv.appendChild(grid); adv.appendChild(el('p', { 'class': 'pc-hint', text: this.t('override_hint') })); form.appendChild(adv); diff --git a/docs/power-calculator.md b/docs/power-calculator.md index 91d946ad9..8c8eb4ae2 100644 --- a/docs/power-calculator.md +++ b/docs/power-calculator.md @@ -42,7 +42,9 @@ power.md. for Prague at the optimal tilt (December 1.5 h, June 5.6 h a day); the calculator opens on December, the worst month, and shows the balance of all twelve. East/west is taken as 60 %, heavy shade 30 %, a flat panel that -snow covers 20-30 % in winter (estimates). +snow covers 20-30 % in winter (estimates). A real installation delivers about + 45 % of that model (calibrated on two of our solar nodes, November 2026; + under *Advanced*). **rxps:** saves about 2 mA and hears fewer weak packets (13-28 % below 0 dB SNR, [details](power.md#rx-duty-cycle-rxps)). With other repeaters around that diff --git a/docs/power-data.json b/docs/power-data.json index a25591dce..2f1c2356d 100644 --- a/docs/power-data.json +++ b/docs/power-data.json @@ -306,7 +306,9 @@ "battery": { "_comment": "defaults of the battery inputs (a board's defaults win); efficiency and voltage are assumptions", "mah": 3000, "usable_pct": 80, "voltage": 3.7, - "panel_w": 0, "charge_eff_pct": 50 + "panel_w": 0, "charge_eff_pct": 50, + "site_pct": 45, + "_site_pct": "share of the modelled panel yield a real installation delivers (dirt, horizon, panel temperature, fog/rime, full-cell cut-off): calibrated on two of our solar repeaters in November 2026 (south and east panel, frost days excluded), both about 0.45 of this model" }, "solar": { "_comment": [ From 033be588c1a46c9f4245111baf8ff81ca47fc5aa Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Fri, 4 Dec 2026 17:55:09 +0100 Subject: [PATCH 10/13] Docs: power calculator -- panel orientation "triangle, 3 panels" around a mast Changelog: - Co-Authored-By: Claude Opus 5.5 --- docs/_js/power-calculator.js | 11 ++++++++--- docs/power-data.json | 13 ++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/docs/_js/power-calculator.js b/docs/_js/power-calculator.js index cc68fafef..c58ceead3 100644 --- a/docs/_js/power-calculator.js +++ b/docs/_js/power-calculator.js @@ -23,7 +23,7 @@ tx_ma: 'TX current (mA), estimate', rx_extra: 'extra current while receiving (mA), estimate', usable_pct: 'usable capacity (%)', voltage: 'battery voltage (V)', charge_eff_pct: 'charging efficiency (%), estimate', site_pct: 'real installation (% of the model)', month: 'Month', orient: 'Panel faces', - charger: 'charger', chem: 'battery chemistry', dark_days: 'days without sun', + panel_w_each: 'W per panel', charger: 'charger', chem: 'battery chemistry', dark_days: 'days without sun', dark_ok: '{d} days without sun: the battery carries them ({p} % left)', dark_bad: '{d} days without sun: the battery lasts only {n}', recover: 'refilled in {n} days of this month\'s balance', norecover: 'this month\'s balance does not refill it', @@ -57,7 +57,7 @@ tx_ma: 'proud při vysílání (mA), odhad', rx_extra: 'proud navíc při příjmu (mA), odhad', usable_pct: 'využitelná kapacita (%)', voltage: 'napětí baterie (V)', charge_eff_pct: 'účinnost nabíjení (%), odhad', site_pct: 'reálná instalace (% modelu)', month: 'Měsíc', orient: 'Panel míří na', - charger: 'nabíječ', chem: 'chemie článku', dark_days: 'dny bez slunce', + panel_w_each: 'W na jeden panel', charger: 'nabíječ', chem: 'chemie článku', dark_days: 'dny bez slunce', dark_ok: 'po {d} dnech bez slunce zbude v baterii {p} %', dark_bad: 'bez slunce vydrží baterie jen {n} (zadáno {d})', recover: 'dobije se za {n} dní bilance tohoto měsíce', norecover: 'bilance tohoto měsíce ji nedobije', @@ -224,6 +224,11 @@ return s.mah * s.usable_pct / 100 * (1 - this.coldLoss(m) / 100); }; + P.orientRow = function () { + var s = this.s; + return this.d.solar.orientation.filter(function (x) { return x.id === s.orient; })[0]; + }; + // solar gain in mAh per day in month m (1..12) P.solarGain = function (m) { var s = this.s, so = this.d.solar; @@ -444,7 +449,7 @@ this.seg('preset', d.traffic.presets.map(function (p) { return { v: p.id, t: self.n(p) }; }), presetDis)])); form.appendChild(el('div', { 'class': 'pc-two' }, [ this.field(this.t('mah'), this.num('mah', { step: 100 })), - this.field(this.t('panel_w'), this.num('panel_w', { step: 0.5 }), this.t('panel_hint')) + this.field(this.t(this.orientRow().per_panel ? 'panel_w_each' : 'panel_w'), this.num('panel_w', { step: 0.5 }), this.t('panel_hint')) ])); var months = []; for (var m = 1; m <= 12; m++) months.push({ v: m, t: this.monthName(m) }); diff --git a/docs/power-data.json b/docs/power-data.json index 2f1c2356d..1ef3ddc47 100644 --- a/docs/power-data.json +++ b/docs/power-data.json @@ -330,7 +330,18 @@ { "id": "flat", "en": "flat / snow-prone", "cs": "plochý / pod sněhem", "factor_month": [0.2, 0.3, 0.7, 0.9, 0.95, 0.95, 0.95, 0.95, 0.85, 0.7, 0.4, 0.2], "_comment": "a flat panel under snow makes nothing (D-Central); winter 0-40 % taken as 20-30 %, summer near the optimal tilt; estimate", - "source": "dcentral" } + "source": "dcentral" }, + { "id": "triangle", "en": "triangle, 3 panels", "cs": "triangl, 3 panely", "per_panel": true, + "factor_month": [1.46, 1.47, 1.48, 1.45, 1.51, 1.51, 1.50, 1.47, 1.45, 1.45, 1.47, 1.46], + "factor_month_tilt60": [1.74, 1.82, 1.95, 2.06, 2.24, 2.29, 2.26, 2.13, 1.97, 1.84, 1.77, 1.68], + "_comment": [ + "Three panels around a mast, azimuths south and +-120 deg, vertical (90 deg, as usually built);", + "the panel input is then W PER PANEL. factor_month = (H(i)_m south + H(i)_m +120 + H(i)_m -120)", + "/ H(i)_m of one south panel at the optimal 38 deg, PVGIS v5.2 PVcalc (MRcalc ignores the", + "azimuth), Prague 50.08 N 14.42 E, SARAH2 2005-2020, DEM horizon, queried 4. 12. 2026.", + "factor_month_tilt60: the same at 60 deg, not used by the page. Estimate." + ], + "source": "pvgis" } ], "orientation_source": "estimate", "chargers": [ From ef49791ef9780d0244a2dbd981348127c38bc5dc Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Fri, 4 Dec 2026 18:53:11 +0100 Subject: [PATCH 11/13] Docs: power calculator takes the SenseCAP Solar baseline from Seeed's measurement (9.47 mA) Changelog: - Co-Authored-By: Claude Opus 5.5 --- docs/power-data.json | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/power-data.json b/docs/power-data.json index 1ef3ddc47..469f166ed 100644 --- a/docs/power-data.json +++ b/docs/power-data.json @@ -56,6 +56,11 @@ "en": "SX1262 datasheet (Semtech), not measured", "cs": "datasheet SX1262 (Semtech), neměřeno" }, + "seeed-table": { + "url": "https://files.seeedstudio.com/wiki/SenseCAP/Meshcore/SolarNode/mesh_repeater_power_table_en1.xlsx", + "en": "Seeed, Solar Node battery life calculation table (MeshCore): baseline 9.47 mA, GPS 40.2 mA, TX EU868 118.7 mA", + "cs": "Seeed, tabulka výdrže Solar Node (MeshCore): základ 9,47 mA, GPS 40,2 mA, TX EU868 118,7 mA" + }, "seeed-wiki": { "url": "https://wiki.seeedstudio.com/meshtastic_solar_node/", "en": "Seeed wiki, SenseCAP Solar Node: 5 W panel, P1-Pro 4x 18650 NMC 3350 mAh, linear charger CN3165", @@ -182,11 +187,18 @@ "date": "2026-12-04", "source": "bench-2026-12-04-czech", "measured": true }, { - "kind": "baseline", "board": "p1pro", "firmware": "tth", - "settings": { "powersaving": "on", "rxps": "off", "rxgain": "on", "ble": "on", "gps": "duty" }, + "kind": "baseline", "board": "p1pro", "firmware": "stock", + "settings": { "powersaving": "off", "rxps": "off", "rxgain": "on", "ble": "off", "gps": "off" }, + "value": 9.47, "unit": "mA", + "note_en": "Seeed's measurement of a MeshCore repeater on the Solar Node (\"screen off\" baseline, GPS and TX apart); firmware, settings and the measuring point are not stated -- taken as stock defaults until our battery-side measurement", + "note_cs": "měření výrobce (Seeed), MeshCore repeater na Solar Node (základ „screen off“, GPS a vysílání zvlášť); firmware, nastavení ani místo měření neuvádí -- bráno jako výchozí stock, než změříme ze strany baterie", + "date": "2025", "source": "seeed-table", "measured": true + }, + { + "kind": "info", "board": "p1pro", "firmware": "tth", "value": 24, "approx": true, "unit": "mA", "voltage": 5.0, - "note_en": "mast configuration, 5 V USB side, charged cell", - "note_cs": "konfigurace stožáru, strana 5 V USB, nabitý článek", + "note_en": "our August 2026 reading on the 5 V USB side (charger path included) -- not the battery-side draw, not used", + "note_cs": "naše čtení ze srpna 2026 na straně 5 V USB (včetně nabíjecí cesty) -- není to odběr z baterie, nepoužívá se", "date": "2026-08", "source": "power-summary", "measured": true }, From 23c65df735c9b6db8d59726fea633b494e8293aa Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Fri, 4 Dec 2026 19:03:35 +0100 Subject: [PATCH 12/13] Docs: power calculator, GPS duty costs ~0.02-0.6 mA, not 1-4 mA Changelog: - Co-Authored-By: Claude Opus 5.5 --- docs/power-data.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/power-data.json b/docs/power-data.json index 469f166ed..3262f83b4 100644 --- a/docs/power-data.json +++ b/docs/power-data.json @@ -249,10 +249,10 @@ { "kind": "delta", "option": "gps", "from": "duty", "to": "off", "board": "p1pro", "firmware": "*", - "value": [-4, -1], "unit": "mA", "date": "2026-08", - "note_en": "derived: 46 mA minus the 42-45 mA duty saves", - "note_cs": "dopočteno: 46 mA minus 42-45 mA, které ušetří duty", - "source": "power-gps", "measured": false + "value": [-0.6, -0.02], "unit": "mA", "date": "2026-12", + "note_en": "estimate for today's duty (one sync a day): ~40 mA for a ~38 s fix = 0.02 mA; without a fix 300 s every 6 h = 0.6 mA (Seeed's GPS figures, our duty timers)", + "note_cs": "odhad pro dnešní duty (sync jednou denně): ~40 mA na ~38 s fixu = 0,02 mA; bez fixu 300 s každých 6 h = 0,6 mA (čísla GPS od Seeedu, naše časovače duty)", + "source": "seeed-table", "measured": false }, { From 6ebf2748fad9884ab9c2f0aa92dd90eb1bab16d2 Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Fri, 4 Dec 2026 19:18:05 +0100 Subject: [PATCH 13/13] Docs: power calculator, MeshCore Czech figures point to the protocol that now has them (C, C2) Changelog: - Co-Authored-By: Claude Opus 5.5 --- docs/power-data.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/power-data.json b/docs/power-data.json index 3262f83b4..a66e1be46 100644 --- a/docs/power-data.json +++ b/docs/power-data.json @@ -23,8 +23,8 @@ }, "bench-2026-12-04-czech": { "url": "measurements/2026-12-04-stock-vs-tth/protocol.md", - "en": "bench 4. 12. 2026 (cells C and C2), protocol update pending", - "cs": "lavice 4. 12. 2026 (buňky C a C2), doplnění protokolu čeká" + "en": "measurement protocol 4. 12. 2026, cells C and C2 (MeshCore Czech, k = 2)", + "cs": "protokol měření 4. 12. 2026, buňky C a C2 (MeshCore Czech, k = 2)" }, "power-summary": { "url": "power.md#summary-every-option-against-stock-firmware", @@ -177,13 +177,13 @@ { "kind": "baseline", "board": "xiao", "firmware": "czech", "settings": { "powersaving": "on", "rxps": "off", "rxgain": "on", "ble": "off", "gps": "off" }, - "value": 7.35, "unit": "mA", "voltage": 3.26, + "value": 7.35, "uncertainty": 0.09, "unit": "mA", "voltage": 3.26, "date": "2026-12-04", "source": "bench-2026-12-04-czech", "measured": true }, { "kind": "baseline", "board": "xiao", "firmware": "czech", "settings": { "powersaving": "on", "rxps": "balanced", "rxgain": "on", "ble": "off", "gps": "off" }, - "value": 5.45, "approx": true, "unit": "mA", "voltage": 3.26, + "value": 5.45, "uncertainty": 0.17, "unit": "mA", "voltage": 3.26, "date": "2026-12-04", "source": "bench-2026-12-04-czech", "measured": true }, {