#include "burst.h"


void
init_burst(int burst_mode, burst_t *burst)
{
  burst->message = SLOWDOWN;  //n for do nothing in the next time increment
    burst->burst_ctr = 0;
    burst->which_mode = 's';
    switch(burst_mode){
  case 0:
    burst->slow_reps = 3;
    burst->fast_reps = 3;
    burst->slow_rate = ".50";
    burst->fast_rate = ".330";
    break;
  case 1:
    burst->slow_reps = 15;
    burst->fast_reps = 3;
    burst->slow_rate = ".50";
    burst->fast_rate = ".330";
    break;
  case 2:
    burst->slow_reps = 5;
    burst->fast_reps = 5;
    burst->slow_rate = ".50";
    burst->fast_rate = ".330";
    break;
  default:
    burst->slow_reps = 10;
    burst->fast_reps = 10;
    burst->slow_rate = ".10";
    burst->fast_rate = ".50";
    break;
    }
 }

void handle_burst(burst_t *burst)
{
switch(burst->which_mode)
   {
   case 's':   //if it is in  slow mode
     if (burst->burst_ctr == burst->slow_reps)
       {
	 burst->burst_ctr = 0;
	 burst->which_mode = 'f';
         burst->message = SLOWDOWN;  
       }
     else
       {
       burst->burst_ctr++;
       burst->message = DONOTHING;
       }
     break;
   case 'f':   //if it is in  fast mode
     if (burst->burst_ctr == burst->slow_reps)
       {
	 burst->burst_ctr = 0;	 
	 burst->which_mode = 's';
	 burst->message = SPEEDUP;  
       }
     else
       {
       burst->burst_ctr++;
       burst->message = DONOTHING;
       }
     break;
   default:
     puts("**your burst modes are super messed up**")  ;
   }
// printf("****current message:  %c,\n counter %d\n\n",burst->message, burst->burst_ctr);
}
