From 6b5f3b0d2af83dc7b1e73b32cfd6d061884a958e Mon Sep 17 00:00:00 2001 From: Rudis Muiznieks Date: Tue, 19 Apr 2022 17:39:44 -0500 Subject: [PATCH] writing a string --- @types/oled-font-5x7.d.ts | 2 ++ bin/main.js | 4 +++- package-lock.json | 11 +++++++++++ package.json | 1 + src/main.ts | 4 +++- 5 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 @types/oled-font-5x7.d.ts diff --git a/@types/oled-font-5x7.d.ts b/@types/oled-font-5x7.d.ts new file mode 100644 index 0000000..867f1a7 --- /dev/null +++ b/@types/oled-font-5x7.d.ts @@ -0,0 +1,2 @@ +declare module 'oled-font-5x7' { +} diff --git a/bin/main.js b/bin/main.js index 426c394..8c052a4 100644 --- a/bin/main.js +++ b/bin/main.js @@ -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); diff --git a/package-lock.json b/package-lock.json index e2fabed..b1a4568 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index 7601dea..0a5b5e5 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ }, "dependencies": { "i2c-bus": "^5.2.2", + "oled-font-5x7": "^1.0.3", "oled-i2c-bus": "^1.0.12" }, "devDependencies": { diff --git a/src/main.ts b/src/main.ts index cbe0384..ddbf070 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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);