I tried the "falling" edge suggestion, but the behavior seems the same, the HTTP server never responds, and I never see the ------ dmpYawPitchRoll output in Espruino console.
Here's the code I'm trying:
function getMPU() {
I2C1.setup({scl:B6,sda:B7, bitrate: 100000});
var MPU6050 = require("MPU6050");
console.log(MPU6050);
var mpu = MPU6050.connect(I2C1);
return mpu
}
function connectToWifi(wifiName, options) {
var resolve, reject
var promise = new Promise(function(res, rej) {resolve = res; reject = rej})
var wifi = require("EspruinoWiFi");
wifi.connect(wifiName, options, function(err) {
if (err) reject(err);
resolve();
});
return promise
}
connectToWifi("wifi", { password : "password" })
.then(function() {
const mpu = getMPU();
const dmp = require('MPU6050_DMP').create(mpu, 3);
const http = require("http");
let dmpYawPitchRoll = null
// This loop locks up the espruino: https://github.com/espruino/EspruinoDocs/issues/367
function dmpLoop() {
const dmpData = dmp.getData()
if (dmpData !== undefined) {
//console.log(
dmpYawPitchRoll = dmp.getYawPitchRoll(dmpData)
//)
}
}
setWatch(dmpLoop, B5, { repeat:true, edge:'falling' });
http.createServer(function (req, res) {
res.writeHead(200);
let result = {
acceleration: mpu.getAcceleration(), // returns an [x,y,z] array with raw accl. data
gravity: mpu.getGravity(), // returns acceleration array in G's
rotation: mpu.getRotation(), // returns an [x,y,z] array with raw gyro data
degreesPerSecond: mpu.getDegreesPerSecond(), // returns gyro array in degrees/s
}
result = JSON.stringify(result)
res.end(result);
// This never fires, HTTP response is never sent to computer
console.log(' ------ dmpYawPitchRoll:', dmpYawPitchRoll)
}).listen(80);
const wifi = require("EspruinoWiFi");
wifi.getIP(function(err, info) {
if (err) throw err
console.log('IP:', info.ip)
});
});
function onInit() {
console.log('Espruino started!');
}
Making an HTTP request from the computer to Espruino doesn't work. If you uncomment the console.log calls, the setWatch loop is working, and I will see that output repeatedly in console.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Continuing from https://github.com/espruino/EspruinoDocs/issues/367#issuecomment-306120068,
I tried the
"falling"
edge suggestion, but the behavior seems the same, the HTTP server never responds, and I never see the------ dmpYawPitchRoll
output in Espruino console.Here's the code I'm trying:
Making an HTTP request from the computer to Espruino doesn't work. If you uncomment the
console.log
calls, thesetWatch
loop is working, and I will see that output repeatedly in console.