Я настроил свой 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
-
Anonymous
1722461191
Anonymous
Я настроил свой 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
Подробнее здесь: [url]https://stackoverflow.com/questions/78818167/how-do-drive-1-4in-display-on-orangepi[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия