有了树莓派,但是没有hdmi显示器,这是个蛋疼的事,但是树莓派就是树莓派,他的GPIO管脚就是我们发挥想象力的地方.可以通过它的GPIO管脚来驱动一个显示屏.GOOGLE了一下,这个项目有个老外做好了,而且提供了patch文件,很容易就能移植到内核里面去.这里我就在这里记
有了树莓派,但是没有hdmi显示器,这是个蛋疼的事,但是树莓派就是树莓派,他的GPIO管脚就是我们发挥想象力的地方.可以通过它的GPIO管脚来驱动一个显示屏.GOOGLE了一下,这个项目有个老外做好了,而且提供了patch文件,很容易就能移植到内核里面去.这里我就在这里记录一下移植这个TFT驱动的过程,然后试着分析这个老外提供的PATCH文件,希望能从中提高自己的能力,也能够熟悉一下内核的移植.
环境: ubuntu 13.10 (交叉编译按前面的文章设置)
TFT : 2.4寸 12864接口 ILI9325主控 (当时叉宝买来给AVR用的)
http://blog.csdn.net/embbnux/article/details/17394793
博主最近自建了博客,以后会更多的用那个了,欢迎关注访问,里面也有很多有用资源:
http://www.embbnux.com/
参考文章:
http://spritesmods.com/?art=rpi_arcade&page=2
http://www.blogjava.net/baicker/archive/2012/12/18/392829.html
首先上张图:
一 首先是接线
用的是P1口:
TFT与P1连线:
这个上面的VCC接的是3.3v,因为我的屏幕接口是5v,所以我给改成5v了.
二 添加TFT驱动到内核
编译内核的环境,就按之前的文章设置,这里不再复述.
用的是spritesmods.com/?art=rpi_arcade&page=2提供的diff文件
原下载链接: ili9325_gpio_driver_rpi.diff
也可以到我的资源下载:
http://download.csdn.net/detail/canyue102/6735059
这个补丁是基于3.6内核的,不同版本的内核可能不一样,自己改一下就好了.
首先把 该diff文件放到内核根目录下,终端进去该目录:
patch -p1 <br> 然后TFT内核源码就被添加到内核去了. <br> <p></p> <pre class="brush:php;toolbar:false">make menuconfig可以在device driver >> graphics support >> support for frame buffer 下看到ILI9325选项,Y选中它就把它添加进内核.另外的BCM2708 framebuffer support就是原来树莓派自带的HDMI和AV显示.
make.
三 测试
进入ssh进入树莓派
ls /dev/fb*
可以看到有fb0 和 fb1, fb1 就是我的TFT.
测试:
cat /dev/urandom > /dev/fb1
如果屏幕出现花屏那就是成功了.
那要如何树莓派默认显示在tft上:
在make menuconfig里面把刚才说到的BCM2708 framebuffer support取消掉就可以了,不过就不支持HDMI了
三 源文件分析
查看该diff文件可以看出作者对内核做了四处改动
1 ) 在 arch/arm/mach-bcm2708/bcm2708.c文件中添加了ILI9325 平台定义
static struct platform_device bcm2708_ili9325 = { .name = "ili9325", .id = 0, }; /*************************/ bcm_register_device(&bcm2708_ili9325);
2 ) 修改了 drivers/video/Kconfig 文件,添加:
config FB_ILI9325 tristate "ILI9325 connected to Raspberry Pi GPIO support" depends on FB select FB_SYS_FILLRECT select FB_SYS_COPYAREA select FB_SYS_IMAGEBLIT select FB_SYS_FOPS select FB_DEFERRED_IO help This driver implements a framebuffer on an LCD controlled by a ILI9325 (or compatible) controller connected to the GPIO of the Raspberry Pi.
只有在Kconfig 中声明定义该模块,在make menuconfig 中才看得到ILI9325选项
3 ) 在 drivers/video/Makefile 添加:
obj-$(CONFIG_FB_ILI9325) += ili9325.o
只有加了这句话,在make menuconfig选中该模块后,make时,该模块才会被编译
4) 在drivers/video/目录下新建了 ili9325.c文件
代码比较长,这里只看核心代码:
static void ili9325_copy(struct ili9325 *item, unsigned int index) { unsigned short x; unsigned short y; unsigned short *buffer; unsigned short *oldbuffer; unsigned int len; unsigned int count; int sendNewPos=1; x = item->pages[index].x; y = item->pages[index].y; buffer = item->pages[index].buffer; oldbuffer = item->pages[index].oldbuffer; len = item->pages[index].len; dev_dbg(item->dev, "%s: page[%u]: x=%3hu y=%3hu buffer=0x%p len=%3hu\n", __func__, index, x, y, buffer, len); //Only update changed pixels in the page. for (count = 0; count =item->info->var.xres) { y++; x=0; } } }
前面还有一系列定义命令和初始化的函数,主要是得符合ILI9325的时序.和单片机上使用该TFT一样,这里的这个函数,主要用来显示,操作TFT上的每一个像素点.
四 有了显示屏那就做个摄像头显示的小项目
我正好有一个USB接口的UVC驱动的摄像头,树莓派兼容的,其他驱动芯片的驱动只要在make menuconfig里面找到相应选项就可以了.
插上usb摄像头,可以看到/dev下多了video0文件,这个就是摄像头了.
装个mplayer:
sudo apt-get install mplayer
然后用mplayer 播放该摄像头
在tft上用鼠标点击终端图标,输入命令:
mplayer tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0
然后就在tft上显示摄像头的图像:
就到这里吧,有空再玩.

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment