Yes it is;
# Turn off backlight
echo 1 | sudo tee /sys/class/backlight/*/bl_power
# Turn on backlight
echo 0 | sudo tee /sys/class/backlight/*/bl_power
Yes it is;
# Turn off backlight
echo 1 | sudo tee /sys/class/backlight/*/bl_power
# Turn on backlight
echo 0 | sudo tee /sys/class/backlight/*/bl_power
1. Edit /boot/config.txt
Add;
dtparam=spi=on
2. Edit /etc/modules
Copy and paste the code below into this file;
flexfb width=320 height=480 regwidth=16 init=-1,0xb0,0x0,-1,0x11,-2,250,-1,0x3A,0x55,-1,0x36,0x28,-1,0xC2,0x44,-1,0xC5,0x00,0x00,0x0,0x0,-1,0xE0,0x0F,0x1F,0x1C,0x0C,0x0F,0x08,0x48,0x98,0x37,0x0A,0x13,0x04,0x11,0x0D,0x00,-1,0xE1,0x0F,0x32,0x2E,0x0B,0x0D,0x05,0x47,0x75,0x37,0x06,0x10,0x03,0x24,0x20,0x00,-1,0xE2,0x0F,0x32,0x2E,0x0B,0x0D,0x05,0x47,0x75,0x37,0x06,0x10,0x03,0x24,0x20,0x00,-1,0x11,-1,0X29,-3 fbtft_device debug=3 rotate=90 name=flexfb speed=16000000 gpios=reset:25,dc:24,led:22 ads7846_device gpio_pendown=17 verbose=3 x_plate_ohms=100 pressure_max=255 swap_xy=1
Rotating the display on PiScreen to portrait mode can be done by editing /boot/config.txt and adding the optional rotation parameter after the overlay statement
dtoverlay=piscreen2r,rotate=90
The values, 0, 90, 180, 270 are supported.
The DPI can be set when starting X windows. Changing the DPI can give you a bit more screen real-estate.
To make a permanent change;
edit /usr/bin/startx as root and enter in some default server arguments.
defaultserverargs=”-dpi 60” serverargs=”-dpi 60”
You will need to use the pygame module to display information on PiScreen with Python.
And before you call pygame.init(), you need to set the environment variable to point the output to PiScreen. (/dev/fb1).
Example code;
import pygame, sys, os from pygame.locals import * os.putenv('SDL_FBDEV', '/dev/fb1') pygame.init() # set up the window DISPLAYSURF = pygame.display.set_mode((480, 320)) # set up the colors BLACK = ( 0, 0, 0) WHITE = (255, 255, 255) RED = (255, 0, 0) GREEN = ( 0, 255, 0) BLUE = ( 0, 0, 255) # draw on the surface object DISPLAYSURF.fill(WHITE) pygame.draw.polygon(DISPLAYSURF, GREEN, ((146, 0), (291, 106), (236, 277), (56, 277), (0, 106))) pygame.draw.line(DISPLAYSURF, BLUE, (60, 60), (120, 60), 4) pygame.draw.line(DISPLAYSURF, BLUE, (120, 60), (60, 120)) pygame.draw.line(DISPLAYSURF, BLUE, (60, 120), (120, 120), 4) pygame.draw.circle(DISPLAYSURF, BLUE, (300, 50), 20, 0) pygame.draw.ellipse(DISPLAYSURF, RED, (300, 200, 40, 80), 1) pygame.draw.rect(DISPLAYSURF, RED, (200, 150, 100, 50)) pixObj = pygame.PixelArray(DISPLAYSURF) pixObj[380][280] = BLACK pixObj[382][282] = BLACK pixObj[384][284] = BLACK pixObj[386][286] = BLACK pixObj[388][288] = BLACK del pixObj # run the game loop while True: for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() pygame.display.update()
PiScreen isnt supported on XBMC. However there is a work around to copy what is display on the HDMI port(fb0) to the PiScreen.
To do this, we will need Framebuffer Copy.
To use Framebuffer Copy the console needs to be on fb0. If it isnt already there, you can change it to fb0 using this command;
The run framebuffer copy in the background
You should now have fb0 mirrored onto fb1(PiScreen).
If you rotate the display on the TFT, you will also need to rotate the touchscreen.
If you haven't already done so, install xinput.
Open up the X init script
And add these lines;
DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axes Swap' 1 DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 1 1
before;
. /etc/X11/Xsession
You may need to change the values at the end of the each line;
Evdev Axes Swap
Swap X & Y
1 for yes and 0 for no
Evdev Axis Inversion
Swap the direction on the X or Y plane.
1 for yes and 0 for no. A number is needed for each plane
You may also need to re-calibrate the touch screen for X windows. This can be done by deleting the file below and then rebooting;
The calibration script runs every time X Windows starts
It first checks for the calibration file and if it is present it then loads this data into X windows.
If the calibration data is not present, it will then start the calibration program.
To rerun the calibration program, delete /etc/pointercal.xinput
When the console is moved to the PiScreen, no console will appear out the HDMI port.
The console can be moved back to the HDMI port by deleting the text below from /boot/cmdline.txt
fbcon=map:10 fbcon=rotate:2 fbcon=font:ProFont6x11
This can be down from a Windows or Mac PC.
You can always leave the console on the HDMI and manually swing it over to piscreen with
con2fbmap 1 1
and back to the HDMI with
con2fbmap 1 0
This will have to be done every time the Pi is booted.
Yes