eren-terzioglu commented on code in PR #3010: URL: https://github.com/apache/nuttx-apps/pull/3010#discussion_r1970343920
########## games/brickmatch/bm_main.c: ########## @@ -300,24 +347,117 @@ void draw_board(FAR struct screen_state_s *state, usleep(100000); } } +#else + +/**************************************************************************** + * Name: dim_color + * + * Description: + * Dim led color to handle brightness. + * + * Parameters: + * val - RGB24 value of the led + * dim - Percentage of brightness + * + * Returned Value: + * Dimmed RGB24 value. + * + ****************************************************************************/ + +uint32_t dim_color(uint32_t val, float dim) +{ + uint16_t r = RGB24RED(val); + uint16_t g = RGB24GREEN(val); + uint16_t b = RGB24BLUE(val); + + float sat = dim; + + r *= sat; + g *= sat; + b *= sat; + + return RGBTO24(r, g, b); +} + +/**************************************************************************** + * Name: draw_board + * + * Description: + * Draw the user board without the edges. + * + * Parameters: + * state - Reference to the game screen state structure + * area - Reference to the valid area structure + * screen - Reference to the information structure of game screen + * + * Returned Value: + * None. + * + ****************************************************************************/ + +void draw_board(FAR struct screen_state_s *state, + FAR struct fb_area_s *area, + FAR struct game_screen_s *screen) +{ + int result; + uint32_t *bp = state->fbmem; + int x; + int y; + int rgb_val; + int tmp; + + for (x = 1; x <= BOARDX_SIZE; x++) + { + for (y = 1; y <= BOARDY_SIZE; y++) + { + rgb_val = RGB16TO24(pallete[board[x][y]]); + tmp = dim_color(rgb_val, 0.15); + *bp++ = ws2812_gamma_correct(tmp); + } + } + + lseek(state->fd_fb, 0, SEEK_SET); + + result = write(state->fd_fb, state->fbmem, 4 * N_LEDS); + if (result != 4 * N_LEDS) + { + fprintf(stderr, + "ws2812_main: write failed: %d %d\n", + result, + errno); + } +} +#endif /* CONFIG_GAMES_BRICKMATCH_USE_LED_MATRIX */ /**************************************************************************** * Name: print_board * * Description: * Draw the board including the user non-visible border for debugging. + * + * Parameters: + * None + * + * Returned Value: + * None. + * ****************************************************************************/ #ifdef DEBUG_BRICKMATCH_GAME void print_board(void) { int row; int col; + int tmp; for (row = 0; row < ROW; row++) { - printf("+---+---+---+---+---+---+---+---+\n"); + for (tmp = 0; tmp < ROW; tmp++) Review Comment: You are right, thanks for notifying. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org