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": {