Beispiel #1
0
void app_cable_event(u8 type, u8 value)
{
    // example - light the Setup LED to indicate cable connections
	if (type == MIDI_IN_CABLE)
	{
		hal_plot_led(TYPESETUP, 0, 0, value, 0); // green
	}
	else if (type == MIDI_OUT_CABLE)
	{
		hal_plot_led(TYPESETUP, 0, value, 0, 0); // red
	}
}
Beispiel #2
0
void clear_leds()
{
    for (u8 i = LP_FIRST_BUTTON; i <= LP_LAST_BUTTON; i++)
    {
        hal_plot_led(TYPEPAD, i, 0x00, 0x00, 0x00);
    }
}
Beispiel #3
0
void app_aftertouch_event(u8 index, u8 value)
{
    // example - send poly aftertouch to MIDI ports
	hal_send_midi(USBMIDI, POLYAFTERTOUCH | 0, index, value);

    // example - set LED to white, brightness in proportion to pressure
	hal_plot_led(TYPEPAD, index, value/2, value/2, value/2);
}
Beispiel #4
0
void app_aftertouch_event(u8 index, u8 value)
{
    if(mode == MODE_NOTE) {
        note_aftertouch(index, value);
        // example - send poly aftertouch to MIDI ports
        //hal_send_midi(midiport, POLYAFTERTOUCH | note_channel, index, value);
        // example - set LED to white, brightness in proportion to pressure
        hal_plot_led(TYPEPAD, index, value/2, value/2, value/2);
    }
}
Beispiel #5
0
void app_surface_event(u8 type, u8 index, u8 value)
{
	switch (type)
	{
		case  TYPEPAD:
		{
			// example - light / extinguish pad LEDs, send MIDI
			hal_plot_led(TYPEPAD, index, value, value, value);
			hal_send_midi(DINMIDI, NOTEON | 0, index, value);
		}
		break;

		case TYPESETUP:
		{
			// example - light the setup LED
			hal_plot_led(TYPESETUP, 0, value, value, value);
		}
		break;
	}
}
Beispiel #6
0
void app_init()
{
    // example - light the LEDs to say hello!
	for (int i=0; i < 10; ++i)
	{
		for (int j=0; j < 10; ++j)
		{
			u8 r = i < 5 ? (MAXLED * (5-i))/5 : 0;
			u8 g = i < 5 ? (MAXLED * i)/5 : (MAXLED * (10-i))/5;
			u8 b = i < 5 ? 0 : (MAXLED * (i-5))/5;

			hal_plot_led(TYPEPAD, j*10 + i, r, b, g);
		}
	}
}
Beispiel #7
0
void clear_pad_leds()
{
    u8 index = FIRST_PAD;

    for (u8 i = 0; i < GRID_SIZE * GRID_SIZE; i++)
    {
        if (i > 0 && i % GRID_SIZE == 0)
        {
            index += ROW_GAP;
        }
        
        hal_plot_led(TYPEPAD, index, 0x00, 0x00, 0x00);

        index++;
    }
}
Beispiel #8
0
//______________________________________________________________________________
//
// not much to initialize really at the moment...
//______________________________________________________________________________
//
void app_init()
{
    // initialize the global variables


    // the midiport to use:
    midiport = USBMIDI;
    // the mode - can be MODE_SEQ_CA, MODE_SEQ_STEP, MODE_NOTES, MODE_USER
    mode = MODE_SEQ_CA;
    seq_ca_running = 0;
    seq_step_running = 0;

    time = 0;

    // tempo estimate in ms/beat
    tempo = 500; // 120 bpm

    setBPMtt(1200); // 125 bpm
    setInternalSync(1);

    for(int i = 0; i<8; i++)
        seq_step_delete_all(i);


    //hal_plot_led(TYPEPAD, BUTTON_DEVICE, MAXLED, MAXLED, MAXLED);

    u8 m = 0b10011101;
    for (int j=1; j < 9; ++j)
    {
        u8 v = rotr8(m,j-1);
        for (int i=1; i < 9; ++i)
        {
            u8 r = 0;
            u8 g = 0;
            u8 b = 0;
            if((v>>(i-1)) & 1) {
                r = MAXLED;
                g = MAXLED;
                b = MAXLED;
            }
            hal_plot_led(TYPEPAD, j * 10 + i, r, b, g);
        }
    }

    setMode(MODE_SEQ_CA);
}
Beispiel #9
0
void game_complete(GrabType grabType)
{
	for (int row = 0 ; row < NUM_ROWS ; row++)
	{
		for (int col = 0 ; col < NUM_COLUMNS ; col++)
		{
			u8 index = (row+1)*10 + (col+1);
			hal_plot_led(TYPEPAD, index, colors[grabType].r, colors[grabType].g, colors[grabType].b);
		}
	}
	
	game_state = GameState_GAME_COMPLETE;
	
	scores[0] = 0;
	scores[1] = 0;
	scores[2] = 0;
	scores[3] = 0;
}
Beispiel #10
0
void update_score_LEDs()
{
	for (int i = 0 ; i < 8 ; i++)
	{
		u8 r = 0;
		u8 g = 0;
		u8 b = 0;
		
		if (scores[GrabType_BOTTOM] > i)
		{
			r = colors[GrabType_BOTTOM].r;
			g = colors[GrabType_BOTTOM].g;
			b = colors[GrabType_BOTTOM].b;
		}
		
		hal_plot_led(TYPEPAD, i+1, r, g, b);
	}
	
	for (int i = 0 ; i < 8 ; i++)
	{
		u8 r = 0;
		u8 g = 0;
		u8 b = 0;
		
		if (scores[GrabType_TOP] > i)
		{
			r = colors[GrabType_TOP].r;
			g = colors[GrabType_TOP].g;
			b = colors[GrabType_TOP].b;
		}
		
		hal_plot_led(TYPEPAD, i+91, r, g, b);
	}
	
	for (int i = 0 ; i < 8 ; i++)
	{
		u8 r = 0;
		u8 g = 0;
		u8 b = 0;
		
		if (scores[GrabType_LEFT] > i)
		{
			r = colors[GrabType_LEFT].r;
			g = colors[GrabType_LEFT].g;
			b = colors[GrabType_LEFT].b;
		}
		
		hal_plot_led(TYPEPAD, 10*(i+1), r, g, b);
	}
	
	for (int i = 0 ; i < 8 ; i++)
	{
		u8 r = 0;
		u8 g = 0;
		u8 b = 0;
		
		if (scores[GrabType_RIGHT] > i)
		{
			r = colors[GrabType_RIGHT].r;
			g = colors[GrabType_RIGHT].g;
			b = colors[GrabType_RIGHT].b;
		}
		
		hal_plot_led(TYPEPAD, 10*(i+1)+9, r, g, b);
	}
}
Beispiel #11
0
void update_LEDs()
{
	for (int row = 0 ; row < NUM_ROWS ; row++)
	{
		for (int col = 0 ; col < NUM_COLUMNS ; col++)
		{
			CellType type = cells[row][col];
			
			u8 r = 0;
			u8 g = 0;
			u8 b = 0;
			
			switch (type)
			{
				case CellType_EMPTY:
				{
					break;
				}
				case CellType_NUGGET:
				{
					r = MAXLED;
					g = MAXLED;
					b = MAXLED;
					break;
				}
				case CellType_GRABBER_TOP:
				{
					r = colors[GrabType_TOP].r;
					g = colors[GrabType_TOP].g;
					b = colors[GrabType_TOP].b;
					break;
				}
				case CellType_GRABBER_BOTTOM:
				{
					r = colors[GrabType_BOTTOM].r;
					g = colors[GrabType_BOTTOM].g;
					b = colors[GrabType_BOTTOM].b;
					break;
				}
				case CellType_GRABBER_LEFT:
				{
					r = colors[GrabType_LEFT].r;
					g = colors[GrabType_LEFT].g;
					b = colors[GrabType_LEFT].b;
					break;
				}
				case CellType_GRABBER_RIGHT:
				{
					r = colors[GrabType_RIGHT].r;
					g = colors[GrabType_RIGHT].g;
					b = colors[GrabType_RIGHT].b;
					break;
				}
				default:
				{
					break;
				}
			}
			
			u8 index = (row+1)*10 + (col+1);
			
			hal_plot_led(TYPEPAD, index, r, g, b);
		}
	}
}
Beispiel #12
0
void handle_input(u8 type, u8 padIndex, u8 value)
{
	GrabType grabType = GrabType_NONE;
	u8 grabIndex = 0;
	
	switch (type)
	{
		case TYPEPAD:
		{
			if (value != 0)
			{
				if (padIndex % 10 == 0)
				{
					grabIndex = (padIndex/10) - 1;
					grabType = GrabType_LEFT;
				}
				else if (padIndex % 10 == 9)
				{
					grabIndex = (padIndex/10) - 1;
					grabType = GrabType_RIGHT;
				}
				else if (padIndex > 90 && padIndex < 99)
				{
					grabIndex = (padIndex % 10) - 1;
					grabType = GrabType_TOP;
				}
				else if (padIndex < 10)
				{
					grabIndex = (padIndex % 10) - 1;
					grabType = GrabType_BOTTOM;
				}
				
				if ((grabType < GrabType_NBR_ELT) && (grabIndex < 8))
				{
					if (grabbers[grabType].state == GrabberState_STOPPED)
					{
						//start grabber
						grabbers[grabType].index = grabIndex;
						grabbers[grabType].state = GrabberState_EXTENDING;
						grabbers[grabType].tick = GRABBER_TICKS;
					}
					else if (grabbers[grabType].state == GrabberState_EXTENDING)
					{
						if (grabbers[grabType].index == grabIndex)
						{
							//nothing
						}
						else
						{
							grabbers[grabType].state = GrabberState_RETRACTING_RESTART;
							grabbers[grabType].next_index = grabIndex;
						}
					}
					else if (grabbers[grabType].state == GrabberState_RETRACTING)
					{
						if (grabbers[grabType].index == grabIndex)
						{
							//nothing
						}
						else
						{
							grabbers[grabType].state = GrabberState_RETRACTING_RESTART;
							grabbers[grabType].next_index = grabIndex;
						}
					}
					else if (grabbers[grabType].state == GrabberState_RETRACTING_RESTART)
					{
						grabbers[grabType].next_index = grabIndex;
					}
				}
			}
		}
			break;
			
		case TYPESETUP:
		{
			// example - light the setup LED
			hal_plot_led(TYPESETUP, 0, value, value, value);
		}
			break;
	}
}
Beispiel #13
0
void app_surface_event(u8 type, u8 index, u8 value) {
    switch (type)
    {
    case  TYPEPAD:
    {
        if(index < BUTTON_SESSION) {
            switch (mode) {
            case MODE_SEQ_STEP:
            {
                seq_step_typepad(index,value);
            }
            break;
            case MODE_NOTE:
            {
                note_typepad(index,value);
            }
            break;
            case MODE_SEQ_CA:
            {
                seq_ca_typepad(index,value);
            }
            break;
            case MODE_USER:
            {}
            break;
            case MODE_SEQ_STEP_SETUP:
            {
                seq_step_setup_typepad(index,value);
            }
            break;
            case MODE_NOTE_SETUP:
            {
                note_setup_typepad(index,value);
            }
            break;
            case MODE_SEQ_CA_SETUP:
            {
                seq_ca_setup_typepad(index,value);
            }
            break;
            case MODE_GLOBAL_SETUP:
            {
                global_setup_typepad(index, value);
            }
            break;
            }
        } else {
            if(value>0) { // index >= BUTTON_SESSION:
                if((mode & 127)!= index) {
                    hal_plot_led(TYPEPAD, (mode & 127), 0, 0, 0);
                    hal_plot_led(TYPEPAD, index, MAXLED, MAXLED, MAXLED);
                    setMode(index|(mode&128));
                }
            }
        }
        // update the buttonState
        int i = index%10;
        int j = index/10;
        buttonState[j] ^= (buttonState[j] ^ ((value?1:0)<<i) ) & (1<<i);
    }
    break;

    case TYPESETUP: // switch to setup mode
    {
        if(value) {
            if(getButtonStateIndex(BUTTON_SHIFT)) {
                setMode(MODE_GLOBAL_SETUP);
            } else {
                mode ^=128;
                value = (mode&128)>>1;
                hal_plot_led(TYPESETUP, 0, value, value, value);
                if(mode == 0) mode = MODE_SEQ_CA;
                setMode(mode);
            }
        }
    }
    break;
    }
}