writing a string

This commit is contained in:
Rudis Muiznieks 2022-04-19 17:39:44 -05:00
parent e039384950
commit 6b5f3b0d2a
Signed by: rudism
GPG Key ID: CABF2F86EF7884F9
5 changed files with 20 additions and 2 deletions

2
@types/oled-font-5x7.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
declare module 'oled-font-5x7' {
}

View File

@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
exports.__esModule = true;
var i2c_bus_1 = require("i2c-bus");
var oled_i2c_bus_1 = __importDefault(require("oled-i2c-bus"));
var oled_font_5x7_1 = __importDefault(require("oled-font-5x7"));
var i2cbus = (0, i2c_bus_1.openSync)(1);
var opts = {
width: 128,
@ -13,4 +14,5 @@ var opts = {
};
var oled = new oled_i2c_bus_1["default"](i2cbus, opts);
oled.clearDisplay();
oled.invertDisplay(true);
oled.setCursor(1, 1);
oled.writeString(oled_font_5x7_1["default"], 1, "This is a string I am writing to the screen", 1, true);

11
package-lock.json generated
View File

@ -6,6 +6,7 @@
"": {
"dependencies": {
"i2c-bus": "^5.2.2",
"oled-font-5x7": "^1.0.3",
"oled-i2c-bus": "^1.0.12"
},
"devDependencies": {
@ -604,6 +605,11 @@
"resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz",
"integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ=="
},
"node_modules/oled-font-5x7": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/oled-font-5x7/-/oled-font-5x7-1.0.3.tgz",
"integrity": "sha512-l25WvKft8CgXYxtaqKdYrAS1P91rnUUUIiOXojAOvjNCsfFzIl1aEsE2JuaRgMh1Euo7slm5lX0w+1qNkL8PpQ=="
},
"node_modules/oled-i2c-bus": {
"version": "1.0.12",
"resolved": "https://registry.npmjs.org/oled-i2c-bus/-/oled-i2c-bus-1.0.12.tgz",
@ -1528,6 +1534,11 @@
"resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz",
"integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ=="
},
"oled-font-5x7": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/oled-font-5x7/-/oled-font-5x7-1.0.3.tgz",
"integrity": "sha512-l25WvKft8CgXYxtaqKdYrAS1P91rnUUUIiOXojAOvjNCsfFzIl1aEsE2JuaRgMh1Euo7slm5lX0w+1qNkL8PpQ=="
},
"oled-i2c-bus": {
"version": "1.0.12",
"resolved": "https://registry.npmjs.org/oled-i2c-bus/-/oled-i2c-bus-1.0.12.tgz",

View File

@ -6,6 +6,7 @@
},
"dependencies": {
"i2c-bus": "^5.2.2",
"oled-font-5x7": "^1.0.3",
"oled-i2c-bus": "^1.0.12"
},
"devDependencies": {

View File

@ -1,5 +1,6 @@
import { openSync } from 'i2c-bus';
import Oled from 'oled-i2c-bus';
import font from 'oled-font-5x7';
const i2cbus = openSync(1);
const opts = {
@ -11,4 +12,5 @@ const opts = {
const oled = new Oled(i2cbus, opts);
oled.clearDisplay();
oled.invertDisplay(true);
oled.setCursor(1, 1);
oled.writeString(font, 1, "This is a string I am writing to the screen", 1, true);