<acronym id="s8ci2"><small id="s8ci2"></small></acronym>
<rt id="s8ci2"></rt><rt id="s8ci2"><optgroup id="s8ci2"></optgroup></rt>
<acronym id="s8ci2"></acronym>
<acronym id="s8ci2"><center id="s8ci2"></center></acronym>

電子發燒友App

硬聲App

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示
電子發燒友網>電子資料下載>電子資料>RGB LED矩陣面板開源項目

RGB LED矩陣面板開源項目

2023-07-12 | zip | 0.00 MB | 次下載 | 免費

資料介紹

描述

介紹

近年來,RGB LED 矩陣面板的使用變得流行起來。您是這些面板的愛好者之一嗎?您是否希望為您的項目添加很多顏色?這些巨大的 RGB LED 矩陣面板是一個很棒的起點。您可以使用它們創建動畫、游戲或各種其他有趣的顯示。最重要的是,得益于兩個 IDC 連接器和一個無縫框架,這些面板可以菊花鏈式連接在一起,形成更大的 LED 顯示屏。在本教程中,我們將學習如何使用這些面板。本教程由 7 個部分組成。留在我身邊。

如何?

如前所述,在本教程中,我們將學習如何設置這些面板。現在,如何將這些面板之一連接到 Raspberry Pi?根據Henner Zeller的教程,連接一個面板需要 16 個連接,這會使它變得更難。看下面的圖片!連接這些電線非?;靵y。

?
?
?
?
pYYBAGO0HLmAIMNSAAI9Pl25Wzs991.jpg
?
1 / 2 ?需要連接 16 根電線,這很混亂。
?

解決辦法是什么?

擺脫這些電線的最佳方法是使用替代驅動板。RGB矩陣面板驅動板ElectroDragon團隊基于Henner Zeller RPI矩陣的有源轉接板設計的。

?
?
?
?
poYBAGO0HL6AFuveAAXYxGkKrDc840.jpg
?
1 / 6 ? ElectroDragon RGB 矩陣面板驅動板
?

特征:

  • 非常便宜,只要2.5美元!
  • 最多支持三個端口輸出到驅動器,P0,P1和P2(HUB75)。
  • 支持Raspberry Pi 2 and 3 & Zero,大部分管腳用于矩陣驅動。
  • 支持 E 線選擇引腳(適用于 64x64 RGB 矩陣面板)。
  • 板載四個邏輯緩沖器74HCT245。通過I2C接口外接板載RTC DS1307,不可與P3口同時使用,通過開關選擇。
  • 額外的板載 AT24C256 EEPROM,替代 I2C 25 和 26 引腳上的 256K 內存。Raspberry PI 3 無法支持替代 I2C 接口,因此只能使用 Raspberry Pi 2。
  • 完全兼容hzeller 適配板。

電源供應

樹莓派上安裝ElectroDragon驅動板后,需要注意的是:還需要一個5V的電源,給矩陣本身供電,樹莓派做不到,計算功率,乘以所有鏈式矩陣的寬度* 0.12 安培:一個 32 像素寬的矩陣最終可以消耗 32*0.12 = 3.85A,因此使用 5V 4A 電源。LED 矩陣面板需要 5V 電源而且很多!至少 5V 2A,您很容易需要 5V 4A 或 5V 10A 電源用于大面積面板!

每個矩陣一次點亮 64 個像素(16x32 或 32x32 面板)或 128 個像素(對于 32x64 面板)。如果全白,每個像素最多可消耗 0.06 安培。因此,每個面板的總最大電流為 64 * 0.06 = 3.95 安培或 128 * 0.06 = 7.68 安培。如果所有 LED 都同時亮起,這不太可能 - 但至少有一半用于電源是好的萬一你變亮了。

安裝庫

在本節中,我們將簡要說明如何安裝hzeller 庫。根據hzeller推薦:推薦使用Raspbian Lite發行版。

安裝先決條件

sudo apt-get install -y --force-yespython2.7-dev python-pillow python3-dev python3-pillow libgraphicsmagick++-devlibwebp-dev

安裝庫

git clone https://github.com/hzeller/rpi-rgb-led-matrix.git
cd rpi-rgb-led-matrix
make all
make build-python
make install-python

為 RTC 啟用 I2C

要在 Raspberry Pi 中啟用 I2C,請使用以下教程:

https://learn.sparkfun.com/tutorials/raspberry-pi-spi-and-i2c-tutorial#i2c-on-pi

將矩陣面板安裝到 RPi

有多種類型的顯示器都帶有相同的 Hub75 連接器。它們在多路復用發生的方式上有所不同。矩陣面板與驅動板的連接需要IDC線。這些可以通過將一個面板的輸出連接到下一個面板的輸入來鏈接。你可以把很多鏈接在一起。

?
pYYBAGO0HMCAWlkLAAC1wwZa1s0473.png
支持的面板列表。
?

64x64 矩陣通常有兩種類型:具有 5 條地址線(A、B、C、D、E)或(A、B)。所謂的“戶外面板”通常更亮,并且在相同尺寸下允許更快的刷新率,但在內部進行了一些多路復用,其中有幾種類型;可以使用--led-multiplexing參數選擇它們。

通常,較高的掃描速率(例如 1:8),即室外面板通常允許更快的刷新率,但如果所提供的三個之一不起作用,您可能需要弄清楚多路復用映射。

?
poYBAGO0HMKAebzeAAB8-k4jUoY143.png
創建鏈
?

正如您在下圖中看到的,您只能將 3 個矩陣面板排成一排連接到驅動板。(這是由于 Raspberry Pi GPIO 的限制。)

?
poYBAGO0HL6AFuveAAXYxGkKrDc840.jpg
只能同時控制三個面板(成行)。
?

如果您連接了多個矩陣面板,在這種情況下,有必要運行帶有參數的示例,請參閱hzeller 說明。

在本教程中,我將兩個矩陣面板 32x32 和 64x64(分別)連接到驅動板。如果地址行少于 5,則無需更改。(例如:32x32 和更小的面板)。但如前所述,對于 64x64 面板,引腳 8 應連接到驅動板上的引腳 E。

?
pYYBAGO0HMmAVgTeAANpWE-AMBY309.jpg
使用 64x64 面板時,應連接這兩個引腳。
?

。最好選擇C、C++語言,執行速度快。

?

示例 #1:使用 Python 滾動新聞

在這個例子中,一個站點的新聞(RSS 提要)被下載并顯示在矩陣面板上。這個例子是用 Python 寫的。要運行,您必須將三個文件(其中一個文件是附在底部的 ttf 字體)傳輸到Python samples 文件夾。

scroll.py文件 :

#!/usr/bin/env python
# -*- encoding:utf8 -*-
# By: Ramin Sangesari
import time
import argparse
import sys
import os
import random
import feedparser
from PIL import Image
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
from logging import getLogger, StreamHandler, DEBUG
logger = getLogger(__name__)
handler = StreamHandler()
handler.setLevel(DEBUG)
logger.setLevel(DEBUG)
logger.addHandler(handler)
logger.propagate = False
sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/..'))
from rgbmatrix import RGBMatrix, RGBMatrixOptions
def run(image, matrix):
   print("Running...")
   image.resize((matrix.width, matrix.height), Image.ANTIALIAS)
   double_buffer = matrix.CreateFrameCanvas()
   img_width, img_height = image.size
   xpos = 0
   while True:
       xpos += 1
       if (xpos > img_width):
           xpos = 0
           break
       double_buffer.SetImage(image, -xpos)
       double_buffer.SetImage(image, -xpos + img_width)
       double_buffer = matrix.SwapOnVSync(double_buffer)
       time.sleep(0.04)
def prepareMatrix(parser):
   args    = parser.parse_args()
   options = RGBMatrixOptions()
   if args.led_gpio_mapping != None:
     options.hardware_mapping = args.led_gpio_mapping
   options.rows = args.led_rows
   options.cols = args.led_cols
   options.chain_length = args.led_chain
   options.parallel = args.led_parallel
   options.pwm_bits = args.led_pwm_bits
   options.brightness = args.led_brightness
   options.pwm_lsb_nanoseconds = args.led_pwm_lsb_nanoseconds
   options.multiplexing = args.led_multiplexing
   if args.led_show_refresh:
     options.show_refresh_rate = 1
   if args.led_slowdown_gpio != None:
       options.gpio_slowdown = args.led_slowdown_gpio
   if args.led_no_hardware_pulse:
     options.disable_hardware_pulsing = True
   return RGBMatrix(options = options)
def getImageFromFile(path):
   image = Image.open(path).convert('RGB')
   return image
parser = argparse.ArgumentParser()
parser.add_argument("-r", "--led-rows", action="store", help="Display rows. 16 for 16x32, 32 for 32x32. Default: 32", default=32, type=int)
parser.add_argument("-t", "--led-cols", action="store", help="Display rows. 16 for 16x32, 32 for 32x32. Default: 32", default=32, type=int)
parser.add_argument("-c", "--led-chain", action="store", help="Daisy-chained boards. Default: 1.", default=1, type=int)
parser.add_argument("-P", "--led-parallel", action="store", help="For Plus-models or RPi2: parallel chains. 1..3. Default: 1", default=1, type=int)
parser.add_argument("-p", "--led-pwm-bits", action="store", help="Bits used for PWM. Something between 1..11. Default: 11", default=11, type=int)
parser.add_argument("-b", "--led-brightness", action="store", help="Sets brightness level. Default: 100. Range: 1..100", default=10, type=int)
parser.add_argument("-m", "--led-gpio-mapping", help="Hardware Mapping: regular, adafruit-hat, adafruit-hat-pwm" , choices=['regular', 'adafruit-hat', 'adafruit-hat-pwm'], type=str)
parser.add_argument("--led-scan-mode", action="store", help="Progressive or interlaced scan. 0 Progressive, 1 Interlaced (default)", default=1, choices=range(2), type=int)
parser.add_argument("--led-pwm-lsb-nanoseconds", action="store", help="Base time-unit for the on-time in the lowest significant bit in nanoseconds. Default: 130", default=130, type=int)
parser.add_argument("--led-show-refresh", action="store_true", help="Shows the current refresh rate of the LED panel")
parser.add_argument("--led-slowdown-gpio", action="store", help="Slow down writing to GPIO. Range: 1..100. Default: 1", choices=range(3), type=int)
parser.add_argument("--led-no-hardware-pulse", action="store", help="Don't use hardware pin-pulse generation")
parser.add_argument("--led-multiplexing", action="store", help="Multiplexing type: 0=direct; 1=strip; 2=checker; 3=spiral (Default: 0)", default=2, type=int)
parser.add_argument("-i", "--image", help="The image to display", default="./news.ppm")
imgdir = os.path.abspath(os.path.dirname(__file__)) + "/newsimg"
matrix = prepareMatrix(parser)
if not os.path.isdir(imgdir):
   print("Error: no img to display, no such directory.")
   sys.exit(0)
else:
   while True:
       files = os.listdir(imgdir)
       if len(files)==0:
           print("Warning: no img to display, I am going to wait news to come.")
           time.sleep(5.0)
       else:
           frnd = random.sample(files,len(files))
           for f in frnd:
               if f[-4:] == '.ppm':
                   f = os.path.join(imgdir, f)
                   try:
                       if os.path.exists(f):
                           run(getImageFromFile(f), matrix)
                       else:
                           print("Warning: no such file, next please...")
                   except IOError:
                       print("Warning: no such file, next please...")
                   except KeyboardInterrupt:
                       print("Exiting\n")
                       sys.exit(0)
               else:
                   printf("Warning: Please do not include non-ppm files.")
                   sys.exit(0)

rss.py文件:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# By : Ramin Sangesari
import datetime
import time
import argparse
import sys
import os
import random
import feedparser
import hashlib
from glob import glob
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
import urllib2
from bs4 import BeautifulSoup
from logging import getLogger, StreamHandler, DEBUG
logger = getLogger(__name__)
handler = StreamHandler()
handler.setLevel(DEBUG)
logger.setLevel(DEBUG)
logger.addHandler(handler)
logger.propagate = False
sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/..'))
Imgformat = '.ppm'
def isOkToCrawl():
    crawl_interval = 5 #sec.
    crawl_interval_file = "./lastcrawl"
    now = time.time()
    if os.path.isfile(crawl_interval_file):
        if os.stat(crawl_interval_file).st_mtime > now - crawl_interval:
            return False
    
    f = open(crawl_interval_file, 'w')
    f.write(str(now) + "\n")
    f.close()
    return True
	
def getImageFromFile(path):
    image = Image.open(path).convert('RGB')
    return image
	
def saveImgFromText(text, imgdir, fontsize):
    path = os.path.abspath(os.path.dirname(__file__))
    print path
    if fontsize == 20:
        font  = [ImageFont.truetype(path + '/VERDANA.TTF', fontsize),2]
    color  = [(255,0,255),
             (0,255,255),
             (255,255,0),
             (0,255,0),
             (255,255,255)]
    width, ignore = font[0].getsize(text)
    im = Image.new("RGB", (width + 40, fontsize+40), "black")
    draw = ImageDraw.Draw(im)
    draw.text((0, font[1]), text, random.choice(color), font=font[0])
    imgname = imgdir+"/"+str(fontsize)+str(hashlib.md5(text.encode('utf_8')).hexdigest())+Imgformat
    if not os.path.exists(imgname):
        im.save(imgname)
		
		
def removeOldImg(imgdir):
    #remove ppm files more than 1 days before.
    if not(imgdir=="") and not(imgdir=="/")and not(imgdir=="."): 
        now = time.time()
        for f in os.listdir(imgdir):
            if f[-4:] == '.ppm':
                f = os.path.join(imgdir, f)
                if os.stat(f).st_mtime < now - 0.5 * 86400:
                    if os.path.isfile(f):
                        os.remove(f)
						
						
def getNewsFromFeed():
    news  = []
    url = ['http://www.france24.com/en/top-stories/rss']
    for tg in url:
        fd = feedparser.parse(tg)
        for ent in fd.entries:
            news.append(u"          "+unicode(ent.title))
    return news
	
			
parser = argparse.ArgumentParser()
if isOkToCrawl():
    
    imgdir = os.path.abspath(os.path.dirname(__file__)) + "/newsimg"
    print imgdir
    if not os.path.isdir(imgdir):
        os.mkdir(imgdir)
    #clean up old news
    removeOldImg(imgdir)
    #get from RSS feed
    for text in getNewsFromFeed():
        saveImgFromText(text, imgdir, 20)
else:
    print ("You need to wait for 1min before next crawl.")

現在運行以下命令:

python rss.py & sudo python scroll.py

。

?

示例 #2:使用 C 顯示隨機效應

下面是 C 語言的例子。打開examples-api-use目錄minimal-example.cc中的文件并復制以下代碼。

// Small example how to use the library.
// By: Ramin Sangesari
#include "led-matrix.h"
#include 
#include 
#include 
#include 
using rgb_matrix::GPIO;
using rgb_matrix::RGBMatrix;
using rgb_matrix::Canvas;
uint8_t buffer[64][64][3] = { 0 };
unsigned long step = 0;
volatile bool interrupt_received = false;
static void InterruptHandler(int signo) {
 interrupt_received = true;
}
static void setPixelp(uint8_t x, uint8_t y, float r, float g, float b) {
 buffer[y][x][0] = uint8_t(std::max(0, std::min(255, int(r))));
 buffer[y][x][1] = uint8_t(std::max(0, std::min(255, int(g))));
 buffer[y][x][2] = uint8_t(std::max(0, std::min(255, int(b))));
}
static void HSVtoRGB(float& r, float& g, float& b, float h, float s, float v) {
 if (s == 0.0) {
   r = v;
   g = v;
   b = v;
 }
 int i = int(h * 6.0);
 float f = (h * 6.0) - i;
 float p = v * (1.0 - s);
 float q = v * (1.0 - s * f);
 float t = v * (1.0 - s * (1.0 - f));
 i = i % 6;
 if (i == 0) {
   r = v; g = t; b = p; return; // v, t, p  
 }
 if (i == 1) {
   r = q; g = v; b = p; return; // q, v, p
 }
 if (i == 2) {
   r = p; g = v; b = t; return; // p, v, t
 }
 if (i == 3) {
   r = p; g = q; b = v; return; // p, q, v
 }
 if (i == 4) {
   r = t; g = p; b = v; return; // t, p, v
 }
 if (i == 5) {
   r = v; g = p; b = q; return; // v, p, q
 }
}
void swirl(uint8_t x, uint8_t y, unsigned long step) {
 float fx = x - 31.5;
 float fy = y - 31.5;
 float dist = sqrt(fx * fx + fy * fy) * 0.5;
 float angle = (step * 0.1) + (dist * 1.5);
 float s = sin(angle);
 float c = cos(angle);
 float xs = x * c - y * s;
 float ys = x * s + y * c;
 float r = abs(xs + ys) * 12.0 - 20;
 float g = r + (s * 130);
 float b = r + (c * 130);
 setPixelp(x, y,
   r,
   g,
   b
 );
}
void setPixelU(uint8_t x, uint8_t y, uint8_t r, uint8_t g, uint8_t b) {
 buffer[y][x][0] = r;
 buffer[y][x][1] = g;
 buffer[y][x][2] = b;
}
void gradient(uint8_t x, uint8_t  y, unsigned long  step) {
 uint8_t g = x * 64;
 uint8_t b = y * 64;
 uint8_t r = 255 - (x * 64);  
 setPixelU(x, y, r, g, b);
}
void rainbowSearch(uint8_t x, uint8_t y, unsigned long step) {
 float xs = sin((step) * 0.01) * 20.0;
 float ys = cos((step) * 0.01) * 20.0;
 float scale = ((sin(step / 60.0) + 1.0) * 0.2) + 0.2;
 float r = sin((x + xs) * scale) + cos((y + xs) * scale);
 float g = sin((x + xs) * scale) + cos((y + ys) * scale);
 float b = sin((x + ys) * scale) + cos((y + ys) * scale);
 setPixelp(x, y,
   r * 255,
   g * 255,
   b * 255
 );
}
void checker(uint8_t _x, uint8_t _y, unsigned long step) {
 //float x = _x - 8;
 //float y = _y - 8;
 float x = _x - 32;
 float y = _y - 32;
 float angle = step / 5.0;
 float s = sin(angle);
 float c = cos(angle);
 float xs = x * c - y * s;
 float ys = x * s + y * c;
 xs -= sin(step / 200.0) * 40.0;
 ys -= cos(step / 200.0) * 40.0;
 float scale = step % 20;
 scale /= 20.0;
 scale = (sin(step / 50.0) / 8.0) + 0.25;
 xs *= scale;
 ys *= scale;
 float xo = abs(xs) - int(abs(xs));
 float yo = abs(ys) - int(abs(ys));
 //  l = 0 if @ else 1 if xo > .1 and  else .5
 float l = int(floor(xs) + floor(ys)) % 2 ? 0 : (xo > 0.1 && yo > .1 ? 1 : 0.5);
 float r, g, b;
 HSVtoRGB(r, g, b, (step % 255) / 255.0, 10, 121);
 setPixelU(_x, _y,
   r * (l * 255),
   g * (l * 255),
   b * (l * 255)
 );
}
static void DrawOnCanvas2(Canvas *canvas) {
 /*
  * Let's create a simple animation. We use the canvas to draw
  * pixels. We wait between each step to have a slower animation.
  */
while (true)  {
 for (uint8_t x = 0; x < 64; x++) {
   for (uint8_t y = 0; y < 64; y++) {
     rainbowSearch(x, y, step);
   }
 }
 for (int x = 0; x < 64; x++) {
   for (int y = 0; y < 64; y++) {
     for (int c = 0; c < 3; c++) {  
			canvas->SetPixel(x, y, buffer[x][y][c], buffer[x][y][c], buffer[x][y][c]);  
     }
   }
 }
 step++;
}
}
int main(int argc, char *argv[]) {
 RGBMatrix::Options defaults;
 defaults.hardware_mapping = "regular";  // or e.g. "adafruit-hat"
 defaults.rows = 64;
 defaults.chain_length = 1;
 defaults.parallel = 1;
 defaults.show_refresh_rate = true;
 Canvas *canvas = rgb_matrix::CreateMatrixFromFlags(&argc, &argv, &defaults);
 if (canvas == NULL)
   return 1;
 // It is always good to set up a signal handler to cleanly exit when we
 // receive a CTRL-C for instance. The DrawOnCanvas() routine is looking
 // for that.
 signal(SIGTERM, InterruptHandler);
 signal(SIGINT, InterruptHandler);
 DrawOnCanvas2(canvas);    // Using the canvas.
 // Animation finished. Shut down the RGB matrix.
 canvas->Clear();
 delete canvas;
 return 0;
} 

保存文件并使用make命令編譯它。要運行演示,請運行以下命令:

sudo ./minimal-example

?


下載該資料的人也在下載 下載該資料的人還在閱讀
更多 >

評論

查看更多

下載排行

本周

  1. 1山景DSP芯片AP8248A2數據手冊
  2. 1.06 MB  |  532次下載  |  免費
  3. 2RK3399完整板原理圖(支持平板,盒子VR)
  4. 3.28 MB  |  339次下載  |  免費
  5. 3TC358743XBG評估板參考手冊
  6. 1.36 MB  |  330次下載  |  免費
  7. 4DFM軟件使用教程
  8. 0.84 MB  |  295次下載  |  免費
  9. 5元宇宙深度解析—未來的未來-風口還是泡沫
  10. 6.40 MB  |  227次下載  |  免費
  11. 6迪文DGUS開發指南
  12. 31.67 MB  |  194次下載  |  免費
  13. 7元宇宙底層硬件系列報告
  14. 13.42 MB  |  182次下載  |  免費
  15. 8FP5207XR-G1中文應用手冊
  16. 1.09 MB  |  178次下載  |  免費

本月

  1. 1OrCAD10.5下載OrCAD10.5中文版軟件
  2. 0.00 MB  |  234315次下載  |  免費
  3. 2555集成電路應用800例(新編版)
  4. 0.00 MB  |  33566次下載  |  免費
  5. 3接口電路圖大全
  6. 未知  |  30323次下載  |  免費
  7. 4開關電源設計實例指南
  8. 未知  |  21549次下載  |  免費
  9. 5電氣工程師手冊免費下載(新編第二版pdf電子書)
  10. 0.00 MB  |  15349次下載  |  免費
  11. 6數字電路基礎pdf(下載)
  12. 未知  |  13750次下載  |  免費
  13. 7電子制作實例集錦 下載
  14. 未知  |  8113次下載  |  免費
  15. 8《LED驅動電路設計》 溫德爾著
  16. 0.00 MB  |  6656次下載  |  免費

總榜

  1. 1matlab軟件下載入口
  2. 未知  |  935054次下載  |  免費
  3. 2protel99se軟件下載(可英文版轉中文版)
  4. 78.1 MB  |  537798次下載  |  免費
  5. 3MATLAB 7.1 下載 (含軟件介紹)
  6. 未知  |  420027次下載  |  免費
  7. 4OrCAD10.5下載OrCAD10.5中文版軟件
  8. 0.00 MB  |  234315次下載  |  免費
  9. 5Altium DXP2002下載入口
  10. 未知  |  233046次下載  |  免費
  11. 6電路仿真軟件multisim 10.0免費下載
  12. 340992  |  191187次下載  |  免費
  13. 7十天學會AVR單片機與C語言視頻教程 下載
  14. 158M  |  183279次下載  |  免費
  15. 8proe5.0野火版下載(中文版免費下載)
  16. 未知  |  138040次下載  |  免費
亚洲欧美日韩精品久久_久久精品AⅤ无码中文_日本中文字幕有码在线播放_亚洲视频高清不卡在线观看
<acronym id="s8ci2"><small id="s8ci2"></small></acronym>
<rt id="s8ci2"></rt><rt id="s8ci2"><optgroup id="s8ci2"></optgroup></rt>
<acronym id="s8ci2"></acronym>
<acronym id="s8ci2"><center id="s8ci2"></center></acronym>