Я настроил свой OrangePI с Debian 11 (яблочко) и теперь пытаюсь подключить этот дисплей.
Дисплей включается, но весь белый, и когда я запускаю код, показанный ниже, я вижу это
const sclk = new Gpio(11, 'out'); // Тактовый вывод SPI
^
TypeError: Gpio не является конструктором
at file:///home/orangepi/app/lcd.js:4:14
Я раньше не запускал никаких дисплеев или чего-то еще, так что я даже знаю, с чего начать. Есть идеи, что мне попробовать дальше?
import pkg from 'orange-pi-gpio';
const { Gpio } = pkg;
const sclk = new Gpio(11, 'out'); // SPI clock pin
const mosi = new Gpio(10, 'out'); // SPI data pin
const cs = new Gpio(8, 'out'); // Chip select
const dc = new Gpio(25, 'out'); // Data/Command control
const rst = new Gpio(27, 'out'); // Reset
const bl = new Gpio(24, 'out'); // Backlight
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
(async () => {
try {
// Initialize the display
await rst.write(0);
await delay(100);
await rst.write(1);
await delay(100);
// Send initialization commands to the display
await sendCommand(0x01); // Software reset
await delay(150);
await sendCommand(0x11); // Sleep out
await delay(500);
await sendCommand(0x29); // Display on
// Display "Hello World"
await displayText("Hello World");
} catch (error) {
console.error('Error initializing display:', error);
}
})();
const sendCommand = async (command) => {
await dc.write(0); // Command mode
await cs.write(0); // Select the display
await spiWrite(command);
await cs.write(1); // Deselect the display
};
const sendData = async (data) => {
await dc.write(1); // Data mode
await cs.write(0); // Select the display
await spiWrite(data);
await cs.write(1); // Deselect the display
};
const spiWrite = async (data) => {
for (let i = 0; i < 8; i++) {
await sclk.write(0);
await mosi.write((data & 0x80) ? 1 : 0);
data
Подробнее здесь: https://stackoverflow.com/questions/788 ... n-orangepi
Как управлять дисплеем 1,4 дюйма на OrangePI? ⇐ Linux
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Попытка подключить клиент OrangePi Zero к удаленному удаленному серверу моего компьютера.
Anonymous » » в форуме Python - 0 Ответы
- 26 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Как получить снимок экрана для экрана размером 5,5 дюйма в Xcode 15 на Sonoma
Гость » » в форуме IOS - 0 Ответы
- 94 Просмотры
-
Последнее сообщение Гость
-