Skip to content

Commit

Permalink
Merge pull request zephyrproject-rtos#221 from jimmy-huang/fix-temper…
Browse files Browse the repository at this point in the history
…ature

[Demo] Fix the temperature display to use integer
  • Loading branch information
poussa authored Sep 28, 2016
2 parents a4e2b41 + aab5901 commit 8d6118f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions samples/WebBluetoothDemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ ble.on('accept', function(clientAddress) {
tmp36.on("change", function(data) {
var voltage = (data / 4096.0) * 3.3;
var celsius = (voltage - 0.5) * 100 + 0.5;
celsius = celsius | 0;

print("Temperature change: " + celsius + " degrees Celsius");
TemperatureCharacteristic.valueChange(celsius);
Expand Down
6 changes: 4 additions & 2 deletions samples/WebBluetoothGroveLcdDemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ TemperatureCharacteristic.onUnsubscribe = function() {

TemperatureCharacteristic.valueChange = function(value) {
this._lastValue = value;
glcd.clear();
glcd.print("Temp: " + value);
glcd.setCursorPos(0, 0);
glcd.print("Temperature: " + value + "C");

var data = new Buffer(1);
data.writeUInt8(value);
Expand Down Expand Up @@ -184,10 +184,12 @@ ble.on('advertisingStart', function(error) {

ble.on('accept', function(clientAddress) {
print("Accepted Connection: " + clientAddress);
glcd.clear();

tmp36.on("change", function(data) {
var voltage = (data / 4096.0) * 3.3;
var celsius = (voltage - 0.5) * 100 + 0.5;
celsius = celsius | 0;

print("Temperature change: " + celsius + " degrees Celsius");
TemperatureCharacteristic.valueChange(celsius);
Expand Down

0 comments on commit 8d6118f

Please sign in to comment.