Created
February 28, 2020 03:01
-
-
Save tresf/7abfdfc3facf0a340004e6bfb1e6ca3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Calculate bits (most significant, least significant) | |
// **WARNING** Magic counting to follow: | |
// 1. MSB incriments when LSB hits 0x46 hex | |
// 2. Counting is done using decimal, BUT... | |
// 3. Decimal is strangly passed in hex format | |
var msb = parseInt(30 + Math.floor(((dBm + 2) + 30)/46), 16); | |
var lsb = parseInt(30 + ((dBm + 2) % 46), 16); | |
console.log("Setting power level to", dBm + "dBm = ", "MSB:", msb.toString(16), "LSB:", lsb.toString(16)); | |
return qz.hid.sendData({ | |
vendorId: vid, | |
productId: pid, | |
usagePage: usage, | |
endpoint: 0x08, | |
data: [0x02, 0x41, 0x4E, 0x31, 0x2C, msb, lsb], | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment