obniz to be used
display height size
Rsponse waiting timeout in milliseconds
display width size
Draw a circle. If you are using node.js, node-canvas is required.
// Javascript Example
obniz.display.circle(40, 30, 20);
obniz.display.circle(90, 30, 20, true); // filled circle
Clear the display.
// Javascript Example
obniz.display.clear();
Draw Display from HTML5 Canvas context. With node-canvas, this works with node.js.
let ctx = $("#canvas")[0].getContext('2d');
ctx.fillStyle = "white";
ctx.font = "30px Avenir";
ctx.fillText('Avenir', 0, 40);
obniz.display.draw(ctx);
let ctx = obniz.util.createCanvasContext(obniz.display.width, obniz.display.height);
ctx.fillStyle = "white";
ctx.font = "30px Avenir";
ctx.fillText('Avenir', 0, 40);
obniz.display.draw(ctx);
// npm install canvas. ( version 2.0.0 or later required )
const { createCanvas } = require('canvas');
const canvas = createCanvas(128, 64);
const ctx = canvas.getContext('2d');
ctx.fillStyle = "white";
ctx.font = "30px Avenir";
ctx.fillText('Avenir', 0, 40);
obniz.display.draw(ctx);
You can specify to transfer the displayed data or not. This affects only the functions that use canvas like clear/print/line/rect/circle/draw. If you are using node.js, node-canvas is required.
Use false to stop updating display and true to restart updating.
// Javascript Example
obniz.display.drawing(false);
for (var i=0;i<100; i++) {
var x0 = Math.random() * 128;
var y0 = Math.random() * 64;
var x1 = Math.random() * 128;
var y1 = Math.random() * 64;
obniz.display.clear();
obniz.display.line(x0, y0, x1, y1);
}
obniz.display.drawing(true);
Calls each of the listeners registered for a given event.
Return an array listing the events for which the emitter has registered listeners.
This changes the font. The options for fontFamily and fontSize depend on your browser. If you are using node.js, node-canvas is required.
The default font is Arial 16px. If you set the parameter to null, you will be using the default font.
// Javascript Example
obniz.display.font('Avenir',30)
obniz.display.print("Avenir")
obniz.display.font(null,30) //default font(Arial) 30px
obniz.display.font('Avenir') //Avenir with default size(16px)
font name
size of font
Getting color for fill/stroke style for further rendering.
const current = obniz.display.getColor();
Getting color depth for all communication for the display
const current = obniz.display.getColorDepth(); // => return current depth. 1 or higher
Draw a line between two points. If you are using node.js, node-canvas is required.
// Javascript Example
obniz.display.line(30, 30, 100, 30);
obniz.display.rect(20, 20, 20, 20);
obniz.display.circle(100, 30, 20);
obniz.display.line(60, 50, 100, 30);
obniz.display.rect(50, 40, 20, 20, true);
obniz.display.line(50, 10, 100, 30);
obniz.display.circle(50, 10, 10, true);
Return the number of listeners listening to a given event.
Return the listeners registered for a given event.
Add a listener for a given event.
Add a one-time listener for a given event.
It changes the display position of a text. If you are using print() to display a text, position it to top left.
If you are using node.js, node-canvas is required.
// Javascript Example
obniz.display.pos(0,30);
obniz.display.print("YES. こんにちは");
Print text on display.
If you are using node.js and text is included characters out of ASCII code range, node-canvas is required.
// Javascript Example
obniz.display.print("Hello!");
// Javascript Example
obniz.display.font('Serif',18)
obniz.display.print("Hello World🧡")
Text to display. With browser, UTF8 string is available.
This shows QR code with given text and correction level. The correction level can be
H is the strongest error correction.
// Javascript Example
obniz.display.qr("https://obniz.io")
Draw BMP image
obniz.display.raw([255, 255,,,,,])
You should care about colorDepth before sending raw datas.
data array. The order is as below. {1byte} {2byte} {3byte}...{16byte} {17byte} {18byte} {19byte}... ..... .....................
Draw a rectangle. If you are using node.js, node-canvas is required.
// Javascript Example
obniz.display.rect(10, 10, 20, 20);
obniz.display.rect(20, 20, 20, 20, true); // filled rect
Remove all listeners, or those of the specified event.
Remove the listeners of a given event.
Setting color for fill/stroke style for further rendering. If you are using node.js, node-canvas is required.
obniz.display.color('#FF0000');
obniz.display.rect(0, 0, 10, 10, false)
obniz.display.color('blue');
obniz.display.rect(0, 10, 10, 10, false)
css acceptable color definition
Setting color depth for all communication for the display higher number will get more beautiful colors and lowest number 1 is just monochrome. But 16 bit color mode is 16 times data bytes needed for same size rendering.
obniz.display.setColorDepth(4); // => 4bit color mode.
monochrome display always 1. For color display 1(monochrome) and 4 and 16 can be selected. default value is highest color depth for your display. If you call just
Generated using TypeDoc
Here we will show letters and pictures on display on obniz Board.