/* Michael Cirineo, mjc89 Cornell University ECE 4760 Final Project The Weather Canvas LED Matrix PWM control and RF receiver control */ #include #include #include #include #include #define begin { #define end } void shimmering(void); //transition method void initialize(void); //all the usual mcu stuff unsigned char i, pic; //pic contains the index of the current picture unsigned int buffer, nextset, hold; //buffer contains the data received from rf //nextset contains the filled buffer data from each transmission // hold determines time to hold each picture before transition to next unsigned char switchpic; //asserted if shimmering() has reached full brightness signed char inc; //used in shimmering() to determine if pic is dimming or brightening //Below, shimmer contains amount of augmented brightness during transition //counter determines how long each transition lasts //VTprev is used in rf reciever to make sure buffer only fills during subsequent data bursts //size contains the number of bits in the receive buffer //index1 is the index of the current picture slot (0-4) used in picseq[index1] unsigned char shimmer, counter, VTprev, size, index1; //picseq contains the sequence of 5 pictures to display from available weather conditions unsigned char picseq[5]; //strength[5] contains the strengths of the current set of pictures //currstrength contains the strength of the current picture in the set for display purposes unsigned char strength[5], currstrength; //changed for each picture, contains the custom rgb pixel values for led grid unsigned long pixel[64]; //below, pwm data for each column of leds (8 column * 3 leds)=24 pwm data unsigned int pwm_delay, pwm1, pwm2, pwm32, pwm3, pwm30, pwm31, pwm5, pwm4, pwm29, pwm27, pwm28, pwm6,pwm22, pwm11, pwm12,pwm13, pwm21, pwm20,pwm19, pwm14, pwm15,pwm16, pwm18, pwm17; //quarter (RGB values at quarter of normal compared to 255, needed to make timing work #define blue 0x01013f #define dark_blue 0x01010f #define very_dark_blue 0x010107 #define black 0x010101 #define red 0x3f0101 #define light_red 0xfc0101 #define dark_red 0x070101 #define very_dark_red 0x030101 #define white 0x3f3f3f #define green 0x012001 #define purple 0x200120 #define yellow 0x3f3f01 #define orange 0x3f2901 #define dark_orange 0x0f0A01 #define violet 0x3b203b #define silver 0x303030 #define gold 0x3f3501 #define gray 0x202020 #define dark_gray 0x080808 #define pink 0x3f3032 #define fuscia 0x3f013f #define light_blue 0x2b3639 #define sky_blue 0x21333a #define aqua 0x013f3f #define khaki 0x3c3923 /* shimmering brightens the leds to become all white on a picture transition */ void shimmering(void) { if (counter==3){ //control speed of transition counter=0; if (shimmer>=100){inc=-1;switchpic=1;} //control amount of white-out in transition //and assert switchpic if full brightness reached else if (shimmer <=1){inc=1;} shimmer=shimmer+inc; } // add value to pwm value in order to brighten pixel pwm1 =pwm1+shimmer; pwm32=pwm32+shimmer; pwm2=pwm2+shimmer; pwm31 =pwm31+shimmer; pwm3=pwm3+shimmer; pwm30=pwm30+shimmer; pwm4 =pwm4+shimmer; pwm29=pwm29+shimmer; pwm5=pwm5+shimmer; pwm28 =pwm28+shimmer; pwm6=pwm6+shimmer; pwm27=pwm27+shimmer; pwm11 =pwm11+shimmer; pwm12=pwm12+shimmer; pwm22=pwm22+shimmer; pwm21 =pwm21+shimmer; pwm20=pwm20+shimmer; pwm13=pwm13+shimmer; pwm14 =pwm14+shimmer; pwm15=pwm15+shimmer; pwm19=pwm19+shimmer; pwm18 =pwm18+shimmer; pwm17=pwm17+shimmer; pwm16=pwm16+shimmer; counter=counter+1; } int main(void) begin initialize(); //PA contains PORTA value to assert each row in sequence to scan thru led's //row used to determine pwm values depending on current row unsigned char PA, row; //main pwm/rf loop while(1) begin if (index1==5){ index1=0;} if (switchpic==1) { //switch current pic to next pic in sequence pic=picseq[index1]; //switch current strength to next strength in sequence currstrength=strength[index1]; index1=index1+1; switchpic=0; } //below, pics defined in terms of color per pixel //sun if (pic==1) { pixel[0]=yellow; pixel[1]=sky_blue; pixel[2]=sky_blue; pixel[3]=sky_blue; pixel[4]=sky_blue; pixel[5]=sky_blue; pixel[6]=sky_blue; pixel[7]=sky_blue; // pixel[8]=sky_blue; pixel[9]=yellow; pixel[10]=sky_blue; pixel[11]=sky_blue; pixel[12]=sky_blue; pixel[13]=sky_blue; pixel[14]=yellow; pixel[15]=sky_blue; // pixel[16]=sky_blue; pixel[17]=sky_blue; pixel[18]=orange; pixel[19]=orange; pixel[20]=orange; pixel[21]=orange; pixel[22]=sky_blue; pixel[23]=sky_blue; // pixel[24]=sky_blue; pixel[25]=sky_blue; pixel[26]=orange; pixel[27]=yellow; pixel[28]=yellow; pixel[29]=orange; pixel[30]=sky_blue; pixel[31]=sky_blue; // pixel[32]=yellow; pixel[33]=yellow; pixel[34]=orange; pixel[35]=yellow; pixel[36]=yellow; pixel[37]=orange; pixel[38]=yellow; pixel[39]=yellow; // pixel[40]=sky_blue; pixel[41]=sky_blue; pixel[42]=orange; pixel[43]=orange; pixel[44]=orange; pixel[45]=orange; pixel[46]=sky_blue; pixel[47]=sky_blue; // pixel[48]=sky_blue; pixel[49]=yellow; pixel[50]=sky_blue; pixel[51]=sky_blue; pixel[52]=sky_blue; pixel[53]=sky_blue; pixel[54]=yellow; pixel[55]=sky_blue; // pixel[56]=yellow; pixel[57]=sky_blue; pixel[58]=sky_blue; pixel[59]=sky_blue; pixel[60]=sky_blue; pixel[61]=sky_blue; pixel[62]=sky_blue; pixel[63]=yellow; } else if (pic==2){ //snow pixel[0]=black; pixel[1]=silver; pixel[2]=black; pixel[3]=black; pixel[4]=black; pixel[5]=black; pixel[6]=silver; pixel[7]=black; // pixel[8]=silver; pixel[9]=black; pixel[10]=silver; pixel[11]=black; pixel[12]=black; pixel[13]=silver; pixel[14]=black; pixel[15]=silver; // pixel[16]=black; pixel[17]=silver; pixel[18]=black; pixel[19]=silver; pixel[20]=silver; pixel[21]=black; pixel[22]=silver; pixel[23]=black; // pixel[24]=black; pixel[25]=black; pixel[26]=silver; pixel[27]=silver; pixel[28]=silver; pixel[29]=silver; pixel[30]=black; pixel[31]=black; // pixel[32]=black; pixel[33]=black; pixel[34]=silver; pixel[35]=silver; pixel[36]=silver; pixel[37]=silver; pixel[38]=black; pixel[39]=black; // pixel[40]=black; pixel[41]=silver; pixel[42]=black; pixel[43]=silver; pixel[44]=silver; pixel[45]=black; pixel[46]=silver; pixel[47]=black; // pixel[48]=silver; pixel[49]=black; pixel[50]=silver; pixel[51]=black; pixel[52]=black; pixel[53]=silver; pixel[54]=black; pixel[55]=silver; // pixel[56]=black; pixel[57]=silver; pixel[58]=black; pixel[59]=black; pixel[60]=black; pixel[61]=black; pixel[62]=silver; pixel[63]=black;} else if (pic==3){ //rain pixel[0]=gray; pixel[1]=dark_gray; pixel[2]=dark_gray; pixel[3]=dark_gray; pixel[4]=dark_gray; pixel[5]=dark_gray; pixel[6]=dark_gray; pixel[7]=gray; // pixel[8]=dark_gray; pixel[9]=dark_gray; pixel[10]=dark_gray; pixel[11]=dark_gray; pixel[12]=dark_gray; pixel[13]=dark_gray; pixel[14]=dark_gray; pixel[15]=dark_gray; // pixel[16]=dark_gray; pixel[17]=dark_gray; pixel[18]=gold; pixel[19]=dark_gray; pixel[20]=dark_gray; pixel[21]=dark_gray; pixel[22]=dark_gray; pixel[23]=dark_gray; // pixel[24]=gray; pixel[25]=dark_gray; pixel[26]=gold; pixel[27]=gold; pixel[28]=dark_gray; pixel[29]=dark_gray; pixel[30]=dark_gray; pixel[31]=gray; // pixel[32]=dark_blue; pixel[33]=gray; pixel[34]=gray; pixel[35]=gold; pixel[36]=gray; pixel[37]=gray; pixel[38]=dark_blue; pixel[39]=gray; // pixel[40]=gray; pixel[41]=dark_blue; pixel[42]=gray; pixel[43]=gold; pixel[44]=gold; pixel[45]=gray; pixel[46]=gray; pixel[47]=dark_blue; // pixel[48]=dark_blue; pixel[49]=gray; pixel[50]=gray; pixel[51]=gray; pixel[52]=gold; pixel[53]=gray; pixel[54]=dark_blue; pixel[55]=gray; // pixel[56]=gray; pixel[57]=dark_blue; pixel[58]=gray; pixel[59]=gray; pixel[60]=gold; pixel[61]=gray; pixel[62]=gray; pixel[63]=dark_blue;} else if (pic==4){ //hot pixel[0]=dark_red; pixel[1]=dark_red; pixel[2]=light_red; pixel[3]=light_red; pixel[4]=light_red; pixel[5]=dark_red; pixel[6]=dark_red; pixel[7]=dark_red; // pixel[8]=dark_red; pixel[9]=dark_red; pixel[10]=light_red; pixel[11]=dark_red; pixel[12]=light_red; pixel[13]=dark_red; pixel[14]=dark_red; pixel[15]=dark_red; // pixel[16]=dark_red; pixel[17]=dark_red; pixel[18]=light_red; pixel[19]=light_red; pixel[20]=light_red; pixel[21]=dark_red; pixel[22]=dark_red; pixel[23]=dark_red; // pixel[24]=light_red; pixel[25]=dark_red; pixel[26]=dark_red; pixel[27]=dark_red; pixel[28]=dark_red; pixel[29]=dark_red; pixel[30]=dark_red; pixel[31]=dark_red; // pixel[32]=light_red; pixel[33]=dark_red; pixel[34]=dark_red; pixel[35]=dark_red; pixel[36]=light_red; pixel[37]=light_red; pixel[38]=light_red; pixel[39]=dark_red; // pixel[40]=light_red; pixel[41]=light_red; pixel[42]=light_red; pixel[43]=dark_red; pixel[44]=dark_red; pixel[45]=light_red; pixel[46]=dark_red; pixel[47]=dark_red; // pixel[48]=light_red; pixel[49]=dark_red; pixel[50]=light_red; pixel[51]=dark_red; pixel[52]=dark_red; pixel[53]=light_red; pixel[54]=dark_red; pixel[55]=dark_red; // pixel[56]=light_red; pixel[57]=dark_red; pixel[58]=light_red; pixel[59]=dark_red; pixel[60]=dark_red; pixel[61]=light_red; pixel[62]=dark_red; pixel[63]=dark_red;} else if (pic==5){ //cold pixel[0]=light_blue; pixel[1]=light_blue; pixel[2]=light_blue; pixel[3]=dark_blue; pixel[4]=light_blue; pixel[5]=light_blue; pixel[6]=light_blue; pixel[7]=dark_blue; // pixel[8]=light_blue; pixel[9]=dark_blue; pixel[10]=dark_blue; pixel[11]=dark_blue; pixel[12]=light_blue; pixel[13]=dark_blue; pixel[14]=light_blue; pixel[15]=dark_blue; // pixel[16]=light_blue; pixel[17]=light_blue; pixel[18]=light_blue; pixel[19]=dark_blue; pixel[20]=light_blue; pixel[21]=light_blue; pixel[22]=light_blue; pixel[23]=dark_blue; // pixel[24]=dark_blue; pixel[25]=dark_blue; pixel[26]=dark_blue; pixel[27]=dark_blue; pixel[28]=dark_blue; pixel[29]=dark_blue; pixel[30]=dark_blue; pixel[31]=dark_blue; // pixel[32]=light_blue; pixel[33]=dark_blue; pixel[34]=dark_blue; pixel[35]=dark_blue; pixel[36]=light_blue; pixel[37]=light_blue; pixel[38]=dark_blue; pixel[39]=dark_blue; // pixel[40]=light_blue; pixel[41]=dark_blue; pixel[42]=dark_blue; pixel[43]=dark_blue; pixel[44]=light_blue; pixel[45]=dark_blue; pixel[46]=light_blue; pixel[47]=dark_blue; // pixel[48]=light_blue; pixel[49]=dark_blue; pixel[50]=dark_blue; pixel[51]=dark_blue; pixel[52]=light_blue; pixel[53]=dark_blue; pixel[54]=light_blue; pixel[55]=dark_blue; // pixel[56]=light_blue; pixel[57]=light_blue; pixel[58]=light_blue; pixel[59]=dark_blue; pixel[60]=light_blue; pixel[61]=light_blue; pixel[62]=dark_blue; pixel[63]=dark_blue;} else if (pic==6){ //windy pixel[0]=sky_blue; pixel[1]=green; pixel[2]=green; pixel[3]=green; pixel[4]=green; pixel[5]=green; pixel[6]=green; pixel[7]=sky_blue; // pixel[8]=sky_blue; pixel[9]=green; pixel[10]=violet; pixel[11]=violet; pixel[12]=violet; pixel[13]=violet; pixel[14]=green; pixel[15]=sky_blue; // pixel[16]=sky_blue; pixel[17]=green; pixel[18]=violet; pixel[19]=green; pixel[20]=green; pixel[21]=violet; pixel[22]=green; pixel[23]=sky_blue; // pixel[24]=sky_blue; pixel[25]=green; pixel[26]=violet; pixel[27]=violet; pixel[28]=green; pixel[29]=violet; pixel[30]=green; pixel[31]=sky_blue; // pixel[32]=sky_blue; pixel[33]=green; pixel[34]=green; pixel[35]=green; pixel[36]=green; pixel[37]=violet; pixel[38]=green; pixel[39]=sky_blue; // pixel[40]=violet; pixel[41]=violet; pixel[42]=violet; pixel[43]=violet; pixel[44]=violet; pixel[45]=violet; pixel[46]=violet; pixel[47]=green; // pixel[48]=violet; pixel[49]=violet; pixel[50]=violet; pixel[51]=violet; pixel[52]=violet; pixel[53]=violet; pixel[54]=green; pixel[55]=sky_blue; // pixel[56]=sky_blue; pixel[57]=sky_blue; pixel[58]=sky_blue; pixel[59]=sky_blue; pixel[60]=sky_blue; pixel[61]=sky_blue; pixel[62]=sky_blue; pixel[63]=sky_blue;} else if (pic==7){ //humid pixel[0]=dark_red; pixel[1]=dark_red; pixel[2]=aqua; pixel[3]=dark_red; pixel[4]=dark_red; pixel[5]=dark_red; pixel[6]=aqua; pixel[7]=dark_red; // pixel[8]=dark_red; pixel[9]=dark_red; pixel[10]=aqua; pixel[11]=dark_red; pixel[12]=aqua; pixel[13]=dark_red; pixel[14]=aqua; pixel[15]=dark_red; // pixel[16]=dark_red; pixel[17]=dark_red; pixel[18]=dark_red; pixel[19]=aqua; pixel[20]=dark_red; pixel[21]=aqua; pixel[22]=dark_red; pixel[23]=dark_red; // pixel[24]=aqua; pixel[25]=aqua; pixel[26]=aqua; pixel[27]=dark_red; pixel[28]=dark_red; pixel[29]=dark_red; pixel[30]=dark_red; pixel[31]=dark_red; // pixel[32]=aqua; pixel[33]=dark_red; pixel[34]=dark_red; pixel[35]=dark_red; pixel[36]=aqua; pixel[37]=aqua; pixel[38]=aqua; pixel[39]=dark_red; // pixel[40]=aqua; pixel[41]=aqua; pixel[42]=dark_red; pixel[43]=dark_red; pixel[44]=dark_red; pixel[45]=aqua; pixel[46]=dark_red; pixel[47]=dark_red; // pixel[48]=aqua; pixel[49]=dark_red; pixel[50]=dark_red; pixel[51]=dark_red; pixel[52]=dark_red; pixel[53]=aqua; pixel[54]=dark_red; pixel[55]=dark_red; // pixel[56]=aqua; pixel[57]=aqua; pixel[58]=aqua; pixel[59]=dark_red; pixel[60]=dark_red; pixel[61]=aqua; pixel[62]=dark_red; pixel[63]=dark_red;} else if (pic==8){ //dry pixel[0]=red; pixel[1]=red; pixel[2]=dark_orange; pixel[3]=dark_orange; pixel[4]=red; pixel[5]=dark_orange; pixel[6]=red; pixel[7]=dark_orange; // pixel[8]=red; pixel[9]=dark_orange; pixel[10]=red; pixel[11]=dark_orange; pixel[12]=red; pixel[13]=red; pixel[14]=red; pixel[15]=dark_orange; // pixel[16]=red; pixel[17]=dark_orange; pixel[18]=red; pixel[19]=dark_orange; pixel[20]=dark_orange; pixel[21]=red; pixel[22]=dark_orange; pixel[23]=dark_orange; // pixel[24]=red; pixel[25]=red; pixel[26]=dark_orange; pixel[27]=dark_orange; pixel[28]=dark_orange; pixel[29]=red; pixel[30]=dark_orange; pixel[31]=dark_orange; // pixel[32]=dark_orange; pixel[33]=dark_orange; pixel[34]=dark_orange; pixel[35]=dark_orange; pixel[36]=dark_orange; pixel[37]=dark_orange; pixel[38]=dark_orange; pixel[39]=dark_orange; // pixel[40]=dark_orange; pixel[41]=dark_orange; pixel[42]=red; pixel[43]=red; pixel[44]=red; pixel[45]=dark_orange; pixel[46]=dark_orange; pixel[47]=dark_orange; // pixel[48]=dark_orange; pixel[49]=dark_orange; pixel[50]=red; pixel[51]=dark_orange; pixel[52]=dark_orange; pixel[53]=dark_orange; pixel[54]=dark_orange; pixel[55]=dark_orange; // pixel[56]=dark_orange; pixel[57]=dark_orange; pixel[58]=red; pixel[59]=dark_orange; pixel[60]=dark_orange; pixel[61]=dark_orange; pixel[62]=dark_orange; pixel[63]=dark_orange;} else if (pic==9){ //cloudy pixel[0]=white; pixel[1]=dark_gray; pixel[2]=dark_gray; pixel[3]=dark_gray; pixel[4]=dark_gray; pixel[5]=dark_gray; pixel[6]=white; pixel[7]=white; // pixel[8]=dark_gray; pixel[9]=dark_gray; pixel[10]=dark_gray; pixel[11]=dark_gray; pixel[12]=dark_gray; pixel[13]=dark_gray; pixel[14]=dark_gray; pixel[15]=white; // pixel[16]=dark_gray; pixel[17]=dark_gray; pixel[18]=dark_gray; pixel[19]=dark_gray; pixel[20]=dark_gray; pixel[21]=dark_gray; pixel[22]=dark_gray; pixel[23]=white; // pixel[24]=dark_gray; pixel[25]=dark_gray; pixel[26]=dark_gray; pixel[27]=dark_gray; pixel[28]=dark_gray; pixel[29]=dark_gray; pixel[30]=dark_gray; pixel[31]=white; // pixel[32]=white; pixel[33]=dark_gray; pixel[34]=dark_gray; pixel[35]=dark_gray; pixel[36]=dark_gray; pixel[37]=dark_gray; pixel[38]=white; pixel[39]=white; // pixel[40]=white; pixel[41]=white; pixel[42]=white; pixel[43]=white; pixel[44]=white; pixel[45]=white; pixel[46]=white; pixel[47]=white; // pixel[48]=white; pixel[49]=white; pixel[50]=white; pixel[51]=white; pixel[52]=white; pixel[53]=white; pixel[54]=white; pixel[55]=white; // pixel[56]=white; pixel[57]=white; pixel[58]=white; pixel[59]=white; pixel[60]=white; pixel[61]=white; pixel[62]=white; pixel[63]=white; } else if (pic==10){ //rainbow pixel[0]=white; pixel[1]=white; pixel[2]=white; pixel[3]=white; pixel[4]=red; pixel[5]=orange; pixel[6]=yellow; pixel[7]=white; // pixel[8]=white; pixel[9]=white; pixel[10]=white; pixel[11]=red; pixel[12]=orange; pixel[13]=yellow; pixel[14]=green; pixel[15]=white; // pixel[16]=white; pixel[17]=white; pixel[18]=red; pixel[19]=orange; pixel[20]=yellow; pixel[21]=green; pixel[22]=blue; pixel[23]=white; // pixel[24]=white; pixel[25]=red; pixel[26]=orange; pixel[27]=yellow; pixel[28]=green; pixel[29]=blue; pixel[30]=violet; pixel[31]=white; // pixel[32]=red; pixel[33]=orange; pixel[34]=yellow; pixel[35]=green; pixel[36]=blue; pixel[37]=violet; pixel[38]=white; pixel[39]=white; // pixel[40]=orange; pixel[41]=yellow; pixel[42]=green; pixel[43]=blue; pixel[44]=violet; pixel[45]=white; pixel[46]=white; pixel[47]=white; // pixel[48]=yellow; pixel[49]=green; pixel[50]=blue; pixel[51]=violet; pixel[52]=white; pixel[53]=white; pixel[54]=white; pixel[55]=white; // pixel[56]=green; pixel[57]=blue; pixel[58]=violet; pixel[59]=white; pixel[60]=white; pixel[61]=white; pixel[62]=white; pixel[63]=white; } else if (pic==11){ //meadow pixel[0]=yellow; pixel[1]=yellow; pixel[2]=sky_blue; pixel[3]=sky_blue; pixel[4]=white; pixel[5]=white; pixel[6]=white; pixel[7]=sky_blue; // pixel[8]=yellow; pixel[9]=yellow; pixel[10]=sky_blue; pixel[11]=sky_blue; pixel[12]=white; pixel[13]=white; pixel[14]=white; pixel[15]=sky_blue; // pixel[16]=sky_blue; pixel[17]=sky_blue; pixel[18]=sky_blue; pixel[19]=sky_blue; pixel[20]=sky_blue; pixel[21]=sky_blue; pixel[22]=sky_blue; pixel[23]=sky_blue; // pixel[24]=sky_blue; pixel[25]=sky_blue; pixel[26]=sky_blue; pixel[27]=sky_blue; pixel[28]=sky_blue; pixel[29]=sky_blue; pixel[30]=sky_blue; pixel[31]=sky_blue; // pixel[32]=sky_blue; pixel[33]=sky_blue; pixel[34]=sky_blue; pixel[35]=sky_blue; pixel[36]=sky_blue; pixel[37]=sky_blue; pixel[38]=sky_blue; pixel[39]=sky_blue; // pixel[40]=green; pixel[41]=green; pixel[42]=green; pixel[43]=green; pixel[44]=green; pixel[45]=green; pixel[46]=green; pixel[47]=green; // pixel[48]=green; pixel[49]=green; pixel[50]=green; pixel[51]=green; pixel[52]=green; pixel[53]=green; pixel[54]=green; pixel[55]=green; // pixel[56]=green; pixel[57]=green; pixel[58]=green; pixel[59]=green; pixel[60]=green; pixel[61]=green; pixel[62]=green; pixel[63]=green; } else if (pic==12){ //night pixel[0]=khaki; pixel[1]=khaki; pixel[2]=khaki; pixel[3]=black; pixel[4]=black; pixel[5]=white; pixel[6]=black; pixel[7]=black; // pixel[8]=khaki; pixel[9]=khaki; pixel[10]=khaki; pixel[11]=black; pixel[12]=white; pixel[13]=black; pixel[14]=black; pixel[15]=black; // pixel[16]=khaki; pixel[17]=khaki; pixel[18]=khaki; pixel[19]=black; pixel[20]=black; pixel[21]=black; pixel[22]=white; pixel[23]=black; // pixel[24]=black; pixel[25]=black; pixel[26]=black; pixel[27]=black; pixel[28]=black; pixel[29]=black; pixel[30]=black; pixel[31]=black; // pixel[32]=black; pixel[33]=black; pixel[34]=white; pixel[35]=black; pixel[36]=white; pixel[37]=black; pixel[38]=white; pixel[39]=black; // pixel[40]=black; pixel[41]=black; pixel[42]=black; pixel[43]=black; pixel[44]=black; pixel[45]=black; pixel[46]=black; pixel[47]=black; // pixel[48]=black; pixel[49]=white; pixel[50]=black; pixel[51]=black; pixel[52]=black; pixel[53]=white; pixel[54]=black; pixel[55]=black; // pixel[56]=black; pixel[57]=black; pixel[58]=black; pixel[59]=white; pixel[60]=black; pixel[61]=black; pixel[62]=white; pixel[63]=black; } else { //blackness, default? pixel[0]=black; pixel[1]=black; pixel[2]=black; pixel[3]=black; pixel[4]=black; pixel[5]=black; pixel[6]=black; pixel[7]=black; // pixel[8]=black; pixel[9]=black; pixel[10]=black; pixel[11]=black; pixel[12]=black; pixel[13]=black; pixel[14]=black; pixel[15]=black; // pixel[16]=black; pixel[17]=black; pixel[18]=black; pixel[19]=black; pixel[20]=black; pixel[21]=black; pixel[22]=black; pixel[23]=black; // pixel[24]=black; pixel[25]=black; pixel[26]=black; pixel[27]=black; pixel[28]=black; pixel[29]=black; pixel[30]=black; pixel[31]=black; // pixel[32]=black; pixel[33]=black; pixel[34]=black; pixel[35]=black; pixel[36]=black; pixel[37]=black; pixel[38]=black; pixel[39]=black; // pixel[40]=black; pixel[41]=black; pixel[42]=black; pixel[43]=black; pixel[44]=black; pixel[45]=black; pixel[46]=black; pixel[47]=black; // pixel[48]=black; pixel[49]=black; pixel[50]=black; pixel[51]=black; pixel[52]=black; pixel[53]=black; pixel[54]=black; pixel[55]=black; // pixel[56]=black; pixel[57]=black; pixel[58]=black; pixel[59]=black; pixel[60]=black; pixel[61]=black; pixel[62]=black; pixel[63]=black; } //currstrength, 0, 1, 3, 5, or 8 //in last column, two pins had to be appropriated for rf receiving //therefore only one color may be produced. it was decided that blue //would be used to represent the "strength" of that condition on screen if (currstrength==0){ pixel[7]=black; pixel[15]=black; pixel[23]=black; pixel[31]=black; pixel[39]=black; pixel[47]=black; pixel[55]=black; pixel[63]=black;} else if (currstrength==1){ pixel[7]=black; pixel[15]=black; pixel[23]=black; pixel[31]=black; pixel[39]=black; pixel[47]=black; pixel[55]=black; pixel[63]=blue;} else if (currstrength==3){ pixel[7]=black; pixel[15]=black; pixel[23]=black; pixel[31]=black; pixel[39]=black; pixel[47]=blue; pixel[55]=blue; pixel[63]=blue;} else if (currstrength==5){ pixel[7]=black; pixel[15]=black; pixel[23]=black; pixel[31]=blue; pixel[39]=blue; pixel[47]=blue; pixel[55]=blue; pixel[63]=blue;} else if (currstrength==8){ pixel[7]=blue; pixel[15]=blue; pixel[23]=blue; pixel[31]=blue; pixel[39]=blue; pixel[47]=blue; pixel[55]=blue; pixel[63]=blue;} PA=0xfe; // assert first row first 11111110 for (row = 0; row < 8; row++) { PORTA=PA; //assign pwm depending on current row //parse pwms of 3 led's per pixel from raw pixel data pwm1 =(char)((pixel[row*8]&0xff0000)>>16); pwm32=(char)((pixel[row*8] & 0xff00)>>8); pwm2=(char)(pixel[row*8] & 0x00ff); pwm31 =(char)((pixel[row*8+1]&0xff0000)>>16); pwm3=(char)((pixel[row*8+1] & 0xff00)>>8); pwm30=(char)(pixel[row*8+1] & 0x00ff); pwm4 =(char)((pixel[row*8+2]&0xff0000)>>16); pwm29=(char)((pixel[row*8+2] & 0xff00)>>8); pwm5=(char)(pixel[row*8+2] & 0x00ff); pwm28 =(char)(pixel[row*8+3]>>16); pwm6=(char)((pixel[row*8+3] & 0xff00)>>8); pwm27=(char)(pixel[row*8+3] & 0x00ff); pwm11 =(char)(pixel[row*8+4]>>16); pwm12=(char)((pixel[row*8+4] & 0xff00)>>8); pwm22=(char)(pixel[row*8+4] & 0x00ff); pwm21 =(char)(pixel[row*8+5]>>16); pwm20=(char)((pixel[row*8+5] & 0xff00)>>8); pwm13=(char)(pixel[row*8+5] & 0x00ff); pwm14 =(char)(pixel[row*8+6]>>16); pwm15=(char)((pixel[row*8+6] & 0xff00)>>8); pwm19=(char)(pixel[row*8+6] & 0x00ff); pwm18 =(char)(pixel[row*8+7]>>16); pwm17=(char)((pixel[row*8+7] & 0xff00)>>8); pwm16=(char)(pixel[row*8+7] & 0x00ff); //start with led's off PORTB=0xff; PORTC=0xff; //port D is special since d.6 and d.7 are for rf PORTD=PORTD|0b00111111; //below, hold current picture for set time before transitioning if (shimmer==5 && inc==1){hold=hold+1; if (hold >= 1000){ shimmer=shimmer+1; shimmering(); hold=0;}} else {shimmering();} //pwm relies on providing differing amounts of power to leds to control colors by //having them on and off for differing amounts of time during the loop below //thereby changing the average power delivered for (pwm_delay = 256/4; pwm_delay !=0; pwm_delay--) { //when pwm1 reaches zero, turn off pwm1 led if (--pwm1 == 0) { PORTB=PORTB & 0xfd; } if (--pwm2 == 0) { PORTB=PORTB & 0xfe; } if (--pwm32 == 0) { PORTB=PORTB & 0xfb; } if (--pwm31 == 0) { PORTB=PORTB & 0xef; } if (--pwm3 == 0) { PORTB=PORTB & 0xdf; } if (--pwm30 == 0) { PORTB=PORTB & 0xf7; } ////////// if (--pwm4 == 0) { PORTB=PORTB & 0x7f; } if (--pwm29 == 0) { PORTC=PORTC & 0xfe; } if (--pwm5 == 0) { PORTB=PORTB & 0xbf; } if (--pwm28 == 0) { PORTC=PORTC & 0xfb; } if (--pwm6 == 0) { PORTC=PORTC & 0xf7; } if (--pwm27 == 0) { PORTC=PORTC & 0xfd; } if (--pwm11 == 0) { PORTC=PORTC & 0xdf; } if (--pwm12 == 0) { PORTC=PORTC & 0xbf; } if (--pwm22 == 0) { PORTC=PORTC & 0xef; } // if (--pwm21 == 0) { PORTD=PORTD & 0xfe; } if (--pwm20 == 0) { PORTD=PORTD & 0xfd; } if (--pwm13 == 0) { PORTC=PORTC & 0x7f; } if (--pwm14 == 0) { PORTD=PORTD & 0xf7; } if (--pwm15 == 0) { PORTD=PORTD & 0xef; } if (--pwm19 == 0) { PORTD=PORTD & 0xfb; } //reassigned to rf //if (--pwm18 == 0) { // PORTD=PORTD & 0xbf; //} //if (--pwm17 == 0) { // PORTD=PORTD & 0x7f; //} if (--pwm16 == 0) { PORTD=PORTD & 0xdf; } } /* time for new PWM cycle */ //cycle next row if (PA==0x7f){ PA=0xfe;} else{ PA=(PA<<1)+1;} } /* time for new row*/ //rf receiver code if ((PIND&0b10000000)==0x80 && (VTprev==0)/* If VT is asserted */){buffer=(buffer<<1)+((PIND&0b01000000)>>6); //PORTA1 = D.0 size=size+1; VTprev=1; } else if ((PIND&0b10000000)==0x00) {VTprev=0;} //Correct condition, full buffer and receiving is done if (size==10) { nextset=buffer; buffer=0x00; size=0; index1=5; } else {nextset=nextset;} //below parse received data to determine picture sequence and strengths //sunny or cloudy if ((nextset&0x300)==0x000){picseq[0]=12;strength[0]=1;} else if ((nextset&0x300)==0x100){picseq[0]=9;strength[0]=3;} else if ((nextset&0x300)==0x200){picseq[0]=1;strength[0]=5;} else if ((nextset&0x300)==0x300){picseq[0]=1;strength[0]=8;} //dry or humid if ((nextset&0xc0)==0x00) {picseq[1]=8;strength[1]=1;} else if ((nextset&0xc0)==0x40) {picseq[1]=8;strength[1]=3;} else if ((nextset&0xc0)==0x80) {picseq[1]=7;strength[1]=5;} else if ((nextset&0xc0)==0xc0) {picseq[1]=7;strength[1]=8;} // rain of no rain if ((nextset&0x30)==0x00){picseq[2]=11;strength[2]=0;} else if ((nextset&0x30)==0x10){picseq[2]=3;strength[2]=5;} else if ((nextset&0x30)==0x20){picseq[2]=2;strength[2]=8;} else if ((nextset&0x30)==0x30){picseq[2]=10;strength[2]=3;} //hot/cold if ((nextset&0x0c)==0x00){picseq[3]=5;strength[3]=1;} else if ((nextset&0x0c)==0x04){picseq[3]=5;strength[3]=3;} else if ((nextset&0x0c)==0x08){picseq[3]=4;strength[3]=5;} else if ((nextset&0x0c)==0x0c){picseq[3]=4;strength[3]=8;} //wind if ((nextset&0x03)==0x00){picseq[4]=6;strength[4]=0;} else if ((nextset&0x03)==0x01){picseq[4]=6;strength[4]=3;} else if ((nextset&0x03)==0x02){picseq[4]=6;strength[4]=5;} else if ((nextset&0x03)==0x03){picseq[4]=6;strength[4]=8;} end // main while loop end //********************************************************** //Set it all up void initialize(void) begin hold=0; switchpic=0; nextset=0b1011101001; index1=0; size=0; VTprev=0; counter=0; shimmer=0; inc=1; //set up the ports DDRB=0xff; // PORT B is an output DDRA=0xff; DDRC=0xff; DDRD=0x3f; // PORT D.6 and D.7 are inputs for rf PORTB=0; PORTC=0; PORTD=PORTD&0b11000000; PORTA=0xff; //set up timer 0 for 1 mSec ticks, no longer TIMSK0 = 2; //turn on timer 0 cmp match ISR OCR0A = 255; //set the compare reg to 250 time ticks TCCR0A = 0b00000010; // turn on clear-on-match TCCR0B = 0b00000001; // clock prescalar to none //crank up the ISRs, no longer //sei(); end