Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
waves.h
00001 int waves_time; 00002 char ledtable_waves [16] [32]; 00003 char waves_val_one; 00004 char waves_val_two; 00005 00006 /************************************************************************* 00007 Function Headers 00008 **************************************************************************/ 00009 void waves_init(void); 00010 void waves_update(void); 00011 00012 void waves_init(void){ 00013 waves_time = tabletimer.read_ms(); 00014 waves_val_one = 3; 00015 waves_val_two = 11; 00016 00017 } 00018 00019 void waves_update(void){ 00020 int waves_move_one; 00021 int waves_move_two; 00022 00023 if((tabletimer.read_ms() - waves_time)>waves_update_time){ 00024 // Update the matrix mapping 00025 00026 // Shift values right 00027 for(int col = 31; col >0; col--){ 00028 ledtable_waves[0][col] = ledtable[0][col-1]; 00029 ledtable_waves[1][col] = ledtable[1][col-1]; 00030 ledtable_waves[2][col] = ledtable[2][col-1]; 00031 ledtable_waves[3][col] = ledtable[3][col-1]; 00032 ledtable_waves[4][col] = ledtable[4][col-1]; 00033 ledtable_waves[5][col] = ledtable[5][col-1]; 00034 ledtable_waves[6][col] = ledtable[6][col-1]; 00035 ledtable_waves[7][col] = ledtable[7][col-1]; 00036 ledtable_waves[8][col] = ledtable[8][col-1]; 00037 ledtable_waves[9][col] = ledtable[9][col-1]; 00038 ledtable_waves[10][col] = ledtable[10][col-1]; 00039 ledtable_waves[11][col] = ledtable[11][col-1]; 00040 ledtable_waves[12][col] = ledtable[12][col-1]; 00041 ledtable_waves[13][col] = ledtable[13][col-1]; 00042 ledtable_waves[14][col] = ledtable[14][col-1]; 00043 ledtable_waves[15][col] = ledtable[15][col-1]; 00044 } 00045 // Update First Wave 00046 if(waves_val_one == 7){ 00047 waves_move_one = rand()%2; 00048 } 00049 else if(waves_val_one == 0){ 00050 waves_move_one = (rand()%2)+1; 00051 } 00052 else{ 00053 waves_move_one = rand()%3; 00054 } 00055 00056 switch(waves_move_one){ 00057 case 0: 00058 // Move waves down 00059 waves_val_one -= 1; 00060 break; 00061 case 1: 00062 // Keep waves the same 00063 break; 00064 case 2: 00065 // Move waves up 00066 waves_val_one += 1; 00067 default: 00068 break; 00069 } 00070 00071 00072 // Update Second waves 00073 if(waves_val_two == 15){ 00074 waves_move_two = rand()%2; 00075 } 00076 else if(waves_val_two == 8){ 00077 waves_move_two = (rand()%2)+1; 00078 } 00079 else{ 00080 waves_move_two = rand()%3; 00081 } 00082 00083 switch(waves_move_two){ 00084 case 0: 00085 // Move waves down 00086 waves_val_two -= 1; 00087 break; 00088 case 1: 00089 // Keep waves the same 00090 break; 00091 case 2: 00092 // Move waves up 00093 waves_val_two += 1; 00094 default: 00095 break; 00096 } 00097 00098 for(int waves = 0; waves < 8; waves ++){ 00099 if(waves < waves_val_one){ 00100 ledtable_waves[waves][0] = 60; 00101 } 00102 else{ 00103 ledtable_waves[waves][0] = 0; 00104 } 00105 } 00106 00107 for(int waves = 8; waves <16 ; waves ++){ 00108 if(waves > waves_val_two){ 00109 ledtable_waves[waves][0] = 60; 00110 } 00111 else{ 00112 ledtable_waves[waves][0] = 0; 00113 } 00114 } 00115 00116 // Update table 00117 for(int i = 0; i <16; i++){ 00118 for(int j = 0; j <32; j++){ 00119 ledtable[i][j] = ledtable_waves[i][j]; 00120 } 00121 } 00122 waves_time = tabletimer.read_ms(); 00123 } 00124 }
Generated on Tue Jul 19 2022 21:07:29 by
1.7.2