',{'class':'mui-tabs__pane mui--is-active',id:(temp + '-pane')}).append(blankChart));
+
+ blankChart = this.generateBlankGraph('pressure');
+
+ // this.$id.append(blankChart);
+ this.$id.append($('
',{'class':'mui-tabs__pane',id:(pressure + '-pane')}).append(blankChart));
+
+
this.$result.temp = $('#' + temp);
this.$result.pressure = $('#' + pressure);
diff --git a/platforms/android/assets/www/js/device/CC2650/cc2650_luxometer.js b/platforms/android/assets/www/js/device/CC2650/cc2650_luxometer.js
index 15b4c03..5276547 100644
--- a/platforms/android/assets/www/js/device/CC2650/cc2650_luxometer.js
+++ b/platforms/android/assets/www/js/device/CC2650/cc2650_luxometer.js
@@ -15,17 +15,16 @@ var CC2650_LUX = function(deviceId) {
this.deviceID = deviceId;
this.capabilityID = 'F000AA70-0451-4000-B000-000000000000';
this.serviceDef = {
- service: 'F000AA70-0451-4000-B000-000000000000',
- data: 'F000AA71-0451-4000-B000-000000000000',
- notification: 'F0002902-0451-4000-B000-000000000000',
- configuration: 'F000AA72-0451-4000-B000-000000000000',
- period: 'F000AA73-0451-4000-B000-000000000000'
+ service: 'F000AA70-0451-4000-B000-000000000000',
+ data: 'F000AA71-0451-4000-B000-000000000000',
+ notification: 'F0002902-0451-4000-B000-000000000000',
+ configuration: 'F000AA72-0451-4000-B000-000000000000',
+ period: 'F000AA73-0451-4000-B000-000000000000'
- };
+ };
this.$result = {temp: null, pressure: null};
-
-
+ this.data = [];
this.startService = function() {
'use strict';
@@ -33,71 +32,85 @@ var CC2650_LUX = function(deviceId) {
console.log('Starting CC2650 Luxometer Service on ', this.deviceID);
console.log(this.serviceDef);
- //this.insertFrame();
+ this.insertFrame();
- ble.startNotification(this.deviceID, this.serviceDef.service, this.serviceDef.data, this.onLuxData.bind(this), this.onError);
+ ble.startNotification(this.deviceID,
+ this.serviceDef.service,
+ this.serviceDef.data,
+ this.onLuxData.bind(this),
+ this.onError);
- //Turn on barometer
+ //Turn on luxometer
var luxConfig = new Uint8Array(1);
luxConfig[0] = 0x01;
- ble.write(this.deviceID, this.serviceDef.service, this.serviceDef.configuration, luxConfig.buffer,
- function() { console.log('Started luxometer.'); },this.onError);
+ ble.write(this.deviceID,
+ this.serviceDef.service,
+ this.serviceDef.configuration,
+ luxConfig.buffer,
+ function() { console.log('Started luxometer.'); },
+ this.onError);
}
};
- this.sensorBarometerConvert = function(data) {
- return (data / 100);
-
- };
-
this.onLuxData = function(data) {
- var pStr;
- var tStr;
- console.log(data);
- var message;
- var a = new Uint8Array(data);
- var b = new Uint16Array(data);
- console.log('lux a',a[0],a[1]);
- console.log('lux b',b[0]);
- console.log('lux b',b[0].toString(2));
+ var m, e, lux;
+ // Console.log(data);
-var m = b[0] | b[0] << 4;
- console.log(m.toString(2));
+ var raw = new Uint16Array(data);
- //0-2 Temp
- //3-5 Pressure
+ m = raw & 0x0FFF;
+ e = (raw & 0xF000) >> 12;
- console.log('Luxometer:', this.state);
- };
+ lux = m * (0.01 * Math.pow(2.0, e));
+
+ this.state = [lux.toFixed(2), 'lux'].join(' ');
+
+
+ //This.storeData(parseInt(lux));
+ this.storeData(lux);
+
+ this.$result.text(this.state);
+
+ // Console.log('Luxometer:', this.state);
+ };
+
+ this.animateGraph = function() {
+ this.simpleGraph(this.data, '');
+ };
this.insertFrame = function() {
var self = this;
- console.log('Overloading...');
+
// Call the parent displayForm first...
this.superClass_.insertFrame.call(self);
- var temp = this.frameID + '-t';
- var pressure = this.frameID + '-p';
+ var lux = this.frameID + '-l';
+
var row = $('
', {class: 'mui-row'});
- $('
', { class: 'mui-col-xs-3 mui--text-accent', text: 'Temp:'}).appendTo(row);
+ $('
',
+ {class: 'mui-col-xs-4 mui--text-accent', text: 'Luminosity:'}).appendTo(
+ row);
- $('
', { class: 'mui-col-xs-3 mui--text-white', id: temp}).appendTo(row);
- $('
', { class: 'mui-col-xs-3 mui--text-accent', text: 'Pressure:'}).appendTo(row);
-
- $('
', { class: 'mui-col-xs-3 mui--text-white', id: pressure}).appendTo(row);
+ $('
',
+ {class: 'mui-col-xs-8 mui--text-white', id: lux}).appendTo(row);
this.$id.append(row);
- this.$result.temp = $('#' + temp);
- this.$result.pressure = $('#' + pressure);
+
+ var blankChart = this.generateBlankGraph();
+
+ this.$id.append(blankChart);
+
+ this.$result = $('#' + lux);
+
+ //Window.requestAnimFrame(this.animateFrame.bind(this));
};
};
-
inheritsFrom(CC2650_LUX, CAPABILITY);
diff --git a/platforms/android/assets/www/js/index.js b/platforms/android/assets/www/js/index.js
index e1adade..df89e21 100644
--- a/platforms/android/assets/www/js/index.js
+++ b/platforms/android/assets/www/js/index.js
@@ -20,205 +20,460 @@
/* global BATTERY, BUTTON */
var app = {
+ stop: false,
+ log: {},
activeServices: [],
- serviceList: {
- 1800: 'Generic Access',
- 1801: 'Generic Attribute',
- '180a': 'Device Information',
- FFE0: 'Button',
- 'F000AA00-0451-4000-B000-000000000000': 'Temperature',
- 'F000AA20-0451-4000-B000-000000000000': 'Humidity',
- 'F000AA80-0451-4000-B000-000000000000': 'Accelerometer',
- 'F000AA40-0451-4000-B000-000000000000': 'Barometer'
-
- },
list: {},
- button: {
- service: 'FFE0',
- data: 'FFE1', // Bit 2: side key, Bit 1- right key, Bit 0 –left key
- },
- accelerometer: {
- service: 'F000AA80-0451-4000-B000-000000000000',
- data: 'F000AA81-0451-4000-B000-000000000000', // Read/notify 3 bytes X : Y : Z
- notification: 'F0002902-0451-4000-B000-000000000000',
- configuration: 'F000AA82-0451-4000-B000-000000000000', // Read/write 1 byte
- period: 'F000AA83-0451-4000-B000-000000000000' // Read/write 1 byte Period = [Input*10]ms
- },
- barometer: {
- service: 'F000AA40-0451-4000-B000-000000000000',
- data: 'F000AA41-0451-4000-B000-000000000000',
- notification: 'F0002902-0451-4000-B000-000000000000',
- configuration: 'F000AA42-0451-4000-B000-000000000000',
- period: 'F000AA43-0451-4000-B000-000000000000'
- },
+ manufactureDecoder: new MANUFACTUREDECODER(),
// Application Constructor
initialize: function() {
- this.bindEvents();
+ this.bindEvents();
+ },
+
+ arrayBufferToIntArray: function(buffer) {
+ var result;
+
+ if (buffer) {
+ var typedArray = new Uint8Array(buffer);
+ result = [];
+ for (var i = 0; i < typedArray.length; i++) {
+ result[i] = typedArray[i];
+ }
+ }
+
+ return result;
},
- doScan: function() {
+
+ parseAdvertisingData: function(bytes) {
+ var length, type, data, i = 0, advertisementData = {};
+
+ while (length !== 0) {
+
+ length = bytes[i] & 0xFF;
+ i++;
+
+ type = bytes[i] & 0xFF;
+ i++;
+
+ data = bytes.slice(i, i + length - 1); // Length includes type byte, but not length byte
+ i += length - 2; // Move to end of data
+ i++;
+
+ advertisementData[type] = data;
+ }
+
+ return advertisementData;
+ },
+ handle255: function(buffer) {
'use strict';
- $('#tbody').empty();
+ var company;
+ var cid;
+ var manID;
+ var bin = buffer;
+ var decoded = {};
+
+ console.log('Block255', bin);
+ var manSpec = bin.map(function(i) {
+
+ return i.toString(16) + ' ';
+ });
+
+ console.log('manSpec: ', manSpec);
+ manID = app.manufactureDecoder.getManID(bin);
+
+ console.log('ManID:', manID);
+
+ cid = '0x' + manID;
+
+ company = bt_company_ids.find(cid);
+
+ switch (manID) {
+ case '004c':
+ decoded = app.manufactureDecoder.decodeIbeacon(bin);
+ decoded.company = company;
+ return decoded;
+ break;
+ case '1235':
+ decoded = app.manufactureDecoder.decodeSiliconLabsSensorPuck(bin);
+ decoded.company = company;
+ return decoded;
+ break;
+ case '0060':
+ decoded = app.manufactureDecoder.decodeSansible(bin);
+ decoded.company = company;
+ return decoded;
+
+ break;
+ default:
+ console.log('Unknown manID: ', manID);
+ }
+ return {company:company};
+ },
+ makeHexBuffer : function(buffer) {
+ 'use strict';
+ var hexBuffer = buffer.map(function(i) {
+ return ('00' + i.toString(16)).slice(-2) + ',';
+ });
+ return hexBuffer;
+ },
+ makeChars : function(buffer) {
+ 'use strict';
+ var output = buffer.map(function(i) {
+
+ return String.fromCharCode(i);
+ });
+
+ return output;
+ },
+ doScan: function(mode) {
+ 'use strict';
+
+ $('#ripple').show();
+ if (mode !== 2) {
+ $('#tbody').empty();
+ }
+
+ var otherData = null;
+ var msgText = '';
ble.startScan([], function(device) {
- console.log(JSON.stringify(device));
+ var parsed;
+ var hexBuffer;
+ var advertBuffer;
+ var newTR;
+ var newId;
+ var _device = device;
+ otherData = null;
+ msgText = '';
+ console.log(JSON.stringify(device));
- var newId = device.id.replace(/:/g, '');
- console.log(newId);
+ newId = device.id.replace(/:/g, '');
+ console.log(newId);
- this.list[newId] = device.id;
+ this.list[newId] = device.id;
- var newTR = $('
');
+ newTR = $('
');
- newTR.append($('').text(device.id));
+ newTR.append($(' | ').text(device.id));
- if (device.hasOwnProperty('name')) {
- newTR.append($(' | ').text(device.name));
- } else {
- newTR.append($(' | ').text('*** Unknown'));
- }
+ if (device.hasOwnProperty('advertising')) {
- newTR.append($(' | ').text(device.rssi));
+ advertBuffer = app.arrayBufferToIntArray(device.advertising);
+ /*var hexBuffer = advertBuffer.map(function(i) {
+ return ('00' + i.toString(16)).slice(-2) + ',';
+ });*/
- $('#tbody').append(newTR);
+ hexBuffer = app.makeHexBuffer(advertBuffer);
- $('#output').append(JSON.stringify(device) + ' ');
+ parsed = app.parseAdvertisingData(advertBuffer);
- }.bind(this), function(e) {
- 'use strict';
- console.error(e);
- });
+ //Console.log(parsed);
+
+ if (parsed.hasOwnProperty('9')) {
+
+ /*var name = parsed['9'].map(function(i) {
+
+ return String.fromCharCode(i);
+ });*/
+
+ var name = app.makeChars(parsed['9']);
+
+ _device.name = name.join('');
+ console.log('Name: ', name.join(''));
+
+ }
+
+ if (parsed.hasOwnProperty('255')) {
+
+ otherData = app.handle255(parsed['255']);
+ console.log(otherData);
+ _device.otherData = otherData;
+ }
+ _device.advertBuffer = advertBuffer;
+ _device.hexBuffer = hexBuffer;
+ _device.parsed = parsed;
+ }
+
+ if (typeof otherData !== 'undefined' && otherData !== null) {
+ if (otherData.hasOwnProperty('msg')) {
+ msgText = ' - ' + otherData.msg;
+ }
+ }
+
+ if (device.hasOwnProperty('name')) {
+ newTR.append($(' | ').text(device.name + msgText));
+ } else {
+ newTR.append($(' | ').text('*** Unknown' + msgText));
+ }
+
+ newTR.append($(' | ').text(device.rssi));
+
+
+ if ($('tr#' + newId).length > 0) {
+ $('tr#' + newId).replaceWith(newTR);
+ } else {
+ $('#tbody').append(newTR);
+ }
+
+
+ //$('#output').append(JSON.stringify(device) + ' ');
+
+ app.log[newId] = _device;
+
+ console.log(JSON.stringify(_device));
+
+ }.bind(this), function(e) {
+ 'use strict';
+ console.error(e);
+ });
+
+ var _t = [5000,60000,200][mode];
setTimeout(ble.stopScan,
- 5000,
- function() { console.log('Scan complete'); },
- function() { console.log('stopScan failed'); }
- );
+ _t,
+ function() { console.log('Scan complete');
+
+ if (mode === 1) {
+ app.saveLog();
+ $('#ripple').hide();
+ }
+
+ if (mode === 2) {
+ if (app.stop == false) {
+ setTimeout(function() {
+ app.doScan(2);
+ }.bind(this), 200);
+ } else {
+ app.saveLog();
+ $('#ripple').hide();
+ }
+
+ }
+ },
+ function() { console.log('stopScan failed');
+ $('#ripple').hide();
+ });
},
+ writeFile: function(fileEntry, dataObj) {
+ // Create a FileWriter object for our FileEntry (log.txt).
+ fileEntry.createWriter(function(fileWriter) {
+
+ fileWriter.onwriteend = function() {
+ console.log('Successful file write...');
+ // ReadFile(fileEntry);
+ };
+
+ fileWriter.onerror = function(e) {
+ console.error('Failed file write: ' + e.toString());
+ };
+
+ // If data object is not passed in,
+ // create a new Blob instead.
+ if (!dataObj) {
+ dataObj = new Blob(['some file data'], { type: 'text/plain' });
+ }
+
+ fileWriter.write(dataObj);
+ });
+ },
+ saveLog: function() {
+ 'use strict';
+ var dt = new Date().toISOString().replace(/:|-/g,'').replace(/(\.\w+)/g,'');
+ var payload = JSON.stringify(app.log);
+ var filename = 'sensortoy-' + dt + '.json';
+
+ // Var dataObj = new Blob(payload, { type: 'text/plain' });
+ window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fs) {
+
+ console.log('file system open: ' + fs.name);
+ fs.root.getFile(filename, { create: true, exclusive: false }, function(fileEntry) {
+
+ console.log('fileEntry is file?' + fileEntry.isFile.toString());
+ // FileEntry.name == 'someFile.txt'
+ // fileEntry.fullPath == '/someFile.txt'
+ console.log('Path: ', fileEntry.fullPath);
+ app.writeFile(fileEntry, payload);
+
+ app.log = [];
+
+ }, app.onError);
+
+ }, app.onError);
+ },
+ forceStop: function() {
+ 'use strict';
+ app.stop = true;
+ $('#scan').show();
+ $('#stop').hide();
+ },
+
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
- var self = this;
- document.addEventListener('deviceready', this.onDeviceReady, false);
- $('#scan').on('click', function() {
- 'use strict';
- this.doScan();
- }.bind(this));
+ var self = this;
+ document.addEventListener('deviceready', this.onDeviceReady, false);
+ $('#scan').on('click', function() {
+ 'use strict';
+ this.stop = false;
+ this.doScan(2);
+ $('#scan').hide();
+ $('#stop').show();
+ }.bind(this));
+ $('#stop').on('click', function() {
+ 'use strict';
+ app.forceStop();
+ }.bind(this));
- $('#tbody').on('click','tr', function() {
- 'use strict';
- var tID = $(this).context.id;
+ $('#longScan').on('click', function() {
+ 'use strict';
+ this.doScan(1);
+ }.bind(this));
- var id = self.list[tID];
+ $('#tbody').on('click', 'tr', function() {
+ 'use strict';
+ var tID = $(this).context.id;
- console.log(tID, id);
+ var id = self.list[tID];
- self.connect(id);
- });
+ console.log(tID, id);
+ app.forceStop();
+ self.connect(id);
+ });
- },
- // Deviceready Event Handler
+ }, // Deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
-
-
}, serviceDiscovery: function(services) {
'use strict';
console.log(services);
+ }, sensorMpu9250GyroConvert: function(data) {
+ return data / (65536 / 500);
},
- sensorMpu9250GyroConvert: function(data) {
- return data / (65536 / 500);
- },
sensorMpu9250AccConvert: function(data) {
- // Change /2 to match accel range...i.e. 16 g would be /16
- return data / (32768 / 2);
+ // Change /2 to match accel range...i.e. 16 g would be /16
+ return data / (32768 / 2);
+ },
+
+ doAnimate: function() {
+ 'use strict';
+ // Console.log('Animate..');
+ for (var t = 0; t < app.activeServices.length;t++) {
+ app.activeServices[t].animateGraph();
}
- ,connect: function(deviceId) {
+ window.requestAnimFrame(app.doAnimate.bind(this));
+ }
- $('#results').slideUp();
- console.log('Connect to ', deviceId);
+ , connect: function(deviceId) {
- var onConnect = function(a) {
- var services = [];
+ $('#results').slideUp();
+ console.log('Connect to ', deviceId);
- 'use strict';
+ var onConnect = function(a) {
+ var services = [];
- console.log('A:', a);
+ 'use strict';
- services = a.services;
+ console.log('A:', a);
- for (var t = 0; t < services.length;t++) {
+ services = a.services;
- var ident = services[t].toUpperCase();
+ for (var t = 0; t < services.length; t++) {
- switch (ident) {
- case '180F':
- var batteryStat = new BATTERY(deviceId);
- batteryStat.startService();
- batteryStat.readBatteryState();
- app.activeServices.push(batteryStat);
+ var ident = services[t].toUpperCase();
- break;
- case 'FFE0':
- var buttonState = new BUTTON(deviceId);
- buttonState.startService();
- app.activeServices.push(buttonState);
- break;
+ switch (ident) {
+ case '180F':
+ var batteryStat = new BATTERY(deviceId);
+ batteryStat.startService();
+ // batteryStat.readBatteryState();
+ app.activeServices.push(batteryStat);
- case 'F000AA80-0451-4000-B000-000000000000':
- var cc2650_accel = new CC2650_ACCEL(deviceId);
- cc2650_accel.startService();
- app.activeServices.push(cc2650_accel);
- break;
+ break;
+ case 'FFE0':
+ var buttonState = new BUTTON(deviceId);
+ buttonState.startService();
+ app.activeServices.push(buttonState);
+ break;
- case 'F000AA40-0451-4000-B000-000000000000':
- var cc2650_bar = new CC2650_BAR(deviceId);
- cc2650_bar.startService();
- app.activeServices.push(cc2650_bar);
- break;
+ case 'F000AA80-0451-4000-B000-000000000000':
+ var cc2650_accel = new CC2650_ACCEL(deviceId);
+ cc2650_accel.startService();
+ app.activeServices.push(cc2650_accel);
+ break;
- case 'F000AA70-0451-4000-B000-000000000000':
- var cc2650_lux = new CC2650_LUX(deviceId);
- cc2650_lux.startService();
- app.activeServices.push(cc2650_lux);
- break;
+ case 'F000AA40-0451-4000-B000-000000000000':
+ var cc2650_bar = new CC2650_BAR(deviceId);
+ cc2650_bar.startService();
+ app.activeServices.push(cc2650_bar);
+ break;
- default:
- console.log('Unknown service: ', ident);
- }
- }
+ case 'F000AA70-0451-4000-B000-000000000000':
+ var cc2650_lux = new CC2650_LUX(deviceId);
+ cc2650_lux.startService();
+ app.activeServices.push(cc2650_lux);
+ break;
+
+ case 'F000AA00-0451-4000-B000-000000000000':
+ var cc2650_tmp = new CC2650_TMP(deviceId);
+ cc2650_tmp.startService();
+ app.activeServices.push(cc2650_tmp);
+ break;
- };
+ case 'F000AA20-0451-4000-B000-000000000000':
+ var cc2650_hum = new CC2650_HUM(deviceId);
+ cc2650_hum.startService();
+ app.activeServices.push(cc2650_hum);
+ break;
- ble.connect(deviceId, onConnect, function(e) {
- 'use strict';
- console.error(e);
- });
+ default:
+ console.error('Unknown service: ', ident);
+ }
+ }
- },
- onError: function(reason) {
- console.error('ERROR: ' + reason); // Real apps should use notification.alert
- },
- updateGyro: function(g) {
+ // Starting animation..
+ window.requestAnimFrame(app.doAnimate.bind(this));
+ };
+
+ ble.connect(deviceId, onConnect, function(e) {
+ 'use strict';
+ console.error(e);
+ });
+
+ }, onError: function(reason) {
+ console.error('ERROR: ' + reason); // Real apps should use notification.alert
+ }, updateGyro: function(g) {
'use strict';
}
};
+
+window.requestAnimFrame = (function() {
+ return window.requestAnimationFrame ||
+ window.webkitRequestAnimationFrame ||
+ window.mozRequestAnimationFrame ||
+ function(callback) {
+ window.setTimeout(callback, 1000 / 60);
+ };
+})();
+
+
+
app.initialize();
diff --git a/platforms/android/assets/www/js/standards/capability.js b/platforms/android/assets/www/js/standards/capability.js
index a1914d7..49147fd 100644
--- a/platforms/android/assets/www/js/standards/capability.js
+++ b/platforms/android/assets/www/js/standards/capability.js
@@ -18,6 +18,10 @@ var CAPABILITY = function(p) {
this.deviceID = null;
+ this.data = [];
+ this.ctx = null;
+ this.first = false;
+
};
CAPABILITY.prototype.setInternalID = function() {
@@ -64,7 +68,174 @@ CAPABILITY.prototype.onError = function(e) {
console.error(e);
};
+CAPABILITY.prototype.storeData = function(data, alt) {
+ if (!this.first) {
+ this.first = true;
+ return [];
+ }
+ var target = alt || this.data;
+
+ if (target.length === 99) {
+ target = target.slice(1);
+ }
+
+ target.push(data);
+ if (alt) {
+ return target;
+ } else {
+ this.data = target;
+ }
+
+
+};
+
+CAPABILITY.prototype.startGraph = function(id) {
+
+ var c;
+ c = id[0].getContext('2d');
+ this.ctx = c;
+
+ this.ctx.fillStyle = '#ffffff';
+ this.ctx.fillRect(0,0,300,150);
+};
+
+CAPABILITY.prototype.generateBlankGraph = function(subID) {
+
+ var _subID = subID || '';
+ var xmlns = 'http://www.w3.org/2000/svg';
+
+ var svgID = this.frameID + _subID + '-svg';
+ var text1ID = this.frameID + _subID + '-txt1';
+ var lineID = this.frameID + _subID + '-line';
+
+ var svg = document.createElementNS(xmlns,'svg');
+
+ svg.setAttributeNS(xmlns,'id',svgID);
+ svg.setAttributeNS(xmlns,'width',300);
+ svg.setAttributeNS(xmlns,'height',150);
+ svg.setAttributeNS(xmlns,'fill', 'blue');
+
+ var line = document.createElementNS(xmlns,'line');
+
+ line.setAttributeNS(null,'x1','46');
+ line.setAttributeNS(null,'y1','12');
+ line.setAttributeNS(null,'x2','280');
+ line.setAttributeNS(null,'y2', '12');
+ line.setAttributeNS(null,'style','stroke:#bad649;stroke-width:2;');
+
+ svg.appendChild(line);
+
+ line = document.createElementNS(xmlns,'line');
+
+ line.setAttributeNS(null,'x1','46');
+ line.setAttributeNS(null,'y1','136');
+ line.setAttributeNS(null,'x2','280');
+ line.setAttributeNS(null,'y2', '136');
+ line.setAttributeNS(null,'style','stroke:#bad649;stroke-width:2;');
+
+ svg.appendChild(line);
+
+ var text = document.createElementNS(xmlns,'text');
+
+ text.setAttributeNS(null,'id',text1ID);
+ text.setAttributeNS(null,'x','36');
+ text.setAttributeNS(null,'y','15');
+ text.setAttributeNS(null,'text-anchor', 'end');
+ text.setAttributeNS(null,'style','font-family:"Ubuntu Condensed",sans-serif;font-size:12;fill: #bad649;text-align:right;');
+ text.textContent = '000';
+
+ svg.appendChild(text);
+
+ text = document.createElementNS(xmlns,'text');
+
+ text.setAttributeNS(null,'id','text2');
+ text.setAttributeNS(null,'x','36');
+ text.setAttributeNS(null,'y','140');
+ text.setAttributeNS(null,'text-anchor', 'end');
+ text.setAttributeNS(null,'style','font-family:"Ubuntu Condensed",sans-serif;font-size:12;fill: #bad649;text-align:right;');
+ text.textContent = '0';
+
+ svg.appendChild(text);
+
+ var polyline = document.createElementNS(xmlns,'polyline');
+
+ polyline.setAttributeNS(null,'id',lineID);
+ polyline.setAttributeNS(null,'fill','none');
+ polyline.setAttributeNS(null,'stroke','#e5f7fd');
+ //#e5f7fd
+ // old #B5C7FF
+ polyline.setAttributeNS(null,'text-anchor', 'end');
+ polyline.setAttributeNS(null,'stroke-width','2');
+
+ svg.appendChild(polyline);
+
+ return svg;
+
+};
+
+CAPABILITY.prototype.animateGraph = function() {
+ //This.simpleGraph(this.data);
+};
+
+
+CAPABILITY.prototype.simpleGraph = function(data, subID) {
+
+ var _subID;
+ var _data;
+ var text1ID;
+ var lineID;
+
+ _data = data || this.data;
+
+ _subID = subID || '';
+
+ lineID = [this.frameID , _subID , '-line'].join('');
+ text1ID = [this.frameID , _subID , '-txt1'].join('');
+
+ if (_data.length > 0) {
+ var ceiling = _data.reduce(function(p, v) {
+ return (p > v ? p : v);
+ });
+
+ /* Var floor = _data.reduce(function(p, v) {
+ return (p < v ? p : v);
+ });
+ */
+
+ var calcArray = [];
+
+ var ceilingLimit = Math.floor(ceiling / 10) * 10;
+ if (ceilingLimit < ceiling) {
+ ceilingLimit = Math.floor((ceiling + (ceiling * 0.25)) / 10) * 10;
+ }
+
+ if (ceilingLimit < 30) {
+ ceilingLimit = 30;
+ }
+
+ var scale = 124 / ceilingLimit;
+ // Var xstep = (280 - 46) / 100;
+ var xstep = 2.34;
+ var startX = 46 + (100 - _data.length) * xstep;
+
+ for (var x = 0;x < _data.length;x++) {
+
+ calcArray.push((startX + (x * xstep)).toFixed(2) + ',' + (136 - ((_data[x]) * scale)).toFixed(2));
+
+ }
+
+ var elm = document.getElementById(lineID);
+
+ elm.setAttribute('points',calcArray.join(' '));
+
+ elm = document.getElementById(text1ID);
+
+ elm.textContent = ceilingLimit;
+
+ }
+
+};
diff --git a/platforms/android/assets/www/test.html b/platforms/android/assets/www/test.html
index c332c56..dff6050 100644
--- a/platforms/android/assets/www/test.html
+++ b/platforms/android/assets/www/test.html
@@ -1,19 +1,31 @@
+
-
+
+
+
|