mirror of
https://github.com/goodtft/LCD-show.git
synced 2024-11-28 17:24:12 +01:00
modift nano 2.4inch driver
This commit is contained in:
parent
4ec94ef008
commit
0f1be15f23
42
NANO24-show
42
NANO24-show
@ -22,6 +22,11 @@ sudo echo "dtparam=spi=on" >> ./boot/config.txt.bak
|
||||
sudo echo "enable_uart=1" >> ./boot/config.txt.bak
|
||||
sudo echo "dtoverlay=tft7789:rotate=90" >> ./boot/config.txt.bak
|
||||
sudo echo "dtoverlay=ft6236" >> ./boot/config.txt.bak
|
||||
sudo echo "hdmi_group=2" >> ./boot/config.txt.bak
|
||||
sudo echo "hdmi_mode=1" >> ./boot/config.txt.bak
|
||||
sudo echo "hdmi_mode=87" >> ./boot/config.txt.bak
|
||||
sudo echo "hdmi_cvt 320 240 60 6 0 0 0" >> ./boot/config.txt.bak
|
||||
sudo echo "hdmi_drive=2" >> ./boot/config.txt.bak
|
||||
sudo echo "gpio=18=op,dh" >> ./boot/config.txt.bak
|
||||
sudo cp -rf ./boot/config.txt.bak /boot/config.txt
|
||||
|
||||
@ -35,9 +40,44 @@ sudo cp -rf ./usr/99-fbturbo.conf /usr/share/X11/xorg.conf.d/99-fbturbo.conf
|
||||
#sudo cp ./usr/cmdline.txt /boot/
|
||||
#fi
|
||||
sudo cp ./usr/inittab /etc/
|
||||
#sudo cp ./boot/config-32.txt /boot/config.txt
|
||||
sudo touch ./.have_installed
|
||||
echo "gpio:resistance:nano24:90:320:240" > ./.have_installed
|
||||
|
||||
#FBCP install
|
||||
wget --spider -q -o /dev/null --tries=1 -T 10 https://cmake.org/
|
||||
if [ $? -eq 0 ]; then
|
||||
sudo apt-get install cmake -y 2> error_output.txt
|
||||
result=`cat ./error_output.txt`
|
||||
echo -e "\033[31m$result\033[0m"
|
||||
grep -q "^E:" ./error_output.txt
|
||||
type cmake > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
sudo rm -rf rpi-fbcp
|
||||
wget --spider -q -o /dev/null --tries=1 -T 10 https://github.com
|
||||
if [ $? -eq 0 ]; then
|
||||
sudo git clone https://github.com/tasanakorn/rpi-fbcp
|
||||
else
|
||||
echo "bad network, copy native fbcp!!!"
|
||||
sudo cp -r ./usr/rpi-fbcp .
|
||||
fi
|
||||
sudo mkdir ./rpi-fbcp/build
|
||||
cd ./rpi-fbcp/build/
|
||||
sudo cmake ..
|
||||
sudo make
|
||||
sudo install fbcp /usr/local/bin/fbcp
|
||||
cd - > /dev/null
|
||||
type fbcp > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
sudo cp -rf ./usr/99-fbturbo-fbcp.conf /usr/share/X11/xorg.conf.d/99-fbturbo.conf
|
||||
sudo cp -rf ./etc/rc.local /etc/rc.local
|
||||
fi
|
||||
else
|
||||
echo "install cmake error!!!!"
|
||||
fi
|
||||
else
|
||||
echo "bad network, can't install cmake!!!"
|
||||
fi
|
||||
|
||||
#evdev install
|
||||
#nodeplatform=`uname -n`
|
||||
#kernel=`uname -r`
|
||||
|
BIN
usr/ft6236.dtb
BIN
usr/ft6236.dtb
Binary file not shown.
14
usr/rpi-fbcp/CMakeLists.txt
Normal file
14
usr/rpi-fbcp/CMakeLists.txt
Normal file
@ -0,0 +1,14 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
SET(COMPILE_DEFINITIONS -Werror)
|
||||
|
||||
include_directories(/opt/vc/include)
|
||||
include_directories(/opt/vc/include/interface/vcos/pthreads)
|
||||
include_directories(/opt/vc/include/interface/vmcs_host)
|
||||
include_directories(/opt/vc/include/interface/vmcs_host/linux)
|
||||
|
||||
link_directories(/opt/vc/lib)
|
||||
|
||||
add_executable(fbcp main.c)
|
||||
|
||||
target_link_libraries(fbcp bcm_host)
|
21
usr/rpi-fbcp/LICENSE
Normal file
21
usr/rpi-fbcp/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2013 Tasanakorn Phaipool
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
62
usr/rpi-fbcp/README.md
Normal file
62
usr/rpi-fbcp/README.md
Normal file
@ -0,0 +1,62 @@
|
||||
Raspberry Pi Framebuffer Copy
|
||||
=============================
|
||||
This program used for copy primary framebuffer to secondary framebuffer (eg. FBTFT). It require lastest raspberry pi firmware (> 2013-07-11) to working properly.
|
||||
|
||||
Tested on Raspberry Pi 3
|
||||
========================
|
||||
2017-11-29-raspbian-stretch
|
||||
|
||||
|
||||
Requirement
|
||||
-----------
|
||||
cmake
|
||||
|
||||
$ sudo apt-get install cmake
|
||||
|
||||
Build
|
||||
-----
|
||||
|
||||
$ mkdir build
|
||||
|
||||
$ cd build
|
||||
|
||||
$ cmake ..
|
||||
|
||||
$ make
|
||||
|
||||
|
||||
How To Use
|
||||
----------
|
||||
$ ./fbcp
|
||||
|
||||
Wanna to run from booting
|
||||
-------------------------
|
||||
$ sudo cp fbcp /usr/bin
|
||||
$ sudo chmod +x /usr/bin/fbcp
|
||||
$ sudo nano /etc/rc.local -> add new line before "exit 0" with "/usr/bin/fbcp &" without quote
|
||||
$ sudo reboot
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
|
||||
Copyright (c) 2013 Tasanakorn Phaipool
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
93
usr/rpi-fbcp/main.c
Normal file
93
usr/rpi-fbcp/main.c
Normal file
@ -0,0 +1,93 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/fb.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <bcm_host.h>
|
||||
|
||||
int process() {
|
||||
DISPMANX_DISPLAY_HANDLE_T display;
|
||||
DISPMANX_MODEINFO_T display_info;
|
||||
DISPMANX_RESOURCE_HANDLE_T screen_resource;
|
||||
VC_IMAGE_TRANSFORM_T transform;
|
||||
uint32_t image_prt;
|
||||
VC_RECT_T rect1;
|
||||
int ret;
|
||||
int fbfd = 0;
|
||||
char *fbp = 0;
|
||||
|
||||
struct fb_var_screeninfo vinfo;
|
||||
struct fb_fix_screeninfo finfo;
|
||||
|
||||
|
||||
bcm_host_init();
|
||||
|
||||
display = vc_dispmanx_display_open(0);
|
||||
if (!display) {
|
||||
syslog(LOG_ERR, "Unable to open primary display");
|
||||
return -1;
|
||||
}
|
||||
ret = vc_dispmanx_display_get_info(display, &display_info);
|
||||
if (ret) {
|
||||
syslog(LOG_ERR, "Unable to get primary display information");
|
||||
return -1;
|
||||
}
|
||||
syslog(LOG_INFO, "Primary display is %d x %d", display_info.width, display_info.height);
|
||||
|
||||
|
||||
fbfd = open("/dev/fb1", O_RDWR);
|
||||
if (fbfd == -1) {
|
||||
syslog(LOG_ERR, "Unable to open secondary display");
|
||||
return -1;
|
||||
}
|
||||
if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) {
|
||||
syslog(LOG_ERR, "Unable to get secondary display information");
|
||||
return -1;
|
||||
}
|
||||
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) {
|
||||
syslog(LOG_ERR, "Unable to get secondary display information");
|
||||
return -1;
|
||||
}
|
||||
|
||||
syslog(LOG_INFO, "Second display is %d x %d %dbps\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel);
|
||||
|
||||
screen_resource = vc_dispmanx_resource_create(VC_IMAGE_RGB565, vinfo.xres, vinfo.yres, &image_prt);
|
||||
if (!screen_resource) {
|
||||
syslog(LOG_ERR, "Unable to create screen buffer");
|
||||
close(fbfd);
|
||||
vc_dispmanx_display_close(display);
|
||||
return -1;
|
||||
}
|
||||
|
||||
fbp = (char*) mmap(0, finfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0);
|
||||
if (fbp <= 0) {
|
||||
syslog(LOG_ERR, "Unable to create memory mapping");
|
||||
close(fbfd);
|
||||
ret = vc_dispmanx_resource_delete(screen_resource);
|
||||
vc_dispmanx_display_close(display);
|
||||
return -1;
|
||||
}
|
||||
|
||||
vc_dispmanx_rect_set(&rect1, 0, 0, vinfo.xres, vinfo.yres);
|
||||
|
||||
while (1) {
|
||||
ret = vc_dispmanx_snapshot(display, screen_resource, 0);
|
||||
vc_dispmanx_resource_read_data(screen_resource, &rect1, fbp, vinfo.xres * vinfo.bits_per_pixel / 8);
|
||||
usleep(25 * 1000);
|
||||
}
|
||||
|
||||
munmap(fbp, finfo.smem_len);
|
||||
close(fbfd);
|
||||
ret = vc_dispmanx_resource_delete(screen_resource);
|
||||
vc_dispmanx_display_close(display);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
setlogmask(LOG_UPTO(LOG_DEBUG));
|
||||
openlog("fbcp", LOG_NDELAY | LOG_PID, LOG_USER);
|
||||
|
||||
return process();
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user