Add JavaScript mraaStub project
Signed-off-by: David Antler <david.a.antler@intel.com> Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
committed by
Brendan Le Foll
parent
a321d6707f
commit
1cfdfcddc6
32
jsstub/test/lightbulb.js
Normal file
32
jsstub/test/lightbulb.js
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @fileoverview Implementation of a LightBulb class abstraction
|
||||
*
|
||||
*/
|
||||
|
||||
module.exports = (function() {
|
||||
"use strict";
|
||||
var m = require('../index');
|
||||
|
||||
/**
|
||||
* Constructor for a new LightBulb
|
||||
* @class LightBulb
|
||||
*
|
||||
* @classdesc This class abstracts access to the control and data registers
|
||||
* on an imaginary lightbulb.
|
||||
* @param {Object} A libmraa I2c object, initialized
|
||||
*/
|
||||
function LightBulb (i2cInterface) {
|
||||
var self = this;
|
||||
self._i2cInterface = i2cInterface;
|
||||
|
||||
self.getBrightness = function() {
|
||||
// Presume our brightness data is one byte at offset 4
|
||||
return self._i2cInterface.readReg(4);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
return LightBulb;
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user