From 4ef11ac4aa5185994db19ef3f69a8c54c70fb06c Mon Sep 17 00:00:00 2001 From: Nick Winans Date: Tue, 16 Feb 2021 14:34:09 -0600 Subject: feat(docs): Add power profiler --- docs/src/pages/power-profiler.js | 297 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 297 insertions(+) create mode 100644 docs/src/pages/power-profiler.js (limited to 'docs/src/pages') diff --git a/docs/src/pages/power-profiler.js b/docs/src/pages/power-profiler.js new file mode 100644 index 0000000..ca46f5c --- /dev/null +++ b/docs/src/pages/power-profiler.js @@ -0,0 +1,297 @@ +/* + * Copyright (c) 2021 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +import React, { useState } from "react"; +import classnames from "classnames"; +import Layout from "@theme/Layout"; +import styles from "./styles.module.css"; +import PowerEstimate from "../components/power-estimate"; +import CustomBoardForm from "../components/custom-board-form"; +import { useInput } from "../utils/hooks"; +import { zmkBoards } from "../data/power"; +import "../css/power-profiler.css"; + +const Disclaimer = `This profiler makes many assumptions about typing + activity, battery characteristics, hardware behavior, and + doesn't account for error of user inputs. For example battery + mAh, which is often incorrectly advertised higher than it's actual capacity. + While it tries to estimate power usage using real power readings of ZMK, + every person will have different results that may be worse or even + better than the estimation given here.`; + +function PowerProfiler() { + const { value: board, bind: bindBoard } = useInput(""); + const { value: split, bind: bindSplit } = useInput(false); + const { value: batteryMilliAh, bind: bindBatteryMilliAh } = useInput(110); + + const { value: psuType, bind: bindPsuType } = useInput(""); + const { value: outputV, bind: bindOutputV } = useInput(3.3); + const { value: quiescentMicroA, bind: bindQuiescentMicroA } = useInput(55); + const { + value: otherQuiescentMicroA, + bind: bindOtherQuiescentMicroA, + } = useInput(0); + const { value: efficiency, bind: bindEfficiency } = useInput(0.9); + + const { value: bondedQty, bind: bindBondedQty } = useInput(1); + const { value: percentAsleep, bind: bindPercentAsleep } = useInput(0.5); + + const { value: glowEnabled, bind: bindGlowEnabled } = useInput(false); + const { value: glowQuantity, bind: bindGlowQuantity } = useInput(10); + const { value: glowBrightness, bind: bindGlowBrightness } = useInput(1); + + const { value: displayEnabled, bind: bindDisplayEnabled } = useInput(false); + const { value: displayType, bind: bindDisplayType } = useInput(""); + + const [disclaimerAcknowledged, setDisclaimerAcknowledged] = useState( + typeof window !== "undefined" + ? localStorage.getItem("zmkPowerProfilerDisclaimer") === "true" + : false + ); + + const currentBoard = + board === "custom" + ? { + powerSupply: { + type: psuType, + outputVoltage: outputV, + quiescentMicroA: quiescentMicroA, + efficiency, + }, + otherQuiescentMicroA: otherQuiescentMicroA, + } + : zmkBoards[board]; + + return ( + +
+
+

ZMK Power Profiler

+

+ {"Estimate your keyboard's power usage and battery life on ZMK."} +

+
+
+
+
+
+

Keyboard Specifications

+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+ + mAh +
+
+
+
+
+ + {board === "custom" && ( + + )} + +
+

Usage Values

+
+
+
+ + + {bondedQty} +
+
+
+
+ + + {Math.round(percentAsleep * 100)}% +
+
+
+
+ +
+

Features

+
+
+
+ + +
+
+
+ + +
+
+
+ {split ? ( + <> + + + + ) : ( + + )} +
+
+ Disclaimer: {Disclaimer} +
+
+
+
+ {!disclaimerAcknowledged && ( +
+
+

Disclaimer

+

{Disclaimer}

+ +
+
+ )} +
+ ); +} + +export default PowerProfiler; -- cgit v1.2.3