53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import { openSync } from 'i2c-bus';
|
|
import Oled from 'oled-i2c-bus';
|
|
import font from 'oled-font-5x7';
|
|
import { MenuConfig, MenuPrinter } from './interface';
|
|
|
|
/*const i2cbus = openSync(1);
|
|
const opts = {
|
|
width: 128,
|
|
height: 64,
|
|
address: 0x3C,
|
|
};
|
|
|
|
const oled = new Oled(i2cbus, opts);
|
|
|
|
oled.clearDisplay();
|
|
oled.setCursor(1, 1);
|
|
oled.writeString(font, 1, "This is a string I am writing to the screen", 1, true);
|
|
oled.turnOffDisplay();*/
|
|
|
|
export class OledPrinter implements MenuPrinter {
|
|
// private _path: number[] = [];
|
|
// private _selectedIndex: number = 0;
|
|
private _config: MenuConfig[];
|
|
// private _curMenu: MenuConfig[];
|
|
private _oled: Oled;
|
|
|
|
constructor(config: MenuConfig[]) {
|
|
this._config = config;
|
|
// this._curMenu = config;
|
|
const i2cbus = openSync(1);
|
|
const opts = {
|
|
width: 128,
|
|
height: 64,
|
|
address: 0x3C,
|
|
};
|
|
this._oled = new Oled(i2cbus, opts);
|
|
this._oled.clearDisplay();
|
|
}
|
|
|
|
private printMenu(): void {
|
|
this._oled.writeString(font, 1, "how many lines does this display hold let's write a whole bunch of stuff with wrapping on and then count the number of lines", 1, true);
|
|
}
|
|
|
|
public async getSelection(): Promise<MenuConfig> {
|
|
return new Promise((resolve) => {
|
|
this.printMenu();
|
|
while (true) {
|
|
}
|
|
resolve(this._config[0]);
|
|
});
|
|
}
|
|
}
|