Skip to content

Commit

Permalink
fix: correctly called serialport from focus and removed unnecesary logs
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Parcet Gonzalez <[email protected]>
  • Loading branch information
alexpargon committed Feb 7, 2025
1 parent bb9e137 commit 4b6e389
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 99 deletions.
14 changes: 0 additions & 14 deletions src/api/colormap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,4 @@ export default class Colormap {
const args = this._flatten(colormap).map(v => v.toString());
return await s.request("colormap.map", ...args);
}

// async focus(s, palette, colormap) {
// if (!palette && !colormap) {
// return this._pull(s);
// }

// if (palette) await this._updatePalette(s, palette);
// if (colormap) await this._updateColormap(s, colormap);
// }
}

// const focus = Focus.getInstance();
// focus.addCommands({ colormap: new Colormap() });
// focus.addMethod("setLayerSize", "colormap");
// focus.addMethod("setLEDMode", "colormap");
12 changes: 4 additions & 8 deletions src/api/focus/Focus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@
*/
import log from "electron-log/renderer";
import { spawn } from "child_process";
import type { SerialPortOpenOptions } from "serialport";
import { SerialPort } from "serialport";
import type { SerialPort, SerialPortOpenOptions } from "serialport";
import type { AutoDetectTypes, PortInfo } from "@serialport/bindings-cpp";
import { DelimiterParser } from "@serialport/parser-delimiter";
import { DygmaDeviceType } from "@Renderer/types/dygmaDefs";
import { VirtualType } from "@Renderer/types/virtual";
import { delay } from "../../main/utils/delay";
import { ctx } from "./Focus.ctx";

// TODO: any reason we can't import directly?
const sp = eval('require("serialport")');
Expand Down Expand Up @@ -55,14 +51,14 @@ export class Focus {
commands: CommandOverrides = { help: this._help };

protected async listSerialPorts(): Promise<PortInfo[]> {
return SerialPort.list();
return sp.SerialPort.list();
}

protected createSerialPort<T extends AutoDetectTypes>(
options: SerialPortOpenOptions<T>,
openCallback?: ErrorCallback,
): SerialPort<T> {
return new SerialPort(options, openCallback);
return new sp.SerialPort(options, openCallback);
}

async find(...devices: DygmaDeviceType[]) {
Expand Down Expand Up @@ -92,7 +88,7 @@ export class Focus {
callbacks: Array<(value: unknown) => void>;
supportedCommands: Array<string>;
_port: SerialPort;
parser: DelimiterParser;
parser: typeof DelimiterParser;

async open(path: string, info: DygmaDeviceType): Promise<SerialPort> {
if (this._port !== undefined && this._port.isOpen === false) {
Expand Down
71 changes: 0 additions & 71 deletions src/api/keymap/bazecor-keymap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,77 +60,6 @@ class Keymap {
for (let i = 0; i < a.length; i += chunkSize) R.push(a.slice(i, i + chunkSize));
return R;
}

// async focus(s: Focus, keymap: KeymapType) {
// if (keymap && keymap.custom && keymap.custom.length > 0) {
// const flatten = (arr: any) => [].concat(...arr);

// if (this.legacyInterface) {
// const args = flatten(keymap.default.concat(keymap.custom)).map(k => this.db.serialize(k));

// return (await s.request("keymap.map", ...args)) as string;
// }

// const args = flatten(keymap.custom).map(k => this.db.serialize(k));

// await s.request("keymap.onlyCustom", keymap.onlyCustom ? "1" : "0");
// return s.request("keymap.custom", ...args);
// }
// let defaults: string;
// let custom: string;
// let onlyCustom: boolean;

// if (!this.legacyInterface) {
// defaults = (await s.request("keymap.default")) as string;
// custom = (await s.request("keymap.custom")) as string;
// onlyCustom = Boolean(parseInt(await s.request("keymap.onlyCustom"), 10)) as boolean;
// }

// if (!defaults && !custom) {
// const localKeymap = ((await s.request("keymap.map")) as string).split(" ").filter(v => v.length > 0);
// const roLayers = parseInt((await s.request("keymap.roLayers")) || "0", 10);

// defaults = localKeymap.slice(0, this._layerSize * roLayers).join(" ");
// custom = localKeymap.slice(this._layerSize * roLayers, localKeymap.length).join(" ");

// onlyCustom = false;
// this.legacyInterface = true;
// }
// const defaultKeymap = defaults
// .split(" ")
// .filter(v => v.length > 0)
// .map(k => this.db.parse(parseInt(k, 10)));
// const customKeymap = custom
// .split(" ")
// .filter(v => v.length > 0)
// .map(k => this.db.parse(parseInt(k, 10)));

// if (customKeymap.length === 0) {
// onlyCustom = false;
// }

// return {
// onlyCustom,
// custom: this._chunk(customKeymap, this._layerSize),
// default: this._chunk(defaultKeymap, this._layerSize),
// };
// }
}

// class OnlyCustom {
// async focus(s, onlyCustom) {
// if (onlyCustom === undefined) {
// return Boolean(parseInt(await s.request("keymap.onlyCustom")));
// }

// return await s.request("keymap.onlyCustom", onlyCustom ? "1" : "0");
// }
// }

// const focus = Focus.getInstance();
// focus.addCommands({
// keymap: new Keymap(),
// });
// focus.addMethod("setLayerSize", "keymap");

export default Keymap;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import React, { useEffect, useState } from "react";
import { Octokit } from "@octokit/core";
import log from "electron-log/renderer";
// import log from "electron-log/renderer";
import SemVer from "semver";
import parse, { domToReact } from "html-react-parser";

Expand Down Expand Up @@ -111,14 +111,14 @@ export function VersionUpdateDialog(props: VersionUpdateProps) {
format: "full",
},
});
log.info("Testing", GHdata);
// log.info("Testing", GHdata);
GHdata.data.forEach(release => {
// eslint-disable-next-line @typescript-eslint/naming-convention
const { prerelease, name, published_at, body_html, tag_name } = release;
const newRelease = { name, version: tag_name, date: published_at, content: body_html };
if (!prerelease) releases.push(newRelease);
});
log.info("Data from Dialog: ", releases, version, oldVersion);
// log.info("Data from Dialog: ", releases, version, oldVersion);
const parsedData = releases.filter(r =>
oldVersion
? SemVer.compare(r.version, oldVersion) > 0 && SemVer.compare(r.version, version) <= 0
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/views/MacroEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ function MacroEditor(props: MacroEditorProps) {
const { selectedList, listToDelete, listToDeleteS, listToDeleteM, keymap, superkeys } = state;
const { startContext } = props;
let macros = localstate ? localstate.futureMacros : state.futureMacros;
log.info("Checking list to delete macros", listToDeleteM, macros);
// log.info("Checking list to delete macros", listToDeleteM, macros);
for (let i = 0; i < listToDelete.length; i += 1) {
if (listToDelete[i].newKey === -1) {
keymap.custom[listToDelete[i].layer][listToDelete[i].pos] = keymapDB.parse(
Expand Down Expand Up @@ -311,7 +311,7 @@ function MacroEditor(props: MacroEditorProps) {
item.id = idx;
return item;
});
log.info("result!", macros);
// log.info("result!", macros);
state.keymap = keymap;
state.superkeys = superkeys;
state.macros = macros;
Expand Down Expand Up @@ -360,7 +360,7 @@ function MacroEditor(props: MacroEditorProps) {
customMacrosList = customMacrosList.concat(macrosList);
}

log.info("result of macro exploration: ", macros, customKeymapList, customSuperList, customMacrosList);
// log.info("result of macro exploration: ", macros, customKeymapList, customSuperList, customMacrosList);

state.futureMacros = localMacros;
state.listToDelete = customKeymapList;
Expand Down

0 comments on commit 4b6e389

Please sign in to comment.