mirror of
https://github.com/litruv/picoGraph.git
synced 2026-07-24 10:46:06 +10:00
Initial commit
moved from private version control
This commit is contained in:
16
scripts/nodes/library/serial/index.js
Normal file
16
scripts/nodes/library/serial/index.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import { serialSendNode } from "./serialSend.js";
|
||||
import { serialReceiveNode } from "./serialReceive.js";
|
||||
|
||||
/**
|
||||
* Node modules covering serial helpers.
|
||||
*/
|
||||
export const serialNodes = [serialSendNode, serialReceiveNode];
|
||||
|
||||
/**
|
||||
* Checklist tracking coverage of serial helpers.
|
||||
* @type {Array<{ function: string, nodeId: string, implemented: boolean }>}
|
||||
*/
|
||||
export const serialFunctionChecklist = [
|
||||
{ function: "SERIAL (send)", nodeId: "serial_send", implemented: true },
|
||||
{ function: "SERIAL (receive)", nodeId: "serial_receive", implemented: true },
|
||||
];
|
||||
33
scripts/nodes/library/serial/serialReceive.js
Normal file
33
scripts/nodes/library/serial/serialReceive.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import { createNodeModule } from "../../nodeTypes.js";
|
||||
|
||||
/**
|
||||
* Reads pending data from a serial channel using serial().
|
||||
*/
|
||||
export const serialReceiveNode = createNodeModule(
|
||||
{
|
||||
id: "serial_receive",
|
||||
title: "Serial Receive",
|
||||
category: "IO",
|
||||
description: "Poll a serial channel for the next message.",
|
||||
searchTags: ["serial", "io", "receive"],
|
||||
inputs: [
|
||||
{
|
||||
id: "channel",
|
||||
name: "Channel",
|
||||
direction: "input",
|
||||
kind: "number",
|
||||
defaultValue: 0,
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{ id: "message", name: "Message", direction: "output", kind: "any" },
|
||||
],
|
||||
properties: [],
|
||||
},
|
||||
{
|
||||
evaluateValue: ({ resolveValueInput }) => {
|
||||
const channel = resolveValueInput("channel", "0");
|
||||
return `serial(${channel})`;
|
||||
},
|
||||
}
|
||||
);
|
||||
43
scripts/nodes/library/serial/serialSend.js
Normal file
43
scripts/nodes/library/serial/serialSend.js
Normal file
@@ -0,0 +1,43 @@
|
||||
import { createNodeModule } from "../../nodeTypes.js";
|
||||
|
||||
/**
|
||||
* Sends data over a serial channel using serial().
|
||||
*/
|
||||
export const serialSendNode = createNodeModule(
|
||||
{
|
||||
id: "serial_send",
|
||||
title: "Serial Send",
|
||||
category: "IO",
|
||||
description: "Transmit a string to a serial channel.",
|
||||
searchTags: ["serial", "io", "send"],
|
||||
inputs: [
|
||||
{ id: "exec_in", name: "Exec", direction: "input", kind: "exec" },
|
||||
{
|
||||
id: "channel",
|
||||
name: "Channel",
|
||||
direction: "input",
|
||||
kind: "number",
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
id: "message",
|
||||
name: "Message",
|
||||
direction: "input",
|
||||
kind: "string",
|
||||
defaultValue: "",
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{ id: "exec_out", name: "Exec", direction: "output", kind: "exec" },
|
||||
],
|
||||
properties: [],
|
||||
},
|
||||
{
|
||||
emitExec: ({ indent, indentLevel, resolveValueInput, emitNextExec }) => {
|
||||
const channel = resolveValueInput("channel", "0");
|
||||
const message = resolveValueInput("message", '""');
|
||||
const line = `${indent(indentLevel)}serial(${channel}, ${message})`;
|
||||
return [line, ...emitNextExec("exec_out")];
|
||||
},
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user