Monday, November 21, 2011

How to protect your Laptop Battery (Li-ion battrey) !!

Li-ion battery packs and a Li-ion battery cell

Most of our laptops, PDA's and Cell phone like gadgets are now comming with Lithium-ion batteries. The battery life of a consumer electronic is a very very critical matter. Keeping the battery healthy as much as possible is anther very important matter. But sadly many people doesn't know how to use the battery or how to charge it properly. That is why I was interested in posting this one. Your opinions and comments are warmly welcome on this topic.

With out lot of descriptions I will tell the thing in a nut shell ... Cool know? ;) 
  • Point 1 - Do I need to do a 16Hrs (or some silly value) charge at the first time?
    • Answer is - NO!!!
    • Explanation - Li-ion batteries do not have the "trickle charge" effect which exists in Ni-Mh batteries. Because of that Li-ion batteries really doesn't need a really long painful first time charge like Ni-Mh batteries! :O
  • Point 2 - What happen when I charge it before the battery is 100% discharged?
    • Answer is - NOTHING!!!
    • Explanation - This is also a wrong understanding about the Li-ion batteries. They  do not have the "memory effect" like old rechargeable batteries. Therefore charging a battery when it is 50% discharge will not make the other 50% unusable. But such a charge will also counted as a full charge cycle.
  • Point 3 - Li-ion batteries can be charged for a number of times only?
    • Answer is - YES!!!
    • Explanation - Li-ion batteries can be charged certain number of times only. But don't be afraid it is a big number.. :) . But this has a point which is even though charging after 50% or 60% present of battery drain make no harm it is counted as a charge cycle. That mean it will reduce the time we can use the battery!!. 
  • Point 4 - Do over-discharging make any problem?
    • Answer is - YES IT IS!!!
    • Explanation -Li-ion should never be discharged too low. It may cause the hardware of the battery fail too. 
Lot more to say.. But I taught stopping here.. If any one is interested feel free to raise your questions, your opinions etc. Once again they are warmly well come.. Then.. Bye for now!!!

Thursday, September 1, 2011

Star Wars in your console!!! :O


Ger ready with your popcorn!!! Now we are going to watch STAR WARS!!! This is the beta release of the  STAR WARS I  and no one has ever got the chance to watch it in a cinema!!!


OK that is enough!!. The thing today I'm going to talk you about is very cool. It's a good example of the creativity. It is a text version of STAR WARS!! It is nothing but a creative use of the well known telnet (http://en.wikipedia.org/wiki/Telnet ) and this is that!! (below I will explain how you can see it)

It begins..





How to we can watch it?? We have to do a simple thing.... But you must have two things with you. A internet connection and telnet installed in your computer (for most of the computers telnet will be  installed) 
  • In windows - Go to run (Winkey + R)  and paste this  telnet towel.blinkenlights.nl and hit enter or go to command line  and type it and hit enter. Another way is to go to command line type telnet and hit enter. That will open the telnet client and type o 94.142.241.111  and hit enter.
  • For other OSes - Invoke your telnet client and telnet to this IP Address 94.142.241.111 or to this domain name   towel.blinkenlights.nl
OK!! that is it for today!! Bye.. !!

Sunday, August 28, 2011

Your own Images to ASCII arts application - Part IV (Implementation)

NEW!! Executable project is @ http://code.google.com/p/image-to-ascii/

Hi...!! In my previous post I discussed about opening an image using java. Now it is time to work with the image. Java 2D has two classes to represent images. java.awt.image and java.awt.image.BufferedImage. Buffered image is the most flexible one for some processing. Because it allow us to work on the image data.
Here what I'm going to do first is to open the image. Then I will convert the image in to a gray scale image with user defined dimensions. There we will have to do two things. 


1. How to change a color image to a gray scale image using java 2D?
2. How to change the dimensions of an image?


Both the questions will answered in the below line of codes. There first I will create a new gray scale Buffered image (answer to the question one) with custom dimensions (answer to the question two). After that I will draw the current image on the newly created image.

BufferedImage imgEdted = new BufferedImage(width,height,BufferedImage.TYPE_BYTE_GRAY);
Graphics graphicEdted = imgEdted.getGraphics();
graphicEdted.drawImage(imgIn, 0, 0, width, height, 0, 0, w, h, null);
Here the image imgEdited is the new image and imgIn is the original image (The full source code is shown below). First we will get the graphic object of the newly created image (graphicEdted) and we will use it to draw the original image on the new image.  Here width and height are the custom widths and heights and w and h are the width and height of the original image. The "drawImage()" method do the trick here. It convert the color and also re scale the image. Here are some of the very important usages of this method.


http://download.oracle.com/javase/tutorial/2d/images/drawimage.html
http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Graphics.html

After the new gray-scale image is created we will use a multilevel threshold to create our ASCII image. For that purpose we have to go through each and every pixel of the image.  For the simplicity I will use read the color value of the pixel and determine it group. That is how we are going to do the multilevel threshold. For each group of color value I will assign a letter (an ASCII) that will eventually produce a ASCII image. The quality of the output image will depend on two facts. The first one is the number of groups and the other is the letter we assign for a color group.
Because I need to create an ASCII image I will collect the ASCII letter for each pixel to a string buffer. After a row of pixel in the image I will append a line break to the string buffer. 


Below code is showing the complete source code for the section I above discussed. It shows a method which take a image (buffered image) and a user defined width and height to create an ASCII image of user defined size. 

package img2ascii.core;

import java.awt.Graphics;
import java.awt.image.BufferedImage;

public class AsciiCreator {
  public static StringBuffer getASCII(BufferedImage imgIn, int width,int height){
    //change the color mode - and reset the size as we need
    int w = imgIn.getWidth(null);
     int h = imgIn.getHeight(null);
 BufferedImage imgEdted = new BufferedImage(width,height,BufferedImage.TYPE_BYTE_GRAY);
 Graphics graphicEdted = imgEdted.getGraphics();
 graphicEdted.drawImage(imgIn, 0, 0, width, height, 0, 0, w, h, null); 
 //create ASCII image by multilevel threshloding and save the result to a String buffer
 StringBuffer asciiBuffer = new StringBuffer();
 
 for(int i=0;i 230){
     System.out.print("`");
     asciiBuffer.append("`");
   }else{
      if(color>200){
      System.out.print("'");
      asciiBuffer.append("'");
   }else{
      if(color>160){
         System.out.print(";");
         asciiBuffer.append(";");
      }else{
         if(color>120){
            System.out.print("O");
     asciiBuffer.append("O");
  }else{
      if(color>80){
     System.out.print("8");
     asciiBuffer.append("8");
      }else{
   if(color>40){
      System.out.print("N");
      asciiBuffer.append("N");
   }else{
      System.out.print("M");
      asciiBuffer.append("M");
    }
      }
   }
        }
      }
     }
   }
  System.out.println("");
  asciiBuffer.append(System.getProperty("line.separator"));
  }
  return asciiBuffer;
 }
}