Corsair_Virtuoso_XT_Headset.js aktualisiert
This commit is contained in:
parent
09f90fca31
commit
99367f298d
@ -26,6 +26,7 @@ export function ControllableParameters() {
|
||||
{"property":"micLedDefState", "group":"lighting", "label":"Microphone Default State", "type":"combobox", "values":["OFF", "ON"], "default":"OFF"},
|
||||
{"property":"micColorOn", "group":"lighting", "label":"Microphone Color ON", "min":"0", "max":"360", "type":"color", "default":"#33cc33"},
|
||||
{"property":"micColorOff", "group":"lighting", "label":"Microphone Color OFF", "min":"0", "max":"360", "type":"color", "default":"#cc0000"},
|
||||
{"property":"critBatLighting", "group":"lighting", "label":"Lighting on Critical Battery", "type":"combobox", "values":["OFF", "ON"], "default":"OFF"},
|
||||
{"property":"idleTimeout", "group":"", "label":"Enable Device Sleep", "type":"boolean", "default":"true"},
|
||||
{"property":"idleTimeoutLength", "group":"", "label":"Device Sleep Timeout (Minutes)", "type":"combobox", "values":["1","2","3","4","5","10","15","20","25","30"], "default":"10"},
|
||||
{"property":"SidetoneAmount", "group":"", "label":"Sidetone", "step":"1", "type":"number", "min":"0", "max":"100", "default":"0"},
|
||||
@ -39,6 +40,7 @@ let micState;
|
||||
let micDefState;
|
||||
let device_status;
|
||||
let previousBatteryLevel = -1;
|
||||
let batteryPercentage = -1;
|
||||
|
||||
const vLedNames = [
|
||||
"Logo", "Mic"
|
||||
@ -132,6 +134,7 @@ export function onidleTimeoutChanged() {
|
||||
}
|
||||
|
||||
function sendColor(shutdown = false) {
|
||||
|
||||
device.set_endpoint(3, 0x0001, 0xFF42);
|
||||
let mxPxColor;
|
||||
const packet = [];
|
||||
@ -145,9 +148,11 @@ function sendColor(shutdown = false) {
|
||||
packet[3] = 0x02;
|
||||
packet[4] = 0x00;
|
||||
device.write(packet, 64);
|
||||
} else {
|
||||
} else {
|
||||
for(let iIdx = 0; iIdx < vLedPositions.length; iIdx++) {
|
||||
if(iIdx == 1 && micLedMode == "MicState") {
|
||||
if ( batteryPercentage >= '0' && batteryPercentage <= "15" && critBatLighting == "OFF") {
|
||||
mxPxColor = hexToRgb("#000000");
|
||||
} else if (iIdx == 1 && micLedMode == "MicState") {
|
||||
mxPxColor = hexToRgb(micState == 0 ? micColorOff : micColorOn);
|
||||
} else {
|
||||
const iPxX = vLedPositions[iIdx][0];
|
||||
@ -227,10 +232,10 @@ function readDevice() {
|
||||
}
|
||||
if (packet[0] == 0x03 && packet[1] == 0x01 && packet[2] == 0x01 && packet[3] == 0x0f && packet[4] == 0x00) {
|
||||
let batteryValue = (packet[5] & 0xFF) | ((packet[6] & 0xFF) << 8);
|
||||
let maxBatteryValue = 65535; // 0xffff in Dezimal
|
||||
let batteryPercentage = Math.round((batteryValue / maxBatteryValue) * 100);
|
||||
let maxBatteryValue = 1023; // 0xff03 in Dezimal
|
||||
batteryPercentage = Math.round((batteryValue / maxBatteryValue) * 100);
|
||||
console.log("Battery Level: " + batteryPercentage + "%");
|
||||
//console.log("Battery Level hex: " + packet[5].toString(16) + " " + packet[6].toString(16));
|
||||
console.log("Battery Level hex: " + packet[5].toString(16) + " " + packet[6].toString(16));
|
||||
battery.setBatteryLevel(batteryPercentage);
|
||||
if (typeof previousBatteryLevel !== 'undefined') {
|
||||
if (batteryPercentage < previousBatteryLevel) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user