dtex / huskylens

Johnny-Five plug in for the HuskyLens AI Vision Center
MIT License
1 stars 0 forks source link

Error: Unknown mode undefined #5

Open Naozumi520 opened 1 year ago

Naozumi520 commented 1 year ago
pi@aipi:~/Desktop/School Ai $ sudo node .
1684247994007 Available Raspi IO  
1684247994011 Connected Raspi IO  
1684247994016 Repl Initialized  
>> Pie ready!
/home/pi/Desktop/School Ai/node_modules/j5-io/dist/index.js:342
            throw new Error(`Unknown mode ${mode}`);
            ^

Error: Unknown mode undefined
    at J5IO.pinMode (/home/pi/Desktop/School Ai/node_modules/j5-io/dist/index.js:342:19)
    at /home/pi/Desktop/School Ai/src/module/huskylens-master/index.js:93:21
    at Array.forEach (<anonymous>)
    at Huskylens.initialize (/home/pi/Desktop/School Ai/src/module/huskylens-master/index.js:91:22)
    at new Huskylens (/home/pi/Desktop/School Ai/src/module/huskylens-master/index.js:74:14)
    at Board.<anonymous> (file:///home/pi/Desktop/School%20Ai/src/main.js:26:18)
    at Board.emit (node:events:525:35)
    at /home/pi/Desktop/School Ai/node_modules/johnny-five/lib/board.js:428:39
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)

Node.js v19.9.0
pi@aipi:~/Desktop/School Ai $ 

I'm using Raspberry Pi 4 Model B, with library raspi-io. But getting this error. Line 26 of main.js is:

const lens = new HuskyLens({
dtex commented 1 year ago

One line is not enough to trace the error. Can you share the rest of your code?

Naozumi520 commented 1 year ago

Update: Code provided in latest comment

Naozumi520 commented 1 year ago

I can't really set it up. When I do new HuskyLens it throw the error.

Naozumi520 commented 1 year ago

After reading the raspi-ui documents, it turns out I set the pin wrong. However, I still can't drive the board with the correct one.

Here's what I have done:

And my current code:

const five = require("johnny-five");
const Raspi = require('raspi-io').RaspiIO;
const HuskyLens = require("./module/huskylens-master/index.js")(five);

const board = new five.Board({
    io: new Raspi({
        enableSerial: true,
        enableI2C: true
    })
});

board.on("ready", () => {

    console.log('Pie ready!')

    const lens = new HuskyLens({
        pins: ['P1-10', 'P1-8'],
        mode: "FACE_RECOGNITION"
    });

    lens.on("ready", () => {
        console.log("The HuskyLens is connected and ready");
    });

    lens.on("block", block => {
        console.log(block);
    });
})

Result:

pi@aipi:~/Desktop/School Ai $ sudo node .
1684310460595 Available Raspi IO  
1684310460601 Connected Raspi IO  
1684310460606 Repl Initialized  
>> Pie ready!

Expected: The HuskyLens is connected and ready show pop up What I've got: nothing

Using:

Naozumi520 commented 1 year ago

@dtex Hello, sorry to bother you. Are you free to review on this?