HwLevel

The Hardware Level



How to...


Install a Raspbian image with LCD drivers

Using a Raspbian image from Downloads page should be very easy. Download it, unzip it and flash (not COPY with file manager) it to SD card. This can be done with Win32DiskImager from Windows or using command line from Linux. OSX can also be used of course. The procedure is  described on http://elinux.org/RPi_Easy_SD_Card_Setup.

The image contains driver modules for all our displays. By default the driver for LCD-PI32 is loaded. If you purchased LCD-PI32 and flashed the image to SD card that's it. Plug the module and connect power.

For LCD-PI33 another driver needs to be loaded in system boot process. Edit /etc/modules and replace ssd1289 with d51.

sudo nano /etc/modules

Besides that, use the prepared xorg.conf file:

sudo cp /etc/X11/xorg.conf_LCD-PI33 /etc/X11/xorg.conf


Use a package with kernel and driver modules

Package contains kernel (kernel.img) and driver modules (/lib folder). The package should be downloaded to RPi and extracted from the command line:

# first make an optional backup of your current kernel and /lib folder
sudo cp /boot/kernel.img .
sudo tar -czvf my_modules.tar.gz /lib
# then unpack the package
sudo tar -C / -xzvf package_name.tar.gz


Start XWindows

LCD-PI module is seen as /def/fb1 device. We have to tell XServer to use it:

FRAMEBUFFER=/dev/fb1 startx


Disable or enable the boot console

You need to the edit /boot/cmdline.txt file:

sudo nano /boot/cmdline.txt
  • to disable boot console: delete fbcon=map:10 fbcon=font:VGA8x8 from cmdline.txt
  • to enable boot console: add fbcon=map:10 fbcon=font:VGA8x8 to the end of cmdline.txt


Use a package with kernel and driver modules

Package contains kernel (kernel.img) and driver modules (/lib folder). The package should be downloaded to RPi and extracted from the command line:

# first make an optional backup of your current kernel and /lib folder
sudo cp /boot/kernel.img .
sudo tar -czvf my_modules.tar.gz /lib
# then unpack the package
sudo tar -C / -xzvf package_name.tar.gz


Control the backlight

On LCD-PI32 and LCD-PI33 backlight can only be switched on and off:

echo 0 > /sys/class/backlight/lcd-pi/brightness
echo 1 > /sys/class/backlight/lcd-pi/brightness

On LCD-PI43 and LCD-PI50 write any number between 0 (off) and 100 (full brightness):

echo 50 > /sys/class/backlight/lcd-pi/brightness


Calibrate the touchscreen


Use tactile switches

Status of tactile switches can be accessed using an ioctl call. Bellow is an example in C (compile on RPi with gcc):

#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/ioctl.h>

#define SSD1289_GET_KEYS _IOR('K', 1, unsigned char *)
 
void print_keys(int fd) {
    unsigned char keys;
 
    if (ioctl(fd, SSD1289_GET_KEYS, &keys) == -1) {
        perror("_apps ioctl get");
    } else {
        printf("Keys : %2x\n", keys);
    }
}
 
int main(int argc, char *argv[]) {
    char *file_name = "/dev/fb1";
    int fd;
    
    fd = open(file_name, O_RDWR);
    if (fd == -1) {
        perror("_apps open");
        return 2;
    }
 
    print_keys(fd);
    printf("Ioctl Number: (dec)%d  (hex)%x\n", SSD1289_GET_KEYS, SSD1289_GET_KEYS);
    
    close (fd);
    return 0;
}