Thursday, November 19, 2009

DIY Sustain Pedal

For the last couple of days I was looking for a cheap sustain pedal for my M-Audio Keyrig49 keyboards. The cheapest I found was an M-Audio SP-1 which is around Php1,300 (US$27) but I don’t find it cheap because i figured out that sustain pedals are just simple SPST(single-pole-single-throw) switch. So decided to build one for only Php300 (US$6).

I used materials available at from the nearest hardware. I used surface-type switch box, a door bell switch (momentary push button), and an extra cover plate.


I cut out the base of the box with a hack-saw so it look more like a switch for the foot. Then I positioned the push button switch in the cover plate.

GEDC0214 GEDC0213

The second cover plate does not have any hole for switches in it. It’s  a cover plate for covering unused junction box in a household electrical installations. I then bolted the second cover plate only fixed in one end. In the other end of the second cover plate bolted it from the inside the box making the head tail of the bolt protrude and serves as a motion guide. After attaching the second cover plate this is how it looks like.


The wirings are simple. The push button switch has only two terminal and the phone cable has also two terminals. So it’s common sense for non electrical/electronics people.

Although it looked like a medical equipment ‘coz it is white… :))  The most important thing is that it works.


Saturday, August 22, 2009

Fun with HP Printer Display

Photo-0067While searching for a programming solution, I stumbled into an article claiming that they can change the default displayed message of your office printer to whatever message you want. The message that will replace the conventional “Ready” message. I got interested, so i took time to read it. When i searched about it in Google, I was amazed that lots of articles where already written about it. Articles that offer a program the author wrote himself to make you do change the “Ready” message of your printer to some more humorous such as “INSERT COIN!”. Some articles suggest that you need to learn the language to do that. I learned pearl just to understand what those line of code does and found out that it’s just simply sending a string of character to an opened TCP socket to the printer on the network. The program exploits the PJL (Printer Job Language) to send a command to the printer to replace the conventional “Ready” message to something else. The command is “@PJL RDYMSG DISPLAY = “ YOUR MESSAGE”.

I didn’t like the idea of using a program written by somebody else, specially if you don’t understand what it really does. It could be a “keylogger” that could secretly grab your passwords. So, for just a simple one-way socket communication, I figured out a pretty easy way to do it without even writing a program or using a new one. I was able to change the network printer’s display at the office saying “WALANG HIMALA!” (No Miracle!) by only using the telnet console application available in all Windows box.

To do it, you only need to run the following in the command prompt:

telnet <the IP address of the printer> 9100


If the command prompt clears out to black screen after issuing the command above, this means that your have successfully opened a TCP socket to the network printer and that you just need type the following text in notepad to change the message:


Then paste what you typed in notepad to the command prompt and then press “Enter”. Bingo, your done, check your printer and leave it there until some officemates notice and starts laughing. I enjoyed observing their reactions the moment they noticed that the printer saying something addressed to them :).

The message will be reverted back to default which is “READY” after a power cycle (Printer reboot). So, no worries.


Saturday, July 25, 2009

Solar Eclipse 2009

July 22, 2009, I woke up early in the morning to join a group of astronomers in observing the longest solar eclipse of our lifetime. 14.62 degrees latitude, 121.10 longitude is the location of the site where we took photos of Luna passing in front of Sol.


The group is consist of member of the University if the Philippines Astronomical Society and some Instructor at the Astronomy department of Rizal Technological university. We photos of the eclipse using Bamm Gabriana’s 10” MEADE reflector together with point and shoot digital cameras. We used combinations of 4 solar filters including red and yellow eyepiece filters to get this results.

We can only see partial solar eclipse from Manila, this is why most of the professional astronomers in the Philippines flew to China to get a chance to take a shot of the longest total solar eclipse.


I took this photo @ exactly 9:44 AM Manila time which is one minute after the Maximum occultation. I also took a photo of the final egress just seconds before the eclipse end (photo below).


This was taken @ around 10:58 AM Manila time.

At the very same time the group of Filipino astronomers back in China experienced the totality as seen in the video below. Although they were not able to take photos as the clouds did not favor them, the totality experience alone is worth going to China.

I enjoyed the day as I was able to witness a remarkable astronomical event which reminds us of how small we are and how marvelous God is (if there is really God).

Monday, January 19, 2009

Disable PrintScreen on C# without Keyboard Hooks

Yes, there is a simple solution to prevent grabbing information on your C# application screen with the keyboard's printscreen key without using keyboard hooks or calling COM interops. The solution makes use of Windows Forms Message Filter to trap keyboard events on your application window.

To trap keyboard events with Windows Message Filter, you need to implement the IMessageFilter interface and override the member PreFilterMessage(ref Message WM) method. This is the method called whenever a Form receives a keyboard or mouse event. You may want to read more about IMessageFilter.

The problem is that even though you have trapped the PrintScreen keypress event, the captured image will still persist to the clipboard. Therefore the simplest solution is to clear up the clipboard right after the PrintScreen is pressed on the keyboard.

This is how the overridden method will look like this:

public bool PreFilterMessage(ref Message WM)
Keys kCode = (Keys)(int)WM.WParam & Keys.KeyCode;

//block printscreen on KeyPress
if (kCode == Keys.Snapshot)
//remove the captured image from clipboard

MessageBox.Show("Printscreen not allowed.");

return true;


return false;


Another thing is that, if this method returns true, the Windows GDI Message will not be received by the Form.

Note: The PrintScreen event can only be captured if the Application window is active.


Saturday, January 10, 2009

Fixing a Problematic Motorola L6

Few days after I have re-flashed my Motorola L6 phone, I encountered a problem with the firmware. It seems like the firmware cannot access the phone memory. When I select an item in the main menu, my phone just displays the message "Please Wait..." and does nothing after. The phone cannot be used in this current state and the only i see one option to fix this and it is to re-flash again with a newer firmware. Now the problem is that i will lose my contact database if i do this so i looked for way to back it up. I tried using Windows XP's hyper terminal to read the phone memory thru AT commands but got no success.

The good thing is that i made a backup of the whole application folder (Motorola Software Update) including the registry changes. I made a copy of the files inside the application folder right after it has backed up the personal data on the phone. So the temporary files were also copied unconsciously.

Restart the Motorola phone on Bootloader mode. This can be done by pressing the *, # and the power buttons together at the same time while the phone is turned off. The phone should display a black screen with white text indicating that the phone is on “Programmable Mode”.

Then run the Motorola Software Update. The software should detect the phone and will automatically commence the firmware upgrade. While update is in progress, copy the personal data temporary file from the temp folder of your backup and paste it to the temp folder under the application folder, usually “C:\Program Files\Motorola\Software Update\temp”. The filename is usually in this format ##############.dat

Wait for the update to finish. The phone will then restart after the update is completed and will then restart the restore process. The software will read from the backup file you placed in the temp folder. This backup file includes the phonebook. Presto!

All though the phone is now fixed, I do not guarantee that whole problem is fully fixed therefore I suggest that you start backing up your phonebook. You may do this by syncing your phone to you PC. Good Luck.