void SDLScreen::Clear() { pthread_mutex_lock(&printing_mutex); SymbolPlace* sp = LockFrameBuffer(); for (int i = 0; i < getFrameBufferWidth() * getFrameBufferHeight(); i++) { sp[i] = createSymbolPlaceWithCurrentColors(0); } UnlockFrameBuffer(); pthread_mutex_unlock(&printing_mutex); }
void SDLScreen::Write(const wchar_t* str) { pthread_mutex_lock(&printing_mutex); SymbolPlace* sp = LockFrameBuffer(); int len = wcslen(str); for (int i = 0; i < len; i++) { if (str[i] == '\r') { cursor_x = 0; } else if (str[i] != '\n') { int pos = cursor_y * getFrameBufferWidth() + cursor_x; sp[pos] = createSymbolPlaceWithCurrentColors(str[i]); cursor_x ++; } else { cursor_x = 0; cursor_y ++; } if (cursor_x >= getFrameBufferWidth()) { cursor_x = 0; cursor_y ++; } if (cursor_y >= getFrameBufferHeight()) { // Move everything up 1 line for (int i = 0; i < getFrameBufferWidth(); i++) for (int j = 1; j < getFrameBufferHeight(); j++) { int pos = j * getFrameBufferWidth() + i; int pos_lineback = (j - 1) * getFrameBufferWidth() + i; sp[pos_lineback] = sp[pos]; } for (int i = 0; i < getFrameBufferWidth(); i++) { int pos = (getFrameBufferHeight() - 1) * getFrameBufferWidth() + i; sp[pos] = createSymbolPlaceWithCurrentColors(0); } cursor_x = 0; cursor_y --; } } UnlockFrameBuffer(); pthread_mutex_unlock(&printing_mutex); }
void glcd_Device::SetDot(uint8_t x, uint8_t y, uint8_t color) { uint8_t data; if ((x >= this->CurrentWidth()) || (y >= this->CurrentHeight())) return; debug::log("GLCD_Device: SetDot"); if (LockFrameBuffer()) { this->GotoXY(x, y - y % 8); // read data from display memory data = _do_ReadData(); if (color == BLACK) { data |= 0x01 << (y % 8); // set dot } else { data &= ~(0x01 << (y % 8)); // clear dot } _do_WriteData(data); // write data back to display UnlockFrameBuffer(); } _updateDisplay(); }