Exemplo n.º 1
0
void loop()                     // run over and over again
{
  // wait here for one of the three buttons to be pushed
  unsigned char button = wait_for_button(ANY_BUTTON);
  clear();
  
  if (button == TOP_BUTTON)
  {
    play_from_program_space(fugue);

    print("Fugue!");
    lcd_goto_xy(0, 1);
    print("flash ->");
  }
  if (button == MIDDLE_BUTTON)
  {
    play("! V8 cdefgab>cbagfedc");
    print("C Major");
    lcd_goto_xy(0, 1);
    print("RAM ->");
  }
  if (button == BOTTOM_BUTTON)
  {
    if (is_playing())
    {
      stop_playing();
      print("stopped");
    }
    else
    {
      play_note(A(5), 200, 15);
      print("note A5"); 
    }
  }
}
Exemplo n.º 2
0
/*callback function*/
void mainwnd::file_exit()
{
    if (is_save()) {
        if (is_pattern_playing)
            stop_playing();
        hide();
    }
}
Exemplo n.º 3
0
void
AmbientSound::update(float deltat)
{
  if (latency-- <= 0) {
    float px,py;
    float rx,ry;

    if (!Sector::current() || !Sector::current()->camera) return;
    // Camera position
    px=Sector::current()->camera->get_center().x;
    py=Sector::current()->camera->get_center().y;

    // Relate to which point in the area
    rx=px<bbox.p1.x?bbox.p1.x:
      (px<bbox.p2.x?px:bbox.p2.x);
    ry=py<bbox.p1.y?bbox.p1.y:
      (py<bbox.p2.y?py:bbox.p2.y);

    // calculate square of distance
    float sqrdistance=(px-rx)*(px-rx)+(py-ry)*(py-ry);
    sqrdistance-=distance_bias;

    // inside the bias: full volume (distance 0)
    if (sqrdistance<0)
      sqrdistance=0;

    // calculate target volume - will never become 0
    targetvolume=1/(1+sqrdistance*distance_factor);
    float rise=targetvolume/currentvolume;

    // rise/fall half life?
    currentvolume*=pow(rise,deltat*10);
    currentvolume += 1e-6f; // volume is at least 1e-6 (0 would never rise)

    if (sound_source != 0) {

      // set the volume
      sound_source->set_gain(currentvolume*maximumvolume);

      if (sqrdistance>=silence_distance && currentvolume<1e-3)
        stop_playing();
      latency=0;
    } else {
      if (sqrdistance<silence_distance) {
        start_playing();
        latency=0;
      }
      else // set a reasonable latency
        latency=(int)(0.001/distance_factor);
      //(int)(10*((sqrdistance-silence_distance)/silence_distance));
    }
  }

  // heuristically measured "good" latency maximum

  //  if (latency>0.001/distance_factor)
  // latency=
}
Exemplo n.º 4
0
bool
mainwnd::on_delete_event(GdkEventAny *a_e)
{
    bool result = is_save();
    if (result && is_pattern_playing)
            stop_playing();

    return !result;
}
Exemplo n.º 5
0
static void uninit(void) {
	vo_zr2_priv_t *p = &priv;
	VERBOSE("uninit() called (may be called from preinit() on error)\n");

	stop_playing(p);

	if (p->buf && munmap(p->buf, p->zrq.size*p->zrq.count))
		ERROR("error munmapping buffer: %s\n", strerror(errno));

	if (p->vdes >= 0) close(p->vdes);
	free(p->subdevice);
}
Exemplo n.º 6
0
bool
mainwnd::on_delete_event(GdkEventAny *a_e)
{
    if ( ! m_quit ){
        file_exit_dialog();
        return true;
    }
    else {
        
        midifile f( "autosave.mid" );
        f.write( m_mainperf );

        stop_playing();
        return false;
    }
}
Exemplo n.º 7
0
bool mainwnd::open_file(const Glib::ustring& fn, bool setlist_mode)
{
    bool result;

    stop_playing();

    /*We aren't using a playlist if we've opened a file*/
    set_wsetlist_mode(setlist_mode);

    m_mainperf->clear_all();

    midifile f(fn);
    result = f.parse(m_mainperf, 0);
    m_modified = !result;

    if (!result) {
    	if(setlist_mode){
    		//We don't want dialog boxes in setlist mode!
    		printf("Error reading file: %s\n",fn.data());
    	}
    	else{
		    Gtk::MessageDialog errdialog(*this,
		            "Error reading file: " + fn, false,
		            Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
		    errdialog.run();
        }
        return false;
    }

    last_used_dir = fn.substr(0, fn.rfind("/") + 1);
    global_filename = fn;
    update_window_title();

    m_main_wid->reset();
    m_entry_notes->set_text(*m_mainperf->get_screen_set_notepad(
                m_mainperf->get_screenset()));
    m_adjust_bpm->set_value( m_mainperf->get_bpm());

    //Check what the max tick is
    m_mainperf->update_max_tick();

    return true;
}
Exemplo n.º 8
0
static void get_next_segment(void)
{
  int propseg;
  
  do {
    propseg = 1;

    segtype = next_segment();
    currseg = segment_pos();

    put_seg_desc();
    
    switch(segtype) {
    case SEG_ERROR:
    case SEG_END:
      stop_playing();
      break;
      
    case SEG_STOP:
      pause_playing();
      put_msg(" * Tape paused; Press Ctrl-o to restart * ");
      break;
      
    case SEG_SKIP:
      propseg = 0;
      break;
      
    case SEG_GRP_BEG:
      ingroup = 1;
      propseg = 0;
      break;
      
    case SEG_GRP_END:
      ingroup = 0;
      propseg = 0;
      break;
    }
  } while(!propseg);
  
  lastdatak = 0;
}
Exemplo n.º 9
0
int main()                    // run once, when the sketch starts
{
  currentIdx = 0;
  print("Music!");

  while(1)                     // run over and over again
  {
    // if we haven't finished playing the song and 
    // the buzzer is ready for the next note, play the next note
    if (currentIdx < MELODY_LENGTH && !is_playing())
    {
      // play note at max volume
      play_note(note[currentIdx], duration[currentIdx], 15);
      
      // optional LCD feedback (for fun)
      lcd_goto_xy(0, 1);                           // go to start of the second LCD line
	  if(note[currentIdx] != 255) // display blank for rests
        print_long(note[currentIdx]);  // print integer value of the current note
      print("  ");                            // overwrite any left over characters
      currentIdx++;
    }

    // Insert some other useful code here...
    // the melody will play normally while the rest of your code executes
    // as long as it executes quickly enough to keep from inserting delays
    // between the notes.
  
    // For example, let the top user pushbutton function as a stop/reset melody button
    if (button_is_pressed(TOP_BUTTON))
    {
      stop_playing(); // silence the buzzer
      if (currentIdx < MELODY_LENGTH)
        currentIdx = MELODY_LENGTH;        // terminate the melody
      else
        currentIdx = 0;                    // restart the melody
      wait_for_button_release(TOP_BUTTON);  // wait here for the button to be released
    }
  }
}
Exemplo n.º 10
0
bool
mainwnd::on_key_press_event(GdkEventKey* a_ev)
{

    if( m_entry_notes->has_focus()){
        m_entry_notes->event( (GdkEvent*) a_ev );
        return false;
    }
    else
    {
        if ( a_ev->type == GDK_KEY_PRESS ){

            if ( global_print_keys ){
                printf( "key_press[%d]\n", a_ev->keyval ); 
            }
            
            if ( a_ev->keyval == m_mainperf->m_key_bpm_dn ){
                m_mainperf->set_bpm( m_mainperf->get_bpm() - 1 );  
                m_adjust_bpm->set_value(  m_mainperf->get_bpm() );
            }
            
            if ( a_ev->keyval ==  m_mainperf->m_key_bpm_up ){
                m_mainperf->set_bpm( m_mainperf->get_bpm() + 1 );   
                m_adjust_bpm->set_value(  m_mainperf->get_bpm() );
            }
            
            if ( a_ev->keyval == m_mainperf->m_key_replace )
            {
                m_mainperf->set_sequence_control_status( c_status_replace );
            }
            
            if (a_ev->keyval ==  m_mainperf->m_key_queue )
            {
                m_mainperf->set_sequence_control_status( c_status_queue );
            }
            
            if ( a_ev->keyval == m_mainperf->m_key_snapshot_1 ||
                 a_ev->keyval == m_mainperf->m_key_snapshot_2 )
            {
                m_mainperf->set_sequence_control_status( c_status_snapshot );
            }
            
            if ( a_ev->keyval == m_mainperf->m_key_screenset_dn ){

                m_mainperf->set_screenset(  m_mainperf->get_screenset() - 1 );  
                m_main_wid->set_screenset(  m_mainperf->get_screenset() );  
                m_adjust_ss->set_value( m_mainperf->get_screenset()  );	
                m_entry_notes->set_text( * m_mainperf->get_screen_set_notepad(m_mainperf->get_screenset()  )); 
            }
            
            if ( a_ev->keyval == m_mainperf->m_key_screenset_up ){

                m_mainperf->set_screenset(  m_mainperf->get_screenset() + 1 );  
                m_main_wid->set_screenset(  m_mainperf->get_screenset() );  
                m_adjust_ss->set_value( m_mainperf->get_screenset()  );	
                m_entry_notes->set_text( * m_mainperf->get_screen_set_notepad(m_mainperf->get_screenset()  )); 
            }
            
            if ( a_ev->keyval == m_mainperf->m_key_start )
            {
                start_playing();            
            }

            if ( a_ev->keyval == m_mainperf->m_key_stop )
            {
                stop_playing();            
            }


            if( m_mainperf->get_key_events()->count( a_ev->keyval) != 0 ){
                
                sequence_key(  (*m_mainperf->get_key_events())[a_ev->keyval] );
            }
        }
    }
    
    return false;
}
Exemplo n.º 11
0
AmbientSound::~AmbientSound()
{
  stop_playing();
}
Exemplo n.º 12
0
void menu_select()
{
    static int menu_index = 0;

    print_two_lines_delay_1s(main_menu_intro_line1,main_menu_intro_line2);

    while(1)
    {
        clear();
        lcd_goto_xy(0,1);
        print_from_program_space(menu_line2);
        lcd_goto_xy(0,0);
        print_from_program_space(main_menu_options[menu_index]);
        lcd_show_cursor(CURSOR_BLINKING);
        // the cursor will be blinking at the end of the option name

        // wait for all buttons to be released, then a press
        while(button_is_pressed(ANY_BUTTON));
        char button = wait_for_button_press(ANY_BUTTON);

        if(button & BUTTON_A)
        {
            play_from_program_space(beep_button_a);
            menu_index --;
        }
        else if(button & BUTTON_B)
        {
            lcd_hide_cursor();
            clear();

            play_from_program_space(beep_button_b);
            wait_for_button_release(button);

            while(!button_is_pressed(BUTTON_B))
            {
                lcd_goto_xy(0,1);
                print_from_program_space(back_line2);
                lcd_goto_xy(0,0);
                main_menu_functions[menu_index]();
            }

            set_motors(0,0);
            stop_playing();
            m1_speed = 0;
            m2_speed = 0;
            red_led(0);
            green_led(0);
            play_from_program_space(beep_button_b);

            return;
        }
        else if(button & BUTTON_C)
        {
            play_from_program_space(beep_button_c);
            menu_index ++;
        }

        if(menu_index < 0)
            menu_index = main_menu_length-1;
        if(menu_index >= main_menu_length)
            menu_index = 0;
    }
}
Exemplo n.º 13
0
static int config(uint32_t width, uint32_t height, uint32_t d_width,
	uint32_t d_height, uint32_t flags, char *title, uint32_t format) {
	int fields = 1, top_first = 1, err = 0;
	int stretchx = 1, stretchy = 1;
	struct mjpeg_params zptmp;
	vo_zr2_priv_t *p = &priv;
	VERBOSE("config() called\n");

	/* paranoia check */
	if (!query_format(format)) {
		ERROR("called with wrong format, should be impossible\n");
		return 1;
	}

	if ((int)height > p->vc.maxheight) {
		ERROR("input height %d is too large, maxheight=%d\n",
				height, p->vc.maxheight);
		err = 1;
	}

	if (format != IMGFMT_ZRMJPEGNI) {
		fields = 2;
		if (format == IMGFMT_ZRMJPEGIB)
			top_first = 0;
	} else if ((int)height > p->vc.maxheight/2) {
		ERROR("input is too high (%d) for non-interlaced playback"
				"max=%d\n", height, p->vc.maxheight);
		err = 1;
	}

	if (width%16 != 0) {
		ERROR("input width=%d, must be multiple of 16\n", width);
		err = 1;
	}

	if (height%(fields*8) != 0) {
		ERROR("input height=%d, must be multiple of %d\n",
				height, 2*fields);
		err = 1;
	}

	/* we assume sample_aspect = 1 */
	if (fields == 1) {
		if (2*d_width <= (uint32_t)p->vc.maxwidth) {
			VERBOSE("stretching x direction to preserve aspect\n");
			d_width *= 2;
		} else VERBOSE("unable to preserve aspect, screen width "
					"too small\n");
	}

	if (d_width == width) stretchx = 1;
	else if (d_width == 2*width) stretchx = 2;
#if 0 /* do minimal stretching for now */
	else if (d_width == 4*width) stretchx = 4;
	else WARNING("d_width must be {1,2,4}*width, using defaults\n");

	if (d_height == height) stretchy = 1;
	else if (d_height == 2*height) stretchy = 2;
	else if (d_height == 4*height) stretchy = 4;
	else WARNING("d_height must be {1,2,4}*height, using defaults\n");
#endif

	if (stretchx*width > (uint32_t)p->vc.maxwidth) {
		ERROR("movie to be played is too wide, width=%d>maxwidth=%d\n",
				width*stretchx, p->vc.maxwidth);
		err = 1;
	}

	if (stretchy*height > (uint32_t)p->vc.maxheight) {
		ERROR("movie to be played is too heigh, height=%d>maxheight"
				"=%d\n", height*stretchy, p->vc.maxheight);
		err = 1;
	}

	if (err == 1) return 1;

	/* some video files (eg. concatenated MPEG files), make MPlayer
	 * call config() during playback while no parameters have changed.
	 * We make configuration changes to a temporary params structure,
	 * compare it with the old params structure and only apply the new
	 * config if it is different from the old one. */
	memcpy(&zptmp, &p->zp, sizeof(zptmp));

	/* translate the configuration to zoran understandable format */
	zptmp.decimation = 0;
	zptmp.HorDcm = stretchx;
	zptmp.VerDcm = stretchy;
	zptmp.TmpDcm = 1;
	zptmp.field_per_buff = fields;
	zptmp.odd_even = top_first;

	/* center the image on screen */
	zptmp.img_x = (p->vc.maxwidth - width*stretchx)/2;
	zptmp.img_y = (p->vc.maxheight - height*stretchy*(3-fields))/4;

	zptmp.img_width = stretchx*width;
	zptmp.img_height = stretchy*height/fields;

	VERBOSE("tv: %dx%d, out: %dx%d+%d+%d, in: %ux%u %s%s%s\n",
			p->vc.maxwidth, p->vc.maxheight,
			zptmp.img_width, 2*zptmp.img_height,
			zptmp.img_x, 2*zptmp.img_y,
			width, height, (fields == 1) ? "non-interlaced" : "",
			(fields == 2 && top_first == 1)
			?  "interlaced top first" : "",
			(fields == 2 && top_first == 0)
			? "interlaced bottom first" : "");

	if (memcmp(&zptmp, &p->zp, sizeof(zptmp))) {
		/* config differs, we must update */
		memcpy(&p->zp, &zptmp, sizeof(zptmp));
		stop_playing(p);
		if (ioctl(p->vdes, MJPIOC_S_PARAMS, &p->zp) < 0) {
			ERROR("error writing display params to card\n");
			return 1;
		}
		VERBOSE("successfully written display parameters to card\n");
	} else VERBOSE("config didn't change, no need to write it to card\n");

	return 0;
}
Exemplo n.º 14
0
bool
mainwnd::on_key_press_event(GdkEventKey* a_ev)
{
    Gtk::Window::on_key_press_event(a_ev);

    // control and modifier key combinations matching
    if ( a_ev->type == GDK_KEY_PRESS ){

        if ( global_print_keys ){
            printf( "key_press[%d]\n", a_ev->keyval );
            fflush( stdout );
        }

        if ( a_ev->keyval == m_mainperf->m_key_bpm_dn ){
            m_mainperf->set_bpm( m_mainperf->get_bpm() - 1 );
            m_adjust_bpm->set_value(  m_mainperf->get_bpm() );
        }

        if ( a_ev->keyval ==  m_mainperf->m_key_bpm_up ){
            m_mainperf->set_bpm( m_mainperf->get_bpm() + 1 );
            m_adjust_bpm->set_value(  m_mainperf->get_bpm() );
        }

        if ( a_ev->keyval == m_mainperf->m_key_replace )
        {
            m_mainperf->set_sequence_control_status( c_status_replace );
        }

        if ((a_ev->keyval ==  m_mainperf->m_key_queue )
                || (a_ev->keyval == m_mainperf->m_key_keep_queue ))
        {
            m_mainperf->set_sequence_control_status( c_status_queue );
        }

        if ( a_ev->keyval == m_mainperf->m_key_snapshot_1 ||
                a_ev->keyval == m_mainperf->m_key_snapshot_2 )
        {
            m_mainperf->set_sequence_control_status( c_status_snapshot );
        }

        if ( a_ev->keyval == m_mainperf->m_key_screenset_dn ){

            m_mainperf->set_screenset(  m_mainperf->get_screenset() - 1 );
            m_main_wid->set_screenset(  m_mainperf->get_screenset() );
            m_adjust_ss->set_value( m_mainperf->get_screenset()  );
            m_entry_notes->set_text(*m_mainperf->get_screen_set_notepad(
                        m_mainperf->get_screenset()));
        }

        if ( a_ev->keyval == m_mainperf->m_key_screenset_up ){

            m_mainperf->set_screenset(  m_mainperf->get_screenset() + 1 );
            m_main_wid->set_screenset(  m_mainperf->get_screenset() );
            m_adjust_ss->set_value( m_mainperf->get_screenset()  );
            m_entry_notes->set_text(*m_mainperf->get_screen_set_notepad(
                        m_mainperf->get_screenset()));
        }

        if ( a_ev->keyval == m_mainperf->m_key_set_playing_screenset ){
            m_mainperf->set_playing_screenset();
        }

        if ( a_ev->keyval == m_mainperf->m_key_group_on ){
            m_mainperf->set_mode_group_mute();
        }

        if ( a_ev->keyval == m_mainperf->m_key_group_off ){
            m_mainperf->unset_mode_group_mute();
        }

        if ( a_ev->keyval == m_mainperf->m_key_group_learn ){
            m_mainperf->set_mode_group_learn();
        }

        // activate mute group key
        if (m_mainperf->get_key_groups()->count( a_ev->keyval ) != 0 )
        {
            m_mainperf->select_and_mute_group(
                    m_mainperf->lookup_keygroup_group(a_ev->keyval));
        }

        // mute group learn
        if (m_mainperf->is_learn_mode() &&
                a_ev->keyval != m_mainperf->m_key_group_learn)
        {
            if( m_mainperf->get_key_groups()->count( a_ev->keyval ) != 0 )
            {
                std::ostringstream os;
                os << "Key \""
                    << gdk_keyval_name(a_ev->keyval)
                    << "\" (code = "
                    << a_ev->keyval
                    << ") successfully mapped.";

                Gtk::MessageDialog dialog(*this,
                        "MIDI mute group learn success", false,
                        Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK, true);
                dialog.set_secondary_text(os.str(), false);
                dialog.run();

                // we miss the keyup msg for learn, force set it off
                m_mainperf->unset_mode_group_learn();
            }
            else
            {
                std::ostringstream os;
                os << "Key \""
                    << gdk_keyval_name(a_ev->keyval)
                    << "\" (code = "
                    << a_ev->keyval
                    << ") is not one of the configured mute-group keys.\n"
                    << "To change this see File/Options menu or .seq24rc";

                Gtk::MessageDialog dialog(*this,
                        "MIDI mute group learn failed", false,
                        Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);

                dialog.set_secondary_text(os.str(), false);
                dialog.run();
                // we miss the keyup msg for learn, force set it
                m_mainperf->unset_mode_group_learn();
            }
        }

        // the start/end key may be the same key (i.e. SPACE)
        // allow toggling when the same key is mapped to both
        // triggers (i.e. SPACEBAR)

        /* dont_toggle is true IF start/end keys are different*/
        bool dont_toggle = m_mainperf->m_key_start != m_mainperf->m_key_stop;

        printf("=====================\nMAINWND:\ndon't toggle is %d\nm_key_start is %d\nm_key_stop is %d\n",dont_toggle,m_mainperf->m_key_start,m_mainperf->m_key_stop);
        printf("keyvl = %d\nis_pattern_plying is %d\n",a_ev->keyval,is_pattern_playing);

        if ( a_ev->keyval == m_mainperf->m_key_start
                && (dont_toggle || !is_pattern_playing))
        {
        	printf("calling start_playing\n");
            start_playing();
        	printf("=====================\n");
        }
        else if ( a_ev->keyval == m_mainperf->m_key_stop
                && (dont_toggle || is_pattern_playing))
        {
            stop_playing();
        }

        /* toggle sequence mute/unmute using keyboard keys... */
        if (m_mainperf->get_key_events()->count( a_ev->keyval) != 0)
        {
            sequence_key(m_mainperf->lookup_keyevent_seq( a_ev->keyval));
        }

        if(m_mainperf->get_setlist_mode()){
        	printf("Setlist mode is true, m_key_leftarrow = %d, as an int = %d\n",m_mainperf->m_key_leftarrow,(int) m_mainperf->m_key_leftarrow);
            if ( a_ev->keyval == m_mainperf->m_key_leftarrow ){
            	//printf("left arrow pressed\n");
            	setlist_jump(-1);
            }
            if ( a_ev->keyval == m_mainperf->m_key_rightarrow ){
            	//printf("right arrow pressed\n");
            	setlist_jump(1);
            }
        }
        else{
        	printf("Setlist mode is false\n");
        }
    }
    return false;
}
Exemplo n.º 15
0
// *** triggered by top button ***
// This function plays a melody from flash in the background while the two
// user LEDs alternately fade in and out.
unsigned char melodyTest()
{
	unsigned char button;
	int i = 0;

	// the following function does not block execution
	play_from_program_space(fugue);	// play music from flash in the background

	red_led(0);		// turn red and green LEDs off
	green_led(0);

	clear();			// clear the LCD, go to the start of the first LCD line
	print("melody:");	// print to the LCD
	lcd_goto_xy(0, 1);	// go to the start of the second LCD line
	print("fugue");		// print to the LCD

	time_reset();		// reset the internal millisecond timer count to zero

	while (1)			// loop here until we detect a button press and return
	{
		if (get_ms() >= 5)	// if 5 or more milliseconds have elapsed
		{
			time_reset();	// reset timer count to zero
			// check if middle or bottom buttons have been pressed
			button = button_is_pressed(MIDDLE_BUTTON | BOTTOM_BUTTON);
			if (button != 0)	// if so, stop melody and return the button ID
			{
				stop_playing();	// stop playing music
				return button;
			}
			i += 5;		// increase our state variable based on the time
			if (i >= 1000)	// once a second has elapsed, reset the state var
				i = 0;
		}

		// the following code alternately flashes the red and green LEDs,
		// fading them in and out over time as the music plays in the
		// background.  This is accomplished by using high-frequency PWM
		// signals on the LED lines.  Essentially, each LED is flickering
		// on and off very quickly, which gives it the apperance of variable
		// brightness depending on the percentage of the cycle the LED is on.
		// Each LED flicker cycle takes a total approximately 251 us.

		if (i < 250)		// phase 1: ramp up the red LED brightness
		{					//  as i increases over time
			red_led(1);			// turn the red LED on
			delay_us(i + 1);	// microsecond delay
			red_led(0);			// turn the red LED off
			delay_us(250 - i);	// microsecond delay
		}
		else if (i < 500)	// phase 2: ramp down the red LED brightness
		{
			red_led(1);			// turn the red LED on
			delay_us(500 - i);	// microsecond delay
			red_led(0);			// turn the red LED off
			delay_us(i - 249);	// microsecond delay
		}
		else if (i < 750)	// phase 3: ramp up the green LED brightness
		{
			green_led(1);		// turn the green LED on
			delay_us(i - 499);	// microsecond delay
			green_led(0);		// turn the green LED off
			delay_us(750 - i);	// microsecond delay
		}
		else				// phase 4: ramp down the green LED brightness
		{
			green_led(1);		// turn the green LED on
			delay_us(1000 - i);	// microsecond delay
			green_led(0);		// turn the green LED off
			delay_us(i - 749);	// microsecond delay
		}
		
	}
}