Skip to content

Commit c3bedd2

Browse files
committed
adc: Add Adc class
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 <[email protected]>
1 parent 0639ea5 commit c3bedd2

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

example/platform/adc/index.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// -*- mode: js; js-indent-level:2; -*-
2+
// SPDX-License-Identifier: ISC
3+
/**
4+
* Copyright 2018-present Samsung Electronics France SAS, and other contributors
5+
*
6+
* This Source Code Form is subject to the terms of the ICS Licence:
7+
* https://spdx.org/licenses/ISC.html#licenseText
8+
*/
9+
10+
const fs = require('fs');
11+
12+
function Adc() {
13+
this.open = function(config, callback) {
14+
this.config = config;
15+
fs.access(config.device, fs.R_OK, callback);
16+
return this;
17+
};
18+
19+
this.readSync = function() {
20+
const contents = fs.readFileSync(this.config.device, 'ascii');
21+
return contents;
22+
};
23+
24+
this.closeSync = function() {
25+
};
26+
}
27+
28+
module.exports = new Adc();

0 commit comments

Comments
 (0)