Skip to content

Commit

Permalink
platform: Add Edison board to test PWM (WebThingsIO#99)
Browse files Browse the repository at this point in the history
It was tested on Intel edison on PWM0
GPIO12 must be manually configured first
using:

```sh
gpio=12
echo $gpio | sudo tee -a /sys/class/gpio/export
echo out | sudo tee /sys/class/gpio/gpio$gpio/direction
echo mode1 | sudo tee /sys/kernel/debug/gpio_debug/gpio${gpio}/current_pinmux
```

More insights at:

https://github.com/rzr/webthing-iotjs/wiki/Actuator

Relate-to: rzr/webthing-iotjs#3
Change-Id: I6f587a840e8c429d91ba2491e7cddfdfab66bf4b
Signed-off-by: Philippe Coval <p.coval@samsung.com>
  • Loading branch information
rzr committed Jul 5, 2019
1 parent bd69220 commit be81085
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions example/platform/board/edison.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// -*- mode: js; js-indent-level:2; -*-
// SPDX-License-Identifier: MPL-2.0

/**
*
* Copyright 2018-present Samsung Electronics France SAS, and other contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.*
*/

const {
Thing,
} = require('webthing');

const PwmProperty = require('../pwm/pwm-property');

class EdisonThing extends Thing {
constructor(name, type, description) {
super('urn:dev:ops:my-edison-1234',
name || 'Edison',
type || [],
description || 'A web connected Edison');
const self = this;
this.pinProperties = [
new PwmProperty(this, 'PWM0', 50, {
description: 'Analog port of Edison',
}),
];
this.pinProperties.forEach((property) => {
self.addProperty(property);
});
}

close() {
this.pinProperties.forEach((property) => {
property.close && property.close();
});
}
}

module.exports = function() {
if (!module.exports.instance) {
module.exports.instance = new EdisonThing();
}
return module.exports.instance;
};

0 comments on commit be81085

Please sign in to comment.