Create library in CadSoft (Eagle) by using existing library

*** Thanks for Kevin Bolding ***

Copying a Symbol from another Library

The first step in copying a symbol is to open up the library that has the existing part.  Use File/Open to open the 74XX-US.lbr library.  Choose the Edit Symbol tool  and select the symbol 7400.  We are going to copy this into our library to make a new gate called the 999.  First, make sure all layers are visible by choosing the Layers button and selecting All.  Now, make the entire symbol into a group by using the Group tool  and drawing a rectangle around everything visible.  Finally, select the Cut tool  to and click on the group to copy the group onto the clipboard.

Now we can copy the symbol into our own library.  Open up your custom library.  Click on Edit Symbol  and enter “999” for the new symbol name.  Now, use the Paste tool  to paste a copy of the 7400 Nand gate into the new symbol.  You may now edit it as you like (for instance, change one of the input pins to be inverted by using the Change tool  to change the function from None to Dot.  Click one of the pins and it will change as shown below:

You may now save your symbol and use it as part of other devices.

Copying a Package  from another Library

Most common packages (such as the DIL8 we just made) already are defined in some library or another.  You’ll find it easiest to copy them rather than re-make them.  Copying packages is the same as copying symbols.  You might want to try copying the DIL8 package from the 74XX-US library into your new library.  (Of course, you won’t want to copy over your existing DIL8, so name the copy DIL8A.)

Ps: Select all layers before group select, and cut group then.

Putting Gates and Packages Together Into Devices

The final task in making a part is to create a device that has information on how symbols are placed inside of a package.  For many devices, there will be only one symbol.  However, many devices contain multiple symbols, as well as hidden power pins.  This is the case for the Gizmo device, which contains three Gizmogates and hidden power pins.

Make a new device by clicking on the Device button .  Enter “GIZMO” in the New field.  Now, add three copies of the Gizmo symbol, since the Gizmo device will contain three Gizmo gates.  Change the names of the three Gizmos to “A”, “B” and “C” by clicking the Names tool .

Since the Gizmo package will have Power and Ground pins, but the symbols don’t include the pins explicitly, we need to add a Power/Ground symbol to the device as well.  To save some time, we’ll copy thePWRN symbol from another library and use it instead of creating a new symbol.  Follow the directions for copying a symbol from another library above and copy the symbol PWRN from the library 74XX-US.lbr.  Give the new symbol the name PWRN in your library.  Now you can put the PWRN symbol in the Gizmo package by using the Add tool .  Give the symbol the name PWR by using the Name tool.

Since there are multiple symbols in this package, we need to specify how they are added to a schematic.  Normally, we just add the next symbol as needed.  In other words, the first symbol is Gizmogate A, then Gizmogate B, and so on.  To specify this, change the Add level to “Next” by using the Change tool  and selecting AddLevel Next.  Click on the three Gizmogates to change their Add levels to Next. The PWRN symbol usually is hidden on a schematic, so we don’t want to add it like we add the Gizmogates.  Change its Add level to Request to indicate that it will only be added if specifically requested by the designer.  It will still be in the gate, but it won’t appear on the schematic.

The final step in making a device is to specify a package and the connections from symbol pins to package pads.  First, we’ll want to specify the package we just designed, the DIL8.  Click on the NEW button at the bottom of the screen under the package variant window. Select your new package, the DIL8.  You may also want to assign a prefix of “GZ” to the symbols in this package - that way the first symbol you add will be GZ1, the next GZ2, and so on.  Use the Prefix button to change the prefix.

Now we can complete the device by assigning symbol pins to package pads.  Click on the Connect button  and a window will pop up to allow you to connect pins to pads.  Since there are three Gizmogates, you’ll see three sets of IN and OUTB pins for gates A, B, and C.  There are also the GND and VCC pins as well.  Start by connecting A.IN to pad P$1 by selecting both and pressing Connect. Connect the remaining pins to pads as follows:


Your final device should look like the following diagram: 

We’re finally done with the device.  Save it!


Linux search command

$ apt-cache search xxx

$ yum search xxx

Install eGalax touch screen in Linux (Ubuntu)

Linux *Ubuntu 下安装触摸屏驱动
** special thanks to Kekezu **
(Install on Fedora:

I made this touch screen (8" 800Y-Y-V USB control) works on Ubuntu 9.04 2.6.28-16-generic.

Step1) Download required packages and TouchKit utility
$ sudo apt-get install linux-source
$ cd ~
$ wget

Step2) Installing TouchKit utility
$ sudo chmod -x TouchKit-2.06.2905-32b-k26.tar.gz
$ sudo tar -xzvf TouchKit-2.06.2905-32b-k26.tar.gz
$ cd eGalaxTouch32
$ sudo sh

Utility will be installed to /usr/local/eGalaxTouch32/

Step3) Building the tkusb module

$ cd /usr/src
$ uname -r  # Checks linux kernel version
$ sudo chmod -x linux-source-2.6.xx.tar.bz2  # Change xx
$ sudo tar -xjvf linux-source-2.6.xx.tar.bz2 
$ sudo cp ./linux-headers-`uname -r`/Module.symvers ./linux-source-2.6.xx   
$ sudo ln -s linux-source-2.6.xx /usr/src/linux
$ cd /usr/src/linux
$ sudo make oldconfig
$ sudo make prepare
$ sudo make modules SUBDIRS=scripts/mod/
$ cd /usr/local/eGalaxTouch32/USBSrc

$ sudo gedit Makefile

Around line 16, find

KDIR := /lib/modules/$(shell uname -r)/build

Replace this line with

KDIR := /usr/scr/linux

$ sudo gedit tkusb.h
around line 25, find
include ams/semaphore.h

Replace this line with


$ sudo make all
$ sudo cp tkusb.ko /lib/modules

Step4) Modifying file /etc/X11/xorg.conf

$ sudo gedit /etc/X11/xorg.conf

Change Option "Device" to "usbauto" in InputDevice section of touch screen

Part of the file xorg.conf

Section InputDevice
Identifier "EETI"
Option    "Device"    "usbauto"

PS: someone told me that the xorg.conf file has been deprecated in favor of a more XML type configuration on his Ubuntu 9.10. He ended up to create an empety xorg.conf file.

Step5) Making startup script to load the module

$ sudo gedit /etc/init.d/addTouchKit

Content of file addTouchKit

#! /bin/sh
rmmod /lib/modules/'uname -r'/kernel/drivers/hid/usbhid/usbhid.ko
insmod /lib/modules/tkusb.ko
sleep 1
insmod /lib/modules/'uname -r'/kernel/drivers/hid/usbhid/usbhid.ko

$ sudo update-rc.d addTouchKit defaults
$ sudo chmod 441 /etc/init.d/addTouchKit

Now panel is installed. Reboot your computer.

Step6) Starting utility and calibrating the panel

$ cd /usr/local/eGalaxTouch32
$ ./eGalaxTouch

Here are some screen shots of the touch screen calibration window

I am a student. If you feel this page is quite useful, 
do you mind click the ad (just once) on the right hand side :)
I appreciate your support ...


Install Adobe Flash player on Linux Fedora & Firefox

To install Adobe Flash player on Fedora Linux, so that you can view Flash movies in Firefox on your Linux machine, simply follow these easy steps:

Step 1- rpm -ivh

Step 2- rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux

Step 3- mkdir -p /usr/lib/mozilla/plugins /usr/lib64/mozilla/plugins

Step 4- yum install flash-plugin

Step 5- mozilla-plugin-config -i -g -v

Then just restart your Firefox browser and Flash will be available.

Auto mount network partition in linux

open /etc/fstab under root, add:

// /media/c-drive cifs gid=myname,uid=myname,user=myname,pass=mycode 0 0


Add Serial Port Communication Lib in Qt

Down load "qextserialport", unzip it.

Two ways to compile it. It depends on the source code I download.
1) qmake  // or qmake-qt4 in fedora
2) make
3) Open project ( in Qt, build it.

After compile the files, I got four files in 'build' folder:

copy all link files to /usr/lib
$ cp -a libq* /usr/lib

Add the lib in .pro file:

LIBS += -lqextserialport
Publish Post
win32:DEFINES = _TTY_WIN_ \
INCLUDEPATH += /home/czhang/Documents/software/qextserialport


Reset Window origin coordination


by default, window / frame's origin coordination is (0,0). it can't be changed in the property window, but can be set up in code.

after create a new window, add following code after "m_ui->setupUi(this)"

QPoint pos; // relocate window

pos.setX(240); // x

pos.setY(100); // y



Resizing pictures in batch in Linux


Software: imagemagick

install: $ sudo apt-get install imagemagick


$ mogrify -resize 50% *.jpg or
$ convert -resize 50% *.jpg (don't over write original photos)


Message box


switch(QMessageBox::warning(this, "Warning",
"Database file is opened,\n"
"please close it first.\n"
"Close database file?",
"Yes", "No", 0, 1)) {
case 0:
db.close(); // close database
dbOpened = false;
openFile(); // open file dialog
break; // pay attention to here
case 1:
break; // and here

Timer event


#include “qtimer.h”

in main.cpp main function add:
startTimer(100) //start timer, and timer event triggered every 100 ms

PS: it is a little bit strange here. i don't need to declare a QTimer class. i may find the reason in the future since i am a just beginner in Qt

in main.h add:
void timerEvent(QTimerEvent *event);

in main.cpp add:
void MainWindow::timerEvent(QTimerEvent *event


my concern was right, my previous code was wrong. i actually calling the system timer event, not the timer which i created.

here is the correct code:

in main.h add:

QTimer *timer1;
void timerEvent();

in main.cpp add:

timer1 = new QTimer(this); // start timer event
connect(timer1, SIGNAL(timeout()), this, SLOT(timerEvent()));


Find application icon


in KDE:

$ kde-config --path icon
will list all icon directory.


$ gnome-config –datadir

will list a path which contains a folder called “pixmaps”.

Get total record count (SQLite)

my_sqlModel = new QSqlQueryModel(); //define a new sql model
my_sqlModel.setQuery(“select * from item”);
int cols = my_sqlModel.rowCount();

Qt Installation in Linux

(Qt 在Linux上的安装) Qt SDK
2.go to the downloaded file folder:
On Linux/Unix, need to make the file executable in order to run it. You can either do this with your desktop's file manager or, at the command line, type:

$ chmod u+x qt-sdk-linux-x86-opensource-2009.02.bin

should now be able to execute the file as normal. to do this from the command line by typing:

$ ./qt-sdk-linux-x86-opensource-2009.02.bin

3.install GNU C++ compliler:

$ sudo apt-get install g++
$ sudo apt-get install build-essential

Create second window/form/dialog


Add New.. Qt – Qt Designer Form Class
Need to include newform.h in mainwindow.cpp file where has slot to open this new window;
Add "extern newDialog *newdialog" in mainwindow.cpp;
"newDialog *newdialog" in newwindow.cpp;

Then, in click-button which open new window slot, add:

void MainWindow::on_pushButton_clicked()
   if (!newdialog)

=  new newDialog (NULL);

The above method creates dialog in heap,  so when i click close(), i don't delete it from memory. To close dialog or window completely, the code needs to be changed as:

void MainWindow::on_pushButton_clicked()
     newDialog newdialog(NULL);

we can not use:;

show() does not block, so you'll only see a quick flash of your dialog, as it'll be destroyed immediately after calling show() ( when exiting the method ). Using exec() blocks until dialog is closed by the user. 

if create new a window/dialog by using code, and did not pre-create window/dialog from “add new.. QT Designer form class”, the new window/dialog may be no shows on the top. This is because that the new window/dialog does not have a parent window/dialog. In order to make sure the new window/dialog shows on the top, use “add new.. QT Designer form class” create a new window/dialog first.

Globle variabal definition


Assume I have a.cpp b.cpp c.cpp and I need use integer i in all three of them.

I declare extern int i in globvar.h file;

Define int i in globevar.cpp file;

#include globvar.h file in all three .cpp files.

Varible definition

parameter definition should be in .h file. If this variable is used in this window/form (qqWidget.h), just declare in “private:”. But if used in anther window/form, should declare in “public:”.

// globalvar.h

extern int variable1;
extern int variable2;


// globalvar.cpp implementation

int variable1= 0;
int variable = 0;

Qt is not qute

my qt program's gui looks like normal...

need to add style header in the including file:

#include "mainwindow.h"

int main(int argc, char *argv[])
QApplication a(argc, argv);
MainWindow w;;
a.setStyle(new QPlastiqueStyle); //this command must be in front of ”return a.exec()”
return a.exec();


Qt4.5 Installation in Windows

(Qt4.5 安装)
to install Qt, need to download and install all three files from Qt website:

after drag and drop component, no need to declare it again in project.
but need to add ui-> in front of each used component if you wanna to use/edit it.


2D barcodes creator/decoder -- Libdmtx


Libdmtx is a 2D barcode, or Data Matrix barcodes, creator and decoder.

it took me a while to install it. here is mainly procedure of installation:

download libdmtx-0.7.0.tar.gz from
$ tar -zxf libdmtx-0.7.0.tar.gz

go to new libdmtx folder
$ ./configure

i got an error message:
checking for MAGICK... no
configure: error: dmtxread/dmtxwrite requires Wand >= 6.2.4
that's because i am using ubuntu. alright, i need to install ImageMagick from the source.
download ImageMagick source file, unpacked,
$ ./configure
$ make
$ sudo make install

(edit: I may need this:
$ sudo apt-get install libmagick++-dev
$ sudo apt-get install libgraphicsmagick1-dev

i may need to install g++ before install ImageMagick
$ sudo apt-get install g++

got anther error when i ran ./configure:
/usr/bin/ld: cannot find -lperl

ok, need to install libperl
$ sudo apt-get install libperl-dev

then, go back to install ImageMagick, and libdmtx.

all done..

To read a 2D barcode:
$ dmtxread /~/Desktop/image.png  
$ dmtxread -N 1 /home/czhang/mypro/UIM.jpg >> /home/czhang/mypro/UIM.txt
read barcode and export code to text file.

PS: This command will take a while (maybe 5 to 15 seconds) to finish decoding a 2D barcode image.

To speed up decoding, take a look command option. 

To create a 2D barcode:
$ dmtxwrite <(echo -n 2dbarcodecontent) -o image.png

get web-cam capture software from here:

Fedora install:
root$ yum install fswebcam

may need to install GDlib:

take a photo with webcam:
$ fswebcam -F 15 -r 352x288 --no-banner --save /mnt/cdrive/UIM.jpg