William Etter / Mbed 2 deprecated LEDTable

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /********************************************************************
00002  LED Table - November 2011
00003  http://williametter.com/portfolio/projects/led-table/
00004  Copyright (c) 2011.  All rights reserved.
00005  
00006  Version: 1.1
00007  February 24, 2012
00008  
00009  Author:
00010        William Etter (UPenn EE 'll/'12)
00011  
00012 ********************************************************************/
00013 
00014 
00015 /* ************************************************************ */
00016 /* ******************* PROGRAM INCLUDES *********************** */
00017 /* ************************************************************ */
00018 #include "mbed.h"
00019 #include "stdlib.h"
00020 #include "LEDTable.h"
00021 #include "tablefunctions.h"
00022 #include "matrix.h"
00023 #include "wave.h"
00024 #include "waves.h"
00025 #include "tunnel.h"
00026 #include "rain.h"
00027 #include "gameoflife.h"
00028 #include "math.h"
00029 
00030 
00031 void init_functions(void);
00032 
00033 
00034 /* ************************************************************ */
00035 /* *****************       MAIN PROGRAM  ********************** */
00036 /* ************************************************************ */
00037 int main(){
00038 
00039     /***    System Initilization   ***/
00040     initTable();        // Initialize the Table
00041     sweepLEDs();
00042     pulseLEDs(2);
00043     enableLEDs();       // Enable LEDs
00044     
00045     /***    Function Initilization   ***/
00046     init_functions();
00047     
00048     
00049     
00050     
00051     while(1) {
00052         /***    Update Table   ***/
00053         wait(displayDelay);
00054         displayTable();
00055         
00056         /***    Update Function   ***/        
00057         switch(current_function){
00058             case -1:
00059                 // Run Random Clear Function
00060                 clearFunction();
00061                 break;
00062             case 0:
00063                 // Current: Matrix
00064                 matrix_update();
00065                 break;
00066             case 1:
00067                 // Current: Wave
00068                 wave_update();
00069                 break;
00070             case 2:
00071                 // Current: Waves
00072                 waves_update();
00073                 break;
00074             case 3:
00075                 // Current: Tunnel
00076                 tunnel_update();
00077                 break;
00078             case 4:
00079                 // Current: Rain
00080                 rain_update();
00081                 break;
00082             default:
00083                 break;
00084         }
00085                 
00086         /***    Change Current Function   ***/
00087         if((tabletimer.read()-tabletimeseconds)>table_change_time){
00088             next_function = get_next_functon(current_function);
00089             current_function = -1;
00090             tabletimeseconds = tabletimer.read();
00091         }    
00092         
00093         // reset timer if 1000 seconds have elapsed
00094         if(tabletimer.read() >= 1000){
00095             tabletimer.reset();
00096             tabletimeseconds = tabletimer.read();
00097         }
00098     }
00099 }
00100 
00101 
00102 
00103 
00104 void init_functions(void){
00105     /***    Function Initilizations   ***/
00106     matrix_init();
00107     wave_init();
00108     waves_init();
00109     tunnel_init();
00110     rain_init();
00111 }