/* * 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, backlightLEDs } 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: backlightEnabled, bind: bindBacklightEnabled } = useInput(false); const { value: backlightQuantity, bind: bindBacklightQuantity } = useInput(60); const { value: backlightColor, bind: bindBacklightColor } = useInput(""); const { value: backlightVoltage, bind: bindBacklightVoltage } = useInput(2.2); const { value: backlightResistance, bind: bindBacklightResistance } = useInput(100); const { value: backlightBrightness, bind: bindBacklightBrightness } = 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]; const currentBacklightVoltage = backlightColor === "custom" ? backlightVoltage : backlightLEDs[backlightColor || "White"]; 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;