From 4ff9508933b78c065721990d133b9a6cd71cc45e Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 19 Nov 2025 10:47:57 -0800 Subject: [PATCH] wip --- src/hq.ts | 47 ----------------------------------------------- src/phone.ts | 6 +++--- 2 files changed, 3 insertions(+), 50 deletions(-) delete mode 100644 src/hq.ts diff --git a/src/hq.ts b/src/hq.ts deleted file mode 100644 index 089dbd8..0000000 --- a/src/hq.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { GPIO } from "./pins" - -console.log(`kill -9 ${process.pid}`) - -const gpio = new GPIO({ resetOnClose: true }) - -// // Blink an LED -using led = gpio.output(21) - -// Read a button -using inputs = gpio.inputGroup({ - button: { pin: 20, pull: "up", debounce: 10 }, - switch: { pin: 16, pull: "up", debounce: 10 } -}) - -led.value = inputs.pins.button.value - -const iteratorEvents = new Promise(async (resolve) => { - for await (const event of inputs.events()) { - if (event.pin === "button") { - console.log(`🌭`, event.value) - led.value = event.value - } - } -}) - -const switchEvent = new Promise(async (resolve) => { - await inputs.pins.switch.waitForValue(0) - console.log("Switch pressed!") - resolve() -}) - -process.on("SIGINT", () => { - inputs.close() - led.close() - process.exit(0) -}) - -process.on("SIGTERM", () => { - inputs.close() - - process.exit(0) -}) - -await Promise.race([iteratorEvents, switchEvent]) - -console.log(`👋 Goodbye!`) \ No newline at end of file diff --git a/src/phone.ts b/src/phone.ts index 8bbf597..3040093 100644 --- a/src/phone.ts +++ b/src/phone.ts @@ -25,9 +25,9 @@ type PhoneContext = { const gpio = new GPIO({ resetOnClose: true }) using ringer = gpio.output(17) using inputs = gpio.inputGroup({ - hook: { pin: 27, debounce: 50 }, - rotaryInUse: { pin: 22, debounce: 50 }, - rotaryNumber: { pin: 23, debounce: 10 }, + hook: { pin: 27, debounce: 3 }, + rotaryInUse: { pin: 22, debounce: 3 }, + rotaryNumber: { pin: 23, debounce: 3 }, }) export const startPhone = async (agentId: string, apiKey: string) => {