Discussion

The 5110 screen displays current system information [Baidu.com translate]

3 3636
tjCFeng  
Post Last Edited by tjCFeng at 2014-9-25 02:04

Very much hope that the banana pie can see some information when running in some large programs, but they do not want to do the occupation of the screen? Do a procedure to realize it.

The general development on Linux C with such relatively flexible, while Python will reload development libraries to operate the IO port is not great, but the most important thing is I can not, ha ha. With 10 years of Delphi, always can't let go of her feelings, so this time with her substitute Lazarus (Free Pascal) to find out the original feeling. In fact,truth is the same, the grammar is different.

This program work entirely in user mode, don't need all that stuff for kernel development, so it is very simple.

The required items:

Software: apt-get install Lazarus

Hardware: LCD5110 + Du Bangxian

Nokia 5110 LCD data export only 5, coupled with the power supply and LED, a total of only 8 pins, the connection is convenient, and the small screen refresh fast, very suitable for display some real information. These pins are respectively:

RST: reset pin, initialization using

SCE: chip select pin, a low level select

D/C: data / command select the foot, 1 data, 0 instruction

SDIN (MOSI): a data receiving line, used for data or instructions sent by a host is received

SCLK: clock line, determined to end data / instruction level

LED: backlight, which can support the PWM dimming

VCC: power supply

GND:

Look at Is it right? Something like SPI, I call it a semi SPI (their own name), only receiving no send.

Given all this, and then have a look how DuPont line connection.

RST - PI14 SCE - PI10

D/C - PI16

SDIN - PH21

SCLK - PH20

1.jpg


2.jpg


In fact, the principle is very simple, is in accordance with a certain time interval to read system information and thendisplayed. But the CPU usage is not a time to get, but need a period of time (at least two) calculated difference.

A practical example:

Obtained from the data in the system

User nice system idle iowait IRQ softirq stealstonlen 1225658189500 guestcpu 380826272759489390

This data is one of the obtained data, like this needs to read two times, with second times the value minus the firstvalue calculation of the percentage is CPU usage, calculation method:

Used:= user +nice + system + iowait + IRQ + softirq + stealstonlen + guest;

Totle:= user +nice + system + idle + iowait + IRQ + softirq + stealstonlen + guest;

Percent:= (used2 - used1) * 100 / (totle2 - totle1);

Memory is very simple, direct access to the current can be.

Two to obtain these data is a file:

CPU:'/proc/stat'

MEM:'/proc/meminfo'

Can use threads, timer to complete, even while+sleep can, but the CPU occupancy is big, so it is still recommendedby the thread.

However, in order to reflect the rapid development of the advantages of Lazarus directly, I put a Timer on the form,simple, low resource consumption.


Since it is the use of 5110 screen to display, to perform IO operations on each pin. Here are the most important is not the method of operation, but to identify the register in the user program virtual address.

Given the A20 manual GPIO base address is 0x01C20800, and PageSize is 4096, so in user mode address is in full page position + offset:

GPIO:= ($01C20800 and $FFFFF000) div PageSize;

Offset:= ($01C20800 and $00000FFF);

So in user space address:

MEM_GPIO:= fpMmap (nil, PAGE_SIZE, PROT_READ or PROT_WRITE, MAP_SHARED, FMEM, MEM_GPIO);

Offset each other configuration register address is GPIO + Offset + each register.


Source code is attached, look at the map under the effect of operation.

3.jpg

system form


4.jpg

The screen interface, the right is reserved for the blank disk space information, interested himself with the bar, pie chart is more beautiful.


5.jpg

The overall effect


The program actually consists of two display mode, can choose where to display according to their own needs.

Project code (a small bug didn't change, is to show that new data should first clear display data):


http://pan.baidu.com/s/1eQrdoJo

I also want to make this work.  You use PASCAL to release it. I have a suggestion if you can package a GPIO library, such as wiringPi, using PASCAL language. I have a little experience of PASCAL.

tjCFeng  
Post Last Edited by tjCFeng at 2014-9-25 20:50

Post Last Edited by tjCFeng at 2014-9-25 20:50

Reply 2# tony_zhang


     Thank you, good advice. I'm doing now, but only achieved GPIO and ADC, the other in written. Complete part upload test part.

English is not good, please forgive me.

tjCFeng  
Reply 2# tony_zhang


   Thank you, good advice. I'm doing now, but only achieved GPIO and ADC, the other in written. Complete part upload test part.

English is not good, please forgive me.

You have to log in before you can reply Login | Sign Up

Points Rules