@ikalogic/at1000 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-DjWAcSYV.cjs +1 -0
- package/dist/com-BHaGVMz5.cjs +2 -0
- package/dist/com-BHaGVMz5.cjs.map +1 -0
- package/dist/com-BdsqVRMC.mjs +2 -0
- package/dist/com-BdsqVRMC.mjs.map +1 -0
- package/dist/com-DCoBgRma.d.mts +606 -0
- package/dist/com-DCoBgRma.d.mts.map +1 -0
- package/dist/com-J1K8y_90.d.cts +606 -0
- package/dist/com-J1K8y_90.d.cts.map +1 -0
- package/dist/com.cjs +1 -0
- package/dist/com.d.cts +2 -0
- package/dist/com.d.mts +2 -0
- package/dist/com.mjs +1 -0
- package/dist/common-ClinPNdn.d.mts +8 -0
- package/dist/common-ClinPNdn.d.mts.map +1 -0
- package/dist/common-CsBdb633.d.cts +8 -0
- package/dist/common-CsBdb633.d.cts.map +1 -0
- package/dist/common-DSzy5K03.mjs +2 -0
- package/dist/common-DSzy5K03.mjs.map +1 -0
- package/dist/common-ix04NEFn.cjs +2 -0
- package/dist/common-ix04NEFn.cjs.map +1 -0
- package/dist/discovery.cjs +2 -0
- package/dist/discovery.cjs.map +1 -0
- package/dist/discovery.d.cts +14 -0
- package/dist/discovery.d.cts.map +1 -0
- package/dist/discovery.d.mts +14 -0
- package/dist/discovery.d.mts.map +1 -0
- package/dist/discovery.mjs +2 -0
- package/dist/discovery.mjs.map +1 -0
- package/dist/gpio-BQXV_UtO.d.cts +253 -0
- package/dist/gpio-BQXV_UtO.d.cts.map +1 -0
- package/dist/gpio-CxHnpe7Y.mjs +2 -0
- package/dist/gpio-CxHnpe7Y.mjs.map +1 -0
- package/dist/gpio-D4KyCVtn.d.mts +253 -0
- package/dist/gpio-D4KyCVtn.d.mts.map +1 -0
- package/dist/gpio-DSTG-dmv.cjs +2 -0
- package/dist/gpio-DSTG-dmv.cjs.map +1 -0
- package/dist/gpio.cjs +1 -0
- package/dist/gpio.d.cts +4 -0
- package/dist/gpio.d.mts +4 -0
- package/dist/gpio.mjs +1 -0
- package/dist/hmi-B04X0czX.mjs +2 -0
- package/dist/hmi-B04X0czX.mjs.map +1 -0
- package/dist/hmi-BMM-GMeM.d.mts +113 -0
- package/dist/hmi-BMM-GMeM.d.mts.map +1 -0
- package/dist/hmi-Cx7xLvkd.d.cts +113 -0
- package/dist/hmi-Cx7xLvkd.d.cts.map +1 -0
- package/dist/hmi-DSFhbR-Y.cjs +2 -0
- package/dist/hmi-DSFhbR-Y.cjs.map +1 -0
- package/dist/hmi.cjs +1 -0
- package/dist/hmi.d.cts +2 -0
- package/dist/hmi.d.mts +2 -0
- package/dist/hmi.mjs +1 -0
- package/dist/index--f0Eile9.d.mts +49 -0
- package/dist/index--f0Eile9.d.mts.map +1 -0
- package/dist/index-CSex8Zr4.d.cts +49 -0
- package/dist/index-CSex8Zr4.d.cts.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +9 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.mjs +1 -0
- package/dist/management-B758IJfF.cjs +2 -0
- package/dist/management-B758IJfF.cjs.map +1 -0
- package/dist/management-BRYyWntE.mjs +2 -0
- package/dist/management-BRYyWntE.mjs.map +1 -0
- package/dist/management-CecISx9d.d.cts +243 -0
- package/dist/management-CecISx9d.d.cts.map +1 -0
- package/dist/management-DYOPvugC.d.mts +243 -0
- package/dist/management-DYOPvugC.d.mts.map +1 -0
- package/dist/management.cjs +1 -0
- package/dist/management.d.cts +2 -0
- package/dist/management.d.mts +2 -0
- package/dist/management.mjs +1 -0
- package/dist/power--6z_aXLw.d.mts +339 -0
- package/dist/power--6z_aXLw.d.mts.map +1 -0
- package/dist/power-AuGIL43h.d.cts +339 -0
- package/dist/power-AuGIL43h.d.cts.map +1 -0
- package/dist/power-DtLWOEQI.cjs +2 -0
- package/dist/power-DtLWOEQI.cjs.map +1 -0
- package/dist/power-kf9bMNDS.mjs +2 -0
- package/dist/power-kf9bMNDS.mjs.map +1 -0
- package/dist/power.cjs +1 -0
- package/dist/power.d.cts +4 -0
- package/dist/power.d.mts +4 -0
- package/dist/power.mjs +1 -0
- package/dist/relays-8a3YZaV7.cjs +2 -0
- package/dist/relays-8a3YZaV7.cjs.map +1 -0
- package/dist/relays-CGntlBiE.d.mts +77 -0
- package/dist/relays-CGntlBiE.d.mts.map +1 -0
- package/dist/relays-Cwtrx0B-.mjs +2 -0
- package/dist/relays-Cwtrx0B-.mjs.map +1 -0
- package/dist/relays-Dn_EI0HH.d.cts +77 -0
- package/dist/relays-Dn_EI0HH.d.cts.map +1 -0
- package/dist/relays.cjs +1 -0
- package/dist/relays.d.cts +2 -0
- package/dist/relays.d.mts +2 -0
- package/dist/relays.mjs +1 -0
- package/dist/src-3DKHMeTA.mjs +2 -0
- package/dist/src-3DKHMeTA.mjs.map +1 -0
- package/dist/src-CJhZ2EuZ.cjs +2 -0
- package/dist/src-CJhZ2EuZ.cjs.map +1 -0
- package/package.json +124 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require(`./chunk-DjWAcSYV.cjs`);let t=require(`valibot`);t=e.t(t);const n=t.pipe(t.number(),t.minValue(-24),t.maxValue(24)),r=t.pipe(t.number(),t.minValue(0),t.maxValue(24)),i=t.boolean();Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return n}});
|
|
2
|
+
//# sourceMappingURL=common-ix04NEFn.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common-ix04NEFn.cjs","names":["v"],"sources":["../src/api/common.ts"],"sourcesContent":["import * as v from 'valibot';\n\nexport const analogLevel = v.pipe(v.number(), v.minValue(-24), v.maxValue(24));\nexport const analogOutputLevel = v.pipe(v.number(), v.minValue(0), v.maxValue(24));\nexport const digitalLevel = v.boolean();\n\nexport type AnalogLevel = v.InferOutput<typeof analogLevel>;\nexport type AnalogOutputLevel = v.InferOutput<typeof analogOutputLevel>;\nexport type DigitalLevel = v.InferOutput<typeof digitalLevel>;\n"],"mappings":"0EAEA,MAAa,EAAcA,EAAE,KAAKA,EAAE,QAAQ,CAAEA,EAAE,SAAS,IAAI,CAAEA,EAAE,SAAS,GAAG,CAAC,CACjE,EAAoBA,EAAE,KAAKA,EAAE,QAAQ,CAAEA,EAAE,SAAS,EAAE,CAAEA,EAAE,SAAS,GAAG,CAAC,CACrE,EAAeA,EAAE,SAAS"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require(`./chunk-DjWAcSYV.cjs`);require(`./com-BHaGVMz5.cjs`),require(`./common-ix04NEFn.cjs`),require(`./gpio-DSTG-dmv.cjs`),require(`./hmi-DSFhbR-Y.cjs`),require(`./management-B758IJfF.cjs`),require(`./power-DtLWOEQI.cjs`),require(`./relays-8a3YZaV7.cjs`);const t=require(`./src-CJhZ2EuZ.cjs`);let n=require(`mdns-scanner`);n=e.t(n);const r=async(e=500)=>{e<10&&(e=10);let r=new n.Scanner({debug:!0}),i=new n.Services(r);if(i.on(`error`,e=>{if(!e.includes(`bind ENOENT`))throw Error(e)}),!await r.init())throw Error(`Failed to initialize mDNS scanner`);r.query(`_at1000_server._tcp.local`),await new Promise(t=>setTimeout(t,e));let a=[...new Set(Object.values(i.namedServices).filter(e=>e!==void 0&&e.service!==void 0).filter(e=>e.service.name.endsWith(`_at1000_server._tcp.local`)).map(e=>e.addresses.filter(e=>e.family==`IPv4`).pop()?.address).filter(e=>e!==void 0))].map(e=>t.t.create(e));return r.destroy(),await Promise.all(a)};exports.findDevices=r;
|
|
2
|
+
//# sourceMappingURL=discovery.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.cjs","names":["Scanner","Services","AT1000"],"sources":["../src/discovery.ts"],"sourcesContent":["import { AT1000 } from './index';\n\nimport { Scanner, Services } from 'mdns-scanner';\n\nexport const findDevices = async (timeout: number = 500): Promise<AT1000[]> => {\n if (timeout < 10) {\n timeout = 10;\n }\n\n let scanner = new Scanner({ debug: true });\n let services = new Services(scanner);\n\n services.on('error', (error: string) => {\n if (!error.includes('bind ENOENT')) {\n throw Error(error);\n }\n });\n\n let ready = await scanner.init();\n if (!ready) {\n throw new Error('Failed to initialize mDNS scanner');\n }\n scanner.query('_at1000_server._tcp.local');\n\n await new Promise((r) => setTimeout(r, timeout));\n\n // Extract unique IPv4 addresses from discovered services\n const addresses = [\n ...new Set(\n Object\n .values(services.namedServices)\n .filter((s: any) =>\n s !== undefined && s.service !== undefined\n )\n .filter((s: any) => (s.service.name as string).endsWith('_at1000_server._tcp.local'))\n .map((s: any) => s.addresses.filter((a: any) => a.family == 'IPv4').pop()?.address)\n .filter((ipv4: string | undefined) => ipv4 !== undefined),\n ),\n ];\n\n const devices = addresses.map((ipv4) => AT1000.create(ipv4));\n\n scanner.destroy();\n\n return await Promise.all(devices);\n};\n"],"mappings":"uVAIA,MAAa,EAAc,MAAO,EAAkB,MAA2B,CACzE,EAAU,KACZ,EAAU,IAGZ,IAAI,EAAU,IAAIA,EAAAA,QAAQ,CAAE,MAAO,GAAM,CAAC,CACtC,EAAW,IAAIC,EAAAA,SAAS,EAAQ,CASpC,GAPA,EAAS,GAAG,QAAU,GAAkB,CACtC,GAAI,CAAC,EAAM,SAAS,cAAc,CAChC,MAAM,MAAM,EAAM,EAEpB,CAGE,CADQ,MAAM,EAAQ,MAAM,CAE9B,MAAU,MAAM,oCAAoC,CAEtD,EAAQ,MAAM,4BAA4B,CAE1C,MAAM,IAAI,QAAS,GAAM,WAAW,EAAG,EAAQ,CAAC,CAgBhD,IAAM,EAbY,CAChB,GAAG,IAAI,IACL,OACG,OAAO,EAAS,cAAc,CAC9B,OAAQ,GACP,IAAM,IAAA,IAAa,EAAE,UAAY,IAAA,GAClC,CACA,OAAQ,GAAY,EAAE,QAAQ,KAAgB,SAAS,4BAA4B,CAAC,CACpF,IAAK,GAAW,EAAE,UAAU,OAAQ,GAAW,EAAE,QAAU,OAAO,CAAC,KAAK,EAAE,QAAQ,CAClF,OAAQ,GAA6B,IAAS,IAAA,GAAU,CAC5D,CACF,CAEyB,IAAK,GAASC,EAAAA,EAAO,OAAO,EAAK,CAAC,CAI5D,OAFA,EAAQ,SAAS,CAEV,MAAM,QAAQ,IAAI,EAAQ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "./com-J1K8y_90.cjs";
|
|
2
|
+
import "./common-CsBdb633.cjs";
|
|
3
|
+
import "./management-CecISx9d.cjs";
|
|
4
|
+
import "./gpio-BQXV_UtO.cjs";
|
|
5
|
+
import "./hmi-Cx7xLvkd.cjs";
|
|
6
|
+
import "./power-AuGIL43h.cjs";
|
|
7
|
+
import "./relays-Dn_EI0HH.cjs";
|
|
8
|
+
import { t as AT1000 } from "./index-CSex8Zr4.cjs";
|
|
9
|
+
|
|
10
|
+
//#region src/discovery.d.ts
|
|
11
|
+
declare const findDevices: (timeout?: number) => Promise<AT1000[]>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { findDevices };
|
|
14
|
+
//# sourceMappingURL=discovery.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.cts","names":[],"sources":["../src/discovery.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAIa,mCAA6C,QAAQ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "./com-DCoBgRma.mjs";
|
|
2
|
+
import "./common-ClinPNdn.mjs";
|
|
3
|
+
import "./management-DYOPvugC.mjs";
|
|
4
|
+
import "./gpio-D4KyCVtn.mjs";
|
|
5
|
+
import "./hmi-BMM-GMeM.mjs";
|
|
6
|
+
import "./power--6z_aXLw.mjs";
|
|
7
|
+
import "./relays-CGntlBiE.mjs";
|
|
8
|
+
import { t as AT1000 } from "./index--f0Eile9.mjs";
|
|
9
|
+
|
|
10
|
+
//#region src/discovery.d.ts
|
|
11
|
+
declare const findDevices: (timeout?: number) => Promise<AT1000[]>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { findDevices };
|
|
14
|
+
//# sourceMappingURL=discovery.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.mts","names":[],"sources":["../src/discovery.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAIa,mCAA6C,QAAQ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./com-BdsqVRMC.mjs";import"./common-DSzy5K03.mjs";import"./gpio-CxHnpe7Y.mjs";import"./hmi-B04X0czX.mjs";import"./management-BRYyWntE.mjs";import"./power-kf9bMNDS.mjs";import"./relays-Cwtrx0B-.mjs";import{t as e}from"./src-3DKHMeTA.mjs";import{Scanner as t,Services as n}from"mdns-scanner";const r=async(r=500)=>{r<10&&(r=10);let i=new t({debug:!0}),a=new n(i);if(a.on(`error`,e=>{if(!e.includes(`bind ENOENT`))throw Error(e)}),!await i.init())throw Error(`Failed to initialize mDNS scanner`);i.query(`_at1000_server._tcp.local`),await new Promise(e=>setTimeout(e,r));let o=[...new Set(Object.values(a.namedServices).filter(e=>e!==void 0&&e.service!==void 0).filter(e=>e.service.name.endsWith(`_at1000_server._tcp.local`)).map(e=>e.addresses.filter(e=>e.family==`IPv4`).pop()?.address).filter(e=>e!==void 0))].map(t=>e.create(t));return i.destroy(),await Promise.all(o)};export{r as findDevices};
|
|
2
|
+
//# sourceMappingURL=discovery.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.mjs","names":[],"sources":["../src/discovery.ts"],"sourcesContent":["import { AT1000 } from './index';\n\nimport { Scanner, Services } from 'mdns-scanner';\n\nexport const findDevices = async (timeout: number = 500): Promise<AT1000[]> => {\n if (timeout < 10) {\n timeout = 10;\n }\n\n let scanner = new Scanner({ debug: true });\n let services = new Services(scanner);\n\n services.on('error', (error: string) => {\n if (!error.includes('bind ENOENT')) {\n throw Error(error);\n }\n });\n\n let ready = await scanner.init();\n if (!ready) {\n throw new Error('Failed to initialize mDNS scanner');\n }\n scanner.query('_at1000_server._tcp.local');\n\n await new Promise((r) => setTimeout(r, timeout));\n\n // Extract unique IPv4 addresses from discovered services\n const addresses = [\n ...new Set(\n Object\n .values(services.namedServices)\n .filter((s: any) =>\n s !== undefined && s.service !== undefined\n )\n .filter((s: any) => (s.service.name as string).endsWith('_at1000_server._tcp.local'))\n .map((s: any) => s.addresses.filter((a: any) => a.family == 'IPv4').pop()?.address)\n .filter((ipv4: string | undefined) => ipv4 !== undefined),\n ),\n ];\n\n const devices = addresses.map((ipv4) => AT1000.create(ipv4));\n\n scanner.destroy();\n\n return await Promise.all(devices);\n};\n"],"mappings":"ySAIA,MAAa,EAAc,MAAO,EAAkB,MAA2B,CACzE,EAAU,KACZ,EAAU,IAGZ,IAAI,EAAU,IAAI,EAAQ,CAAE,MAAO,GAAM,CAAC,CACtC,EAAW,IAAI,EAAS,EAAQ,CASpC,GAPA,EAAS,GAAG,QAAU,GAAkB,CACtC,GAAI,CAAC,EAAM,SAAS,cAAc,CAChC,MAAM,MAAM,EAAM,EAEpB,CAGE,CADQ,MAAM,EAAQ,MAAM,CAE9B,MAAU,MAAM,oCAAoC,CAEtD,EAAQ,MAAM,4BAA4B,CAE1C,MAAM,IAAI,QAAS,GAAM,WAAW,EAAG,EAAQ,CAAC,CAgBhD,IAAM,EAbY,CAChB,GAAG,IAAI,IACL,OACG,OAAO,EAAS,cAAc,CAC9B,OAAQ,GACP,IAAM,IAAA,IAAa,EAAE,UAAY,IAAA,GAClC,CACA,OAAQ,GAAY,EAAE,QAAQ,KAAgB,SAAS,4BAA4B,CAAC,CACpF,IAAK,GAAW,EAAE,UAAU,OAAQ,GAAW,EAAE,QAAU,OAAO,CAAC,KAAK,EAAE,QAAQ,CAClF,OAAQ,GAA6B,IAAS,IAAA,GAAU,CAC5D,CACF,CAEyB,IAAK,GAAS,EAAO,OAAO,EAAK,CAAC,CAI5D,OAFA,EAAQ,SAAS,CAEV,MAAM,QAAQ,IAAI,EAAQ"}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { t as AnalogOutputLevel } from "./common-CsBdb633.cjs";
|
|
2
|
+
import { n as Device } from "./management-CecISx9d.cjs";
|
|
3
|
+
import { UpFetch } from "up-fetch";
|
|
4
|
+
import * as v from "valibot";
|
|
5
|
+
|
|
6
|
+
//#region src/api/gpio.d.ts
|
|
7
|
+
declare const analogInputConfiguration: v.ObjectSchema<{
|
|
8
|
+
readonly mode: v.LiteralSchema<"analog", undefined>;
|
|
9
|
+
readonly direction: v.LiteralSchema<"input", undefined>;
|
|
10
|
+
}, undefined>;
|
|
11
|
+
declare const analogOutputConfiguration: v.ObjectSchema<{
|
|
12
|
+
readonly mode: v.LiteralSchema<"analog", undefined>;
|
|
13
|
+
readonly direction: v.LiteralSchema<"output", undefined>;
|
|
14
|
+
readonly value: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 24, undefined>]>, undefined>;
|
|
15
|
+
}, undefined>;
|
|
16
|
+
declare const digitalInputConfiguration: v.ObjectSchema<{
|
|
17
|
+
readonly mode: v.LiteralSchema<"digital", undefined>;
|
|
18
|
+
readonly direction: v.LiteralSchema<"input", undefined>;
|
|
19
|
+
readonly vil: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
20
|
+
readonly vih: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
21
|
+
}, undefined>;
|
|
22
|
+
declare const digitalOutputConfiguration: v.ObjectSchema<{
|
|
23
|
+
readonly mode: v.LiteralSchema<"digital", undefined>;
|
|
24
|
+
readonly direction: v.LiteralSchema<"output", undefined>;
|
|
25
|
+
readonly value: v.BooleanSchema<undefined>;
|
|
26
|
+
readonly vol: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
27
|
+
readonly voh: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
28
|
+
readonly vil: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
29
|
+
readonly vih: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
30
|
+
}, undefined>;
|
|
31
|
+
type AnalogInputConfiguration = v.InferOutput<typeof analogInputConfiguration>;
|
|
32
|
+
type AnalogOutputConfiguration = v.InferOutput<typeof analogOutputConfiguration>;
|
|
33
|
+
type DigitalInputConfiguration = v.InferOutput<typeof digitalInputConfiguration>;
|
|
34
|
+
type DigitalOutputConfiguration = v.InferOutput<typeof digitalOutputConfiguration>;
|
|
35
|
+
declare const partialAnalogOutputConfiguration: Omit<v.ObjectSchema<{
|
|
36
|
+
readonly mode: v.LiteralSchema<"analog", undefined>;
|
|
37
|
+
readonly direction: v.LiteralSchema<"output", undefined>;
|
|
38
|
+
readonly value: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 24, undefined>]>, undefined>;
|
|
39
|
+
}, undefined>, "~types" | "~run" | "~standard" | "entries"> & {
|
|
40
|
+
readonly entries: Omit<{
|
|
41
|
+
readonly mode: v.LiteralSchema<"analog", undefined>;
|
|
42
|
+
readonly direction: v.LiteralSchema<"output", undefined>;
|
|
43
|
+
readonly value: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 24, undefined>]>, undefined>;
|
|
44
|
+
}, "mode" | "direction">;
|
|
45
|
+
readonly '~standard': v.StandardProps<{
|
|
46
|
+
value?: number | undefined;
|
|
47
|
+
}, {
|
|
48
|
+
value?: number | undefined;
|
|
49
|
+
}>;
|
|
50
|
+
readonly '~run': (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
|
|
51
|
+
value?: number | undefined;
|
|
52
|
+
}, v.NumberIssue | v.MinValueIssue<number, 0> | v.ObjectIssue | v.MaxValueIssue<number, 24>>;
|
|
53
|
+
readonly '~types'?: {
|
|
54
|
+
readonly input: {
|
|
55
|
+
value?: number | undefined;
|
|
56
|
+
};
|
|
57
|
+
readonly output: {
|
|
58
|
+
value?: number | undefined;
|
|
59
|
+
};
|
|
60
|
+
readonly issue: v.NumberIssue | v.MinValueIssue<number, 0> | v.ObjectIssue | v.MaxValueIssue<number, 24>;
|
|
61
|
+
} | undefined;
|
|
62
|
+
};
|
|
63
|
+
type PartialAnalogOutputConfiguration = v.InferOutput<typeof partialAnalogOutputConfiguration>;
|
|
64
|
+
declare const partialDigitalInputConfiguration: Omit<v.ObjectSchema<{
|
|
65
|
+
readonly mode: v.LiteralSchema<"digital", undefined>;
|
|
66
|
+
readonly direction: v.LiteralSchema<"input", undefined>;
|
|
67
|
+
readonly vil: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
68
|
+
readonly vih: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
69
|
+
}, undefined>, "~types" | "~run" | "~standard" | "entries"> & {
|
|
70
|
+
readonly entries: Omit<{
|
|
71
|
+
readonly mode: v.LiteralSchema<"digital", undefined>;
|
|
72
|
+
readonly direction: v.LiteralSchema<"input", undefined>;
|
|
73
|
+
readonly vil: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
74
|
+
readonly vih: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
75
|
+
}, "mode" | "direction">;
|
|
76
|
+
readonly '~standard': v.StandardProps<{
|
|
77
|
+
vil: number;
|
|
78
|
+
vih: number;
|
|
79
|
+
}, {
|
|
80
|
+
vil: number;
|
|
81
|
+
vih: number;
|
|
82
|
+
}>;
|
|
83
|
+
readonly '~run': (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
|
|
84
|
+
vil: number;
|
|
85
|
+
vih: number;
|
|
86
|
+
}, v.NumberIssue | v.ObjectIssue | v.MaxValueIssue<number, 24> | v.MinValueIssue<number, -24>>;
|
|
87
|
+
readonly '~types'?: {
|
|
88
|
+
readonly input: {
|
|
89
|
+
vil: number;
|
|
90
|
+
vih: number;
|
|
91
|
+
};
|
|
92
|
+
readonly output: {
|
|
93
|
+
vil: number;
|
|
94
|
+
vih: number;
|
|
95
|
+
};
|
|
96
|
+
readonly issue: v.NumberIssue | v.ObjectIssue | v.MaxValueIssue<number, 24> | v.MinValueIssue<number, -24>;
|
|
97
|
+
} | undefined;
|
|
98
|
+
};
|
|
99
|
+
type PartialDigitalInputConfiguration = v.InferOutput<typeof partialDigitalInputConfiguration>;
|
|
100
|
+
declare const partialDigitalOutputConfiguration: Omit<v.ObjectSchema<{
|
|
101
|
+
readonly mode: v.LiteralSchema<"digital", undefined>;
|
|
102
|
+
readonly direction: v.LiteralSchema<"output", undefined>;
|
|
103
|
+
readonly value: v.BooleanSchema<undefined>;
|
|
104
|
+
readonly vol: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
105
|
+
readonly voh: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
106
|
+
readonly vil: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
107
|
+
readonly vih: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
108
|
+
}, undefined>, "~types" | "~run" | "~standard" | "entries"> & {
|
|
109
|
+
readonly entries: Omit<{
|
|
110
|
+
readonly mode: v.LiteralSchema<"digital", undefined>;
|
|
111
|
+
readonly direction: v.LiteralSchema<"output", undefined>;
|
|
112
|
+
readonly value: v.BooleanSchema<undefined>;
|
|
113
|
+
readonly vol: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
114
|
+
readonly voh: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
115
|
+
readonly vil: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
116
|
+
readonly vih: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
117
|
+
}, "mode" | "direction">;
|
|
118
|
+
readonly '~standard': v.StandardProps<{
|
|
119
|
+
value: boolean;
|
|
120
|
+
vil: number;
|
|
121
|
+
vih: number;
|
|
122
|
+
vol: number;
|
|
123
|
+
voh: number;
|
|
124
|
+
}, {
|
|
125
|
+
value: boolean;
|
|
126
|
+
vil: number;
|
|
127
|
+
vih: number;
|
|
128
|
+
vol: number;
|
|
129
|
+
voh: number;
|
|
130
|
+
}>;
|
|
131
|
+
readonly '~run': (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
|
|
132
|
+
value: boolean;
|
|
133
|
+
vil: number;
|
|
134
|
+
vih: number;
|
|
135
|
+
vol: number;
|
|
136
|
+
voh: number;
|
|
137
|
+
}, v.NumberIssue | v.MinValueIssue<number, 0> | v.BooleanIssue | v.ObjectIssue | v.MaxValueIssue<number, 24> | v.MinValueIssue<number, -24>>;
|
|
138
|
+
readonly '~types'?: {
|
|
139
|
+
readonly input: {
|
|
140
|
+
value: boolean;
|
|
141
|
+
vil: number;
|
|
142
|
+
vih: number;
|
|
143
|
+
vol: number;
|
|
144
|
+
voh: number;
|
|
145
|
+
};
|
|
146
|
+
readonly output: {
|
|
147
|
+
value: boolean;
|
|
148
|
+
vil: number;
|
|
149
|
+
vih: number;
|
|
150
|
+
vol: number;
|
|
151
|
+
voh: number;
|
|
152
|
+
};
|
|
153
|
+
readonly issue: v.NumberIssue | v.MinValueIssue<number, 0> | v.BooleanIssue | v.ObjectIssue | v.MaxValueIssue<number, 24> | v.MinValueIssue<number, -24>;
|
|
154
|
+
} | undefined;
|
|
155
|
+
};
|
|
156
|
+
type PartialDigitalOutputConfiguration = v.InferOutput<typeof partialDigitalOutputConfiguration>;
|
|
157
|
+
declare const syncConfiguration: v.ObjectSchema<{
|
|
158
|
+
readonly action: v.PicklistSchema<["release", "hold"], "Invalid sync action">;
|
|
159
|
+
}, undefined>;
|
|
160
|
+
type SyncConfiguration = v.InferOutput<typeof syncConfiguration>;
|
|
161
|
+
declare class GpioApi {
|
|
162
|
+
private readonly fetch;
|
|
163
|
+
private count;
|
|
164
|
+
constructor(fetch: UpFetch, device: Device);
|
|
165
|
+
/**
|
|
166
|
+
* Resets all IO configurations to default.
|
|
167
|
+
*/
|
|
168
|
+
reset(): Promise<void>;
|
|
169
|
+
/**
|
|
170
|
+
* Access a specific digital IO pin by id.
|
|
171
|
+
* @param io The IO pin id.
|
|
172
|
+
* @returns The digital IO instance.
|
|
173
|
+
*/
|
|
174
|
+
digital(io: number): DigitalIO;
|
|
175
|
+
/**
|
|
176
|
+
* Access a specific analog IO pin by id.
|
|
177
|
+
* @param io The IO pin id.
|
|
178
|
+
* @returns The analog IO instance.
|
|
179
|
+
*/
|
|
180
|
+
analog(io: number): AnalogIO;
|
|
181
|
+
/**
|
|
182
|
+
* Holds the current state of all GPIO pins.
|
|
183
|
+
* @returns The applied sync state.
|
|
184
|
+
*/
|
|
185
|
+
hold(): Promise<SyncConfiguration>;
|
|
186
|
+
/**
|
|
187
|
+
* Releases control of the IO pins, allowing external control.
|
|
188
|
+
*
|
|
189
|
+
* This also sets the device as a slave.
|
|
190
|
+
*
|
|
191
|
+
* @returns The applied sync state.
|
|
192
|
+
*/
|
|
193
|
+
release(): Promise<SyncConfiguration>;
|
|
194
|
+
}
|
|
195
|
+
declare class DigitalIO {
|
|
196
|
+
private readonly fetch;
|
|
197
|
+
readonly id: number;
|
|
198
|
+
constructor(fetch: UpFetch, id: number);
|
|
199
|
+
/**
|
|
200
|
+
* Configure the pin as a digital input.
|
|
201
|
+
* @param config The digital input configuration.
|
|
202
|
+
* @returns The applied configuration.
|
|
203
|
+
*/
|
|
204
|
+
configure_input(config: PartialDigitalInputConfiguration): Promise<DigitalInputConfiguration>;
|
|
205
|
+
/**
|
|
206
|
+
* Configures the pin as a digital output.
|
|
207
|
+
* @param config The digital output configuration.
|
|
208
|
+
* @returns The applied configuration.
|
|
209
|
+
*/
|
|
210
|
+
configure_output(config: PartialDigitalOutputConfiguration): Promise<DigitalOutputConfiguration>;
|
|
211
|
+
/**
|
|
212
|
+
* Reads the current state of the pin.
|
|
213
|
+
* @returns The current state of the pin.
|
|
214
|
+
*/
|
|
215
|
+
read(): Promise<boolean>;
|
|
216
|
+
/**
|
|
217
|
+
* Writes a value to the pin.
|
|
218
|
+
* @param value The value to write.
|
|
219
|
+
* @returns The written value.
|
|
220
|
+
*/
|
|
221
|
+
write(value: boolean): Promise<boolean>;
|
|
222
|
+
}
|
|
223
|
+
declare class AnalogIO {
|
|
224
|
+
private readonly fetch;
|
|
225
|
+
readonly id: number;
|
|
226
|
+
constructor(fetch: UpFetch, id: number);
|
|
227
|
+
/**
|
|
228
|
+
* Configures the pin as an analog input.
|
|
229
|
+
* @returns The applied configuration.
|
|
230
|
+
* @returns The applied configuration.
|
|
231
|
+
*/
|
|
232
|
+
configure_input(): Promise<AnalogInputConfiguration>;
|
|
233
|
+
/**
|
|
234
|
+
* Configures the pin as an analog output.
|
|
235
|
+
* @param config The analog output configuration.
|
|
236
|
+
* @returns The applied configuration.
|
|
237
|
+
*/
|
|
238
|
+
configure_output(value: AnalogOutputLevel): Promise<AnalogOutputConfiguration>;
|
|
239
|
+
/**
|
|
240
|
+
* Reads the current state of the pin.
|
|
241
|
+
* @returns The current state of the pin.
|
|
242
|
+
*/
|
|
243
|
+
read(): Promise<number>;
|
|
244
|
+
/**
|
|
245
|
+
* Writes a value to the pin.
|
|
246
|
+
* @param value The value to write.
|
|
247
|
+
* @returns The written value.
|
|
248
|
+
*/
|
|
249
|
+
write(value: number): Promise<number>;
|
|
250
|
+
}
|
|
251
|
+
//#endregion
|
|
252
|
+
export { DigitalInputConfiguration as a, PartialAnalogOutputConfiguration as c, SyncConfiguration as d, DigitalIO as i, PartialDigitalInputConfiguration as l, AnalogInputConfiguration as n, DigitalOutputConfiguration as o, AnalogOutputConfiguration as r, GpioApi as s, AnalogIO as t, PartialDigitalOutputConfiguration as u };
|
|
253
|
+
//# sourceMappingURL=gpio-BQXV_UtO.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpio-BQXV_UtO.d.cts","names":[],"sources":["../src/api/gpio.ts"],"sourcesContent":[],"mappings":";;;;;;cASM,0BAAwB,CAAA,CAAA;EAAxB,SAAA,IAAA,iBAGJ,CAAA,QAAA,EAAA,SAAA,CAAA;;;cACI,yBAJwB,EAIC,CAAA,CAAA,YAJD,CAAA;EAAA,SAAA,IAAA,iBAAA,CAAA,QAAA,EAAA,SAAA,CAAA;EAIxB,SAAA,SAAA,iBAIJ,CAAA,QAAA,EAAA,SAAA,CAAA;;;cACI,2B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CT,QAAQ;;;;;;0BAaH,oBAAoB,QAAQ;;;;;UAetC;;;;;;wBASc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{n as e,r as t,t as n}from"./common-DSzy5K03.mjs";import*as r from"valibot";const i=r.picklist([`release`,`hold`],`Invalid sync action`),a=r.object({mode:r.literal(`analog`),direction:r.literal(`input`)}),o=r.object({mode:r.literal(`analog`),direction:r.literal(`output`),value:r.optional(e)}),s=r.object({mode:r.literal(`digital`),direction:r.literal(`input`),vil:n,vih:n}),c=r.object({mode:r.literal(`digital`),direction:r.literal(`output`),value:t,vol:e,voh:e,vil:n,vih:n});r.omit(o,[`direction`,`mode`]),r.omit(s,[`direction`,`mode`]),r.omit(c,[`direction`,`mode`]);const l=r.object({value:t}),u=r.object({value:n}),d=r.object({action:i});var f=class{count;constructor(e,t){this.fetch=e,this.count=t.capabilities.io.count}reset(){return this.fetch(`/gpio/reset`,{method:`POST`,parseResponse:()=>{}})}digital(e){if(e<0||e>=this.count)throw Error(`Invalid GPIO pin ${e} (RESOURCE_NOT_FOUND)\n Suggestion: Use a pin number between 0 and ${this.count-1}\n Path: /gpio/${e}`);return new p(this.fetch,e)}analog(e){if(e<0||e>=this.count)throw Error(`Invalid GPIO pin ${e} (RESOURCE_NOT_FOUND)\n Suggestion: Use a pin number between 0 and ${this.count-1}\n Path: /gpio/${e}`);return new m(this.fetch,e)}hold(){return this.fetch(`/gpio/sync`,{method:`POST`,body:{action:`hold`},schema:d})}release(){return this.fetch(`/gpio/sync`,{method:`POST`,body:{action:`release`},schema:d})}},p=class{constructor(e,t){this.fetch=e,this.id=t}configure_input(e){return this.fetch(`/gpio/${this.id}/config`,{method:`PATCH`,body:r.parse(s,{...e,mode:`digital`,direction:`input`}),schema:s})}configure_output(e){return this.fetch(`/gpio/${this.id}/config`,{method:`PATCH`,body:r.parse(c,{...e,mode:`digital`,direction:`output`}),schema:c})}async read(){return(await this.fetch(`/gpio/${this.id}/state`,{schema:l})).value}async write(e){return(await this.fetch(`/gpio/${this.id}/state`,{method:`PUT`,body:{value:e},schema:l})).value}},m=class{constructor(e,t){this.fetch=e,this.id=t}configure_input(){return this.fetch(`/gpio/${this.id}/config`,{method:`PATCH`,body:{mode:`analog`,direction:`input`},schema:a})}configure_output(e){return this.fetch(`/gpio/${this.id}/config`,{method:`PATCH`,body:r.parse(o,{value:e,mode:`analog`,direction:`output`}),schema:o})}async read(){return(await this.fetch(`/gpio/${this.id}/state`,{schema:u})).value}async write(e){return(await this.fetch(`/gpio/${this.id}/state`,{method:`PUT`,body:{value:e},schema:u})).value}};export{p as n,f as r,m as t};
|
|
2
|
+
//# sourceMappingURL=gpio-CxHnpe7Y.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpio-CxHnpe7Y.mjs","names":["fetch: UpFetch","id: number"],"sources":["../src/api/gpio.ts"],"sourcesContent":["import type { UpFetch } from 'up-fetch';\nimport * as v from 'valibot';\n\nimport { analogLevel, type AnalogOutputLevel, analogOutputLevel, digitalLevel } from './common';\nimport type { Device } from './management';\n\nexport type { AnalogOutputLevel };\n\nconst syncAction = v.picklist(['release', 'hold'], 'Invalid sync action');\nconst analogInputConfiguration = v.object({\n mode: v.literal('analog'),\n direction: v.literal('input'),\n});\nconst analogOutputConfiguration = v.object({\n mode: v.literal('analog'),\n direction: v.literal('output'),\n value: v.optional(analogOutputLevel),\n});\nconst digitalInputConfiguration = v.object({\n mode: v.literal('digital'),\n direction: v.literal('input'),\n vil: analogLevel,\n vih: analogLevel,\n});\nconst digitalOutputConfiguration = v.object({\n mode: v.literal('digital'),\n direction: v.literal('output'),\n value: digitalLevel,\n vol: analogOutputLevel,\n voh: analogOutputLevel,\n vil: analogLevel,\n vih: analogLevel,\n});\nexport type AnalogInputConfiguration = v.InferOutput<typeof analogInputConfiguration>;\nexport type AnalogOutputConfiguration = v.InferOutput<typeof analogOutputConfiguration>;\nexport type DigitalInputConfiguration = v.InferOutput<typeof digitalInputConfiguration>;\nexport type DigitalOutputConfiguration = v.InferOutput<typeof digitalOutputConfiguration>;\n\nconst partialAnalogOutputConfiguration = v.omit(analogOutputConfiguration, ['direction', 'mode']);\nexport type PartialAnalogOutputConfiguration = v.InferOutput<\n typeof partialAnalogOutputConfiguration\n>;\nconst partialDigitalInputConfiguration = v.omit(digitalInputConfiguration, ['direction', 'mode']);\nexport type PartialDigitalInputConfiguration = v.InferOutput<\n typeof partialDigitalInputConfiguration\n>;\nconst partialDigitalOutputConfiguration = v.omit(digitalOutputConfiguration, ['direction', 'mode']);\nexport type PartialDigitalOutputConfiguration = v.InferOutput<\n typeof partialDigitalOutputConfiguration\n>;\n\nconst digitalState = v.object({ value: digitalLevel });\nconst analogState = v.object({ value: analogLevel });\n\nconst syncConfiguration = v.object({ action: syncAction });\nexport type SyncConfiguration = v.InferOutput<typeof syncConfiguration>;\n\nexport class GpioApi {\n private count: number;\n\n constructor(private readonly fetch: UpFetch, device: Device) {\n this.count = device.capabilities.io.count;\n }\n\n /**\n * Resets all IO configurations to default.\n */\n reset(): Promise<void> {\n return this.fetch('/gpio/reset', { method: 'POST', parseResponse: () => {} });\n }\n\n /**\n * Access a specific digital IO pin by id.\n * @param io The IO pin id.\n * @returns The digital IO instance.\n */\n digital(io: number): DigitalIO {\n if (io < 0 || io >= this.count) {\n throw new Error(\n `Invalid GPIO pin ${io} (RESOURCE_NOT_FOUND)\\n Suggestion: Use a pin number between 0 and ${\n this.count - 1\n }\\n Path: /gpio/${io}`,\n );\n }\n\n return new DigitalIO(this.fetch, io);\n }\n\n /**\n * Access a specific analog IO pin by id.\n * @param io The IO pin id.\n * @returns The analog IO instance.\n */\n analog(io: number): AnalogIO {\n if (io < 0 || io >= this.count) {\n throw new Error(\n `Invalid GPIO pin ${io} (RESOURCE_NOT_FOUND)\\n Suggestion: Use a pin number between 0 and ${\n this.count - 1\n }\\n Path: /gpio/${io}`,\n );\n }\n\n return new AnalogIO(this.fetch, io);\n }\n\n /**\n * Holds the current state of all GPIO pins.\n * @returns The applied sync state.\n */\n hold(): Promise<SyncConfiguration> {\n return this.fetch('/gpio/sync', {\n method: 'POST',\n body: { action: 'hold' } satisfies SyncConfiguration,\n schema: syncConfiguration,\n });\n }\n\n /**\n * Releases control of the IO pins, allowing external control.\n *\n * This also sets the device as a slave.\n *\n * @returns The applied sync state.\n */\n release(): Promise<SyncConfiguration> {\n return this.fetch('/gpio/sync', {\n method: 'POST',\n body: { action: 'release' } satisfies SyncConfiguration,\n schema: syncConfiguration,\n });\n }\n}\n\nexport class DigitalIO {\n constructor(private readonly fetch: UpFetch, public readonly id: number) {}\n\n /**\n * Configure the pin as a digital input.\n * @param config The digital input configuration.\n * @returns The applied configuration.\n */\n configure_input(config: PartialDigitalInputConfiguration): Promise<DigitalInputConfiguration> {\n return this.fetch(`/gpio/${this.id}/config`, {\n method: 'PATCH',\n body: v.parse(\n digitalInputConfiguration,\n { ...config, mode: 'digital', direction: 'input' } satisfies DigitalInputConfiguration,\n ),\n schema: digitalInputConfiguration,\n });\n }\n\n /**\n * Configures the pin as a digital output.\n * @param config The digital output configuration.\n * @returns The applied configuration.\n */\n configure_output(config: PartialDigitalOutputConfiguration): Promise<DigitalOutputConfiguration> {\n return this.fetch(`/gpio/${this.id}/config`, {\n method: 'PATCH',\n body: v.parse(\n digitalOutputConfiguration,\n { ...config, mode: 'digital', direction: 'output' } satisfies DigitalOutputConfiguration,\n ),\n schema: digitalOutputConfiguration,\n });\n }\n\n /**\n * Reads the current state of the pin.\n * @returns The current state of the pin.\n */\n async read(): Promise<boolean> {\n return (await this.fetch(`/gpio/${this.id}/state`, { schema: digitalState })).value;\n }\n\n /**\n * Writes a value to the pin.\n * @param value The value to write.\n * @returns The written value.\n */\n async write(value: boolean): Promise<boolean> {\n return (await this.fetch(`/gpio/${this.id}/state`, {\n method: 'PUT',\n body: { value },\n schema: digitalState,\n }))\n .value;\n }\n}\n\nexport class AnalogIO {\n constructor(private readonly fetch: UpFetch, public readonly id: number) {}\n\n /**\n * Configures the pin as an analog input.\n * @returns The applied configuration.\n * @returns The applied configuration.\n */\n configure_input(): Promise<AnalogInputConfiguration> {\n return this.fetch(`/gpio/${this.id}/config`, {\n method: 'PATCH',\n body: { mode: 'analog', direction: 'input' } satisfies AnalogInputConfiguration,\n schema: analogInputConfiguration,\n });\n }\n\n /**\n * Configures the pin as an analog output.\n * @param config The analog output configuration.\n * @returns The applied configuration.\n */\n configure_output(value: AnalogOutputLevel): Promise<AnalogOutputConfiguration> {\n return this.fetch(`/gpio/${this.id}/config`, {\n method: 'PATCH',\n body: v.parse(\n analogOutputConfiguration,\n { value, mode: 'analog', direction: 'output' } satisfies AnalogOutputConfiguration,\n ),\n schema: analogOutputConfiguration,\n });\n }\n\n /**\n * Reads the current state of the pin.\n * @returns The current state of the pin.\n */\n async read(): Promise<number> {\n return (await this.fetch(`/gpio/${this.id}/state`, { schema: analogState })).value;\n }\n\n /**\n * Writes a value to the pin.\n * @param value The value to write.\n * @returns The written value.\n */\n async write(value: number): Promise<number> {\n return (await this.fetch(`/gpio/${this.id}/state`, {\n method: 'PUT',\n body: { value },\n schema: analogState,\n }))\n .value;\n }\n}\n"],"mappings":"kFAQA,MAAM,EAAa,EAAE,SAAS,CAAC,UAAW,OAAO,CAAE,sBAAsB,CACnE,EAA2B,EAAE,OAAO,CACxC,KAAM,EAAE,QAAQ,SAAS,CACzB,UAAW,EAAE,QAAQ,QAAQ,CAC9B,CAAC,CACI,EAA4B,EAAE,OAAO,CACzC,KAAM,EAAE,QAAQ,SAAS,CACzB,UAAW,EAAE,QAAQ,SAAS,CAC9B,MAAO,EAAE,SAAS,EAAkB,CACrC,CAAC,CACI,EAA4B,EAAE,OAAO,CACzC,KAAM,EAAE,QAAQ,UAAU,CAC1B,UAAW,EAAE,QAAQ,QAAQ,CAC7B,IAAK,EACL,IAAK,EACN,CAAC,CACI,EAA6B,EAAE,OAAO,CAC1C,KAAM,EAAE,QAAQ,UAAU,CAC1B,UAAW,EAAE,QAAQ,SAAS,CAC9B,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,MACR,KAAM,CAAE,QAAO,CACf,OAAQ,EACT,CAAC,EACC"}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { t as AnalogOutputLevel } from "./common-ClinPNdn.mjs";
|
|
2
|
+
import { n as Device } from "./management-DYOPvugC.mjs";
|
|
3
|
+
import { UpFetch } from "up-fetch";
|
|
4
|
+
import * as v from "valibot";
|
|
5
|
+
|
|
6
|
+
//#region src/api/gpio.d.ts
|
|
7
|
+
declare const analogInputConfiguration: v.ObjectSchema<{
|
|
8
|
+
readonly mode: v.LiteralSchema<"analog", undefined>;
|
|
9
|
+
readonly direction: v.LiteralSchema<"input", undefined>;
|
|
10
|
+
}, undefined>;
|
|
11
|
+
declare const analogOutputConfiguration: v.ObjectSchema<{
|
|
12
|
+
readonly mode: v.LiteralSchema<"analog", undefined>;
|
|
13
|
+
readonly direction: v.LiteralSchema<"output", undefined>;
|
|
14
|
+
readonly value: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 24, undefined>]>, undefined>;
|
|
15
|
+
}, undefined>;
|
|
16
|
+
declare const digitalInputConfiguration: v.ObjectSchema<{
|
|
17
|
+
readonly mode: v.LiteralSchema<"digital", undefined>;
|
|
18
|
+
readonly direction: v.LiteralSchema<"input", undefined>;
|
|
19
|
+
readonly vil: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
20
|
+
readonly vih: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
21
|
+
}, undefined>;
|
|
22
|
+
declare const digitalOutputConfiguration: v.ObjectSchema<{
|
|
23
|
+
readonly mode: v.LiteralSchema<"digital", undefined>;
|
|
24
|
+
readonly direction: v.LiteralSchema<"output", undefined>;
|
|
25
|
+
readonly value: v.BooleanSchema<undefined>;
|
|
26
|
+
readonly vol: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
27
|
+
readonly voh: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
28
|
+
readonly vil: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
29
|
+
readonly vih: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
30
|
+
}, undefined>;
|
|
31
|
+
type AnalogInputConfiguration = v.InferOutput<typeof analogInputConfiguration>;
|
|
32
|
+
type AnalogOutputConfiguration = v.InferOutput<typeof analogOutputConfiguration>;
|
|
33
|
+
type DigitalInputConfiguration = v.InferOutput<typeof digitalInputConfiguration>;
|
|
34
|
+
type DigitalOutputConfiguration = v.InferOutput<typeof digitalOutputConfiguration>;
|
|
35
|
+
declare const partialAnalogOutputConfiguration: Omit<v.ObjectSchema<{
|
|
36
|
+
readonly mode: v.LiteralSchema<"analog", undefined>;
|
|
37
|
+
readonly direction: v.LiteralSchema<"output", undefined>;
|
|
38
|
+
readonly value: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 24, undefined>]>, undefined>;
|
|
39
|
+
}, undefined>, "~types" | "~run" | "~standard" | "entries"> & {
|
|
40
|
+
readonly entries: Omit<{
|
|
41
|
+
readonly mode: v.LiteralSchema<"analog", undefined>;
|
|
42
|
+
readonly direction: v.LiteralSchema<"output", undefined>;
|
|
43
|
+
readonly value: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 24, undefined>]>, undefined>;
|
|
44
|
+
}, "mode" | "direction">;
|
|
45
|
+
readonly '~standard': v.StandardProps<{
|
|
46
|
+
value?: number | undefined;
|
|
47
|
+
}, {
|
|
48
|
+
value?: number | undefined;
|
|
49
|
+
}>;
|
|
50
|
+
readonly '~run': (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
|
|
51
|
+
value?: number | undefined;
|
|
52
|
+
}, v.NumberIssue | v.MinValueIssue<number, 0> | v.ObjectIssue | v.MaxValueIssue<number, 24>>;
|
|
53
|
+
readonly '~types'?: {
|
|
54
|
+
readonly input: {
|
|
55
|
+
value?: number | undefined;
|
|
56
|
+
};
|
|
57
|
+
readonly output: {
|
|
58
|
+
value?: number | undefined;
|
|
59
|
+
};
|
|
60
|
+
readonly issue: v.NumberIssue | v.MinValueIssue<number, 0> | v.ObjectIssue | v.MaxValueIssue<number, 24>;
|
|
61
|
+
} | undefined;
|
|
62
|
+
};
|
|
63
|
+
type PartialAnalogOutputConfiguration = v.InferOutput<typeof partialAnalogOutputConfiguration>;
|
|
64
|
+
declare const partialDigitalInputConfiguration: Omit<v.ObjectSchema<{
|
|
65
|
+
readonly mode: v.LiteralSchema<"digital", undefined>;
|
|
66
|
+
readonly direction: v.LiteralSchema<"input", undefined>;
|
|
67
|
+
readonly vil: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
68
|
+
readonly vih: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
69
|
+
}, undefined>, "~types" | "~run" | "~standard" | "entries"> & {
|
|
70
|
+
readonly entries: Omit<{
|
|
71
|
+
readonly mode: v.LiteralSchema<"digital", undefined>;
|
|
72
|
+
readonly direction: v.LiteralSchema<"input", undefined>;
|
|
73
|
+
readonly vil: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
74
|
+
readonly vih: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
75
|
+
}, "mode" | "direction">;
|
|
76
|
+
readonly '~standard': v.StandardProps<{
|
|
77
|
+
vil: number;
|
|
78
|
+
vih: number;
|
|
79
|
+
}, {
|
|
80
|
+
vil: number;
|
|
81
|
+
vih: number;
|
|
82
|
+
}>;
|
|
83
|
+
readonly '~run': (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
|
|
84
|
+
vil: number;
|
|
85
|
+
vih: number;
|
|
86
|
+
}, v.NumberIssue | v.ObjectIssue | v.MaxValueIssue<number, 24> | v.MinValueIssue<number, -24>>;
|
|
87
|
+
readonly '~types'?: {
|
|
88
|
+
readonly input: {
|
|
89
|
+
vil: number;
|
|
90
|
+
vih: number;
|
|
91
|
+
};
|
|
92
|
+
readonly output: {
|
|
93
|
+
vil: number;
|
|
94
|
+
vih: number;
|
|
95
|
+
};
|
|
96
|
+
readonly issue: v.NumberIssue | v.ObjectIssue | v.MaxValueIssue<number, 24> | v.MinValueIssue<number, -24>;
|
|
97
|
+
} | undefined;
|
|
98
|
+
};
|
|
99
|
+
type PartialDigitalInputConfiguration = v.InferOutput<typeof partialDigitalInputConfiguration>;
|
|
100
|
+
declare const partialDigitalOutputConfiguration: Omit<v.ObjectSchema<{
|
|
101
|
+
readonly mode: v.LiteralSchema<"digital", undefined>;
|
|
102
|
+
readonly direction: v.LiteralSchema<"output", undefined>;
|
|
103
|
+
readonly value: v.BooleanSchema<undefined>;
|
|
104
|
+
readonly vol: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
105
|
+
readonly voh: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
106
|
+
readonly vil: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
107
|
+
readonly vih: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
108
|
+
}, undefined>, "~types" | "~run" | "~standard" | "entries"> & {
|
|
109
|
+
readonly entries: Omit<{
|
|
110
|
+
readonly mode: v.LiteralSchema<"digital", undefined>;
|
|
111
|
+
readonly direction: v.LiteralSchema<"output", undefined>;
|
|
112
|
+
readonly value: v.BooleanSchema<undefined>;
|
|
113
|
+
readonly vol: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
114
|
+
readonly voh: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
115
|
+
readonly vil: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
116
|
+
readonly vih: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
117
|
+
}, "mode" | "direction">;
|
|
118
|
+
readonly '~standard': v.StandardProps<{
|
|
119
|
+
value: boolean;
|
|
120
|
+
vil: number;
|
|
121
|
+
vih: number;
|
|
122
|
+
vol: number;
|
|
123
|
+
voh: number;
|
|
124
|
+
}, {
|
|
125
|
+
value: boolean;
|
|
126
|
+
vil: number;
|
|
127
|
+
vih: number;
|
|
128
|
+
vol: number;
|
|
129
|
+
voh: number;
|
|
130
|
+
}>;
|
|
131
|
+
readonly '~run': (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
|
|
132
|
+
value: boolean;
|
|
133
|
+
vil: number;
|
|
134
|
+
vih: number;
|
|
135
|
+
vol: number;
|
|
136
|
+
voh: number;
|
|
137
|
+
}, v.NumberIssue | v.MinValueIssue<number, 0> | v.BooleanIssue | v.ObjectIssue | v.MaxValueIssue<number, 24> | v.MinValueIssue<number, -24>>;
|
|
138
|
+
readonly '~types'?: {
|
|
139
|
+
readonly input: {
|
|
140
|
+
value: boolean;
|
|
141
|
+
vil: number;
|
|
142
|
+
vih: number;
|
|
143
|
+
vol: number;
|
|
144
|
+
voh: number;
|
|
145
|
+
};
|
|
146
|
+
readonly output: {
|
|
147
|
+
value: boolean;
|
|
148
|
+
vil: number;
|
|
149
|
+
vih: number;
|
|
150
|
+
vol: number;
|
|
151
|
+
voh: number;
|
|
152
|
+
};
|
|
153
|
+
readonly issue: v.NumberIssue | v.MinValueIssue<number, 0> | v.BooleanIssue | v.ObjectIssue | v.MaxValueIssue<number, 24> | v.MinValueIssue<number, -24>;
|
|
154
|
+
} | undefined;
|
|
155
|
+
};
|
|
156
|
+
type PartialDigitalOutputConfiguration = v.InferOutput<typeof partialDigitalOutputConfiguration>;
|
|
157
|
+
declare const syncConfiguration: v.ObjectSchema<{
|
|
158
|
+
readonly action: v.PicklistSchema<["release", "hold"], "Invalid sync action">;
|
|
159
|
+
}, undefined>;
|
|
160
|
+
type SyncConfiguration = v.InferOutput<typeof syncConfiguration>;
|
|
161
|
+
declare class GpioApi {
|
|
162
|
+
private readonly fetch;
|
|
163
|
+
private count;
|
|
164
|
+
constructor(fetch: UpFetch, device: Device);
|
|
165
|
+
/**
|
|
166
|
+
* Resets all IO configurations to default.
|
|
167
|
+
*/
|
|
168
|
+
reset(): Promise<void>;
|
|
169
|
+
/**
|
|
170
|
+
* Access a specific digital IO pin by id.
|
|
171
|
+
* @param io The IO pin id.
|
|
172
|
+
* @returns The digital IO instance.
|
|
173
|
+
*/
|
|
174
|
+
digital(io: number): DigitalIO;
|
|
175
|
+
/**
|
|
176
|
+
* Access a specific analog IO pin by id.
|
|
177
|
+
* @param io The IO pin id.
|
|
178
|
+
* @returns The analog IO instance.
|
|
179
|
+
*/
|
|
180
|
+
analog(io: number): AnalogIO;
|
|
181
|
+
/**
|
|
182
|
+
* Holds the current state of all GPIO pins.
|
|
183
|
+
* @returns The applied sync state.
|
|
184
|
+
*/
|
|
185
|
+
hold(): Promise<SyncConfiguration>;
|
|
186
|
+
/**
|
|
187
|
+
* Releases control of the IO pins, allowing external control.
|
|
188
|
+
*
|
|
189
|
+
* This also sets the device as a slave.
|
|
190
|
+
*
|
|
191
|
+
* @returns The applied sync state.
|
|
192
|
+
*/
|
|
193
|
+
release(): Promise<SyncConfiguration>;
|
|
194
|
+
}
|
|
195
|
+
declare class DigitalIO {
|
|
196
|
+
private readonly fetch;
|
|
197
|
+
readonly id: number;
|
|
198
|
+
constructor(fetch: UpFetch, id: number);
|
|
199
|
+
/**
|
|
200
|
+
* Configure the pin as a digital input.
|
|
201
|
+
* @param config The digital input configuration.
|
|
202
|
+
* @returns The applied configuration.
|
|
203
|
+
*/
|
|
204
|
+
configure_input(config: PartialDigitalInputConfiguration): Promise<DigitalInputConfiguration>;
|
|
205
|
+
/**
|
|
206
|
+
* Configures the pin as a digital output.
|
|
207
|
+
* @param config The digital output configuration.
|
|
208
|
+
* @returns The applied configuration.
|
|
209
|
+
*/
|
|
210
|
+
configure_output(config: PartialDigitalOutputConfiguration): Promise<DigitalOutputConfiguration>;
|
|
211
|
+
/**
|
|
212
|
+
* Reads the current state of the pin.
|
|
213
|
+
* @returns The current state of the pin.
|
|
214
|
+
*/
|
|
215
|
+
read(): Promise<boolean>;
|
|
216
|
+
/**
|
|
217
|
+
* Writes a value to the pin.
|
|
218
|
+
* @param value The value to write.
|
|
219
|
+
* @returns The written value.
|
|
220
|
+
*/
|
|
221
|
+
write(value: boolean): Promise<boolean>;
|
|
222
|
+
}
|
|
223
|
+
declare class AnalogIO {
|
|
224
|
+
private readonly fetch;
|
|
225
|
+
readonly id: number;
|
|
226
|
+
constructor(fetch: UpFetch, id: number);
|
|
227
|
+
/**
|
|
228
|
+
* Configures the pin as an analog input.
|
|
229
|
+
* @returns The applied configuration.
|
|
230
|
+
* @returns The applied configuration.
|
|
231
|
+
*/
|
|
232
|
+
configure_input(): Promise<AnalogInputConfiguration>;
|
|
233
|
+
/**
|
|
234
|
+
* Configures the pin as an analog output.
|
|
235
|
+
* @param config The analog output configuration.
|
|
236
|
+
* @returns The applied configuration.
|
|
237
|
+
*/
|
|
238
|
+
configure_output(value: AnalogOutputLevel): Promise<AnalogOutputConfiguration>;
|
|
239
|
+
/**
|
|
240
|
+
* Reads the current state of the pin.
|
|
241
|
+
* @returns The current state of the pin.
|
|
242
|
+
*/
|
|
243
|
+
read(): Promise<number>;
|
|
244
|
+
/**
|
|
245
|
+
* Writes a value to the pin.
|
|
246
|
+
* @param value The value to write.
|
|
247
|
+
* @returns The written value.
|
|
248
|
+
*/
|
|
249
|
+
write(value: number): Promise<number>;
|
|
250
|
+
}
|
|
251
|
+
//#endregion
|
|
252
|
+
export { DigitalInputConfiguration as a, PartialAnalogOutputConfiguration as c, SyncConfiguration as d, DigitalIO as i, PartialDigitalInputConfiguration as l, AnalogInputConfiguration as n, DigitalOutputConfiguration as o, AnalogOutputConfiguration as r, GpioApi as s, AnalogIO as t, PartialDigitalOutputConfiguration as u };
|
|
253
|
+
//# sourceMappingURL=gpio-D4KyCVtn.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpio-D4KyCVtn.d.mts","names":[],"sources":["../src/api/gpio.ts"],"sourcesContent":[],"mappings":";;;;;;cASM,0BAAwB,CAAA,CAAA;EAAxB,SAAA,IAAA,iBAGJ,CAAA,QAAA,EAAA,SAAA,CAAA;;;cACI,yBAJwB,EAIC,CAAA,CAAA,YAJD,CAAA;EAAA,SAAA,IAAA,iBAAA,CAAA,QAAA,EAAA,SAAA,CAAA;EAIxB,SAAA,SAAA,iBAIJ,CAAA,QAAA,EAAA,SAAA,CAAA;;;c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;;qBArCT,QAAQ;;;;;;0BAaH,oBAAoB,QAAQ;;;;;UAetC;;;;;;wBASc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require(`./chunk-DjWAcSYV.cjs`),t=require(`./common-ix04NEFn.cjs`);let n=require(`valibot`);n=e.t(n);const r=n.picklist([`release`,`hold`],`Invalid sync action`),i=n.object({mode:n.literal(`analog`),direction:n.literal(`input`)}),a=n.object({mode:n.literal(`analog`),direction:n.literal(`output`),value:n.optional(t.n)}),o=n.object({mode:n.literal(`digital`),direction:n.literal(`input`),vil:t.t,vih:t.t}),s=n.object({mode:n.literal(`digital`),direction:n.literal(`output`),value:t.r,vol:t.n,voh:t.n,vil:t.t,vih:t.t});n.omit(a,[`direction`,`mode`]),n.omit(o,[`direction`,`mode`]),n.omit(s,[`direction`,`mode`]);const c=n.object({value:t.r}),l=n.object({value:t.t}),u=n.object({action:r});var d=class{count;constructor(e,t){this.fetch=e,this.count=t.capabilities.io.count}reset(){return this.fetch(`/gpio/reset`,{method:`POST`,parseResponse:()=>{}})}digital(e){if(e<0||e>=this.count)throw Error(`Invalid GPIO pin ${e} (RESOURCE_NOT_FOUND)\n Suggestion: Use a pin number between 0 and ${this.count-1}\n Path: /gpio/${e}`);return new f(this.fetch,e)}analog(e){if(e<0||e>=this.count)throw Error(`Invalid GPIO pin ${e} (RESOURCE_NOT_FOUND)\n Suggestion: Use a pin number between 0 and ${this.count-1}\n Path: /gpio/${e}`);return new p(this.fetch,e)}hold(){return this.fetch(`/gpio/sync`,{method:`POST`,body:{action:`hold`},schema:u})}release(){return this.fetch(`/gpio/sync`,{method:`POST`,body:{action:`release`},schema:u})}},f=class{constructor(e,t){this.fetch=e,this.id=t}configure_input(e){return this.fetch(`/gpio/${this.id}/config`,{method:`PATCH`,body:n.parse(o,{...e,mode:`digital`,direction:`input`}),schema:o})}configure_output(e){return this.fetch(`/gpio/${this.id}/config`,{method:`PATCH`,body:n.parse(s,{...e,mode:`digital`,direction:`output`}),schema:s})}async read(){return(await this.fetch(`/gpio/${this.id}/state`,{schema:c})).value}async write(e){return(await this.fetch(`/gpio/${this.id}/state`,{method:`PUT`,body:{value:e},schema:c})).value}},p=class{constructor(e,t){this.fetch=e,this.id=t}configure_input(){return this.fetch(`/gpio/${this.id}/config`,{method:`PATCH`,body:{mode:`analog`,direction:`input`},schema:i})}configure_output(e){return this.fetch(`/gpio/${this.id}/config`,{method:`PATCH`,body:n.parse(a,{value:e,mode:`analog`,direction:`output`}),schema:a})}async read(){return(await this.fetch(`/gpio/${this.id}/state`,{schema:l})).value}async write(e){return(await this.fetch(`/gpio/${this.id}/state`,{method:`PUT`,body:{value:e},schema:l})).value}};Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return p}});
|
|
2
|
+
//# sourceMappingURL=gpio-DSTG-dmv.cjs.map
|