Example #1
0
//---------------------------------------------------------------------------
void DrawFFTGraph(const FFTGraphParam & param)
{
	GetVisBuffer(param.sb, 2048, 1, 0);
	DoFFT();

	tjs_int type = 0;
	static tjs_uint32 type_hint = 0;
	type = GetValueFromOptions(param.options, L"type", &type_hint, type);

	switch(type)
{
	case 0: // winamp, fire風
	  {
#if 1
		const static tjs_uint32 firecolors[16] =
			{
				0xff20ff00, 0xff40ff00, 0xff60ff00, 0xff80ff00,
				0xffa0ff00, 0xffc0ff00, 0xffe0ff00, 0xffffff00,
				0xffffe000, 0xffffc000, 0xffffa000, 0xffff8000,
				0xffff6000, 0xffff4000, 0xffff2000, 0xffffff00
			};
		const tjs_uint32 peak_color = 0xff808080;
#else
			/* あきさんモード */
		const static tjs_uint32 firecolors[16] =
			{
				0xff11DDFF, 0xff11CCEE, 0xff11BBDD, 0xff11AACC,
				0xff1199CC, 0xff1188BB, 0xff1177AA, 0xff0066AA,
				0xff005599, 0xff004499, 0xff004488, 0xff003388,
				0xff002277, 0xff001166, 0xff000066, 0xff000055
			};
		const tjs_uint32 peak_color = 0xff11eeff;
#endif


		GetBandSpectrum(param.width, 3.7, -70, param.height - 1,
			(param.height+15) / 16, 30, (param.height+31) / 32);

		tjs_uint8 *lbstart = param.laybuf +
			(param.top + param.height - 1) * param.laybufpitch +
			param.left * sizeof(tjs_uint32);

		for(int x = 0; x < param.width; x++)
		{
			tjs_uint8 *lb = lbstart + x * sizeof(tjs_uint32);

			int y;
			for(y = 0; y < BandData[x]; y ++)
			{
				int c = 15 - BandData[x] + y;
				*(tjs_uint32*)lb = c < 0 ? 0xff00ff00 : firecolors[c];
				lb -= param.laybufpitch;
			}
			for(; y < param.height; y++)
			{
				*(tjs_uint32*)lb = 0;
				lb -= param.laybufpitch;
			}

			*(tjs_uint32*)
				(lbstart + x * sizeof(tjs_uint32) - BandPeakData[x] * param.laybufpitch)
					= peak_color;
		}
	  }
	  break;
	case 1: // LCD 風
	  {
		tjs_int division = 16;
		tjs_int thick = 2;
		tjs_int oncolor = 0xff000000;
		tjs_int offcolor = 0xffb0b0b0;
		tjs_int bgcolor = 0xffc0c0c0;
		tjs_int peakcolor = 0xff707070;

		static tjs_uint32 hints[6];

		division = GetValueFromOptions(param.options, L"division", hints + 0, division);
		thick = GetValueFromOptions(param.options, L"thick", hints + 1, thick);
		oncolor = GetValueFromOptions(param.options, L"oncolor", hints + 2, oncolor);
		offcolor = GetValueFromOptions(param.options, L"offcolor", hints + 3, offcolor);
		bgcolor = GetValueFromOptions(param.options, L"bgcolor", hints + 4, bgcolor);
		peakcolor = GetValueFromOptions(param.options, L"peakcolor", hints + 5, peakcolor);

		DrawBarGraph(param, division, thick, oncolor, offcolor, bgcolor, peakcolor);
	  }
	  break;
	}
}
Example #2
0
void Vectored_Interrupt(int button){
	char cString[4], currDiffString[4];
	//GLCD_Clear(White);                    /* Clear graphical LCD display        */
	GLCD_SetBackColor(Blue);
	GLCD_SetTextColor(White);
	
	switch(button){
		case USER_BUTTON:

				//GLCD_DisplayString(0, 0, __FI, "< --User Button -- >");
				switch(currentState) {
					case WELCOME_SCREEN: // If on the welcome screen, set up difficulty screen
						GLCD_Clear(White);
						if(currentDifficulty == 0){
							currentDifficulty = 1;
						}
						updateNextDifficulty(nextDifficulty);
						DisplayInstructions();
						DrawBarGraph(BAR_X,BAR_Y,currentDifficulty * 20,BAR_HEIGHT,BAR_VALUE);
						
						currentState = DIFFICULTY_SCREEN;
						
					break;
						
					case DIFFICULTY_SCREEN: // Transition to Question Screen
						
						updateScoreAndDifficulty(currentScore, currentDifficulty, nextDifficulty);
					
						currentDifficulty = nextDifficulty; // Set the difficulty
						
						currentState = QUESTION_SCREEN;
					
						questionScreen(); // Display the question screen
					
					
					break;
					
					case QUESTION_SCREEN: // Question Screen uses countdown timer - no inputs
						
					break;
					
					case ANSWER_SCREEN:
						
						//answerScreen();
					
						currentState = MARKING_SCREEN; // Mark the users answer
					break;
					

					
					case MARKING_SCREEN: // Mark the users answer attempt
						markAnswer();
					
						currentDifficulty = nextDifficulty; // Set the difficulty
					
						currentState = NEXT_QUESTION;
					
					break;
					
					case NEXT_QUESTION: // Move on to next question
						
						currentDifficulty = nextDifficulty; // Set the difficulty
						currentState = QUESTION_SCREEN;
						questionScreen(); // Display the question screen

					
					break;
					
			};
						
		
		
				//GLCD_DisplayString(6, 0, __FI, GenerateRandomString(5));
				
				//doTone = ~doTone;
			break;
		
		case JOYSTICK_SELECT:
				//GLCD_DisplayString(0, 0, __FI, "< --JSTK Select -->");
				// Left available for future program improvements
			break;
		
		case JOYSTICK_UP:
				//GLCD_DisplayString(0, 0, __FI, "< --JSTK UP   -- >");
				
				inputAnswer(JOYSTICK_UP);
			break;
		
		case JOYSTICK_DOWN:
				//GLCD_DisplayString(0, 0, __FI, "< --JSTK DOWN -- >");
				
				inputAnswer(JOYSTICK_DOWN);
			break;
		
		case JOYSTICK_RIGHT:
				//GLCD_DisplayString(0, 0, __FI, "< --JSTK RIGHT-- >");
				
				inputAnswer(JOYSTICK_RIGHT);
			break;
		
		case JOYSTICK_LEFT:
				//GLCD_DisplayString(0, 0, __FI, "< --JSTK LEFT -- >");
				
				inputAnswer(JOYSTICK_LEFT);
			break;
		
		case POTENTIOMETER_TURNED:
			  //sprintf(cString, "%02d", c);
		
			switch(currentState) {
				case DIFFICULTY_SCREEN:
					nextDifficulty = (c / 3) + 1;
									
					nextDifficulty = nextDifficulty > 5 ? 5 : nextDifficulty;
				
					sprintf(currDiffString, "%1d", nextDifficulty);
					//updateScoreAndDifficulty(currentScore, currDifficulty, nextDifficulty);
					updateNextDifficulty(nextDifficulty);
					DrawBarGraph(BAR_X,BAR_Y,nextDifficulty * 20,BAR_HEIGHT,BAR_VALUE);
					//GLCD_SetBackColor(Red);
				break;
				
				case WELCOME_SCREEN:
					
				break;
				
				
				default:
					nextDifficulty = (c / 3) + 1;
									
					nextDifficulty = nextDifficulty > 5 ? 5 : nextDifficulty;
					sprintf(currDiffString, "%1d", nextDifficulty);
					
					updateScoreAndDifficulty(currentScore, currentDifficulty, nextDifficulty);
					
					
				break;
			}		
					
			break;
		
		default:
			break;
	}
}