Home Database Mysql Tutorial 基于树莓派raspberry: 移植 2.4寸TFT显示屏以及源码分析

基于树莓派raspberry: 移植 2.4寸TFT显示屏以及源码分析

Jun 07, 2016 pm 03:24 PM
based on show raspberry

有了树莓派,但是没有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

首先上张图:

                      基于树莓派raspberry: 移植 2.4寸TFT显示屏以及源码分析

                     基于树莓派raspberry: 移植 2.4寸TFT显示屏以及源码分析

一  首先是接线

      用的是P1口:

      基于树莓派raspberry: 移植 2.4寸TFT显示屏以及源码分析

       TFT与P1连线:

      基于树莓派raspberry: 移植 2.4寸TFT显示屏以及源码分析

    这个上面的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
Copy after login
     可以在device driver >> graphics support >> support for frame buffer 下看到ILI9325选项,Y选中它就把它添加进内核.另外的BCM2708 framebuffer support就是原来树莓派自带的HDMI和AV显示.

make 
Copy after login
   .

三  测试

     进入ssh进入树莓派

   

ls /dev/fb*
Copy after login

     可以看到有fb0 和 fb1,  fb1 就是我的TFT.

测试:

cat /dev/urandom > /dev/fb1
Copy after login

如果屏幕出现花屏那就是成功了.

 那要如何树莓派默认显示在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);
Copy after login

  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.
Copy after login

只有在Kconfig 中声明定义该模块,在make menuconfig 中才看得到ILI9325选项

   3 ) 在 drivers/video/Makefile 添加:

 

obj-$(CONFIG_FB_ILI9325)		  += ili9325.o
Copy after login

    只有加了这句话,在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;
		}
	}
}
Copy after login

前面还有一系列定义命令和初始化的函数,主要是得符合ILI9325的时序.和单片机上使用该TFT一样,这里的这个函数,主要用来显示,操作TFT上的每一个像素点.


四  有了显示屏那就做个摄像头显示的小项目

     我正好有一个USB接口的UVC驱动的摄像头,树莓派兼容的,其他驱动芯片的驱动只要在make menuconfig里面找到相应选项就可以了.

     插上usb摄像头,可以看到/dev下多了video0文件,这个就是摄像头了.

     装个mplayer:

   

sudo apt-get install mplayer
Copy after login

    然后用mplayer 播放该摄像头

    在tft上用鼠标点击终端图标,输入命令:

  mplayer tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0  
Copy after login

   然后就在tft上显示摄像头的图像:

       基于树莓派raspberry: 移植 2.4寸TFT显示屏以及源码分析

     

就到这里吧,有空再玩.



Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to remove news and trending content from Windows 11 Search How to remove news and trending content from Windows 11 Search Oct 16, 2023 pm 08:13 PM

When you click the search field in Windows 11, the search interface automatically expands. It displays a list of recent programs on the left and web content on the right. Microsoft displays news and trending content there. Today's check promotes Bing's new DALL-E3 image generation feature, the "Chat Dragons with Bing" offer, more information about dragons, top news from the Web section, game recommendations, and the Trending Search section. The entire list of items is independent of your activity on your computer. While some users may appreciate the ability to view news, all of this is abundantly available elsewhere. Others may directly or indirectly classify it as promotion or even advertising. Microsoft uses interfaces to promote its own content,

iOS 17's standby mode turns a charging iPhone into a home hub iOS 17's standby mode turns a charging iPhone into a home hub Jun 06, 2023 am 08:20 AM

In iOS 17 Apple is introducing Standby Mode, a new display experience designed for charging iPhones in a horizontal orientation. In this position, the iPhone is able to display a series of full-screen widgets, turning it into a useful home hub. Standby mode automatically activates on an iPhone running iOS 17 placed horizontally on the charger. You can view time, weather, calendar, music controls, photos, and more. You can swipe left or right through the available standby options and then long press or swipe up/down to customize. For example, you can choose from analog view, digital view, bubble font, and daylight view, where the background color changes based on time as time passes. There are some options

Windows 11 User Guide: How to disable ad pop-ups Windows 11 User Guide: How to disable ad pop-ups Sep 22, 2023 pm 07:21 PM

Microsoft's Windows 11 operating system may periodically display suggestions as pop-ups on your computer using the notification system. The suggestions system, originally intended to provide users with tips and suggestions for improving their Windows 11 workflows, has almost completely transformed into an advertising system to promote Microsoft services and products. Suggestion pop-ups might advertise a Microsoft 365 subscription to users, suggest linking an Android phone to the device, or set up a backup solution. If these pop-ups annoy you, you can tweak your system to disable them entirely. The following guide provides recommendations on disabling pop-ups on devices running Microsoft’s Windows 11 operating system.

Reasons and solutions for desktop layout being locked Reasons and solutions for desktop layout being locked Feb 19, 2024 pm 06:08 PM

What happens when the desktop layout is locked? When using the computer, sometimes we may encounter the situation where the desktop layout is locked. This problem means that we cannot freely adjust the position of desktop icons or change the desktop background. So, what exactly is going on when it says that the desktop layout is locked? 1. Understand the desktop layout and locking functions. First, we need to understand the two concepts of desktop layout and desktop locking. Desktop layout refers to the arrangement of various elements on the desktop, including shortcuts, folders, widgets, etc. we can be free

How to turn on live captions instantly in Windows 11 How to turn on live captions instantly in Windows 11 Jun 27, 2023 am 08:33 AM

How to turn on live subtitles instantly in Windows 11 1. Press Ctrl+L on your keyboard 2. Click Agree 3. A popup will appear saying Ready to add subtitles in English (US) (depending on your preferred language) 4. Additionally, you can filter profanity by clicking the gear button? Preference? Filtering Swear Words Related Articles How to Fix Activation Error Code 0xc004f069 in Windows Server The activation process on Windows sometimes takes a sudden turn to display an error message containing this error code 0xc004f069. Although the activation process is online, some older systems running Windows Server may experience this issue. Pass these preliminary checks and if these checks do not

How to make a remote desktop connection display the other party's taskbar How to make a remote desktop connection display the other party's taskbar Jan 03, 2024 pm 12:49 PM

There are many users using Remote Desktop Connection. Many users will encounter some minor problems when using it, such as the other party's taskbar not being displayed. In fact, it is probably a problem with the other party's settings. Let's take a look at the solutions below. How to display the other party's taskbar during Remote Desktop Connection: 1. First, click "Settings". 2. Then open "Personalization". 3. Then select "Taskbar" on the left. 4. Turn off the Hide Taskbar option in the picture.

How to check the current directory in Linux? How to check the current directory in Linux? Feb 23, 2024 pm 05:54 PM

In Linux systems, you can use the pwd command to display the current path. The pwd command is the abbreviation of PrintWorkingDirectory and is used to display the path of the current working directory. Enter the following command in the terminal to display the current path: pwd After executing this command, the terminal will display the full path of the current working directory, such as: /home/user/Documents. In addition, you can use some other options to enhance the functionality of the pwd command. For example, the -P option can display

How to display the wifi password QR code? It is recommended to scan the wifi password on WeChat in 3 seconds. How to display the wifi password QR code? It is recommended to scan the wifi password on WeChat in 3 seconds. Feb 20, 2024 pm 01:42 PM

You don’t need to enter the WIFI password often, so it’s normal to forget it. Today I will teach you the simplest way to find the password of your own WIFI. It can be done in 3 seconds. To check the WIFI password, use WeChat to scan it. The premise of this method is: there must be a mobile phone that can connect to WIFI. Okay, let’s start the tutorial: Step 1. We enter the phone, pull down from the top of the phone, bring up the status bar, and the WIFI icon. Step 2. Long press the WIFI icon to enter the WLAN settings; long press the WIFI icon. Step 3. Click Connected. Enter the WIFI name of your home, click Share Password, and a QR code will pop up; Step 4 of sharing WIFI password, we take a screenshot and save this QR code; Step 5, long press the WeChat icon on the desktop, and click Scan

See all articles