A bit of a background:
I have a small microcontroller with a display and I have to make a GUI. Testing and deploying the result on the MCU is difficult (slow-going) and I want to be able to do it on my PC.
The way the code is written on the MCU, all I have is a callback which sets a color to a (x,y).
I tried this for each pixel:
Code: Select all
brush.SetColour(r,g,b);
dc.SetBrush(brush);
dc.DrawRectangle(x * PixelSize, y * PixelSize, PixelSize, PixelSize);
Also, I tried to buffer the pixels in a "graphics memory" and paint it periodically:
Code: Select all
void BasicDrawPane::render(wxDC& dc) {
auto start = std::chrono::steady_clock::now();
dc.SetPen(*wxTRANSPARENT_PEN);
dc.DrawRectangle(0, 0, width, height);
for (int i = 0; i < LCD_XSIZE; i++) {
for (int j = 0; j < LCD_YSIZE; j++) {
if(gpuMEM[i][j] & DirtyBit) {
this->brush.SetColour(make_rgb_triplet(gpuMEM[i][j]));
dc.SetBrush(brush);
dc.DrawRectangle(i * PixelSize, j * PixelSize, PixelSize, PixelSize);
}
}
}
MilliSeconds totalTime = std::chrono::duration_cast<MilliSeconds>(std::chrono::steady_clock::now() - start);
printf("Total time in ms: %lld\n", totalTime.count());
}
What I would like to have is:
Code: Select all
int tft_drawPixel(int x, int y, COLOR_T color) {
//gpuMEM[x][y] = static_cast<uint32_t>(color) | DirtyBit;
wxColor wxCol(get_R(color), get_G(color), get_B(color));
someWxObject.SetPixel(x, y, wxCol);
elapsed = 0;
return 0;
}
Code: Select all
someWxObject.DrawRectangle(wxCol, x * PixelSize, y * PixelSize, PixelSize, PixelSize);