Skip to content

Commit

Permalink
Fix bugs120 (#455)
Browse files Browse the repository at this point in the history
* Fixed colors on wireless settings view in light mode

* Change the max-height to trigger the collpased main menu

* Refactoring Navigation menu in order to reduce CSS complexity

* fix: battery status reads did not stop when flashing

Signed-off-by: Alejandro Parcet <[email protected]>

* chore: clean aftermarth of FWUpdate and fix functional components

Signed-off-by: Alejandro Parcet <[email protected]>

* Added differents color indicator in the battery indicator

* fix: Fixed keyboardSelect enumerator only showing first element

Signed-off-by: Alejandro Parcet <[email protected]>

* Create unique id on the svg that renders a battery level on DefyBatteryIndicator

* Fixing BatteryStatus component missing semicolumn

* fix: Solved connectivity issues when revisiting keyboard select view

Signed-off-by: Alejandro Parcet <[email protected]>

* Added new component to show the saving mode status

* fix: Added 2s timeout to help slow computers to cope with disconnect

Signed-off-by: Alejandro Parcet <[email protected]>

* Fixed the fonts and paddings in tooltips

* fix: Added check to avoid error when reading bootloader property

Signed-off-by: Alejandro Parcet <[email protected]>

* fix: Added flash sides check to avoid reflashing when there is no need

Signed-off-by: Alejandro Parcet <[email protected]>

* Added styles to represent the battery charging

* Fix: Text for transparent button description was wrong

Signed-off-by: Alejandro Parcet <[email protected]>

* Fix: replaced regular button element from div to button and fixed it with transp-bg

Signed-off-by: Alejandro Parcet <[email protected]>

---------

Signed-off-by: Alejandro Parcet <[email protected]>
Co-authored-by: Thiago Hernandez <[email protected]>
  • Loading branch information
AlexDygma and thiagohernandez authored Jun 29, 2023
1 parent 3b39990 commit 80b91f2
Show file tree
Hide file tree
Showing 54 changed files with 645 additions and 1,152 deletions.
99 changes: 50 additions & 49 deletions src/api/flash/defyFlasher/sideFlasher.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default class sideFlaser {
}

// Update process
console.log(this.firmwareSides);
// console.log(this.firmwareSides);
const seal = recoverSeal(this.firmwareSides.slice(0, 28));
console.log("This is the seal", seal);
// console.dir(seal);
Expand All @@ -109,14 +109,14 @@ export default class sideFlaser {
// Begin upgrade process for selected side
let ans;
const sideId = side === "right" ? 0 : 1;
console.log(`flashing ${side} side keyboard`);
serialport.write(`upgrade.keyscanner.isConnected ${sideId}\n`);
await readLine();
let isConnected = await readLine();
isConnected = isConnected.includes("true");
serialport.write(`upgrade.keyscanner.isBootloader ${sideId}\n`);
await readLine();
let isItBootloader = await readLine();
if (!isConnected || !isItBootloader) return;
isItBootloader = isItBootloader.includes("true");
serialport.write(`upgrade.keyscanner.begin ${sideId}\n`);
await readLine();
ans = await readLine();
Expand All @@ -125,7 +125,7 @@ export default class sideFlaser {
serialport.write("upgrade.keyscanner.getInfo\n");
await readLine();
ans = await readLine();
console.log("Received data from Side: ", ans);
console.log("Received Info from Side: ", ans);
ans = ans.split(" ");
let info = {
hardwareVersion: parseInt(ans[0]),
Expand All @@ -139,54 +139,54 @@ export default class sideFlaser {
let step = 0;
let totalsteps = this.firmwareSides.length / 256;
console.log("CRC check is ", info.programCrc !== seal.programCrc, ", info:", info.programCrc, "seal:", seal.programCrc);
// if (info.programCrc != seal.programCrc) {
let validate = "false",
retry = 0;
// while (validate !== "true" && retry < 3) {
// console.log("retry count: ", retry);
for (let i = 0; i < this.firmwareSides.length; i = i + 256) {
// console.log(`Addres ${i} of ${this.firmwareSides.length}`);
serialport.write("upgrade.keyscanner.sendWrite ");
if (wiredOrWireless == "wireless") await sleep(4);
const writeAction = new Uint8Array(new Uint32Array([info.flashStart + i, 256]).buffer);
const data = this.firmwareSides.slice(i, i + 256);
const crc = new Uint8Array(new Uint32Array([crc32("CRC-32", data)]).buffer);
const blob = new Uint8Array(writeAction.length + data.length + crc.length);
blob.set(writeAction);
blob.set(data, writeAction.length);
blob.set(crc, data.length + writeAction.length);
const buffer = new Buffer.from(blob);
// console.log("write sent: ", buffer);
// console.log("write sent, %", (step / totalsteps) * 100);
serialport.write(buffer);
if (wiredOrWireless == "wireless") await sleep(4);
let ack = await readLine();
ack = ack + (await readLine());
// console.log("ack received: ", ack);
if (!ack.includes("true") || ack.includes("false")) {
let retries = 3;
if (wiredOrWireless == "wireless") await sleep(100);
while (retries > 0 && (!ack.includes("true") || ack.includes("false"))) {
serialport.write("upgrade.keyscanner.sendWrite ");
if (wiredOrWireless == "wireless") await sleep(10);
serialport.write(buffer);
if (wiredOrWireless == "wireless") await sleep(10);
ack = await readLine();
ack = ack + (await readLine());
console.log(`received ${ack} after ${3 - retries} retires`);
retries--;
if (info.programCrc !== seal.programCrc || isItBootloader === true) {
let validate = "false",
retry = 0;
// while (validate !== "true" && retry < 3) {
// console.log("retry count: ", retry);
for (let i = 0; i < this.firmwareSides.length; i = i + 256) {
// console.log(`Addres ${i} of ${this.firmwareSides.length}`);
serialport.write("upgrade.keyscanner.sendWrite ");
if (wiredOrWireless == "wireless") await sleep(4);
const writeAction = new Uint8Array(new Uint32Array([info.flashStart + i, 256]).buffer);
const data = this.firmwareSides.slice(i, i + 256);
const crc = new Uint8Array(new Uint32Array([crc32("CRC-32", data)]).buffer);
const blob = new Uint8Array(writeAction.length + data.length + crc.length);
blob.set(writeAction);
blob.set(data, writeAction.length);
blob.set(crc, data.length + writeAction.length);
const buffer = new Buffer.from(blob);
// console.log("write sent: ", buffer);
// console.log("write sent, %", (step / totalsteps) * 100);
serialport.write(buffer);
if (wiredOrWireless == "wireless") await sleep(4);
let ack = await readLine();
ack = ack + (await readLine());
// console.log("ack received: ", ack);
if (!ack.includes("true") || ack.includes("false")) {
let retries = 3;
if (wiredOrWireless == "wireless") await sleep(100);
while (retries > 0 && (!ack.includes("true") || ack.includes("false"))) {
serialport.write("upgrade.keyscanner.sendWrite ");
if (wiredOrWireless == "wireless") await sleep(10);
serialport.write(buffer);
if (wiredOrWireless == "wireless") await sleep(10);
ack = await readLine();
ack = ack + (await readLine());
console.log(`received ${ack} after ${3 - retries} retires`);
retries--;
}
}
stateUpd(side, (step / totalsteps) * 100);
step++;
// }
}
stateUpd(side, (step / totalsteps) * 100);
step++;
// }
serialport.write("upgrade.keyscanner.validate\n");
validate = await readLine();
validate = validate + (await readLine());
console.log("result of validation", validate);
// retry++;
}
serialport.write("upgrade.keyscanner.validate\n");
validate = await readLine();
validate = validate + (await readLine());
console.log("result of validation", validate);
// retry++;
// }

serialport.write("upgrade.keyscanner.finish\n");
await readLine();
Expand All @@ -197,6 +197,7 @@ export default class sideFlaser {
}

await serialport.close();
if (side.includes("left")) await sleep(2000);
console.log("after serialport close");

return { error: false, message: "" };
Expand Down
2 changes: 1 addition & 1 deletion src/api/focus/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class Focus {

this.result = "";
if (resolve) {
resolve(result);
resolve(result.trim());
}
} else {
if (this.result.length == 0) {
Expand Down
19 changes: 7 additions & 12 deletions src/api/hardware-dygma-defy-wired/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,13 @@ const Defy_wired = {
},

isDeviceSupported: async port => {
// let focus = new Focus();
// let layout = localStorage.getItem(port.serialNumber);
// if (!layout) {
// focus._port && focus._port.path === port.path
// ? await focus.open(focus._port, port.device, null)
// : await focus.open(port.path, port.device, null);
// layout = await focus.command("hardware.layout");
// focus.close();
// localStorage.setItem(port.serialNumber, layout);
// }
// return layout.trim() === "ANSI";
return 1;
let focus = new Focus();
focus._port && focus._port.path === port.path
? await focus.open(focus._port, port.device, null)
: await focus.open(port.path, port.device, null);
port.serialNumber = await focus.command("hardware.chip_id");
focus.close();
return true;
}
};

Expand Down
19 changes: 7 additions & 12 deletions src/api/hardware-dygma-defy-wireless/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,13 @@ const Defy_wireless = {
},

isDeviceSupported: async port => {
// let focus = new Focus();
// let layout = localStorage.getItem(port.serialNumber);
// if (!layout) {
// focus._port && focus._port.path === port.path
// ? await focus.open(focus._port, port.device, null)
// : await focus.open(port.path, port.device, null);
// layout = await focus.command("hardware.layout");
// focus.close();
// localStorage.setItem(port.serialNumber, layout);
// }
// return layout.trim() === "ANSI";
return 1;
let focus = new Focus();
focus._port && focus._port.path === port.path
? await focus.open(focus._port, port.device, null)
: await focus.open(port.path, port.device, null);
port.serialNumber = await focus.command("hardware.chip_id");
focus.close();
return true;
}
};

Expand Down
1 change: 1 addition & 0 deletions src/api/hardware-dygma-raise-ansi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const Raise_ANSI = {
focus._port && focus._port.path === port.path
? await focus.open(focus._port, port.device, null)
: await focus.open(port.path, port.device, null);
port.serialNumber = await focus.command("hardware.chip_id");
layout = await focus.command("hardware.layout");
focus.close();
localStorage.setItem(port.serialNumber, layout);
Expand Down
1 change: 1 addition & 0 deletions src/api/hardware-dygma-raise-iso/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const Raise_ISO = {
focus._port && focus._port.path === port.path
? await focus.open(focus._port, port.device, null)
: await focus.open(port.path, port.device, null);
port.serialNumber = await focus.command("hardware.chip_id");
layout = await focus.command("hardware.layout");
focus.close();
localStorage.setItem(port.serialNumber, layout);
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import Dark from "./theme/DarkTheme";

import SelectKeyboard from "./views/SelectKeyboard";
import FirmwareUpdate from "./views/FirmwareUpdate";
import AltFirmwareUpdate from "./views/AltFirmwareUpdate";
import LayoutEditor from "./views/LayoutEditor";
import MacroEditor from "./views/MacroEditor";
import SuperkeysEditor from "./views/SuperkeysEditor";
Expand Down Expand Up @@ -359,6 +358,7 @@ class App extends React.Component {
<SelectKeyboard
path="/keyboard-select"
connected={connected}
device={this.state.device}
onConnect={this.onKeyboardConnect}
onDisconnect={this.onKeyboardDisconnect}
titleElement={() => document.querySelector("#page-title")}
Expand Down Expand Up @@ -390,7 +390,7 @@ class App extends React.Component {
inContext={contextBar}
titleElement={() => document.querySelector("#page-title")}
/>
<AltFirmwareUpdate
<FirmwareUpdate
path="/firmware-update"
device={this.state.device}
toggleFlashing={this.toggleFlashing}
Expand Down
63 changes: 60 additions & 3 deletions src/renderer/component/Battery/BatteryStatusSide.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Style = Styled.div`
--color-status: ${({ theme }) => theme.colors.brandPrimary};
}
.status--charging {
--color-status: ${({ theme }) => theme.colors.purple200};
--color-status: ${({ theme }) => theme.styles.batteryIndicator.fillShapeColor};
}
.size--sm {
padding: 4px;
Expand All @@ -37,10 +37,67 @@ const Style = Styled.div`
&.status--saving {
background-color: ${({ theme }) => theme.styles.batteryIndicator.pileBackgroundSavingMode};
}
.pileIndicator {
max-width: 100%;
}
}
.size--lg {
--color-stroke: ${({ theme }) => theme.styles.batteryIndicator.strokeShapeColor};
.shapeIndicator {
opacity: 0.1;
}
&.status--default {
--color-status: ${({ theme }) => theme.styles.batteryIndicator.fillShapeColor};
.shapeIndicator {
opacity: 0;
}
}
&.status--saving {
--color-status: ${({ theme }) => theme.colors.brandWarning};
--color-stroke: ${({ theme }) => theme.colors.brandWarning};
.shapeIndicator {
opacity: 0.25;
}
}
&.status--critical:not(.status--saving) {
.shapeIndicator {
opacity: 0.2;
}
}
&.status--charging,
&.status--charging.status--saving {
--color-status: ${({ theme }) => theme.styles.batteryIndicator.fillShapeColor};
--color-stroke: ${({ theme }) => theme.styles.batteryIndicator.strokeShapeColor};
.lightningbattery {
color: ${({ theme }) => theme.styles.batteryIndicator.fillShapeColor};
}
.shapeIndicator {
opacity: 0.1;
}
}
}
@media screen and (max-width: 999px) {
.size--sm {
.battery-item--container {
.battery-indicator--side {
display: none;
}
}
}
}
@media screen and (max-height: 870px) {
.size--sm {
.battery-item--container {
.battery-indicator--side {
display: none;
}
}
}
}
`;

const BatteryStatusSide = ({ side, batteryLevel, size, isSavingMode, isCharging }) => {
const BatteryStatusSide = ({ side, batteryLevel, isSavingMode, isCharging, size }) => {
const [loading, setLoading] = useState(true);
const [sideFirstLetter, setSideFirstLetter] = useState("");
const [sideStatus, setSideStatus] = useState("default");
Expand All @@ -59,7 +116,7 @@ const BatteryStatusSide = ({ side, batteryLevel, size, isSavingMode, isCharging
if (batteryLevel < 10 && !isCharging && !isSavingMode) {
setSideStatus("critical");
}
}, [batteryLevel]);
}, [size, batteryLevel, isCharging, isSavingMode]);

if (loading) return <div></div>;
return (
Expand Down
Loading

0 comments on commit 80b91f2

Please sign in to comment.