void S_IncPlayerScore(void){ char scoreU = '0'; char scoreD = '0'; uint8_t scoreTmp; scoreTmp = playerScore; playerScore++; GLCD_SetForegroundColor (GLCD_COLOR_GREEN); GLCD_SetFont (&GLCD_Font_16x24); while (scoreTmp > 9){ scoreTmp -= 10; scoreD += 1; } scoreU += scoreTmp; GLCD_DrawChar (5, 0*24, scoreD); GLCD_DrawChar (20, 0*24, scoreU); if (playerScore > SCORE_MAX_SHOOTER) { stopShooter = true; } }
/*----------------------------------------------------------------------------- Increase the Score of the Machine and refresh score in GLCD *----------------------------------------------------------------------------*/ void S_IncMachineScore(void){ char scoreU = '0'; char scoreD = '0'; uint8_t scoreTmp; scoreTmp = machineScore; machineScore++; GLCD_SetForegroundColor (GLCD_COLOR_RED); GLCD_SetFont (&GLCD_Font_16x24); while (scoreTmp > 9){ scoreTmp -= 10; scoreD += 1; } scoreU += scoreTmp; GLCD_DrawChar (165, 0*24, scoreD); GLCD_DrawChar (180, 0*24, scoreU); if (machineScore > SCORE_MAX_SHOOTER) { stopShooter = true; } }
void GLCD_DisplayChar (unsigned int ln, unsigned int col, unsigned char c) { c -= 32; GLCD_DrawChar(col * CHAR_W, ln * CHAR_H, (unsigned short *)&Font_24x16[c * CHAR_H]); }
int main (void) { int32_t max_num = LED_GetCount() - 1; int32_t num = 0; int32_t dir = 1; uint32_t keyMsk, adcVal; int32_t key = -1; int32_t adc = -1; SystemCoreClockUpdate(); LED_Initialize(); /* LED Initialization */ ADC_Initialize(); /* A/D Converter Init */ Buttons_Initialize(); /* Button initialization */ GLCD_Initialize(); /* Initialize the GLCD */ SysTick_Config(SystemCoreClock/100); /* Generate interrupt each 10 ms */ GLCD_SetBackgroundColor (GLCD_COLOR_WHITE); GLCD_ClearScreen (); GLCD_SetBackgroundColor (GLCD_COLOR_BLUE); GLCD_SetForegroundColor (GLCD_COLOR_WHITE); GLCD_SetFont (&GLCD_Font_16x24); GLCD_DrawString (0*16, 0*24, " STM32303C-EVAL Demo"); GLCD_DrawString (0*16, 1*24, " Blinky Example "); GLCD_DrawString (0*16, 2*24, " www.keil.com "); GLCD_SetBackgroundColor (GLCD_COLOR_WHITE); GLCD_SetForegroundColor (GLCD_COLOR_BLUE); GLCD_DrawString (0*16, 5*24, "LEDs: "); GLCD_DrawString (0*16, 6*24, "AD value: "); GLCD_DrawString (0*16, 7*24, "Buttons : "); GLCD_SetForegroundColor (GLCD_COLOR_LIGHT_GREY); GLCD_DrawString (9*16, 5*24, "0123"); while (1) { /* Force refresh */ key = -1; adc = -1; if (LEDOn) { LEDOn = 0; LED_On (num); /* Turn specified LED on */ GLCD_SetForegroundColor (GLCD_COLOR_RED); GLCD_DrawChar ((9+num)*16, 5*24, numStr[num]); } if (LEDOff) { LEDOff = 0; LED_Off (num); /* Turn specified LED off */ GLCD_SetForegroundColor (GLCD_COLOR_LIGHT_GREY); GLCD_DrawChar ((9+num)*16, 5*24, numStr[num]); num += dir; /* Change LED number */ if (dir == 1 && num == max_num) { dir = -1; /* Change direction to down */ } else if (num == 0) { dir = 1; /* Change direction to up */ } } keyMsk = Buttons_GetState(); /* Show buttons state */ if (key ^ keyMsk) { GLCD_SetForegroundColor (GLCD_COLOR_BLACK); if (keyMsk & KEY_USER ) { GLCD_DrawString (9*16, 7*24, "Key"); } GLCD_SetForegroundColor (GLCD_COLOR_LIGHT_GREY); if (!(keyMsk & KEY_USER )) { GLCD_DrawString (9*16, 7*24, "Key"); } } ADC_StartConversion(); /* Show A/D conversion bargraph */ adcVal = ADC_GetValue(); if (adc ^ adcVal) { adc = adcVal; GLCD_SetForegroundColor (GLCD_COLOR_GREEN); GLCD_DrawBargraph (9*16, 6*24, 160, 20, (adcVal * 100) / ((1 << ADC_GetResolution()) - 1)); } } }