beyondscreen / node-rpi-ws281x-native

native bindings to drive WS2811 (or WS2812) LED-Controllers on a Raspberry Pi
MIT License
224 stars 101 forks source link

Raspberry Pi 4 bcm2711 #107

Open westerxddd opened 4 years ago

westerxddd commented 4 years ago

I had to add: case 'bcm2711': return 1; to: lib/ws281x-native.js

var raspberryVersion = (function() {
        var cpuInfo = require('fs').readFileSync('/proc/cpuinfo').toString(),
            socFamily = cpuInfo.match(/hardware\s*:\s*(bcm\d+)/i);
            console.log(cpuInfo.match(/hardware\s*:\s*(bcm\d+)/i));
        if(!socFamily) { return 0; }

        switch(socFamily[1].toLowerCase()) {
            case 'bcm2708': return 1;
            case 'bcm2835': return 1;
            case 'bcm2709': return 2;
            case 'bcm2711': return 1; <--- this line to work with my raspberry pi 4
            default: return 0;
        }
    } ());
CaskAle commented 4 years ago

I discovered the same and found that the same case statement with a return of 2 rather than 1 works as well. I was not able to determine what the return value is used for??

westerxddd commented 4 years ago

@CaskAle me too.

So i suspect this is only to limit script only for raspberry use.

dJPoida commented 4 years ago

I also had to add this line on a Raspberry Pi 4. Does the return value perhaps describe the device GPIO pinout?

Deboracgs commented 4 years ago

I had to add: case 'bcm2711': return 1; to: lib/ws281x-native.js

var raspberryVersion = (function() {
        var cpuInfo = require('fs').readFileSync('/proc/cpuinfo').toString(),
            socFamily = cpuInfo.match(/hardware\s*:\s*(bcm\d+)/i);
            console.log(cpuInfo.match(/hardware\s*:\s*(bcm\d+)/i));
        if(!socFamily) { return 0; }

        switch(socFamily[1].toLowerCase()) {
            case 'bcm2708': return 1;
            case 'bcm2835': return 1;
            case 'bcm2709': return 2;
            case 'bcm2711': return 1; <--- this line to work with my raspberry pi 4
            default: return 0;
        }
    } ());

it's really works! thank you!