Wacom Bamboo CTL-460 with Fedora 13

Here is the way i got Wacom  BAMBOO PEN CTL-460 (its the one without touch, pen only) working on Fedora 13, snapshot:

[Update 13.6.2010]: Works with  Fedora 13 Final (2.6.33.5 kernel) and linuxwacom driver version 0.8.8

[Note]: For my variant it’s not needed to uninstall linuxwacom generic package provided by fedora, like some other guides suggest.

Install prerequisites:


gcc
gcc-c++
kernel-headers
kernel-devel
libXi-devel
libX11-devel
xorg-x11-proto-devel
xorg-x11-server-devel
tk-devel
tcl-devel
ncurses-devel
xorg-x11-drv-wacom-devel
libXrandr-devel

Download latest linuxwacom package (at the moment of writing v.0.8.6-1)  from http://linuxwacom.sourceforge.net and  configure it as follows:

root@f13# ./configure --disable-libwacomcfg --disable-libwacomxi --disable-wacdump --disable-xidump --disable-xsetwacom --disable-wacomxrrd --disable-wacomdrv --enable-wacom

output should look similar to this

BUILD ENVIRONMENT:
architecture – i686-redhat-linux
linux kernel – yes 2.6.30
module versioning – no
kernel source – yes /lib/modules/2.6.33.2-57.fc13.i686/source
XFree86 source – no
Xorg SDK – yes /usr/include/xorg
XSERVER64 – no
dlloader – yes
XLib – yes /usr/lib
xf86config – yes
TCL – yes /usr/include
TK – yes /usr/include
ncurses – yes

BUILD OPTIONS:
wacom.o – yes
wacdump – no
xidump – no
libwacomcfg – no
libwacomxi – no
xsetwacom – no
wacomxrrd – no
hid.o – no
wacom_drv.so – no /usr/lib/xorg/modules/input
wacom_drv.o – no
wacom*_drv quirks – IsXExtensionPointer key-events dixScreenOrigins

Now we can build the module with:
root@f13# make
Then copy newly  built module and overwrite existing one
root@f13# cd src/2.6.30/
root@f13# cp wacom.ko  /lib/modules/<kernel-version>/kernel/drivers/input/tablet/
Now we test the module
root@f13# depmod -a
root@f13# modprobe wacom
Make the module to load on boot

root@f13#echo modprobe wacom >> /etc/rc.modules
root@f13#chmod +x /etc/rc.modules
References
1. http://lists.fedoraproject.org/pipermail/users/2010-March/369767.html
2. http://linuxwacom.sourceforge.net/index.php/minihowto
3. http://docs.fedoraproject.org/deployment-guide/f12/en-US/html/s1-kernel-modules-persistant.html
4. http://frankgroeneveld.nl/2010/04/11/get-wacom-bamboo-fun-pen-working-in-ubuntu-lucid/

Advertisements

Meaningful Details

System update at Kubuntu:

And if we click on the „Details“ button, we’ll be presented a very
meaningful and informative specification of the process — a bouncing bar!

Windows 7 … sarcastic

„Windows 7 — we lay 7 years back behind Mac OS“   

😉 

Let the ruby shine !

Recently I’ve discovered the Ruby Scripting langauge for me. And got dependent of it 🙂 Programming has never been so much fun as i have now, with ruby. It’s not simple source code development, its the continuous attempt to wirte the code the ruby way. In ruby its possible to produce very concise but still well readable code. In only one week i produced more source codes in ruby, than i did in all other languages over all past time. You get the idea for some programm or algorithm, you fire up the ditor, write down your code, make debugging, read some additional info in web on that special issue. and you are done. Ruby is as transparent as possible. Java ? No, thanks. I dont want to cancel all my previous expierience with Java, but Ruby is much more lightweight, and it has less syntax boundaries the ruby language is very natural, all concepts are well documented, every part of the language is consistent with the other part.  In Java there are many „black-box“ concepts. You are forced to use code while  you never understood why this code  works. In ruby every single syntactical construct is well documented or discussed on the web. Ruby uses conventions, but you can always use your own way of doing it and come to the same result. Less efficiently, maybe, but still. And after getting more understanding for better syntactical constructs you may rewrite your code into more efficient one.  

I’m totally (positively) smashed by Ruby. It just took me over 🙂

May be i will post some stories with sources of my ruby adventures later.

More Java. Continued.

Last time we worked out an implementation of a simple thermometer software in java. I promised to add  an interface to it and to show you that you can provide it some nifty methods, to make your thermometer more powerful. So lets begin.

First of all, let me explain the use of interface classes in Java. The need for an interface doesnt seem to be quite obvious in some cases. An interface is a declaration of some certain, obligatory behaviour. We know that behaviour in java is defined through methods, methods describe how to perform this or that action. We also know, that classes can inherit from their parents, those things they have in common. A bus can inherit from vehicle, and tea can be a child-class of a HotDrinks class. A notebook is a child of a computer, and so forth. But what do we do, if we want a certain class present some features which are not typical for this sort of objects. I mean, for instance,  what if you want a tree class which  probably extends the plant class, not only to perform grow method but also do something untypical, like walk over the ground, and speak. Yes, lets assume you want make your plants  to be units of some simulation or strategy game, so they have to speak, und to walk. To speak and to walk taken together is an characteristic of a human being. But even if we do create a Human class, we still cant inherit from it, because java doesnt support multiple inheritance. Java goes another way here, providing us a tool, called interface, to satisfact all our polymorphing needs. So we create an Interface, lets call it  isHuman.

An interface does only provide the declarations of methods, and never provides their implementation. Interfaces can also contain constans. Constans will be common to all classes which implement the interface. Its important to know that you can implement as many interfaces as you like, to provide the desired bahavior to your object. So, here is what the isHuman interface could look like:

interface isHuman{

public speak(String message);

public walk(int distance);

}

and our Tree class would implement this interface and look something like:

class Tree extends Plant implements isHuman {

public void speak(String message){ System.out.printline(message); }

public void walk(int distance){

/* consider that moving the tree around will change its position, or its coordinate. But a nor the plant class nor his tree subclass do define any  class variables  to save coordinates. So we would probably like to attach a position variable to the tree class. On the other hand it would be better object oriented desing, if we wouldnt  put litter into pure classes, so we should subclass the Tree class (i.e. MagicTree) and  provide MagicTree with  position variable and let it implement the isHuman interface*/

} }

Enough explanation to take off. Lets now provide our thermometer some interface. What would we like our thermometer to do, something which is not common to all thermomethers ? Our thermometer will have a display built in, which should show the registered temperature.So let’s define an Interface hasDisplay. Every device which has a display, have probably two actions in common, it can display something and reset the display. So here we go:

public interface hasDisplay {

void display();

void reset();

}

The other thing, we would like to teach our thermomether is to perform statistics onto collected data. For expample, to calculate average of all gathered values. So lets define an interface:

public interface supportsStatistics {

double getAverage();

}

So lets put these methods into our Thermometer class.It looks  now as follows:

import java.util.Stack; //Stack is good for collecting values

import java.util.Iterator; //Is a useful class to walk through the data of a stack

public class thermometer implements hasDisplay, supportsStatistics{

boolean isApplied;

Stack s; // Our thermometer has a memory, represented through the stack here.

sensor sen;


private void apply()

{

if (isApplied == false) isApplied=true;

}

double getTemperature()

{

this.apply();

return this.sen.getLevel();

}

void remove(){ isApplied = false; }

public void reset(){};

public void display()

{

System.out.println(new Double(this.getTemperature()).toString());

/* Create an Object of type „Double“ from the value,returned through getTemperature method. The Method toString,  built in into Double class, returns a String representation of the Double object in turn, which becomes an argument of a println method. */

}

public void display(double d)

{ /* this one can show any double value you pass to it*/

System.out.println(d);

}

/* Methods for memory handing */

void pushValueToStack()

{

Double d = Double.valueOf(this.getTemperature());

s.push(d);

System.out.println(“ [ „+ s.peek() + “ pushed ]“);

}

double retrieveValueFromStack()

{

return Double.valueOf( s.pop().toString() );

}

public double getAverage()

{      double av=0.0;

int c=0;

Iterator it = s.iterator();

while(it.hasNext())

{    c++;

System.out.println(„sum = „+av);

av=av+Double.valueOf( it.next().toString() );

}

return av/c;

}


public thermometer(){ // Constructor

this.s = new Stack();

this.sen = new sensor();

}

}

Now we have implemented an interface and provided our thermometer with a possibility to store, and process values. Quite useful, isn’t ist ? Now let me try to answer the last question about interfaces:

„Doesnt it look like, when one implements an interface he has to write the method declarations twice ? First time in the Interface, and the second time inside the class. Why not ommit the Interface and add desired methods rigth into the class, without any interface-bla-bla.“

The answer is quite simple: „Sure, you are free to do so, but imagine you have project which contains hundreds of classes, and you would add some behavior here and some behaviour there, without using the interfaces. Nobody else but you would then know, what special abilities can the class use. By declaring interfaces, and using them consistently inside your project, helps you get better picture of the possibilities, dependencies and duties of every single class. Interfaces is an object oriented design tool. Nobody forces you to use it. But by doing so you profit in the long run.

Thank you for your attention.

P.S: If you have  wishes or questions , feel free to leave a comment.

So long, A.S.

More Java (basic part)

Today i would like to introduce you a more complex example for java. We will program a piece of software for a thermometer. Lets imagine we would have a microcontroller which is able to get the temperature and put it in some system variable. And we would have a possibility to access this system variable, representing the current temperature. In fact we will emulate this system variable simply by a random number generator. But there are Java microcontrollers in real life, so the whole piece of software which we are going to write is not far from reality.

Let’s start then. First of all we need to think about the Class structure for our thermometer.We obviously need a Class thermometer , which will represent a thermometer. In addition we will create a class sensor which will represent a sensor integrated inside the thermometer. As we will step through the creation process we will need some more classes, for the purpose of better object oriented design.

For now lets write the Thermometer class.  A thermometer has, as such a state which describes if it is applied or not. Having a boolean isApplied variable lets us check wether the thermomeer is applied. We can apply it if it is not applied. So we can only get temepature value from our device in case it is applied. This describes the real world situation precisely enough. Lets look at the code:

class Thermometer {

boolean isApplied;

}

Our Thermomether has a sensor, so lets put a sensor inside our thermomether class.

class Thermometer {

boolean isApplied;

Sensor sen;

}

Well variable sen has type of Sensor , but there is no such built-in class in Java library called „sensor“. Of course not. We will create the Sensor-Class. So lets create a new file Sensor.java and think about properties of a sensor. Sensor can be active or not, so we define a boolean variable isActive. A sensor has a level, its the amount of signal is measures. It doesnt matter if it measures temperature, pressure, velocity, distance or amplitude, a sensor only gives back some numeric value. So we define a level variable of type double.

Here is our Sensor.class

public  class sensor {

private double level;
private boolean active;

}

why is the level variable defined as private. It has a good reason. We will define a special initalization routine for the sensor later, and only this initialisation procedure (method) has the right to access the value of the level variable. If some other class would like to use our Sensor class, it couldnt just create an instance of a Sensor, and then write something like mysensor.level = 123.45. He would be forced to use the special method provided by the Sensor class,to access the value of the level variable. Lets now write the methods to acess the instance variables for the Sensor class. First a method which sets our sensor to the active state.

public void setActive(){

this.active = true;

}

Now the method which returns the sensor level. Forst of all we set the Sensor to the active state, and use the method setActive we defined before. After this we have to run the initialization. We will define the initialization procedure in the init() method. init() returns zero if the initalization went sucessful. So we check if the initialization was sucessful and want to process an exceptional state which occurs if the program flow goes in a way it is not intended to go. We throw an exception. There are many exceptions defined inside the java library, but we create our own exception here. It will inherit from the Exception class. The catch block contains the code, which will be executed if the exception, we were afraid of, occurs.

Then we assign a random value to the level variable, and return this value, to the caller object.

public double getLevel()
{
try
{
this.setActive();
this.init();
if (this.init()!=0) throw new badSensorException();
this.level = Math.random()*100;
return level;
}

catch (badSensorException e)
{
System.out.println(„Error occured!“+e);
}

return this.level;

}

Okay, lets look deeper iside these exceptions. An exception is an object too. An exception is created, and passed as a paramether to to handling procedure, the catch procedure. Here is class for the badSensorException

public class badSensorException extends Exception{

badSensorException(){};
}

as i said before, all user defined exceptions inherit form the standart library class Exception. The only line inside the class is the default constructor. Exceptions are objects and need to be created, like all other objects. Nothing special.

later on in the sensor class we define the init() method. Here is what it looks like:

private int init() throws badSensorException
{
return 0;
}

The method is a dummy method. It do just return Zero, like if it would all go flawlessly and correctly. But take a look at the declaration. We do provide the compiler the information, that the execution of this method, may lead to an exceptional state.  So lets sum up, if we know that something in  a method can go the way we dont want it to, we declare that this method throws someException, then we we write a class for someException which extends the Exception class. An then every time we have to use a method which is capable of throwing an exception, we put it inside the try-block  and then we handle the exeptional state within the corresponding catch -block. Thats it.

finally we have to create a constructor for our sensor. here is what it looks like.

public sensor()
{
try
{
if (this.init()!=0); throw new badSensorException();
}
catch (badSensorException e){
System.err.println(e.getMessage());}
}

As we can see, creating a sensor incudes an obligatory initalization procedure. Which requires exception handling, since, the init() mehtod is capable of throwing an exception. Our Sensor Class is complete now. Feel free to add some more methods, which you consider useful, like  a reset() or deactivate() or whataever.

Here is what the complete Sensor.class looks like:

public  class sensor {
private boolean active;
private double level;
public void setActive() {  this.active = true;  }
public double getLevel()
{
try
{
this.setActive();
this.init();
if (this.init()!=0) throw new badSensorException();
this.level = Math.random()*100;
return level;
}

catch (badSensorException e)
{

System.out.println(„Error occured!“+e);
}

return this.level;

}

private int init() throws badSensorException
{
return 0;
}

public sensor()
{
try
{
if (this.init()!=0); throw new badSensorException();
}
catch (badSensorException e)

{
System.err.println( e.getMessage() );

}
}

}

Lets now return to our thermometer class.That what it looked like.

class Thermometer {

boolean isApplied;

Sensor sen;

}

So first of all we write a method to apply the thermometer.

private void apply()
{
if (isApplied == false) isApplied=true;

}

Lets now look at the constructor for the thermomether. We just create a new sensor inside every thermometer, thats it.

public thermometer(){
this.sen = new sensor();
}

You recall,  by writing this.sen we mean the sen variable of this object. Now  lets define a method which will get the temperature from the thermometer. Here it is:

double getTemperature()
{
this.apply();
return this.sen.getLevel();
}

the method returns the value, provided by the level variable of the Sensor object.

this.sen.getLevel() means: „call the getLevel() method of the sen object, which is defined inside this thermomether object“. Before we can call getTemperature() method, we have to create an instance of Thermometer class. Creating this, we automatically create an instance of Sensor, this is  defined inside the constructor. So every Thermometer object knows a Sensor object, which belongs to it. By calling this.sen.getLevel() you tell that we want to use the Sensor of  this thermomerter, not one other’s.

Finally lets write a display method. It will send the temperature values to any output device, we provide. For our example we will use the console for output.

public void display()
{
System.out.println(new Double(this.getTemperature()).toString());

}

The System.out.println() method accepts a string value as a parameter, and we want it to print a double value. So we have to convert the double value to String. Every object which inherits from the Object has access to the toString() method.It returns a String representation of the object its called on. The temperature values are of Type double. It is a primitive type. Primitive types are not objects, so we cant use all the power of objects on them. But Java instroduces a nice concept to help out.  The wrapper classes. Wrapper class is a corresponding Object Type for every Primitive type. So there is Integer wrapper class  corresponding to int, and Double corresponding  to double. But we know, objects have to be created. Every wrapper class has plenty of  constructor methods, there is also one constructor, to create an Object from the corresponding primitive type. The signature of such a constructor looks like this Double(double d).  So we call the constructor for Double, passing  the return value of the getTemperature() of this object to it.

new Double(this.getTemperature()) returns an Object of Double, Having an Object we can  call to the toString() method on it. so we simply attact a method call to our newly created Double object. toString has a return type of String. This whole strange looking performance is called casting. We cast a variable form one type to other.

Now the basic implementation for  our Thermomether class is complete. Here is what it looks like:

public class Thermometer {

boolean isApplied;
Sensor sen;

private void apply()
{
if (isApplied == false) isApplied=true;
}
double getTemperature()
{
this.apply();
return this.sen.getLevel();
}

public void display()
{
System.out.println(new Double(this.getTemperature()).toString());

}

public Thermometer()

{
this.sen = new sensor();
}

}

Now we do have a Sensor class, a Thermomether Class which uses the Sensor class , the last thing we will need is a main method to start everything up. Here we have two possibilites. The first is to make an extra class file, where the main function will reside, und the second is to place the main method inside our Thermometer class.

I wanted to write about using of interfaces. but did intentionally reduced the code. It would otherwise be hard to keep a track of all dependencies betwenn the classes.

Lets summarise, what we have done today. We created three classes, we learned the use of private variables, we used exception handling, we did a type casting, and learned about wrapper classes. Pretty much for one session.

The next time we will attach an interface to our class and  add some new interesting and useful functionality to our thermometer class.

Think in objects !

So long,   A.S

Which language

Im not a programmer. Programming is the way i do sometimes spend my spare time on weekend, thinking over an algorithm or two. I see ruby language makes lots of thing much easier, because of this nifty object model, it look like you can even do ( Ruby.write.theProgram.forMe ) and the interpreter would obey 🙂 But what i’am looking for, is a language where you can quickly and easily try out some algorithms, for instance, matrix conversion or similar simple algorithms. I understand, that to get familiar with ruby i have to trust it on the way it does things in lots of cases. I wish the language wouldn’t make so much work for you, so you can see, what is going on behind the scenes, where do objects come from, ans so on. Like java. But java is a little bit heavyweight for some quick trial-and-error session. I like the way on C language very much. It does nearly nothing for you, it has got a high level of standartization over the years. It is the language of operating systems. But its somewhat not a „mainstream“. People take C only when the doing some project where they have to communicate to the maschine or operation system. It is never mentioned as Programming language for hobbyists. I like C very much. The modern-fashioned languages like ruby , python  have their own way of defining things, and they try to help the programmer by taking much of the low-level programming off him.

Is there something in the middle between C and Ruby/Python  ? Objective C maybe ? C++ ?

I need your advice.

Java is object oriented.

I’ve gone a long way, to start to understand the idea behind design of java. And as i grasped its caveeats, like interfaces and abstracts classes, i discovered for myself how genious java actually is.

Everything is an object. I tend to call Java a real world modelling language. One who want to understand java has better to throw all his knoweledge of Pascal or any other procedural language programming  over board. Java is another way of thinking, another way of program design. Its like you would add a third dimension to the existing two.

Every object of the real world has  some properties, und usually you can do something with it.

The pen, has color, length, and maybe a price, it has certain geometric form, it can be translucient, be disposable or not, use ink or be a gel pen and so on. And when we say, „I need a pen“  we usually have a distinct picture in mind, but what we really mean can be any kind of a pen, with any set of attributes. We recognize a pen, if it has some of the typicall attributes of a pen. In terms of java language, we say that a pen is a class, and any certain pen which really exists , is an object of the class „pen“. A Java Class does describe the attributes of our imaginary object, and we create the  objects by instantiating the class.

Lets look at an example:

public class pen

{

int length;

int width;

double inklevel;

}

that’s it,  one possible implementation of pen in java. But to use our pen further in the program, we have to assemble those attributes to an object. That is what we call „to make an instance of a class“.  When we create an object of a class, the space is allocated in the memory for all attributes/variables, which the object contain. But you are not limited to only one object, you can create as much as you want. Its important to understand, that if we create one object from the pen class and after that a second one, they are not the same – they differ, even though all their attributes may contain same values.

Lets create a main class, where we can create an instance of the pen.

public class Main // [1]

{

public static void main(String [] args) // [2]

{

pen p = new pen(); //[3]

}

}

Okay, what we did, we created a new class, called Main. Its a common practice, to call the Class Main, because this is one where all the program  management  happens. Its a good idea, to give the classes such names, which reflect their role or intention. Its important to notice, the name of the class has to be written „Main“ and not „main“, because in such a case, the java compiler will think of an main() method inside, as of a constructor, and not a start-up statement. What are constructors  ? Constructors, are special methods which are used to initialize the objects attributes with values at the moment of their creation. This can be very useful. The constructor method has to have exactly the same name as the class itself, and to be declared as public. The word public declares that other classes and parts of the programm  have free access to it. The access management in java programs is one of the powerful concepts, which make java to be spoken of as a  secure language. Back to constructors. Through defining several different constructors you may make sure that an object will have certain attributes initialized at the moment of creation. The constructor methods of the same class differ in the attributes they need for the execution.

Lets add some constructors to our pen class.

public class pen

{

int length;

int width;

double inklevel;

public pen(){}  //[4]

public pen(int length){this.length = length } //[5]

public pen(int le, double ile){length = le; this.inklevel = ile; } //[6]

}

Now, we have three different constuctors for our pen class. The fisrt one is called default constructor , we dont have excpicitely to write it, because if we dont define any default constructor at all , java compiler creates one for us. Default constructor is called in case we didnt specified any special values we would like to pass to our object at the moment of creation. What does the word „this“ @[5] mean, you may ask. The word „this“ indicates the one object which variable is meant. I gave the attribute of the constructor here the same name, as the instance variable. if we dont indicate the variable we want to use, explicitely, the compiler wouldn’t know which one we are actually meaning, the „length“ variable passed to the constructor, or the one belonging to the object. To avoid such misunderstanding we indicate with specials word „this“ that we want to assign the value of the passed variable to the „length“ variable of our object . You can certainly, avoid such thing simply by using differend variable names, as i did @ [6].

In our Main  class we called the default constructor @ [3] Lets add another constructor, for the case we want to create a pen with a certain length.

public class Main

{

public static void main(String [] args)

{

pen p = new pen();

pen p1 = new pen ( 23 ); // [7]

}

}

We passed an integer value to the constructor @ [7]. The compiler knows which constructor to use, because there is only one constructor which accepts an integer value, the one @ [5]. Thats why you shouldnt define two constructors which have same signature (combination of the name and accepted attributes ).The compiler wouldnt just know which one to pick.

We can acces the values of the intance variables in our two objects, to do this we just tell which object we want to use , and put a point sign after it, then we write the variable name we want to use. We can  assign the „length“ value for our pen object „p“. So we write

public class Main

{

public static void main(String [] args)

{

pen p = new pen();

pen p1 = new pen ( 23 );

p.length = 16; // [8]

System.out.println(p.length); //[9]

}

}

Now the length of the pen „p“ is set to 16 units. We can send the value of the „length“ variable of  „p“-object to the system output device (usually the console or command line) as we do in line @[9]. But what if we dont want that any other classes can set, reset, and call the values of the instance variables. We can prohibit public access to  it, by putting the word „private“ before it. So the pen class would look like this

public class pen

{

private int length;

int width;

double inklevel;

public pen(){}

public pen(int length){this.length = length }

public pen(int le, double ile){length = le; this.inklevel = ile; }

}

So now only the methods which are declared inside the class may have full access  to the variable „length“.

Okay enough for the first time… write me if you wish more examples or more explanation on particular point.

Any suggestions and hints are warmly appreciated.

Next time i wish to wite about interfaces, and why you should use them, and i will come along with some more interesting example for the classes than a pen.

Think in Objects!

So long, A.S.