summaryrefslogtreecommitdiff
path: root/peripheral/libmraa/jsstub/test/lightbulb.js
blob: f05ba57abeaf1b3d12e733d1a3efdb766c9e021a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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;
})();