opengpio
Version:
A performant c++ based general purpose GPIO controller for linux devices. OpenGPIO is written using libgpiod, line & chip based abstractions.
25 lines (21 loc) • 690 B
text/typescript
import binding from 'bindings';
import { type OpenGpioBindings } from './types';
import { debug as debugLogger } from './debug';
const debug = debugLogger.extend('bindings');
let bindings: OpenGpioBindings;
const mocked = process.env.OPENGPIO_MOCKED === 'true';
if (!mocked) {
debug('Loading bindings...');
bindings = binding('opengpio');
} else {
// Mocked bindings
debug('Using mocked bindings...');
bindings = {
info: () => 'mocked',
input: () => [() => true, () => {}],
output: () => [() => {}, () => {}],
pwm: () => [() => {}, () => {}, () => {}],
watch: () => [() => true, () => {}]
};
}
export { bindings, mocked };