static void PONG_GameOver(void) { int i; #if PL_HAS_MP3 MUSIC_PlayTheme(MUSIC_THEME_BUZZER); #endif for(i=0;i<PONG_NOF_PIXELS;i++) { NEO_SetPixelColor(i, 0x300000); } NEO_TransferPixels(); }
static void PONG_RemoveBall(PONG_BallT *ball) { uint32_t color; int i; color = PONG_DEFAULT_BACKGROUND_RGB; /* default */ for(i=0;i<PONG_NOF_BALLS;i++) { if (&PONG_Balls[i]!=ball && PONG_Balls[i].pos==ball->pos) { /* other ball on our position */ color = PONG_Balls[i].color; /* use other balls color */ } } (void)NEO_SetPixelColor(ball->pos, color); }
uint8_t NEO_SetAllPixelColor(uint32_t rgb) { NEO_PixelIdxT x, y; uint8_t res; for(y=0;y<NEO_NOF_Y;y++) { for(x=0;x<NEO_NOF_X;x++) { res = NEO_SetPixelColor(x, y, rgb); if (res!=ERR_OK) { return res; } } } return ERR_OK; }
uint8_t NEO_ParseCommand(const unsigned char *cmd, bool *handled, const CLS1_StdIOType *io) { uint8_t res = ERR_OK; uint32_t color; int32_t tmp, x, y; const uint8_t *p; if (UTIL1_strcmp((char*)cmd, CLS1_CMD_HELP)==0 || UTIL1_strcmp((char*)cmd, "neo help")==0) { CLS1_SendHelpStr((unsigned char*)"neo", (const unsigned char*)"Group of neo commands\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" help|status", (const unsigned char*)"Print help or status information\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" clear all", (const unsigned char*)"Clear all pixels\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" set all <rgb>", (const unsigned char*)"Set all pixel with RGB value\r\n", io->stdOut); CLS1_SendHelpStr((unsigned char*)" set <x> <y> <rgb>", (const unsigned char*)"Set pixel with RGB value\r\n", io->stdOut); *handled = TRUE; return ERR_OK; } else if ((UTIL1_strcmp((char*)cmd, CLS1_CMD_STATUS)==0) || (UTIL1_strcmp((char*)cmd, "neo status")==0)) { *handled = TRUE; return PrintStatus(io); } else if (UTIL1_strcmp((char*)cmd, "neo clear all")==0) { NEO_ClearAllPixel(); NEO_TransferPixels(); *handled = TRUE; return ERR_OK; } else if (UTIL1_strncmp((char*)cmd, "neo set all", sizeof("neo set all")-1)==0) { p = cmd+sizeof("neo set all")-1; res = UTIL1_xatoi(&p, &tmp); /* read color RGB value */ if (res==ERR_OK && tmp>=0 && tmp<=0xffffff) { /* within RGB value */ color = tmp; NEO_SetAllPixelColor(color); NEO_TransferPixels(); *handled = TRUE; } } else if (UTIL1_strncmp((char*)cmd, "neo set", sizeof("neo set")-1)==0) { p = cmd+sizeof("neo set")-1; res = UTIL1_xatoi(&p, &x); /* read x pixel index */ if (res==ERR_OK && x>=0 && x<NEO_NOF_X) { res = UTIL1_xatoi(&p, &y); /* read y pixel index */ if (res==ERR_OK && y>=0 && y<NEO_NOF_Y) { res = UTIL1_xatoi(&p, &tmp); /* read color RGB value */ if (res==ERR_OK && tmp>=0 && tmp<=0xffffff) { color = tmp; NEO_SetPixelColor((NEO_PixelIdxT)x, (NEO_PixelIdxT)y, color); NEO_TransferPixels(); *handled = TRUE; } } } } return res; }
static void PONG_InitGame(void) { int i; NEO_ClearAllPixel(); /* background */ for(i=0;i<PONG_NOF_PIXELS;i++) { NEO_SetPixelColor(i, PONG_DEFAULT_BACKGROUND_RGB); } NEO_TransferPixels(); for(i=0;i<PONG_NOF_BALLS;i++) { PONG_InitBall(&PONG_Balls[i]); } POING_InitLimiter(&PONG_LeftLimiter); POING_InitLimiter(&PONG_RightLimiter); }
static void PONG_SetLimiter(PONG_LimiterT *limiter) { (void)NEO_SetPixelColor(limiter->pos, limiter->color); limiter->isOn = TRUE; }
static void PONG_DrawBall(PONG_BallT *ball) { (void)NEO_SetPixelColor(ball->pos, ball->color); ball->drawTickCounter = FRTOS1_xTaskGetTickCount(); }
static void PONG_ClearLimiter(PONG_LimiterT *limiter) { (void)NEO_SetPixelColor(limiter->pos, PONG_DEFAULT_BACKGROUND_RGB); limiter->isOn = FALSE; }