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:
33
scripts/nodes/library/gpio/gpioRead.js
Normal file
33
scripts/nodes/library/gpio/gpioRead.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import { createNodeModule } from "../../nodeTypes.js";
|
||||
|
||||
/**
|
||||
* Reads a value from a GPIO pin using gpio().
|
||||
*/
|
||||
export const gpioReadNode = createNodeModule(
|
||||
{
|
||||
id: "gpio_read",
|
||||
title: "GPIO Read",
|
||||
category: "IO",
|
||||
description: "Fetch the current value of a GPIO pin.",
|
||||
searchTags: ["gpio", "hardware", "input"],
|
||||
inputs: [
|
||||
{
|
||||
id: "index",
|
||||
name: "Pin",
|
||||
direction: "input",
|
||||
kind: "number",
|
||||
defaultValue: 0,
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{ id: "value", name: "Value", direction: "output", kind: "number" },
|
||||
],
|
||||
properties: [],
|
||||
},
|
||||
{
|
||||
evaluateValue: ({ resolveValueInput }) => {
|
||||
const pin = resolveValueInput("index", "0");
|
||||
return `gpio(${pin})`;
|
||||
},
|
||||
}
|
||||
);
|
||||
43
scripts/nodes/library/gpio/gpioWrite.js
Normal file
43
scripts/nodes/library/gpio/gpioWrite.js
Normal file
@@ -0,0 +1,43 @@
|
||||
import { createNodeModule } from "../../nodeTypes.js";
|
||||
|
||||
/**
|
||||
* Writes a value to a GPIO pin using gpio().
|
||||
*/
|
||||
export const gpioWriteNode = createNodeModule(
|
||||
{
|
||||
id: "gpio_write",
|
||||
title: "GPIO Write",
|
||||
category: "IO",
|
||||
description: "Set the value for a GPIO pin.",
|
||||
searchTags: ["gpio", "hardware", "output"],
|
||||
inputs: [
|
||||
{ id: "exec_in", name: "Exec", direction: "input", kind: "exec" },
|
||||
{
|
||||
id: "index",
|
||||
name: "Pin",
|
||||
direction: "input",
|
||||
kind: "number",
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
id: "value",
|
||||
name: "Value",
|
||||
direction: "input",
|
||||
kind: "number",
|
||||
defaultValue: 0,
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{ id: "exec_out", name: "Exec", direction: "output", kind: "exec" },
|
||||
],
|
||||
properties: [],
|
||||
},
|
||||
{
|
||||
emitExec: ({ indent, indentLevel, resolveValueInput, emitNextExec }) => {
|
||||
const pin = resolveValueInput("index", "0");
|
||||
const value = resolveValueInput("value", "0");
|
||||
const line = `${indent(indentLevel)}gpio(${pin}, ${value})`;
|
||||
return [line, ...emitNextExec("exec_out")];
|
||||
},
|
||||
}
|
||||
);
|
||||
16
scripts/nodes/library/gpio/index.js
Normal file
16
scripts/nodes/library/gpio/index.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import { gpioReadNode } from "./gpioRead.js";
|
||||
import { gpioWriteNode } from "./gpioWrite.js";
|
||||
|
||||
/**
|
||||
* Node modules covering GPIO helpers.
|
||||
*/
|
||||
export const gpioNodes = [gpioReadNode, gpioWriteNode];
|
||||
|
||||
/**
|
||||
* Checklist tracking coverage of GPIO read/write helpers.
|
||||
* @type {Array<{ function: string, nodeId: string, implemented: boolean }>}
|
||||
*/
|
||||
export const gpioFunctionChecklist = [
|
||||
{ function: "GPIO (read)", nodeId: "gpio_read", implemented: true },
|
||||
{ function: "GPIO (write)", nodeId: "gpio_write", implemented: true },
|
||||
];
|
||||
Reference in New Issue
Block a user