void GameOfLightHW::screen_goto(uint8_t index, uint8_t line) { line &= 0x07; //Allows range [0, 7] index &= 0x7F; //Allows range [0, 127] if (_screen_index != index) { screen_cmd(CMD_TYPE_SETX, index); _screen_index = index; } if (_screen_line != line) { screen_cmd(CMD_TYPE_SETY, line); _screen_line = line; } }
void GameOfLightSim::screen_goto(uint8_t index, uint8_t line) { line &= 0x07; //Allows range [0, 7] index &= 0x7F; //Allows range [0, 127] /* Note: when using update() this doesn't send any actual goto-commands as the lines * naturally overflow into the next transfer meaning we don't need to issue goto-commands */ if (_screen_index != index) { screen_cmd(CMD_TYPE_SETX, index); _screen_index = index; } if (_screen_line != line) { screen_cmd(CMD_TYPE_SETY, line); _screen_line = line; } }
void GameOfLightHW::clearDisplay() { // Clears both the internal buffer and the screen screen_cmd(CMD_TYPE_CLEAR, 0); _screen_line = 0; _screen_index = 0; clear(); }
//Note: The screencontroller has a limited buffersize. Care must be taken to not call this function // too often, lest the buffer overflows and lines are lost. 6-7 lines in rapid succesion is the aprox //limit. //Also note that issuing updates of concecutive lines in numerical order is a little bit faster // than random access as the requests are automatically combined for faster writes to the screen. void GameOfLightHW::update(const uint8_t line) { // Sends a single line to the screen int i; digitalWrite(SCREEN_SS_PIN, HIGH); //disable slave SPI digitalWrite(SCREEN_SS_PIN, LOW); //enable slave SPI -> resync with slave screen_cmd(CMD_TYPE_LINE , line); //To indicate a line is coming and which line it is for (i = 0; i < 128; i++) { SPI.transfer(buff[line][i]); } //Keep track of where the screen is currently at: _screen_line++; if (_screen_line >= 8) _screen_line = 0; //Note: _screen_index unchanged due to wrap }
//WARNING: For the time being this is an unsupported operation, it will be ignored. void GameOfLightHW::screen_data(uint8_t data) { // Write data directly to the display at current display-position. screen_cmd(CMD_TYPE_DATA, 0); SPI.transfer(data); //Update trackers of screen position _screen_index++; if (_screen_index > 127) { _screen_index = 0; _screen_line++; if (_screen_line > 7) { _screen_line = 0; } } //delayMicroseconds(6); }
int do_input_event(command_t cmd) { if (cmd == CMD_QUIT) { g_main_loop_quit(main_loop); return -1; } screen_cmd(mpd, cmd); if (cmd == CMD_VOLUME_UP || cmd == CMD_VOLUME_DOWN) /* make sure we don't update the volume yet */ disable_update_timer(); return 0; }
int screen_get_mouse_event(struct mpdclient *c, unsigned long *bstate, int *row) { MEVENT event; /* retrieve the mouse event from curses */ #ifdef PDCURSES nc_getmouse(&event); #else getmouse(&event); #endif /* calculate the selected row in the list window */ *row = event.y - screen.title_bar.window.rows; /* copy button state bits */ *bstate = event.bstate; /* if button 2 was pressed switch screen */ if (event.bstate & BUTTON2_CLICKED) { screen_cmd(c, CMD_SCREEN_NEXT); return 1; } return 0; }
void GameOfLightSim::clearDisplay() { // Clears both the internal buffer and the screen screen_cmd(CMD_TYPE_CLEAR, 0); clear(); }