Alphabet for writing to TV (very small code)

Greetings fellow nerds!

I needed to fit a whole alphabet on the Atmega328 but with all the setPixel() for every letter the memory soon got full.

So i came up with this reduction i wanned to share with you. ::slight_smile:

This is the function printv(int h, int v,char[] text,byte color)
To write any text to the TV with the setPixel function you can find in Alastair Parkers Arduino Pong(http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1187659197)

void printv(int h, int v,char text[],byte col)
{
  color=col;
  char buffer=-1;
  int count=0;
  int oldh=0;
  int oldv=0;
  int letter_width=0;
  int sum_width=0;
  int line=1;
  int i=0;
  oldh=h;
  oldv=v;
  
  //number of letters
  while(buffer != 0){
    buffer = text[count];
    count++;
  }  
  
 count=count-1;
 
  while(line<6){

    for(i=0;i<count;i++){
      if(text[i]=='i'){
        letter_width=1;
      }
      else if(text[i]=='c' ||text[i]=='f' ||text[i]=='j' ||text[i]=='l' ||text[i]=='t'){
        letter_width=3;
      }
      else if(text[i]=='b' || text[i]=='d' || text[i]=='e' || text[i]=='g' || text[i]=='h' || text[i]=='k' || text[i]=='n' || text[i]=='o' || text[i]=='p' || text[i]=='q' || text[i]=='r' || text[i]=='s' || text[i]=='u' || text[i]=='z'){
        letter_width=4;
      }
      else if(text[i]=='a' || text[i]=='m' || text[i]=='v' || text[i]=='w' || text[i]=='x' || text[i]=='y' || text[i]=='z'){
        letter_width=5;
      }
      else{
       // letter_width=1;
      }
       
      switch(line){
        case 1:
          if(!(text[i]<97 || text[i]>122)){//not lower case alphabet
            if(text[i]!=97 && text[i]!=99 && text[i]!=103 && text[i]!=106 && text[i]!=111 && text[i]!=113 && text[i]!=115){
              setPixel(h,v);
            }
            if(text[i]!=97  && !(text[i]>=104 && text[i]<=110) && !(text[i]>=117 && text[i]<=121)){
              setPixel(h+1,v);
            }
            if(text[i]!=98 && text[i]!=104 && text[i]!=105 && !(text[i]>=107 && text[i]<=110) && !(text[i]>=117 && text[i]<=121)){
              setPixel(h+2,v);
            }
            if(!(text[i]>=97 && text[i]<=100) && text[i]!=102 && text[i]!=105 && text[i]!=106 && text[i]!=108 && text[i]!=109 && !(text[i]>=111 && text[i]<=114) && text[i]!=116 && !(text[i]>=118 && text[i]<=121)){
              setPixel(h+3,v);
            }
            if(!(text[i]>=97 && text[i]<=108) && !(text[i]>=110 && text[i]<=117) && text[i]!=122){
              setPixel(h+4,v);
            }  
          }
        break;
        
        case 2:
          if(!(text[i]<97 || text[i]>122)){
            if(text[i]!=97 && text[i]!=106 && text[i]!=116 && !(text[i]>=120 && text[i]<=122)){
              setPixel(h,v);
            }
            if(text[i]!=98  && text[i]!=99 && text[i] != 100 && !(text[i]>=101 && text[i]<=108) && !(text[i]>=111 && text[i]<=115) && !(text[i]>=117 && text[i]<=119) && text[i]!=122){
              setPixel(h+1,v);
            }
            if(text[i]!=97 && text[i]!=99 && text[i] != 100 && !(text[i]>=101 && text[i]<=105) && !(text[i]>=108 && text[i]<=122)){
              setPixel(h+2,v);
            }
            if(text[i] != 98 && text[i] != 99 && !(text[i]>=101 && text[i]<=103) && !(text[i]>=105 && text[i]<=108) && text[i]!=115 && text[i]!=116 && text[i]!=118 && text[i]!=119 ){
              setPixel(h+3,v);
            }
            if(!(text[i]>=97 && text[i]<=108) && !(text[i]>=110 && text[i]<=117) && !(text[i]>=120 && text[i]<=122)){
              setPixel(h+4,v);
            }      
          }
        break;
        
        case 3:
           if(!(text[i]<97 || text[i]>122)){
              if(text[i]!=97 && text[i]!=106 && text[i]!=116 && text[i]!=118 && !(text[i]>=120 && text[i]<=122)){
                setPixel(h,v);
              }
              if(text[i]!=99  && text[i]!=100 && text[i]!=103 && text[i]!=105 && text[i]!=106 && !(text[i]>=108 && text[i]<=111) && text[i]!=113 && text[i]!=117 && !(text[i]>=119 && text[i]<=122)){
                setPixel(h+1,v);
              }
              if(text[i]!=97 && text[i]!=99 && text[i]!=100 && text[i]!=102 && text[i]!=105 && text[i]!=107 && text[i]!=108 && text[i]!=111 && text[i]!=113 && !(text[i]>=116 && text[i]<=118)){
                setPixel(h+2,v);
              }
              if(text[i]!=99 && text[i]!=101 && text[i]!=102 && !(text[i]>=105 && text[i]<=109) && text[i]!=116 && !(text[i]>=119 && text[i]<=122)){
                setPixel(h+3,v);
              }
              if(!(text[i]>=97 && text[i]<=108) && !(text[i]>=110 && text[i]<=118) && !(text[i]>=120 && text[i]<=122) ){
                setPixel(h+4,v);
              }      
          }
       break;
       
       case 4:
         if(!(text[i]<97 || text[i]>122)){
          if(text[i]!=115 && text[i]!=116 && text[i]!=118 && !(text[i]>=120 && text[i]<=122)){
            setPixel(h,v);
          }
          if(!(text[i]>=98 && text[i]<=115) && text[i]!=117 && text[i]!=119 && text[i]!=121){
            setPixel(h+1,v);
          }
          if(!(text[i]>=98 && text[i]<=105) && !(text[i]>=108 && text[i]<=112) && !(text[i]>=115 && text[i]<=118) && text[i]!=120 && text[i]!=122 ){
            setPixel(h+2,v);
          }
          if(text[i]!=99 && text[i]!=101 && text[i]!=102 && text[i]!=105 && text[i]!=106 && text[i]!=108 && text[i]!=109 && !(text[i]>=112 && text[i]<=114) && text[i]!=116 && text[i]!=119 && text[i]!=121 && text[i]!=122){
            setPixel(h+3,v);
          }
          if(!(text[i]>=98 && text[i]<=108) && !(text[i]>=110 && text[i]<=118) && !(text[i]>=120 && text[i]<=122) ){
            setPixel(h+4,v);
          }     
        }
      break;
      
      case 5:
        if(!(text[i]<97 || text[i]>122)){
          if(text[i]!=99 && text[i]!=103 && text[i]!=106 && text[i]!=111 && text[i]!=113 && !(text[i]>=116 && text[i]<=119) && text[i]!=121){
            setPixel(h,v);
          }
          if(text[i]!=97 && text[i]!=102 && text[i]!=104 && text[i]!=105 && text[i]!=107 && text[i]!=109 && text[i]!=110 && text[i]!=112 && text[i]!=114 && text[i]!=118 && text[i]!=120 && text[i]!=121){
            setPixel(h+1,v);
          }
          if(text[i]!=97 && text[i]!=102 && text[i]!=104 && text[i]!=105 && text[i]!=107 && text[i]!=109 && text[i]!=110 && !(text[i]>=112 && text[i]<=114) && text[i]!=116 && text[i]!=119 && text[i]!=120){
            setPixel(h+2,v);
          }
          if(!(text[i]>=97 && text[i]<=100) && text[i]!=102 && text[i]!=105 && text[i]!=106 && text[i]!=108 && text[i]!=109 && text[i]!=111 && text[i]!=112 && text[i]!=115 && text[i]!=116 && text[i]!=118 && text[i]!=120 && text[i]!=121){
            setPixel(h+3,v);
          }
          if(!(text[i]>=98 && text[i]<=108) && !(text[i]>=110 && text[i]<=119) && text[i]!=121 && text[i]!=122){
            setPixel(h+4,v);
          }
        }
      break;

      }
    
        h=h+letter_width+1;

    }
    
    v=v+1; 
    line++;
    h=oldh;
    
  }
     
}

You could also try my library for outputting to a tv:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1272593798

you would have to switch the pins the resistors connect to:
IE:
sync on pin 9
vid on pin 8

It has a much higher resolution than the arduino pong and runs in the background.

WHAT!?
And you telling me this- now?

Oh, I see its ntsc.
No! Wait, added PAL support!

Oh Im getting so excited!

Thanks a LOT!

I saw this earlier and thought someone should make an oversized, nicer font for the tvout library as well as regular, if it will fit. The library seems to be expanding quickly with additions at the moment.

yeah I agree that font I have is crap, If anyone knows of a good way to convert fonts to bitmaps that would be very helpful. Ive looked and looked for something that will do what I need to no avail. Ive found a few but they dont give me info on the how the byte is arranged....
an 8x8 font would be ideal as it could be placed into memory very fast and should be large enough to look decent(currently its 5x7).