8x8matrix 中文文档教程

发布于 6年前 浏览 32 项目主页 更新于 3年前

Adafruit 8x8-Matrix with NodeJS

控制你的 带 NodeJS 的 Adafruit 8x8 矩阵。 您的 nodejs 脚本必须以 root 身份运行。

Setup

$ npm i 8x8matrix
const Matrix = require('8x8matrix');

let matrix = new Matrix();
matrix.writeArray(matrix.smily);

Options

let matrix = new Matrix({
    brightness: 15,
    slaveAddress: 0x70,
    bautrate: 10000
});

API

像素可以由具有 64 个对象的简单 js 数组编写。

var smily = [
    0,0,1,1,1,1,0,0,
    0,1,0,0,0,0,1,0,
    1,0,1,0,1,0,0,1,
    1,0,1,0,1,0,0,1,
    1,0,0,0,0,1,0,1,
    1,0,1,1,1,0,0,1,
    0,1,0,0,0,0,1,0,
    0,0,1,1,1,1,0,0
];

matrix.writeArray(smily);

/**
  * Set brightness of all LED
  * Values: 1 (very low) to 15 (very bright)
  */

matrix.setBrightness(8);

/**
  * Set first top-left LED to on
  * matrix.setLED(x, y, true/false);
  */

matrix.setLED(0, 0, 1);

Test

$ sudo node test.js

Adafruit 8x8-Matrix with NodeJS

Control your Adafruit 8x8 Matrix with NodeJS. Your nodejs script have to run as root.

Setup

$ npm i 8x8matrix
const Matrix = require('8x8matrix');

let matrix = new Matrix();
matrix.writeArray(matrix.smily);

Options

let matrix = new Matrix({
    brightness: 15,
    slaveAddress: 0x70,
    bautrate: 10000
});

API

Pixels can be written by a simple js-array with 64 objects.

var smily = [
    0,0,1,1,1,1,0,0,
    0,1,0,0,0,0,1,0,
    1,0,1,0,1,0,0,1,
    1,0,1,0,1,0,0,1,
    1,0,0,0,0,1,0,1,
    1,0,1,1,1,0,0,1,
    0,1,0,0,0,0,1,0,
    0,0,1,1,1,1,0,0
];

matrix.writeArray(smily);

/**
  * Set brightness of all LED
  * Values: 1 (very low) to 15 (very bright)
  */

matrix.setBrightness(8);

/**
  * Set first top-left LED to on
  * matrix.setLED(x, y, true/false);
  */

matrix.setLED(0, 0, 1);

Test

$ sudo node test.js
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文