Too much code

if my hex code exceeds the size aloocated to ucontrollers flash memory, do i have an option of breaking my hex into chunks, saving some part of it in my SD card and then redirecting the pointer in my flash (maybe by generating an interrupt or anyhow) to the code in my SD card so that i can even program large code by adding an external memory OR i have no option but to change to another micro controller ( atmega 256 or may be an ARM ) if my program's size is exceeding that of my flash . Plz help !!

yahska,
Please go thru & delete some of your messages, you seem to be posting the same thing in muliple places.

You could look into bitlash, and run your program from SD card I think.
http://bitlash.net/wiki/start

Thanks
Moderator

Also, post your code - it's quite possible that there may be ways to shrink/simplify your program.

do i have an option of breaking my hex into chunks, saving some part of it in my SD card and then redirecting the pointer in my flash

No. Get a larger Arduino or trim your code.

As mentioned post it and we can probably make savings.


Rob

this code uses only one pre-built lcd function -- SetLCDPixel(), rest all functions are derived from it

#include <avr/io.h>
#include        "LCD_driver.c"
#include   "WProgram.h"
void line(float x1,float y1,float x2,float y2,int color)
{
  float m= ((y2-y1)/(x2-x1));
  while(x2>=x1)
  {
  y2 = m*(x2-x1)+y1;
  LCDSetPixel(color,x2,y2);
  x2--;
  }
  while(x2<=x1)
  {
  y2 = m*(x2-x1)+y1;
  LCDSetPixel(color,x2,y2);
  x2++;
  }
}

void lengthline(float x1,float y1,float length,float slope,int color)
{
  float x2,y2;
  x2 = x1 + length*(cos(slope*0.01746));
  y2 = y1 + length*(sin(slope*0.01746));
  line(x1,y1,x2,y2,color);
}

void lengthlinemid(float x,float y,float length,double slope,int color)
{
  float x1,y1,x2,y2;
  x1 = x +((length/2)*(cos(slope*0.01746)));
  y1 = y - ((length/2)*(sin(slope*0.01746)));
  x2 = x -((length/2)*(cos(slope*0.01746)));
  y2 = y +((length/2)*(sin(slope*0.01746)));
  line(x1,y1,x2,y2,color);
}
void square(float x,float y, float side,int color)
{
  float x1,y1;
  for(x1 = x,y1 = y; y1 <= (y + side);y1++)
  lengthline(x1,y1,side,0,color);
}

double j =150,k=290;

void second()
{
  for(float i =0;i<360;i+=0.6)
  {
  for(int l=(-1);l<=1;l++)
  lengthline(70,67,35,i+l,0x00F);
  delay(18);
   for(int l=(-2);l<=2;l++)
  lengthline(70,67,28,j+l,RED);
   for(int l=(-3);l<=3;l++)
  lengthline(70,67,21,k+l,RED);
  j+=0.01;
  k+=(0.01/(60));
  for(int l=(-2);l<=2;l++)
  lengthline(70,67,28,j+l,0x00F);
  for(int l=(-3);l<=3;l++)
  lengthline(70,67,21,k+l,0x00F);
  for(int l=(-1);l<=1;l++)
  lengthline(70,67,35,i+l,RED);
  }
  LCDCommand(P_DISPON);

}


void cube()
{
  
  for(int i=0;i<=132;i++)
  lengthline(1,i,132,0,WHITE);
  for(int i = 0;i<=25;i++)
  lengthline(56,1+i,25,30,0x0EF);
  for(int i = 0;i<=25;i++)
  lengthline(56,1+i,25,150,0x5FF);
 for(float i = 0;i<=25;i+=0.5)
 lengthline(56 + i*(cos(150*0.01746)),26 + i*(sin(150*0.01746)),25,30,0x1FF);
 
  for(int i = 0;i<=30;i++)
  lengthline(20,25+i,30,30,0x0B0);
  for(int i = 0;i<=30;i++)
  lengthline(20,25+i,30,150,0x0E0);
 for(float i = 0;i<=30;i+=0.5)
 lengthline(20 + i*(cos(150*0.01746)),55 + i*(sin(150*0.01746)),30,30,0x0A0);
 
 for(int i = 0;i<=50;i++)
  lengthline(30,80+i,50,30,0x00E);
  for(int i = 0;i<=50;i++)
  lengthline(30,80+i,50,150,0x00F);
 for(float i = 0;i<=50;i+=0.5)
 lengthline(30 + i*(cos(150*0.01746)),130 + i*(sin(150*0.01746)),50,30,0x008);
 
 for(int i = 0;i<=50;i++)
  lengthline(100,75+i,50,30,0xDE0);
  for(int i = 0;i<=50;i++)
  lengthline(100,75+i,50,150,0xFF0);
 for(float i = 0;i<=50;i+=0.5)
 lengthline(100 + i*(cos(150*0.01746)),125 + i*(sin(150*0.01746)),50,30,0xED0);
 
 for(int i = 0;i<=35;i++)
  lengthline(110,5+i,35,30,0xFB0);
  for(int i = 0;i<=35;i++)
  lengthline(110,5+i,35,150,0xFC0);
 for(float i = 0;i<=35;i+=0.5)
 lengthline(110 + i*(cos(150*0.01746)),40 + i*(sin(150*0.01746)),35,30,0xFA0);
 
  for(int i = 0;i<=45;i++)
  lengthline(76,33+i,45,30,0xA00);
  for(int i = 0;i<=45;i++)
  lengthline(76,33+i,45,150,RED);
 for(float i = 0;i<=45;i+=0.5)
 lengthline(76 + i*(cos(150*0.01746)),78 + i*(sin(150*0.01746)),45,30,0x800);
 
 while(1)
  {
  for(float i =0;i<360;i+=0.6)
  {
  for(int l=(0);l<=0;l++)
  {lengthline(57,65,18,i+l,0xFFF);
  }
  delay(18);
   for(int l=(-1);l<=1;l++)
  {lengthline(57,65,15,j+l,RED);
  }
   for(int l=(-3);l<=3;l++)
  {lengthline(57,65,11,k+l,RED);
  }
  j+=0.01;
  k+=(0.01/(60));
  for(int l=(-1);l<=1;l++)
  {lengthline(57,65,15,j+l,0xFFF);
  }
  for(int l=(-3);l<=3;l++)
  {lengthline(57,65,11,k+l,0xFFF);
  }
  for(int l=(0);l<=0;l++)
  {lengthline(57,65,18,i+l,RED);
  }
  }
  LCDCommand(P_DISPON);

  
  }
}
  
void second1()
{
  
  for(float i =0;i<360;i+=0.6)
  {
  for(int l=(0);l<=0;l++)
  lengthline(66,67,24,i+l,0xFFF);
  delay(18);
   for(int l=(-1);l<=1;l++)
  lengthline(66,67,20,j+l,0x000);
   for(int l=(-3);l<=3;l++)
  lengthline(66,67,16,k+l,0x000);
 j+=0.01;
  k+=(0.01/(60));
  for(int l=(-1);l<=1;l++)
  lengthline(66,67,20,j+l,0xFFF);
  for(int l=(-3);l<=3;l++)
  lengthline(66,67,16,k+l,0xFFF);
 for(int l=(0);l<=0;l++)
  lengthline(66,67,24,i+l,0x000);
   LCDCommand(P_DISPON);
   
  }

}
void edge(float x,float y,float length,int angle, int color)
{
  for(float i = (-12+angle);i<=(12+angle);i+=0.5) 
  lengthline(x,y,22,i,BLACK);
for(float i = (-8+angle);i<=(8+angle);i+=0.5) 
  lengthline(x,y,20,i,BLUE); 
}


void hexagon()
{
 
  int u=1,e=0;
   for(int x1 = 1,y1 = 1; y1 <= 132;y1++)
lengthline(x1,y1,132,0,BLACK);
for(e=0;e<=1;e++,u++)
 lengthline(1,u,132,0,0xF00);
for(e=0;e<=1;e++,u++)
 lengthline(1,u,132,0,0xE00);
 for(e=0;e<=1;e++,u++)
 lengthline(1,u,132,0,0xD00);
 for(e=0;e<=1;e++,u++)
 lengthline(1,u,132,0,0xC00);
 for(e=0;e<=1;e++,u++)
 lengthline(1,u,132,0,0xB00);
for(e=0;e<=1;e++,u++)
 lengthline(1,u,132,0,0xA00);
 for(e=0;e<=3;e++,u++)
 lengthline(1,u,132,0,0x900);
 for(e=0;e<=3;e++,u++)
 lengthline(1,u,132,0,0x800);
 for(e=0;e<=3;e++,u++)
 lengthline(1,u,132,0,0x700);
 for(e=0;e<=3;e++,u++)
 lengthline(1,u,132,0,0x600);
 for(e=0;e<=3;e++,u++)
 lengthline(1,u,132,0,0x500);
 for(e=0;e<=3;e++,u++)
 lengthline(1,u,132,0,0x400);
 for(e=0;e<=3;e++,u++)
 lengthline(1,u,132,0,0x300);
 for(e=0;e<=3;e++,u++)
 lengthline(1,u,132,0,0x200);
 for(e=0;e<=3;e++,u++)
 lengthline(1,u,132,0,0x100);


for(float i = 0,x1=10,y1=132;i<=30;i+=0.1)
line(x1+i,132,40,y1-(4.2*i),0xFFF);
for(float i = 0,x1=70,y1=132;i<=30;i+=0.1)
line(x1-i,132,40,y1-(4.2*i),0xFFF);
 for(int s =0;s<132;s+=4) 
lengthline(1+s,132,100,315,BLACK);
 for(int s =0;s<30;s+=4) 
lengthline(1,132-s,100,315,BLACK);
 for(int s =0;s<132;s+=4) 
lengthline(132-s,132,100,235,BLACK);
 for(int s =0;s<20;s+=4) 
lengthline(132,132-s,100,235,BLACK);

for(int x1 = 0,y1 = 50; y1 <= 132;y1++)
lengthline(x1,y1,25,0,BLACK);
for(int x=0;x<=25;x+=6)
{
  for(int y = 50;y<=132;y+=5)
{
 for(int i = 0;i<=2;i++)
 lengthline(x-i,y+i,i*2,0,0xFFF);
 for(int i = 0;i<=1;i++)
 lengthline(x-2,y+2+i,4,0,0xFFF);
 for(int i = 0;i<=1;i++)
 lengthline(x-2,y+3+i,4,0,0xFFF);
 for(int i = 2;i>=0;i--)
 lengthline(x-i,y+6-i,i*2,0,0xFFF);
}
}
for(int i = 0;i<=72;i++)
 lengthline(110-(i),60+(i),i*2,0,0xFFF);
 for(int s =0;s<=140;s+=5) 
 lengthline(38+s,132,100,315,BLACK);
for(int x1 =85,y1 = 100; y1 <= 132;y1++)
lengthline(x1,y1,48,0,BLACK);
for(int x=87;x<=135;x+=5)
{
  for(int y = 100;y<=132;y+=4)
{
 for(int i = 0;i<=1;i++)
 lengthline(x-i,y+i,i,0,0xFFF);
 for(int i = 0;i<=2;i++)
 lengthline(x-1,y+1+i,1,0,0xFFF);
 for(int i = 0;i<=2;i++)
 lengthline(x-1,y+3+i,1,0,0xFFF);
 for(int i = 1;i>=0;i--)
 lengthline(x-i,y+6-i,i,0,0xFFF);
}
}
for(int x1 = 57,y1 = 60; y1 <= 132;y1++)
lengthline(x1,y1,20,0,BLACK);
for(int x=57;x<=77;x+=5)
{
  for(int y = 60;y<=132;y+=5)
{
 for(int i = 0;i<=1;i++)
 lengthline(x-i,y+i,i*2,0,0xFFF);
 for(int i = 0;i<=1;i++)
 lengthline(x-1,y+1+i,2,0,0xFFF);
 for(int i = 0;i<=1;i++)
 lengthline(x-1,y+2+i,2,0,0xFFF);
 for(int i = 1;i>=0;i--)
 lengthline(x-i,y+3-i,i*2,0,0xFFF);
}
}

   for(int i = 0;i<=25;i++)
 lengthline(77,5+i,50,0,0xFFF);
 for(int i = 0;i<=25;i++)
 lengthline(77,30+i,50,0,0xCFF);
 
 
  while(1)
  {
  for(float i =0;i<360;i+=0.6)
  {
  for(int l=(0);l<=0;l++)
  lengthline(102,30,22,i+l,0x000);
  delay(18);
   for(int l=(-1);l<=1;l++)
 {if((i>0)&&(i<180))
  lengthline(102,30,18,j+l,0xCFF);
  else
  lengthline(102,30,18,j+l,0xFFF);}
   for(int l=(-3);l<=3;l++)
  { if((i>0)&&(i<180))
  lengthline(102,30,14,k+l,0xCFF);
  else
  lengthline(102,30,14,k+l,0xFFF);}
  j+=0.01;
  k+=((0.01)/60);
  for(int l=(-1);l<=1;l++)
  lengthline(102,30,18,j+l,0x000);
  for(int l=(-3);l<=3;l++)
  lengthline(102,30,14,k+l,0x000);
 for(int l=(0);l<=0;l++)
 {
   if((i>0)&&(i<180))
  lengthline(102,30,22,i+l,0xCFF);
  else
  lengthline(102,30,22,i+l,0xFFF);}
   LCDCommand(P_DISPON);
   
  }
 }
}

(code tags added by moderator)

code continued ...

void theme2()
{
  
 square(1,1,132,0xF00);
 square(4,4,126,0xE00);
 square(7,7,120,0xD00);
 square(10,10,114,0xC00);
 square(13,13,108,0xB00);
 square(16,16,102,0xA00);
 square(19,19,96,0x900);
 square(22,22,90,0x800);
 square(25,25,84,0x700);
 square(28,28,78,0x600);
 square(31,31,72,0x500);
 square(34,34,66,0x400);
 square(37,37,60,0x300);
 square(40,40,54,0x200);
 square(43,43,48,0x100);
 square(46,46,42,0x000);
 while(1)
 {
  second1();
 }
}

void   setup()
{
Serial.begin(9600);
pinMode(10,INPUT);

   //Initialize ARM I/O
   ioinit();
        delay(100);
   ioinit();
        delay(100);
        ioinit();
   pinMode(13,OUTPUT);
   delay(100);
   LCDInit();         //Initialize the LCD
   
}

void theme1()
{
   for(int i=0;i<=132;i++)
 lengthline(1,i,132,0,RED);
 edge(106,69,15,0,BLUE);
 edge(100,87,15,30,BLUE);
 edge(87,100,15,60,BLUE);
 edge(70,106,15,90,BLUE);
 edge(50,100,15,120,BLUE);
 edge(35,87,15,150,BLUE);
 edge(30,69,15,180,BLUE);
 edge(35,50,15,210,BLUE);
  edge(50,35,15,240,BLUE);
 edge(70,26,15,270,BLUE);
 edge(87,35,15,300,BLUE);
 edge(103,47,15,330,BLUE);

 for(int i=26;i<=100;i++)
  lengthline(64,i,6,0,RED);

 while(1)
 {
second();
 }
}

void cuboid(int x,int y,int lt,int ht,int bt)
{
 for(int i = 0;i<=ht;i++)
 lengthline(x,y+i,bt,30,0x0B0);
 for(int i = 0;i<=ht;i++)
 lengthline(x,y+i,lt,150,0x0E0);
 for(float i = 0;i<=lt;i+=0.5)
 lengthline(x + i*(cos(150*0.01746)),y+ht + i*(sin(150*0.01746)),bt,30,0x0A0);
}

void cuboid1(int x,int y,int lt,int ht,int bt)
{
 for(int i = 0;i<=ht;i++)
 lengthline(x,y+i,bt,30,0x500);
 for(int i = 0;i<=ht;i++)
 lengthline(x,y+i,lt,150,0xA00);
 for(float i = 0;i<=lt;i+=0.5)
 lengthline(x + i*(cos(150*0.01746)),y+ht + i*(sin(150*0.01746)),bt,30,0x000);
}

void cuboid2(int x,int y,int lt,int ht,int bt)
{
 for(int i = 0;i<=ht;i++)
 lengthline(x,y+i,bt,30,0xFFF);
 for(int i = 0;i<=ht;i++)
 lengthline(x,y+i,lt,150,0xFFF);
 for(float i = 0;i<=lt;i+=0.5)
 lengthline(x + i*(cos(150*0.01746)),y+ht + i*(sin(150*0.01746)),bt,30,0xFFF);
}

void one(int x,int y)
{
 int ht,bt,lt;
 ht = 5;bt = 5;lt = 10;
 cuboid(x,y,lt,ht,bt);
 x=x;y=y+ht-1;ht = 22;lt = 5; bt = 5;
 cuboid(x,y,lt,ht,bt);
}
void seven(int x,int y)
{
 int ht,bt,lt;
 ht = 5;bt = 5;lt = 17;
 cuboid(x,y,lt,ht,bt);
 x=x;y=y+ht-1;ht = 22;lt = 5; bt = 5;
 cuboid(x,y,lt,ht,bt);
}
void three(int x,int y)
{
  int ht,bt,lt;
  lt=17;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
  x=x;y=y+ht-1;lt=5;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
   x=x;y=y+ht-1;lt=17;bt=5;ht=6;
   cuboid(x,y,lt,ht,bt);
   x=x;y=y+ht-1;lt=5;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
  x=x;y=y+ht-1;lt=17;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
}
void two(int x,int y)
{
   int ht,bt,lt;
  lt=17;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
  x=x;y=y+ht-1;lt=5;bt=5;ht=5;
  cuboid(x,y,lt,ht,bt);
   x=x;y=y+ht-1;lt=17;bt=5;ht=6;
   cuboid(x,y,lt,ht,bt);
   x=x-10;y=y+ht+6-1;lt=5;bt=5;ht=7;
  cuboid(x,y,lt,ht,bt);
  x=x+10;y=y+ht-6-1;lt=17;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
}
void five(int x,int y)
{
   int ht,bt,lt;
  lt=17;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
  x=x-10;y=y+ht+6-1;lt=5;bt=5;ht=5;
  cuboid(x,y,lt,ht,bt);
   x=x+10;y=y+ht-6-1;lt=17;bt=5;ht=6;
   cuboid(x,y,lt,ht,bt);
   x=x;y=y+ht-1;lt=5;bt=5;ht=7;
  cuboid(x,y,lt,ht,bt);
  x=x;y=y+ht-1;lt=17;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
}
void s(int x,int y)
{
   int ht,bt,lt;
  lt=17;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
  x=x-10;y=y+ht+6-1;lt=5;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
   x=x+10;y=y+ht-6-1;lt=17;bt=5;ht=7;
   cuboid(x,y,lt,ht,bt);
   x=x;y=y+ht-1;lt=5;bt=5;ht=8;
  cuboid(x,y,lt,ht,bt);
  x=x;y=y+ht-1;lt=17;bt=5;ht=7;
  cuboid(x,y,lt,ht,bt);
}
void dot(int x,int y)
{
  int lt,bt,ht;
  lt = 5;ht= 5;bt =5;
  cuboid(x,y,lt,ht,bt);
}

void eight(int x,int y)
{
   int ht,bt,lt;
  lt=17;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
  x=x;y=y+ht-1;lt=5;bt=5;ht=5;
  cuboid(x,y,lt,ht,bt);
  x=x-10;y=y+6;lt=5;bt=5;ht=5;
  cuboid(x,y,lt,ht,bt);
   x=x+10;y=y+ht-6-1;lt=17;bt=5;ht=6;
   cuboid(x,y,lt,ht,bt);
   x=x;y=y+ht-1;lt=5;bt=5;ht=7;
  cuboid(x,y,lt,ht,bt);
   x=x-10;y=y+6;lt=5;bt=5;ht=7;
  cuboid(x,y,lt,ht,bt);
  x=x+10;y=y+ht-6-1;lt=17;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
}
void four(int x,int y)
{
   int ht,bt,lt;
  x=x;y=y;lt=5;bt=5;ht=10;
  cuboid(x,y,lt,ht,bt);
  x=x-10;y=y+6;lt=5;bt=5;ht=10;
  cuboid(x,y,lt,ht,bt);
   x=x+10;y=y+ht-6-1;lt=17;bt=5;ht=8;
   cuboid(x,y,lt,ht,bt);
   x=x;y=y+ht-1;lt=5;bt=5;ht=12;
  cuboid(x,y,lt,ht,bt);
}

void zero(int x,int y)
{
   int ht,bt,lt;
  lt=17;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
  x=x;y=y+ht-1;lt=5;bt=5;ht=18;
  cuboid(x,y,lt,ht,bt);
  x=x-10;y=y+6;lt=5;bt=5;ht=18;
  cuboid(x,y,lt,ht,bt);
  x=x+10;y=y+ht-6-1;lt=17;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
}

void nine(int x,int y)
{
   int ht,bt,lt;
  lt=17;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
  x=x;y=y+ht-1;lt=5;bt=5;ht=5;
  cuboid(x,y,lt,ht,bt);
  x=x-10;y=y+6;lt=5;bt=5;ht=5;
  cuboid(x,y,lt,ht,bt);
   x=x+10;y=y+ht-6-1;lt=17;bt=5;ht=6;
   cuboid(x,y,lt,ht,bt);
   x=x;y=y+ht-1;lt=5;bt=5;ht=7;
  cuboid(x,y,lt,ht,bt);
  x=x;y=y+ht-1;lt=17;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
}

void six(int x,int y)
{
   int ht,bt,lt;
  lt=17;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
  x=x-10;y=y+6+ht-1;lt=5;bt=5;ht=5;
  cuboid(x,y,lt,ht,bt);
   x=x+10;y=y+ht-6-1;lt=17;bt=5;ht=6;
   cuboid(x,y,lt,ht,bt);
   x=x;y=y+ht-1;lt=5;bt=5;ht=7;
  cuboid(x,y,lt,ht,bt);
   x=x-10;y=y+6;lt=5;bt=5;ht=7;
  cuboid(x,y,lt,ht,bt);
  x=x+10;y=y+ht-6-1;lt=17;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
}
void day(int date,int month,int year)
{
  long unsigned int p=0,l=0,r=0,s=0;
  for(l=0;l<=year;l++)
  {
  if(((year-1)/100)^((year-1)/400)^((year-1)/4))
  p++;
  }
  p = p + (year*365);
  switch(month){
    case 1:p = p+date;
    break;
    case 2:p=p+31+date;
    break;
    case 3:{
    if(((year)/100)^((year)/400)^((year)/4))
    p = p+31+date+29;
    else
    p=p+31+date+28;
    }
    case 4:p = p=p+31+date+28+31;
    break;
    case 5:p = p=p+31+date+28+31+30;
    break;
    case 6:p = p=p+31+date+28+31+30+31;
    break;
    case 7:p = p=p+31+date+28+31+30+31+30;
    break;
    case 8:p = p=p+31+date+28+31+30+31+30+31;
    break;
    case 9:p = p=p+31+date+28+31+30+31+30+31+31;
    break;
    case 10:p = p=p+31+date+28+31+30+31+30+31+31+30;
    break;
    case 11:p = p=p+31+date+28+31+30+31+30+31+31+30+31;
    break;
    case 12:p = p=p+31+date+28+31+30+31+30+31+31+30+31+30;
    break;
  }
  p = (p%7);
  }
void t(int x,int y)
{
 int ht,bt,lt;
 ht = 5;bt = 5;lt = 20;
 cuboid(x,y,lt,ht,bt);
 x=x-7;y=y+ht+4;ht = 24;lt = 5; bt = 5;
 cuboid(x,y,lt,ht,bt);
}
void u(int x,int y)
{
  int ht,bt,lt;
   x=x;y=y;lt=5;bt=5;ht=24;
  cuboid(x,y,lt,ht,bt);
  x=x-10;y=y+6;lt=5;bt=5;ht=24;
  cuboid(x,y,lt,ht,bt);
  x=x+10;y=y+ht-6-1;lt=17;bt=5;ht=7;
  cuboid(x,y,lt,ht,bt);
}

void nt(int x,int y)
{
   int ht,bt,lt;
  lt=21;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
  x=x;y=y+ht-1;lt=5;bt=5;ht=25;
  cuboid(x,y,lt,ht,bt);
  x=x-10;y=y+6;lt=5;bt=5;ht=25;
  cuboid(x,y,lt,ht,bt);
  x=x+10;y=y+ht-6-1;lt=17;bt=5;ht=7;
 // cuboid(x,y,lt,ht,bt);
}
void a(int x,int y)
{
   int ht,bt,lt;
  lt=17;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
  x=x;y=y+ht-1;lt=5;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
  x=x-10;y=y+6;lt=5;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
   x=x+10;y=y+ht-6-1;lt=17;bt=5;ht=7;
   cuboid(x,y,lt,ht,bt);
   x=x;y=y+ht-1;lt=5;bt=5;ht=14;
  cuboid(x,y,lt,ht,bt);
   x=x-10;y=y+6;lt=5;bt=5;ht=14;
  cuboid(x,y,lt,ht,bt);
}

code continued ....

void r(int x,int y)
{
   int ht,bt,lt;
  lt=17;bt=5;ht=6;
  cuboid(x-3,y,lt,ht,bt);
  x=x-3;y=y+ht-1;lt=5;bt=5;ht=8;
  cuboid(x,y,lt,ht,bt);
  x=x-7;y=y+6;lt=5;bt=5;ht=6;
  cuboid(x,y,lt,ht,bt);
   x=x+10;y=y+ht-6-1;lt=17;bt=5;ht=7;
   cuboid(x,y,lt,ht,bt);
   x=x;y=y+ht-1;lt=5;bt=5;ht=14;
  cuboid(x,y,lt,ht,bt);
   x=x-10;y=y+6;lt=5;bt=5;ht=14;
  cuboid(x,y,lt,ht,bt);
}

void test()
{float x,y,m,m1,x1;
  for(int i =0;i<=132;i++)
lengthline(1,i,132,0,WHITE);
x=66;y=66;
m= tan(130*0.01746);
m1 = tan(150*0.01746);
for(float i =0; i<=30;i++,y++)
{
x = ((y-66)/m)+66;
x1 = ((y-66)/m1)+66;
line(x,y,x1,y,((i/2)*16*16));
}
for(;x>=x1;x1+=0.3,y+=0.5)
{
 x = ((y-66)/m)+66;
line(x,y,x1,y,0xF00);
}
x=66;y=66;
m= tan(150*0.01746);
m1 = tan(170*0.01746);
for(float i =0; i<=30;i++,y++)
{
x = ((y-66)/m)+66;
x1 = ((y-66)/m1)+66;
line(x,y,x1,y,(((i/2)+2)*16*16));
}
for(;x<=x1;x--,y++)
{
 x1 = ((y-66)/m1)+66;
line(x,y,x1,y,0xF00);
}
}


int pl ;
void play(int x,int y)
{
 

  for(int j =0;j<4;j++)
  {int i=4;
    i=i-j;
  for(;i>0;i--)
  {
    if(pl==0)
  cuboid(x+(j*,y+(i*+(j*4),4,4,4);
  else
  cuboid1(x+(j*,y+(i*+(j*4),4,4,4);
  }
  }
}


void ff(int x,int y)
{

  for(int j =0;j<3;j++)
  {int i=4;
    i=i-j;
  for(;i>0;i--)
  {
  cuboid(x+(j*6),y+(i*6)+(j*3),3,3,3);
  }
  }

for(int j =0;j<4;j++)
  {int i=4;
    i=i-j;
  for(;i>0;i--)
  {
  cuboid(x+19+(j*6),y+(i*6)+(j*3),3,3,3);
  }
  }

}


void bb(int x,int y)
{

  for(int j =4;j>0;j--)
  {int i=4;
  i=i-j;
  for(;i>=0;i--)
  {
  cuboid(x+((4-j)*6),y+(i*6)+(j*3),3,3,3);
  }
  }

for(int j =3;j>0;j--)
  {int i=4;
    i=i-j;
  for(;i>=0;i--)
  {
  cuboid(x+18+((4-j)*6),y+(i*6)+(j*3),3,3,3);
  }
  }

}


void sat()
{
   for(int i=0;i<=132;i++)
 lengthline(1,i,132,0,0xFFF);

 cuboid(40,0,70,10,110);
  cuboid(110,0,70,10,110);
   cuboid(15,30,10,10,110);
 cuboid(60,25,70,10,110);

 cuboid(75,85,100,10,60);
 cuboid(115,90,100,10,10);
 cuboid(20,75,20,20,20);
 
  five(50,80);
  a(75,60);
  t(100,40);
 cuboid(120,25,20,20,20);
}


void calender(int date,int month,int year)
{

  int x=20,y=80;
  for(int i=0;i<=132;i++)
 lengthline(1,i,132,0,0xFFF);

 cuboid(40,0,70,10,110);
  cuboid(110,0,70,10,110);
   cuboid(15,30,10,10,110);
 cuboid(60,25,70,10,110);

 cuboid(75,85,100,10,60);
 cuboid(115,90,100,10,10);
  
 if((date/10)==0)
  zero(x,y);
  if((date/10)==1)
  one(x,y);
  if((date/10)==2)
  two(x,y);
  if((date/10)==3)
  three(x,y);
  
  if((date%10)==1)
  one(x+17,y-11);
  if((date%10)==2)
  two(x+17,y-11);
  if((date%10)==3)
  three(x+17,y-11);
  if((date%10)==4)
  four(x+17,y-11);
  if((date%10)==5)
  five(x+17,y-11);
  if((date%10)==6)
  six(x+17,y-11);
  if((date%10)==7)
  seven(x+17,y-11);
  if((date%10)==8)
  eight(x+17,y-11);
  if((date%10)==9)
  nine(x+17,y-11);
  if((date%10)==0)
  zero(x+17,y-11);
  
  dot(x+26,y-4);
  
   if((month/10)==0)
  zero(x+44,y-26);
  if((month/10)==1)
  one(x+44,y-26);
 
   if((month%10)==1)
  one(x+61,y-37);
  if((month%10)==2)
  two(x+61,y-37);
  if((month%10)==3)
  three(x+61,y-37);
  if((month%10)==4)
  four(x+61,y-37);
  if((month%10)==5)
  five(x+61,y-37);
  if((month%10)==6)
  six(x+61,y-37);
  if((month%10)==7)
  seven(x+61,y-37);
  if((month%10)==8)
  eight(x+61,y-37);
  if((month%10)==9)
  nine(x+61,y-37);
  if((month%10)==0)
  zero(x+61,y-37);

dot(x+70,y-30);
  
 if(((year%100)/10)==1)
  one(x+88,y-52);
  if(((year%100)/10)==2)
  two(x+88,y-52);
  if(((year%100)/10)==3)
  three(x+88,y-52);
  if(((year%100)/10)==4)
  four(x+88,y-52);
  if(((year%100)/10)==5)
  five(x+88,y-52);
  if(((year%100)/10)==6)
  six(x+88,y-52);
  if(((year%100)/10)==7)
  seven(x+88,y-52);
  if(((year%100)/10)==8)
  eight(x+88,y-52);
  if(((year%100)/10)==9)
  nine(x+88,y-52);
  if(((year%100)/10)==0)
  zero(x+88,y-52);
  
  if(((year%100)%10)==1)
  one(x+105,y-63);
  if(((year%100)%10)==2)
  two(x+105,y-63);
  if(((year%100)%10)==3)
  three(x+105,y-63);
  if(((year%100)%10)==4)
  four(x+105,y-63);
  if(((year%100)%10)==5)
  five(x+105,y-63);
  if(((year%100)%10)==6)
  six(x+105,y-63);
  if(((year%100)%10)==7)
  seven(x+105,y-63);
  if(((year%100)%10)==8)
  eight(x+105,y-63);
  if(((year%100)%10)==9)
  nine(x+105,y-63);
  if(((year%100)%10)==0)
  zero(x+105,y-63);
   LCDCommand(P_DISPON);
   while(1);

}
int kk;
void bar(int y)
{ 
  if(kk>=y)
  {
  for(float vol = 1;vol<=(12-(y/10));vol++)
   cuboid2(130-(vol*10),110,4,16,4);
  }
  if(kk<=y)
  {
 for(float vol = 1;vol<=(y/10);vol++)
 cuboid1((vol*10),110,4,16,4);
  }
  kk=y;

}
//************************************************************************
//               Loop
//************************************************************************
float i=0;
void   loop()
{ int p=0,n =2;
if(n==6)
{
  sat();
  while(1);
}
 if(n==0)
 {
 for(int i =0;i<=132;i++)
lengthline(1,i,132,0,0xFFF);
pl =1;
play(5,0);
ff(5,40);
bb(5,70);
kk=50;
int o=(-10);
while(1)
{
o=(-1)*o;
for(int y= 0;y<=120 && y>=0;y+=o)
bar(y);
}
}
if(n==3)
 cube();
 if(n==2)
 theme2();
 if(n==1)
 theme1();
 if(n==4)
 hexagon();
 if(n==5)
 calender(31,12,2011);
digitalWrite(13,HIGH);   

}

//************************************************************************
void ioinit(void)
{
   DDRD   =   ((1<<CS)|(1<<DIO)|(1<<SCK)|(1<<LCD_RES));   //Set the control pins as outputs
}




//************************************************************************

if you wish to see what this code does... here's a link --

http://arduino.cc/forum/index.php/topic,85364.0.html

help me with the process of reduction of size only that shouldnt affect it's features

if you wish to see what this code does, it actually runs a clocks with 5 different themes, displays date and day, here's a link --

Moderator edit. Multi posted video removed. OP, you're heading for a timeout. Cut it out. AWOL

Please edit your entry to wrap the code in code tags.

My first impression is that you should go for table driven programming table driven programming - Google Search. The next thing that you need to pull this of is to learn about progmem PROGMEM - Arduino Reference.

The next thing that you need to pull this of is to learn about progmem

Normally, a good idea. But it doesn't help when the code doesn't fit on the chip.

The code, as posted, is malformed and doesn't compile.

and is buggy.

Pete

dude u dont have LCD_driver.c or nokia_tester.h
these are external libraries... download them online or i'll post them too and then try... it will definitely work

if you are interested in running this code... please let me know and i'll post LCD_driver.c along with LCD_driver.h and nokia_tester.h
store them in same directory and include them in your code (which has already been done) to run it without any errors . If errors still persist, let me know and i'll resolve them for you

Running? No!

Compiling, helpful!

While it's healthy to be skeptical you should probably go through the trouble of downloading what you posted and try compiling it yourself before posting such an adamant reply.

int pl;

void play(int x,int y)
{
    for ( int j = 0; j < 4; j++ )
    {
        int i   = 4;
        i       = i - j;
        for ( ; i > 0; i-- )
        {
            if ( pl == 0 )
                 cuboid(x + (j *, y + (i * + (j * 4), 4, 4, 4);     <- MISSING TWO CLOSING ')'
            else
                cuboid1(x + (j *, y + (i * + (j * 4), 4, 4, 4);     <- MISSING TWO CLOSING ')'
        }
    }
}

... and then what the heck is

cuboid(x + (j *,

... or

cuboid1(x + (j *,
switch(month){
    case 1:p = p+date;
    break;
    case 2:p=p+31+date;
    break;
    case 3:{
    if(((year)/100)^((year)/400)^((year)/4))
    p = p+31+date+29;
    else
    p=p+31+date+28;
    }
    case 4:p = p=p+31+date+28+31;
    break;
    case 5:p = p=p+31+date+28+31+30;
    break;
    case 6:p = p=p+31+date+28+31+30+31;
    break;
    case 7:p = p=p+31+date+28+31+30+31+30;
    break;
    case 8:p = p=p+31+date+28+31+30+31+30+31;
    break;
    case 9:p = p=p+31+date+28+31+30+31+30+31+31;
    break;
    case 10:p = p=p+31+date+28+31+30+31+30+31+31+30;
    break;
    case 11:p = p=p+31+date+28+31+30+31+30+31+31+30+31;
    break;
    case 12:p = p=p+31+date+28+31+30+31+30+31+31+30+31+30;
    break;
  }

Two things here,
1 - do the calculations...

    case 12:p = p=p+date+334;

2 - Did you actually mean 'p equals p equals p plus date plus x'?

Do these date calculations once each, into variables, and check those.

 if((date/10)==0)
  zero(x,y);
  if((date/10)==1)
  one(x,y);
  if((date/10)==2)
  two(x,y);
  if((date/10)==3)
  three(x,y);
  
  if((date%10)==1)
  one(x+17,y-11);
  if((date%10)==2)
  two(x+17,y-11);
  ...
 
   if((month%10)==1)
  one(x+61,y-37);
  if((month%10)==2)
  two(x+61,y-37);
  ...

 dot(x+70,y-30);
  
 if(((year%100)/10)==1)
  one(x+88,y-52);
  if(((year%100)/10)==2)
  two(x+88,y-52);
...
  
  if(((year%100)%10)==1)
  one(x+105,y-63);
  if(((year%100)%10)==2)
  two(x+105,y-63);
...

This...

for(float i = 0,x1=10,y1=132;i<=30;i+=0.1)
line(x1+i,132,40,y1-(4.2*i),0xFFF);

is an interesting construction. It is valid, but seems a strange use of a for statement. The values of x1 and y1 won't change, so you might as well use literals.

There's a couple of things I don't understand...

Inside loop() you call theme2() which makes a bunch of calls to square(,,,) at the end of which you call

while(1){
	second1();
}

which tells me that once you start to display second1() it just stays there forever. Even when you reset the Arduino it defaults to n==2 so it always runs theme2() after a reset and will fall back into the forever loop with second1() being displayed.

And the second thing I don't understand is your use of the following for-loop inside cube() and other functions.

for(int i=0;i<=132;i++)
	lengthline(1,i,132,0,WHITE);

I broke this code out and ran it separately. It seems to redraw the same lines hundreds of times. Is that supposed to happen? I don't see how this code was used to make that video. It just doesn't look like it will do what I saw.

And to use cube() as an example again, you have a call to a for loop that looks like:

for(int l=(0); l<=0; l++)
{
	lengthline(57,65,18,i+l,0xFFF);
}

which doesn't increment anything. It iterates the value of 'l' from zero to zero. Why do you even have this for-loop construct?

Fair dinkum yahska that's some of the worst code I've seen in years. I really don't know where to start but for example

 if(((year%100)/10)==1)
  one(x+88,y-52);
  if(((year%100)/10)==2)
  two(x+88,y-52);
  if(((year%100)/10)==3)
  three(x+88,y-52);
  if(((year%100)/10)==4)
  four(x+88,y-52);
  if(((year%100)/10)==5)
  five(x+88,y-52);
  if(((year%100)/10)==6)
  six(x+88,y-52);
  if(((year%100)/10)==7)
  seven(x+88,y-52);
  if(((year%100)/10)==8)
  eight(x+88,y-52);
  if(((year%100)/10)==9)
  nine(x+88,y-52);
  if(((year%100)/10)==0)
  zero(x+88,y-52);

could be

someVar = year%100)/10;
switch someVar {
    case 1:
// etc etc
}

But then the one() two() etc functions all appear to the the same thing with a single value that's different, combine them all into one function and add a third parameter. Probably something like

someNew Func (year%100)/10);

would replace all the above code and several other similar blocks you have.

    case 4:p = p=p+31+date+28+31;
    break;
    case 5:p = p=p+31+date+28+31+30;
    break;
    case 6:p = p=p+31+date+28+31+30+31;
    break;
    case 7:p = p=p+31+date+28+31+30+31+30;
    break;
    case 8:p = p=p+31+date+28+31+30+31+30+31;
    break;
    case 9:p = p=p+31+date+28+31+30+31+30+31+31;
    break;
    case 10:p = p=p+31+date+28+31+30+31+30+31+31+30;
    break;
    case 11:p = p=p+31+date+28+31+30+31+30+31+31+30+31;
    break;
    case 12:p = p=p+31+date+28+31+30+31+30+31+31+30+31+30;
    break;

Maybe

int daysUpToMonth[12] = {30, 28, etc etc};
p += daysUpToMonth[month] + date;

This code could probably be done in have the size, look at every time you have repetitive code and optimize it.


Rob

Fair dinkum yahska that's some of the worst code I've seen in years. I really don't know where to start but for example

 if(((year%100)/10)==1)
  one(x+88,y-52);
  if(((year%100)/10)==2)
  two(x+88,y-52);
  if(((year%100)/10)==3)
  three(x+88,y-52);
  if(((year%100)/10)==4)
  four(x+88,y-52);
  if(((year%100)/10)==5)
  five(x+88,y-52);
  if(((year%100)/10)==6)
  six(x+88,y-52);
  if(((year%100)/10)==7)
  seven(x+88,y-52);
  if(((year%100)/10)==8)
  eight(x+88,y-52);
  if(((year%100)/10)==9)
  nine(x+88,y-52);
  if(((year%100)/10)==0)
  zero(x+88,y-52);

could be

someVar = (year%100)/10;
switch someVar {
    case 1:
// etc etc
}

But then the one() two() etc functions all appear to the the same thing with a single value that's different, combine them all into one function and add a third parameter. Probably something like

someNewFunc (x, y, year); // do +88, -52 and %100)/10 in the function

would replace all the above code and several other similar blocks you have.

    case 4:p = p=p+31+date+28+31;
    break;
    case 5:p = p=p+31+date+28+31+30;
    break;
    case 6:p = p=p+31+date+28+31+30+31;
    break;
    case 7:p = p=p+31+date+28+31+30+31+30;
    break;
    case 8:p = p=p+31+date+28+31+30+31+30+31;
    break;
    case 9:p = p=p+31+date+28+31+30+31+30+31+31;
    break;
    case 10:p = p=p+31+date+28+31+30+31+30+31+31+30;
    break;
    case 11:p = p=p+31+date+28+31+30+31+30+31+31+30+31;
    break;
    case 12:p = p=p+31+date+28+31+30+31+30+31+31+30+31+30;
    break;

Maybe

int daysUpToMonth[12] = {31, 59, etc etc};
p += daysUpToMonth[month] + date;

This code could probably be done in half the size, look at every time you have repetitive code and optimize it.


Rob