Skip to content

Commit

Permalink
feat: update m4g
Browse files Browse the repository at this point in the history
  • Loading branch information
Theaninova committed Dec 9, 2024
1 parent 588719d commit 1300381
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 30 deletions.
13 changes: 13 additions & 0 deletions src/lib/assets/layouts/m4g.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,33 @@ col:
row:
- switch: { e: 26, n: 27, w: 28, s: 29 }
- switch: { e: 21, n: 22, w: 23, s: 24 }
- offset: [4, 0]
switch: { w: 66, n: 67, e: 68, s: 69 }
- switch: { w: 71, n: 72, e: 73, s: 74 }
- offset: [2, 0]
row:
- switch: { e: 41, n: 42, w: 43, s: 44 }
- switch: { e: 36, n: 37, w: 38, s: 39 }
- offset: [4, 0]
switch: { w: 81, n: 82, e: 83, s: 84 }
- switch: { w: 86, n: 87, e: 88, s: 89 }
# Pinkie / Index
- offset: [0, -3]
row:
- switch: { e: 31, n: 32, w: 33, s: 34 }
- offset: [4, 0]
switch: { e: 16, n: 17, w: 18, s: 19 }
- switch: { w: 61, n: 62, e: 63, s: 64 }
- offset: [4, 0]
switch: { w: 76, n: 77, e: 78, s: 79 }
# Thumbs
- row:
- offset: [5.5, 0.5]
switch: { e: 11, n: 12, w: 13, s: 14 }
- offset: [1, 0.5]
switch: { w: 56, n: 57, e: 58, s: 59 }
- row:
- offset: [4.5, -0.25]
switch: { e: 6, n: 7, w: 8, s: 9 }
- offset: [3, -0.25]
switch: { w: 51, n: 52, e: 53, s: 54 }
24 changes: 0 additions & 24 deletions src/lib/assets/layouts/m4gr.yml

This file was deleted.

4 changes: 2 additions & 2 deletions src/lib/serial/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const KEY_COUNTS = {
TWO: 90,
LITE: 67,
X: 256,
M4G: 64,
M4GR: 64,
M4G: 90,
M4GR: 90,
} as const;

if (
Expand Down
33 changes: 29 additions & 4 deletions src/routes/(app)/ccos/[device]/[version]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@
const { Transport, ESPLoader } = await import("esptool-js");
const espLoader = new ESPLoader({
transport: new Transport(port),
baudrate: Number(esptool.baud),
romBaudrate: Number(esptool.baud),
baudrate: 9600, // Number(esptool.baud),
romBaudrate: 9600, // Number(esptool.baud),
debugLogging: true,
terminal: {
clean: () => {
terminalOutput = "";
Expand All @@ -127,8 +128,10 @@
},
},
} satisfies LoaderOptions);
await espLoader.connect(esptool.before);
await espLoader.runStub();
await espLoader.detectChip(esptool.before);
if (!espLoader.IS_STUB) {
await espLoader.runStub();
}
return espLoader;
}
Expand Down Expand Up @@ -162,6 +165,25 @@
port.close();
}
}
async function eraseSPI() {
const port = await navigator.serial.requestPort();
try {
console.log(data.meta);
const spiFlash = data.meta.spi_flash!;
espLoader = await connectEsp(port);
/*espLoader.flashSpiAttach(
(spiFlash.connection.clk << 0) |
(spiFlash.connection.q << 8) |
(spiFlash.connection.d << 16) |
(spiFlash.connection.cs << 24),
);
espLoader.flashId();*/
} finally {
port.close();
}
}
</script>

<div class="container">
Expand Down Expand Up @@ -288,6 +310,9 @@
<label
><input type="checkbox" id="erase" bind:checked={eraseAll} />Erase All</label
>
<button onclick={eraseSPI}
><span class="icon">developer_board</span>Erase SPI Flash</button
>
</div>

<pre>{terminalOutput}</pre>
Expand Down
1 change: 1 addition & 0 deletions src/routes/(app)/ccos/[device]/[version]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const load = (async ({ fetch, params }) => {
(entry) =>
entry.type === "file" && (!meta?.files || entry.name in meta.files),
) as FileListing[],
spi_flash: meta?.spi_flash ?? undefined,
},
};
}) satisfies PageLoad;
15 changes: 15 additions & 0 deletions src/routes/(app)/ccos/[device]/[version]/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ export interface VersionMeta {
esptool: EspToolData | null;
};
files: string[];
spi_flash: SPIFlashInfo | null;
}

export interface SPIFlashInfo {
type: string;
size: string;
connection: SPIConnection;
}

export interface SPIConnection {
clk: number;
q: number;
d: number;
hd: number;
cs: number;
}

export interface EspToolData {
Expand Down

0 comments on commit 1300381

Please sign in to comment.