<commit_before>#include "BigNumber.h"
#include "SecondsRing.h"

#include "graphics.h"
#include "gpio.h"
#include "led-matrix.h"
#include "threaded-canvas-manipulator.h"

#include <algorithm>
#include <cinttypes>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <memory>
#include <unistd.h>

using namespace rgb_matrix;
using namespace uwhtimer;

class GameModel {
public:
    unsigned BlackScore;
    unsigned WhiteScore;
    unsigned GameClockMins;
    unsigned GameClockSecs;
};

class GameDisplay : public ThreadedCanvasManipulator {
public:
    GameDisplay(Canvas *Canvas, GameModel *Model)
        : ThreadedCanvasManipulator(Canvas) {}

    void Run() {
      Font F;
      if (!F.LoadFont("matrix/fonts/9x18.bdf")) {
        std::cerr << "Error: couldn't load font\n";
        exit(-1);
      }
      Color Blue(0, 0, 255);
      Color White(200, 200, 200);
      Color Yellow(255, 255, 0);
      Color Black(0, 0, 0);
      int v = 0;
      while (running()) {
        //DrawText(canvas(), F, -2, F.baseline()-2, Yellow, "123456");
        v++;
        if (v>=999) v = 0;
        BigNumber::Render(canvas(), 0, v / 100, Blue, &Black);
        BigNumber::Render(canvas(), 1, v % 100, White, &Black);
        SecondsRing::Render(canvas(), 0, v, Yellow, &Black);
        usleep(1000000);
      }
    }
};

int main(int argc, char *argv[]) {
    GPIO IO;

    if (!IO.Init()) {
        std::cerr << "Error: Could not init GPIO. Try again with 'sudo'?\n";
        exit(-1);
    }

    auto Matrix = std::unique_ptr<RGBMatrix>(new RGBMatrix(&IO, 32, 2, 1));
    Matrix->SetPWMBits(4);

    GameModel Model;

    auto Display = std::unique_ptr<GameDisplay>(new GameDisplay(&*Matrix, &Model));
    Display->Start();

    sleep(INT_MAX);<commit_msg>Double buffer the GameDisplay<commit_after>#include "BigNumber.h"
#include "SecondsRing.h"

#include "graphics.h"
#include "gpio.h"
#include "led-matrix.h"
#include "threaded-canvas-manipulator.h"

#include <algorithm>
#include <cinttypes>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <memory>
#include <unistd.h>

using namespace rgb_matrix;
using namespace uwhtimer;

class GameModel {
public:
    unsigned BlackScore;
    unsigned WhiteScore;
    unsigned GameClockMins;
    unsigned GameClockSecs;
};

class GameDisplay : public ThreadedCanvasManipulator {
public:
    GameDisplay(RGBMatrix *M, GameModel *Model)
        : ThreadedCanvasManipulator(M), M(M) {}

    void Run() {
      Font F;
      if (!F.LoadFont("matrix/fonts/9x18.bdf")) {
        std::cerr << "Error: couldn't load font\n";
        exit(-1);
      }
      Color Blue(0, 0, 255);
      Color White(200, 200, 200);
      Color Yellow(255, 255, 0);
      Color Black(0, 0, 0);
      int v = 0;
      FrameCanvas *Frame = M->CreateFrameCanvas();
      while (running()) {
        //DrawText(canvas(), F, -2, F.baseline()-2, Yellow, "123456");
        v++;
        if (v>=999) v = 0;
        BigNumber::Render(Frame, 0, v / 100, Blue, &Black);
        BigNumber::Render(Frame, 1, v % 100, White, &Black);
        SecondsRing::Render(Frame, 0, v, Yellow, &Black);
        Frame = M->SwapOnVSync(Frame);
        usleep(1000000);
      }
    }
private:
    RGBMatrix *M;
};

int main(int argc, char *argv[]) {
    GPIO IO;

    if (!IO.Init()) {
        std::cerr << "Error: Could not init GPIO. Try again with 'sudo'?\n";
        exit(-1);
    }

    auto Matrix = std::unique_ptr<RGBMatrix>(new RGBMatrix(&IO, 32, 2, 1));
    Matrix->SetPWMBits(4);

    GameModel Model;

    auto Display = std::unique_ptr<GameDisplay>(new GameDisplay(&*Matrix, &Model));
    Display->Start();

    sleep(INT_MAX);
{'fraction_non_alphanumeric': 0.1573187414500684, 'fraction_numerical': 0.03447332421340629, 'mean_word_length': 3.0397790055248617, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2676328', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1228, 'n_words': 315}