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.
wave.h
00001 int wave_time; 00002 char ledtable_wave [16] [32]; 00003 char wave_val; 00004 00005 /************************************************************************* 00006 Function Headers 00007 **************************************************************************/ 00008 void wave_init(void); 00009 void wave_update(void); 00010 00011 void wave_init(void){ 00012 wave_time = tabletimer.read_ms(); 00013 wave_val = 7; 00014 00015 } 00016 00017 void wave_update(void){ 00018 int wave_move; 00019 if((tabletimer.read_ms() - wave_time)>wave_update_time){ 00020 // Update the matrix mapping 00021 00022 // Shift values right 00023 for(int col = 31; col >0; col--){ 00024 ledtable_wave[0][col] = ledtable[0][col-1]; 00025 ledtable_wave[1][col] = ledtable[1][col-1]; 00026 ledtable_wave[2][col] = ledtable[2][col-1]; 00027 ledtable_wave[3][col] = ledtable[3][col-1]; 00028 ledtable_wave[4][col] = ledtable[4][col-1]; 00029 ledtable_wave[5][col] = ledtable[5][col-1]; 00030 ledtable_wave[6][col] = ledtable[6][col-1]; 00031 ledtable_wave[7][col] = ledtable[7][col-1]; 00032 ledtable_wave[8][col] = ledtable[8][col-1]; 00033 ledtable_wave[9][col] = ledtable[9][col-1]; 00034 ledtable_wave[10][col] = ledtable[10][col-1]; 00035 ledtable_wave[11][col] = ledtable[11][col-1]; 00036 ledtable_wave[12][col] = ledtable[12][col-1]; 00037 ledtable_wave[13][col] = ledtable[13][col-1]; 00038 ledtable_wave[14][col] = ledtable[14][col-1]; 00039 ledtable_wave[15][col] = ledtable[15][col-1]; 00040 } 00041 // Update first column 00042 if(wave_val == 15){ 00043 wave_move = rand()%2; 00044 } 00045 else if(wave_val == 0){ 00046 wave_move = (rand()%2)+1; 00047 } 00048 else{ 00049 wave_move = rand()%3; 00050 } 00051 switch(wave_move){ 00052 case 0: 00053 // Move wave down 00054 wave_val -= 1; 00055 break; 00056 case 1: 00057 // Keep wave the same 00058 break; 00059 case 2: 00060 // Move wave up 00061 wave_val += 1; 00062 default: 00063 break; 00064 } 00065 00066 for(int wave = 0; wave < 16; wave ++){ 00067 if(wave < wave_val){ 00068 ledtable_wave[wave][0] = 60; 00069 } 00070 else{ 00071 ledtable_wave[wave][0] = 0; 00072 } 00073 } 00074 00075 // Update table 00076 for(int i = 0; i <16; i++){ 00077 for(int j = 0; j <32; j++){ 00078 ledtable[i][j] = ledtable_wave[i][j]; 00079 } 00080 } 00081 wave_time = tabletimer.read_ms(); 00082 } 00083 }
Generated on Tue Jul 19 2022 21:07:29 by
1.7.2