Skip to content

Commit

Permalink
adc: Add Adc class
Browse files Browse the repository at this point in the history
To abstract different ADC or sysfs API,

Note: later this class could land later in separate project
(ie: gpio, iotjs-node? sysfs-node?)
but since it's trivial let's share it here.

Relate-to: EnotionZ/gpio#53
Change-Id: I923159901d3af3e1990ccf3e1510d561c2e0783b
Signed-off-by: Philippe Coval <p.coval@samsung.com>
  • Loading branch information
rzr committed Oct 1, 2018
1 parent 0639ea5 commit c3bedd2
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions example/platform/adc/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// -*- mode: js; js-indent-level:2; -*-
// SPDX-License-Identifier: ISC
/**
* Copyright 2018-present Samsung Electronics France SAS, and other contributors
*
* This Source Code Form is subject to the terms of the ICS Licence:
* https://spdx.org/licenses/ISC.html#licenseText
*/

const fs = require('fs');

function Adc() {
this.open = function(config, callback) {
this.config = config;
fs.access(config.device, fs.R_OK, callback);
return this;
};

this.readSync = function() {
const contents = fs.readFileSync(this.config.device, 'ascii');
return contents;
};

this.closeSync = function() {
};
}

module.exports = new Adc();

0 comments on commit c3bedd2

Please sign in to comment.