initial commit

This commit is contained in:
Rudis Muiznieks 2022-04-19 17:17:19 -05:00
commit 8912bce342
Signed by: rudism
GPG Key ID: CABF2F86EF7884F9
6 changed files with 1924 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules/

36
@types/oled-i2c-bus.d.ts vendored Normal file
View File

@ -0,0 +1,36 @@
declare module 'oled-i2c-bus' {
import { I2CBus } from 'i2c-bus';
class Oled {
constructor(i2c: I2CBus, opts: OLED.Options);
clearDisplay(): void;
dimDisplay(dimming: boolean): void;
invertDisplay(invert: boolean): void;
turnOffDisplay(): void;
turnOnDisplay(): void;
drawPixel(pixels: OLED.Point[]): void;
drawLine(x0: number, y0: number, x1: number, y1: number, color: number): void;
fillRect(x0: number, y0: number, x1: number, y1: number, color: number): void;
drawBitmap(bitmap: any): void;
drawRGBAImage(image: any, x: number, y: number): void;
startScroll(direction: 'left'|'right', startRow: number, endRow: number): void;
stopScroll(): void;
setCursor(x: number, y: number): void;
writeString(font: any, size: number, text: string, color: number, wrap: boolean, sync?: boolean): void;
update(): void;
}
namespace OLED {
interface Options {
height?: number;
width?: number;
address?: number;
linespacing?: number;
letterspacing?: number;
}
type Point = [number, number, number];
}
export = Oled;
}

1834
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

15
package.json Normal file
View File

@ -0,0 +1,15 @@
{
"scripts": {
"start": "ts-node --project tsconfig.json src/index.ts"
},
"dependencies": {
"i2c-bus": "^5.2.2",
"oled-i2c-bus": "^1.0.12"
},
"devDependencies": {
"@types/i2c-bus": "^5.1.0",
"ts-node": "^10.7.0",
"typescript": "^4.6.3",
"typescript-language-server": "^0.9.7"
}
}

14
src/index.ts Normal file
View File

@ -0,0 +1,14 @@
import { openSync } from 'i2c-bus';
import Oled = require('oled-i2c-bus');
const i2cbus = openSync(1);
const opts = {
width: 128,
height: 64,
address: 0x3C,
};
const oled = new Oled(i2cbus, opts);
oled.clearDisplay();
oled.invertDisplay(true);

24
tsconfig.json Normal file
View File

@ -0,0 +1,24 @@
{
"compilerOptions": {
"allowJs": false,
"checkJs": false,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"paths": {
"*": ["@types/*"]
},
"typeRoots": [
"./node_modules/@types",
"./@types"
]
},
"include": ["src/**/*"]
}