forked from WebThingsIO/webthing-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
example: platform: Add play-phat board
Note that gpio_key could overlap, see later makefile Change-Id: I0de4ace8a21a0592e5e09e692d43aa04ed7488e8 Origin: https://github.com/rzr/webthing-iotjs Forwarded: WebThingsIO#31 Signed-off-by: Philippe Coval <p.coval@samsung.com>
- Loading branch information
Showing
1 changed file
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// -*- 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 GpioProperty = require('../gpio/gpio-property'); | ||
|
||
class PlayPHatThing extends Thing { | ||
constructor(name, type, description) { | ||
super(name || 'PlayPHat', | ||
type || [], | ||
description || 'A web connected Play RaspberryPi Hat'); | ||
const _this = this; | ||
this.gpioProperties = [ | ||
new GpioProperty(this, 'Left', false, | ||
{description: | ||
'SW1 Sensor Button on GPIO4 (Pin7)'}, | ||
{direction: 'in', pin: 4}), | ||
new GpioProperty(this, 'Right', false, | ||
{description: | ||
'SW2 Sensor button on GPIO17 (Pin11)'}, | ||
{direction: 'in', pin: 17}), | ||
new GpioProperty(this, 'Up', false, | ||
{description: | ||
'SW3 Sensor button on GPIO22 (Pin15)'}, | ||
{direction: 'in', pin: 22}), | ||
new GpioProperty(this, 'Down', false, | ||
{description: | ||
'SW4 Sensor button on GPIO27 (Pin13)'}, | ||
{direction: 'in', pin: 27}), | ||
new GpioProperty(this, 'A', false, | ||
{description: | ||
'SW5 Sensor button on GPIO19 (Pin35)'}, | ||
{direction: 'in', pin: 19}), | ||
new GpioProperty(this, 'B', false, | ||
{description: | ||
'SW6 Sensor button on GPIO26 (Pin37)'}, | ||
{direction: 'in', pin: 26}), | ||
new GpioProperty(this, 'Start', false, | ||
{description: | ||
'SW7 Sensor button on GPIO5 (Pin29)'}, | ||
{direction: 'in', pin: 5}), | ||
new GpioProperty(this, 'Select', false, | ||
{description: | ||
'SW8 Sensor button on GPIO6 (Pin31)'}, | ||
{direction: 'in', pin: 6}), | ||
]; | ||
this.gpioProperties.forEach((property) => { | ||
_this.addProperty(property); | ||
}); | ||
} | ||
|
||
close() { | ||
this.gpioProperties.forEach((property) => { | ||
property.close && property.close(); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = function() { | ||
if (!module.exports.instance) { | ||
module.exports.instance = new PlayPHatThing(); | ||
} | ||
return module.exports.instance; | ||
}; |