diff --git a/.gitignore b/.gitignore index 337b8ef..0b1882b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ x.ts +x.sh sandbox.ts dump.ts test diff --git a/mod.ts b/mod.ts index 7f16cc9..834d4a9 100644 --- a/mod.ts +++ b/mod.ts @@ -240,5 +240,15 @@ export class Pin { ); } - // TODO: read 'n' bits and pipe to file for + /** + * queues up an instruction to request a number of bits while sleeping in between each fetch. + * @param n number of bits to read + * @param toFile file to pipe the bits to + * @param sleep how much to sleep in between each bit fetch. + */ + readNBits(n: number, toFile: string, sleep = 0){ + instructionsQueue.getInstance().add( + `for ((i = 0 ; i < ${n} ; i++)); do head -n 1 /sys/class/gpio/gpio${this.number}/value >> ${toFile}; sleep ${sleep}; done` + ); + } }