Skip to content

Commit

Permalink
Merge branch 'main' into fc/add-panel-test-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
noahm committed Feb 2, 2025
2 parents 7b3ac81 + 77f8f38 commit 9a1667b
Show file tree
Hide file tree
Showing 25 changed files with 2,208 additions and 2,089 deletions.
25 changes: 0 additions & 25 deletions .github/dependabot.yml

This file was deleted.

12 changes: 6 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ jobs:
runs-on: ubuntu-latest
name: Vite Build
steps:
- uses: actions/checkout@v4
- uses: actions/configure-pages@v5
- uses: actions/setup-node@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
with:
node-version: 20
node-version: 22
cache: "yarn"
- run: yarn --immutable

- name: Vite Build
run: yarn build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3
with:
path: ./dist
deploy:
Expand All @@ -43,5 +43,5 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4

24 changes: 12 additions & 12 deletions .github/workflows/status-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,43 @@ jobs:
runs-on: ubuntu-latest
name: Biome Lint
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
with:
node-version: 20
node-version: 22
cache: "yarn"
- run: yarn --immutable
- run: yarn lint:ci
tsc:
runs-on: ubuntu-latest
name: Typescript
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
with:
node-version: 20
node-version: 22
cache: "yarn"
- run: yarn --immutable
- run: yarn typecheck
test:
runs-on: ubuntu-latest
name: Tests
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
with:
node-version: 20
node-version: 22
cache: "yarn"
- run: yarn --immutable
- run: yarn test
build:
runs-on: ubuntu-latest
name: Vite Build
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
with:
node-version: 20
node-version: 22
cache: "yarn"
- run: yarn --immutable
- run: yarn build
Expand Down
2 changes: 1 addition & 1 deletion .mise.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[tools]
node = "20.11"
node = "22.13"
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"editor.defaultFormatter": "biomejs.biome",
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[css]": {
"editor.defaultFormatter": "biomejs.biome"
},
"typescript.preferences.preferTypeOnlyAutoImports": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
Expand Down
893 changes: 0 additions & 893 deletions .yarn/releases/yarn-4.1.1.cjs

This file was deleted.

934 changes: 934 additions & 0 deletions .yarn/releases/yarn-4.6.0.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.1.1.cjs
yarnPath: .yarn/releases/yarn-4.6.0.cjs
25 changes: 12 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,20 @@
"@nmann/struct-buffer": "^5.4.1",
"baconjs": "patch:baconjs@npm%3A3.0.17#~/.yarn/patches/baconjs-npm-3.0.17-1a95474784.patch",
"classnames": "^2.5.1",
"jotai": "^2.8.0",
"logrocket": "^8.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"jotai": "^2.9.3",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"devDependencies": {
"@biomejs/biome": "1.7.0",
"@types/react": "^18.2.75",
"@types/react-dom": "^18.2.25",
"@biomejs/biome": "1.9.4",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"@types/w3c-web-hid": "1.0.6",
"@vitejs/plugin-react": "^4.2.1",
"typescript": "^5.4.5",
"vite": "^5.2.8",
"vite-plugin-mkcert": "^1.17.5",
"vitest": "^1.5.0"
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.5.4",
"vite": "^6.0.7",
"vite-plugin-mkcert": "^1.17.6",
"vitest": "^2.1.8"
},
"packageManager": "yarn@4.1.1"
"packageManager": "yarn@4.6.0"
}
10 changes: 10 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:best-practices",
":preserveSemverRanges",
"group:allNonMajor",
"group:linters",
"group:react"
]
}
13 changes: 8 additions & 5 deletions sdk/commands/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ const packed_panel_settings_t = new StructBuffer("packed_panel_settings_t", {
loadCellHighThreshold: uint8_t,

/**
* FSR Thresholds
* 4 Sensors per threshold
* Activation threshold when pressing.
* 4 values, one for each sensor on this panel.
*/
fsrLowThreshold: uint8_t[4],
/**
* Release threshold when lifting.
* 4 values, one for each sensor on this panel.
*/
fsrHighThreshold: uint8_t[4],

/**
Expand Down Expand Up @@ -357,14 +361,13 @@ export class SMXConfig {
*/
constructor(data: Uint8Array, firmwareVersion: number) {
this.firmwareVersion = firmwareVersion;
console.log("Config Firmware Version: ", this.firmwareVersion);
console.log("CONFIG RAW DATA: ", data.toString());
console.debug("CONFIG RAW DATA: ", data.toString());

if (this.firmwareVersion >= 5) {
this.config = smx_config_t.decode(data.slice(2, -1), true);
} else {
this.oldConfigSize = data[1];
console.log("Reading Old Config");
console.debug("Reading Old Config");

const slicedData = data.slice(2, -1);
// handle very old stage's smaller config data by padding
Expand Down
2 changes: 1 addition & 1 deletion sdk/commands/data_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class SMXDeviceInfo {
player = 0;

constructor(data: Uint8Array) {
console.log("DEVICEINFO RAW DATA: ", data.toString());
console.debug("DEVICEINFO RAW DATA: ", data.toString());
this.#decode(data);
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export {
SENSOR_COUNT,
PANEL_COUNT,
} from "./api.js";
export { type PanelName, type EachPanel } from "./commands/inputs.js";
export type { PanelName, EachPanel } from "./commands/inputs.js";
export { SensorTestMode, type SMXPanelTestData, type SMXSensorTestData } from "./commands/sensor_test.js";
export { SMXStage } from "./smx.js";
2 changes: 1 addition & 1 deletion sdk/packet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export async function send_data(dev: HIDDevice, data: Uint8Array, debug = false)
// Send each packet
for (const packet of packets) {
if (debug) {
console.log("OUTGOING RAW PACKET: ", packet.toString());
console.debug("OUTGOING RAW PACKET: ", packet.toString());
}
await dev.sendReport(HID_REPORT_OUTPUT, packet);
}
Expand Down
12 changes: 5 additions & 7 deletions sdk/smx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ class SMXEvents {
.filter((e) => e.type === "host_cmd_finished")
.map((e) => e.type === "host_cmd_finished");

finishedCommand$.log("Cmd Finished");

const okSend$ = finishedCommand$.startWith(true);

// Main USB Output
Expand Down Expand Up @@ -103,7 +101,7 @@ export class SMXStage {

// write outgoing events to the device
this.events.eventsToSend$.onValue(async (value) => {
this.debug && console.log("writing to HID");
this.debug && console.debug("writing to HID");
await send_data(this.dev, value, this.debug);
});

Expand Down Expand Up @@ -338,9 +336,9 @@ void SMX::SMXManager::UpdatePanelTestMode()
const encoded_config = this._config.encode();
if (encoded_config) {
this.debug &&
console.log("Config Encodes Correctly: ", data.slice(2, -1).toString() === encoded_config.toString());
console.debug("Config Encodes Correctly: ", data.slice(2, -1).toString() === encoded_config.toString());
}
this.debug && console.log("Got Config: ", this.config);
this.debug && console.info("Got Config: ", this.config);

return this._config;
}
Expand All @@ -349,15 +347,15 @@ void SMX::SMXManager::UpdatePanelTestMode()
// biome-ignore lint/style/noNonNullAssertion: config should very much be defined here
this.test = new SMXSensorTestData(data, this.test_mode, this.config!.flags.PlatformFlags_FSR);

this.debug && console.log("Got Test: ", this.test);
this.debug && console.debug("Got Test: ", this.test);

return this.test;
}

private handleDeviceInfo(data: Uint8Array): SMXDeviceInfo {
this.info = new SMXDeviceInfo(data);

this.debug && console.log("Got Info: ", this.info);
this.debug && console.debug("Got Info: ", this.info);

return this.info;
}
Expand Down
12 changes: 6 additions & 6 deletions sdk/state-machines/collate-packets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ export type Packet = { type: "host_cmd_finished" } | DataPacket | AckPacket;
export const collatePackets: StateF<DataView, PacketHandlingState, Packet> = (state, event) => {
// TODO: This whole function could maybe just use a bit more comments
if (!Bacon.hasValue(event)) {
console.log("No Event Value");
console.debug("No Event Value");
return [state, []];
}

let currentPacket = state.currentPacket;
const data = new Uint8Array(event.value.buffer);

console.log("INCOMING RAW PACKET: ", data.toString());
console.debug("INCOMING RAW PACKET: ", data.toString());

// Return if packet is empty
if (data.length <= PACKET_PREAMBLE_SIZE) {
console.log("Empty Packet");
console.debug("Empty Packet");
return [state, []];
}
const cmd = data[0];
Expand All @@ -46,12 +46,12 @@ export const collatePackets: StateF<DataView, PacketHandlingState, Packet> = (st
// we ignore the packet if we didn't request it, since it might be requested
// for a different program.
// TODO: Handle this? Not sure there's anything to handle here tbh
console.log("Found Packet Flag Device Info");
console.debug("Found Packet Flag Device Info");
}

if (PACKET_PREAMBLE_SIZE + byte_len > data.length) {
// TODO: Can this even happen???
console.log("Communication Error: Oversized Packet (ignored)");
console.warn("Communication Error: Oversized Packet (ignored)");
return [state, []];
}

Expand All @@ -71,7 +71,7 @@ export const collatePackets: StateF<DataView, PacketHandlingState, Packet> = (st
* This shouldn't happen, so warn about it and recover by clearing the junk in the buffer.
* TODO: Again, does this actually happen???!?
*/
console.log(
console.warn(
"Got PACKET_FLAG_OF_START_COMMAND, but we had ${current_packet.length} bytes in the buffer. Dropping it and continuing.",
);
currentPacket = new Uint8Array(0);
Expand Down
3 changes: 0 additions & 3 deletions ui/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import * as Bacon from "baconjs";
import { Provider } from "jotai";
import LogRocket from "logrocket";
import { createRoot } from "react-dom/client";

import { uiState } from "./state.ts";
import { UI } from "./ui.tsx";

LogRocket.init("rgozwj/smx-config-web");

Bacon.fromEvent(document, "DOMContentLoaded").onValue(async () => {
const rootEl = document.getElementById("root");
if (!rootEl) return;
Expand Down
12 changes: 11 additions & 1 deletion ui/pad-coms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@ export async function promptSelectDevice() {

export async function open_smx_device(dev: HIDDevice, autoSelect = false) {
if (!dev.opened) {
await dev.open();
try {
await dev.open();
} catch (e) {
console.error(e);
uiState.set(nextStatusTextLine$, "failed to open device; more details in the browser console.");
uiState.set(
nextStatusTextLine$,
"if you are using linux, permissions to talk to a stage are still an unsolved puzzle.",
);
return;
}
}

const stage = new SMXStage(dev);
Expand Down
Loading

0 comments on commit 9a1667b

Please sign in to comment.