Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2022
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
- #include "plugin.h"
- #include "lib/pluginlib_actions.h"
- const struct button_mapping* plugin_contexts[]= {
- pla_main_ctx,
- #if defined(HAVE_REMOTE_LCD)
- pla_remote_ctx,
- #endif
- };
- const int NOT_GUESSED = 0;
- const int GUESSED_RIGHT_WRONG_POSITION = 1;
- const int GUESSED_RIGHT = 2;
- int cubeSize = 24;
- int cubeSpacing = 4;
- #ifdef HAVE_SCROLLWHEEL
- #define ACT_UP PLA_SCROLL_FWD
- #define ACT_UP_REPEAT PLA_SCROLL_FWD_REPEAT
- #define ACT_DOWN PLA_SCROLL_BACK:
- #define ACT_DOWN_REPEAT PLA_SCROLL_BACK_REPEAT:
- #else
- #define ACT_UP PLA_UP
- #define ACT_UP_REPEAT PLA_UP_REPEAT
- #define ACT_DOWN PLA_DOWN:
- #define ACT_DOWN_REPEAT PLA_DOWN_REPEAT:
- #endif
- struct candidate
- {
- char character;
- int guess;
- };
- struct candidate candidates[26];
- static void cleanup(void *parameter)
- {
- (void)parameter;
- }
- void make_background(void)
- {
- rb->lcd_set_background(LCD_WHITE);
- rb->lcd_set_foreground(LCD_BLACK);
- rb->lcd_clear_display();
- }
- void draw_square(int x, int y)
- {
- rb->lcd_fillrect(x,y,cubeSize,cubeSize);
- }
- enum plugin_status plugin_start(const void* parameter)
- {
- (void)parameter;
- bool quit = false;
- int action = ACTION_NONE;
- for (int i = 0; i < 26; i++)
- {
- candidates[i].character = 65 + i;
- }
- int xStart = (LCD_WIDTH - (5 * cubeSize) - (4 * cubeSpacing)) / 2;
- int yStart = 32;
- while(!quit)
- {
- make_background();
- int xPosTest = 0;
- rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
- for (int i = 0; i < 26; i++)
- {
- char tempCharacter[2];
- rb->snprintf(tempCharacter, sizeof(tempCharacter), "%c", candidates[i].character);
- rb->lcd_putsxy(0,xPosTest, tempCharacter);
- xPosTest += 15;
- }
- rb->lcd_set_drawmode(DRMODE_SOLID);
- int xPos = xStart;
- int yPos = yStart;
- for (int i = 0; i < 5; i++)
- {
- for (int j = 0; j < 5; j++)
- {
- draw_square(xPos, yPos);
- xPos += cubeSize + cubeSpacing;
- }
- yPos += cubeSize + cubeSpacing;
- xPos = xStart;
- }
- //rb->lcd_set_drawmode(DRMODE_BG);
- //rb->lcd_fillrect(0,0,LCD_WIDTH,LCD_HEIGHT);
- //rb->lcd_set_drawmode(DRMODE_SOLID);
- rb->lcd_update();
- action = pluginlib_getaction(0, plugin_contexts, ARRAYLEN(plugin_contexts));
- switch (action)
- {
- case PLA_EXIT:
- /* FALL-Through */
- case PLA_CANCEL:
- quit = true;
- cleanup(NULL);
- return PLUGIN_OK;
- case PLA_LEFT:
- break;
- case PLA_RIGHT:
- break;
- case ACT_UP:
- /* FALL-Through */
- case ACT_UP_REPEAT:
- break;
- case ACT_DOWN:
- /* FALL-Through */
- case ACT_DOWN_REPEAT:
- break;
- default:
- if (rb->default_event_handler_ex(action, cleanup, NULL)
- == SYS_USB_CONNECTED)
- return PLUGIN_USB_CONNECTED;
- }
- }
- return PLUGIN_OK;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement