Uno Q - Notes on SDL2

So while the framebuffer works but don't like the whole drop out of gui just to run my gui..
Was actually trying to get SDL2 working and had troubles so I got the framebuffer working..

Success today and thinking it's easier than all the trouble I went through..

First I installed libsdl2-2.0-0 using the Synaptic Package Manager, no issues..
Got stopped trying to install the dev package, got a conflict with dependent lib that has a new qcom version installed..

I downloaded the source tar.gz from gitHub SDL release-2.32.4..

extracted to my /projects/libs/ folder and renamed it to SDL2
opened a terminal to the SDL2 folder..
cmake -S . -B build
cmake --build build
took a while but got a clean build..
I moved my LovyanGFX folder to the /libs/ folder too..
Copied the /libs/LovyAnGFX/examples_for_PC/CMake_SDL to the /projects folder..
fixed up the cmakelists file and got a clean compile..
ported solitaire and nesso mazes..
mazes still a work in progress as i need to try and figure out mcu access..

here's the user_code.cpp..


#define LGFX_USE_V1
#include <LovyanGFX.hpp>
#include <LGFX_AUTODETECT.hpp>
#include <string>
//#include "cards.h"
#include "bigcards.h"

#define SCREEN_WIDTH 1280
#define SCREEN_HEIGHT 720

LGFX Display(1280, 720);
LGFX_Sprite Sprite(&Display);

int8_t ButtonWidth = 60;
int8_t ButtonHeight = 30;
int8_t CardWidth = 72;
int8_t CardHeight = 110;
int8_t CardBack = 52;
int8_t CardOL = 30;
int8_t Border = 20;
int8_t Gap = 30;

int TableWidth = (CardWidth * 7) + (Gap * 6) + (Border * 2);
int TableHeight = (CardHeight * 2) + (Border * 2) + (CardOL * 12) + (Gap *2) + ButtonHeight;
int TableLeft = (SCREEN_WIDTH - TableWidth) / 2;
int TableTop = (SCREEN_HEIGHT - TableHeight) / 2;

int8_t Deck[52];

int8_t HiddenTabs[6][6];
int8_t Tableau[7][13];
int8_t Foundations[4][13];
int8_t Stock[24];
int8_t Waste[24];

int8_t StockCount = 0;
int8_t WasteCount = 0;
int8_t CurrentCard = 0;
int8_t TableauCounts[7] = {0, 0, 0, 0, 0, 0, 0};
int8_t HiddenCounts[7] = {0, 0, 0, 0, 0, 0, 0};
int8_t FoundationCounts[4] = {0, 0, 0, 0};
int8_t SelectedCard = -1;
int8_t SelectedArea = -1;
int8_t SelectCount = 0;

struct TouchSpot
{
  int x;
  int y;
  int w;
  int h;
  int area;
};

TouchSpot Spots[13];
TouchSpot Button;

struct SelectionRect
{
  int x;
  int y;
  int w;
  int h;
};

SelectionRect SelectRect;

SelectionRect BattLevelRect,BattVoltageRect,BattChargingRect;

unsigned long lastTouch;
unsigned long touchDebounce = 200;
unsigned long now;

unsigned long lastBattCheck;
unsigned long battCheckInterval = 1000;


bool debug = true;

// forward declarations..
void CutDeck(int8_t *deck, int size);
void shuffle(int8_t *array, int size);
unsigned long millis();
void SetupTable();
void StockFlip();
bool TouchArea(int px, int py, int x, int y, int w, int h);
void CheckScreenTouch(int tx, int ty);
void HandleTouch(int spot, int y);
bool CheckFoundationMove(int f);
void MoveToFoundations(int f);
void SelectFoundation(int f);
int GetCardColor(int acard);
int GetCardNumber(int acard);
bool CheckTableauMove(int a);
void MoveToTableau(int a);
void SelectTableau(int a, int y);
void DrawSelection();

unsigned long millis()
{
  unsigned long ms;
  ms = lgfx::millis();
  return ms;
}

void SetupTable()
{
  // clear out the old values..
  memset(HiddenTabs, -1, sizeof(HiddenTabs));
  memset(Tableau, -1, sizeof(Tableau));
  memset(Foundations, -1, sizeof(Foundations));
  memset(Stock, -1, sizeof(Stock));
  memset(Waste, -1, sizeof(Waste));
  memset(HiddenCounts, 0, sizeof(HiddenCounts));
  StockCount = 0;
  WasteCount = 0;
  CurrentCard = 0;
  for (int i = 0; i < sizeof(TableauCounts); i++)
  {
    TableauCounts[i] = 1;
    if (i < sizeof(FoundationCounts))
      FoundationCounts[i] = 0;
  }

  shuffle(Deck, sizeof(Deck));
  CutDeck(Deck,sizeof(Deck));
  shuffle(Deck, sizeof(Deck));
  CutDeck(Deck,sizeof(Deck));

  // fill the tableau
  int c = 0;
  for (int j = 0; j < 7; j++)
  {
    Tableau[j][0] = Deck[c];
    c++;
    for (int i = j; i < 6; i++)
    {
      HiddenTabs[i][j] = Deck[c];
      HiddenCounts[i + 1]++;
      c++;
    }
  }
  // fill stock
  StockCount = 52 - c;
  int p = 0;
  for (int i = c; i < 52; i++)
  {
    Stock[p] = Deck[c];
    p++;
    c++;
  }

  printf("Card #:%d \n", c);
  printf("Stock Count : %d \n", StockCount);
  printf("Size of HiddenTabs: %d \n", sizeof(HiddenTabs));
  printf("Size of spots: %d\n", sizeof(Spots) / sizeof(Spots[0]));
  for (int i = 0; i < sizeof(HiddenCounts); i++)
  {
    printf("Count # %d = %d\n", i + 1, HiddenCounts[i]);
  }

  Sprite.fillSprite(TFT_DARKGREEN);

  int sw, sh, x, y;

  sw = Display.width();
  sh = Display.height();

  y = Border;
  x = sw - (200 + Border);
  BattLevelRect.x = x;
  BattLevelRect.y = y;
  BattLevelRect.w = 200;
  BattLevelRect.h = 60;
  Sprite.setFont(&fonts::FreeSansBold9pt7b);
  Sprite.setTextSize(1);
  Sprite.setTextColor(TFT_BLACK);
  Sprite.fillRoundRect(x,y,200,60,4,TFT_WHITE);
  Sprite.drawRoundRect(x,y,200,60,4,TFT_YELLOW);
   
  Sprite.setTextColor(TFT_BLACK);
  Sprite.setColor(TFT_WHITE);
  //Sprite.setTextFont(1);
  Sprite.setFont(&fonts::FreeSansBold9pt7b);
  Sprite.setTextSize(1);
  //Sprite.drawString("Is Charging",x+3,y+3);
  //Sprite.drawString("Yes",x+3,y+30);
  y+= 60+ Gap;
  //x -= (200 + Gap);
  BattVoltageRect.x = x;
  BattVoltageRect.y = y;
  BattVoltageRect.w = 200;
  BattVoltageRect.h = 60;
  Sprite.fillRoundRect(x,y,200,60,4,TFT_WHITE);
  Sprite.drawRoundRect(x,y,200,60,4,TFT_YELLOW);
  y+= 60 + Gap;
  //x -= (200 + Gap);
  BattChargingRect.x = x;
  BattChargingRect.y = y;
  BattChargingRect.w = 200;
  BattChargingRect.h = 60;
  Sprite.fillRoundRect(x,y,200,60,4,TFT_WHITE);
  Sprite.drawRoundRect(x,y,200,60,4,TFT_YELLOW);

  x = Border + TableLeft;
  y = Border + TableTop;
  Button.x = x;
  Button.y = y;
  Button.w = ButtonWidth;
  Button.h = ButtonHeight;
  Sprite.fillRoundRect(x,y, ButtonWidth, ButtonHeight, 8 , TFT_LIGHTGRAY);
  Sprite.setTextColor(TFT_BLACK);
  
  Sprite.drawString("New",x+3,y+6);
  Sprite.drawRoundRect(x, y, ButtonWidth, ButtonHeight,8, TFT_YELLOW);
  y+=ButtonHeight+Gap;

  Spots[0].y = y;
  Spots[0].x = x;
  Spots[0].h = CardHeight;
  Spots[0].w = CardWidth;
  Spots[0].area = 1;
  Sprite.pushImage(x, y, CardWidth, CardHeight, card[CardBack]);
  Sprite.drawRect(x, y, CardWidth, CardHeight, TFT_YELLOW);
  x += CardWidth + Gap;
  Spots[1].y = y;
  Spots[1].x = x;
  Spots[1].h = CardHeight;
  Spots[1].w = CardWidth;
  Spots[1].area = 2;
  Sprite.drawRect(x, y, CardWidth, CardHeight, TFT_YELLOW);
  x += (CardWidth + Gap) * 2;

  for (int i = 0; i < 4; i++)
  {
    Spots[i + 2].y = y;
    Spots[i + 2].x = x;
    Spots[i + 2].h = CardHeight;
    Spots[i + 2].w = CardWidth;
    Spots[i + 2].area = i + 3;
    Sprite.drawRect(x, y, CardWidth, CardHeight, TFT_YELLOW);
    x += CardWidth + Gap;
  }
  x = Border + TableLeft;
  y = CardHeight + Border + Gap + TableTop+ButtonHeight+Gap;

  for (int i = 0; i < 7; i++)
  {
    Spots[i + 6].y = y;
    Spots[i + 6].x = x;
    Spots[i + 6].h = CardHeight;
    Spots[i + 6].w = CardWidth;
    Spots[i + 6].area = i + 7;
    if (i > 0)
    {
      Sprite.pushImage(x, y, CardWidth, CardHeight, card[CardBack]);
    }
    Sprite.drawRect(x, y, CardWidth, CardHeight, TFT_YELLOW);
    Sprite.pushImage(x, y + CardOL, CardWidth, CardHeight, card[Tableau[i][0]]);
    Sprite.drawRect(x, y + CardOL, CardWidth, CardHeight, TFT_YELLOW);
    x += CardWidth + Gap;
  }
  // show it..
  //Sprite.pushImage(2, 2 , 72, 110, KS);
  Sprite.pushSprite(0, 0);
}

void StockFlip()
{
  if (SelectedCard > -1){
  SelectedCard = -1;
  SelectedArea = -1;
  SelectCount = 0;
  DrawSelection();
  }
  if (StockCount == 0)
  {
    // restock..
    int flip = WasteCount - 1;
    for (int i = 0; i < WasteCount; i++)
    {
      Stock[i] = Waste[flip--];
    }
    StockCount = WasteCount;
    WasteCount = 0;
    Sprite.pushImage(Spots[0].x, Spots[0].y, CardWidth, CardHeight, card[CardBack]);
    Sprite.drawRoundRect(Spots[0].x, Spots[0].y, CardWidth, CardHeight, 4, TFT_YELLOW);
  }
  // flip the next stock card over..
  Waste[WasteCount] = Stock[StockCount - 1];
  WasteCount++;
  Stock[StockCount - 1] = -1;
  if (StockCount > 0)
    StockCount--;
  if (StockCount == 0)
  {
    // no more stock..
    Sprite.fillRect(Spots[0].x, Spots[0].y, CardWidth, CardHeight, TFT_DARKGREEN);
    Sprite.drawRoundRect(Spots[0].x, Spots[0].y, CardWidth, CardHeight, 4, TFT_YELLOW);
  }
  printf("card:%d\n", Waste[WasteCount - 1]);
  Sprite.pushImage(Spots[1].x, Spots[1].y, CardWidth, CardHeight, card[Waste[WasteCount - 1]]);
  Sprite.drawRoundRect(Spots[1].x, Spots[1].y, CardWidth, CardHeight, 4, TFT_YELLOW);
  Sprite.pushSprite(0, 0);
}

void SelectWaste()
{
  if (WasteCount > 0)
  {
    printf("Waste Card Selected: %d\n", Waste[WasteCount - 1]);
    SelectedCard = Waste[WasteCount - 1];
    SelectedArea = 2;
    SelectCount = 1;
    SelectRect.x = Spots[1].x;
    SelectRect.y = Spots[1].y;
    SelectRect.w = Spots[1].w;
    SelectRect.h = Spots[1].h;
    DrawSelection();
  }
  else
    printf("No Waste..\n");
}

bool CheckFoundationMove(int f)
{
  bool result = false;
  int nextCard;
  if (FoundationCounts[f - 3] > 0)
  {
    if (FoundationCounts[f - 3] == 1)
    {
      // it's the ace..
      nextCard = Foundations[f - 3][FoundationCounts[f - 3] - 1] - 12;
    }
    else
    {
      nextCard = Foundations[f - 3][FoundationCounts[f - 3] - 1] + 1;
    }
    if (SelectedCard == nextCard)
      result = true;
  }
  else
  {
    // looking for an ace
    switch (SelectedCard)
    {
    case 12:
    case 25:
    case 38:
    case 51:
      result = true;
      break;
    }
  }
  return result;
}

void MoveToFoundations(int f)
{
  //
  printf("Move to Foundation. Card:%d  Area:%d\n", SelectedCard, SelectedArea);
  if (SelectedArea == 2 && SelectedCard > -1)
  {
    // move a waste card..
    Foundations[f - 3][FoundationCounts[f - 3]] = Waste[WasteCount - 1];
    FoundationCounts[f - 3]++;
    Waste[WasteCount - 1] = -1;
    WasteCount--;
    if (WasteCount < 1)
    {
      Sprite.fillRect(Spots[1].x, Spots[1].y, CardWidth, CardHeight, TFT_DARKGREEN);
      Sprite.drawRoundRect(Spots[1].x, Spots[1].y, CardWidth, CardHeight, 4, TFT_YELLOW);
    }
    else
    {
      Sprite.pushImage(Spots[1].x, Spots[1].y, CardWidth, CardHeight, card[Waste[WasteCount - 1]]);
      Sprite.drawRoundRect(Spots[1].x, Spots[1].y, CardWidth, CardHeight, 4, TFT_YELLOW);
    }
    Sprite.pushImage(Spots[f - 1].x, Spots[f - 1].y, CardWidth, CardHeight, card[Foundations[f - 3][FoundationCounts[f - 3] - 1]]);
    Sprite.drawRoundRect(Spots[f - 1].x, Spots[f - 1].y, CardWidth, CardHeight, 4, TFT_YELLOW);
    Sprite.pushSprite(0, 0);
    SelectedCard = -1;
    SelectedArea = -1;
    SelectCount = 0;
    DrawSelection();
  }
  else
  {
    if (SelectedArea > 6)
    {
      // moving from the tasbleau
      if (SelectedCard == Tableau[SelectedArea - 7][TableauCounts[SelectedArea - 7] - 1])
      {
        // can only move a top card..
        Foundations[f - 3][FoundationCounts[f - 3]] = Tableau[SelectedArea - 7][TableauCounts[SelectedArea - 7] - 1];
        FoundationCounts[f - 3]++;
        Tableau[SelectedArea - 7][TableauCounts[SelectedArea - 7] - 1] = -1;
        TableauCounts[SelectedArea - 7]--;

        int newy = CardOL * TableauCounts[SelectedArea - 7];
        Spots[SelectedArea - 1].h = CardHeight + newy;
        printf("Table Count: %d newy: %d\n", TableauCounts[SelectedArea - 7], newy);
        // erase old card first
        Sprite.fillRect(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y + newy + CardOL, CardWidth, CardHeight, TFT_DARKGREEN);
        // redraw last card in pile..
        if (TableauCounts[SelectedArea - 7] > 0)
          Sprite.pushImage(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y + newy, CardWidth, CardHeight, card[Tableau[SelectedArea - 7][TableauCounts[SelectedArea - 7] - 1]]);
        else if (SelectedArea > 7 && HiddenCounts[SelectedArea - 7] > 0) // do we have something??
          Sprite.pushImage(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y + newy, CardWidth, CardHeight, card[CardBack]);
        Sprite.drawRoundRect(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y + newy, CardWidth, CardHeight, 4, TFT_YELLOW);
        // draw card in foundation
        Sprite.pushImage(Spots[f - 1].x, Spots[f - 1].y, CardWidth, CardHeight, card[Foundations[f - 3][FoundationCounts[f - 3] - 1]]);
        Sprite.drawRoundRect(Spots[f - 1].x, Spots[f - 1].y, CardWidth, CardHeight, 4, TFT_YELLOW);
        Sprite.pushSprite(0, 0);
        SelectedCard = -1;
        SelectedArea = -1;
      }
      else
      {
        // just unselect pile
        SelectedCard = -1;
        SelectedArea = -1;
        SelectCount = 0;
        DrawSelection();
      }
    }
    else
    {
      // just unselect pile
      SelectedCard = -1;
      SelectedArea = -1;
      SelectCount = 0;
      DrawSelection();
    }
  }
}

void SelectFoundation(int f)
{
  // select a foundation card..
  if (FoundationCounts[f - 3] > 0)
  {
    SelectedCard = Foundations[f - 3][FoundationCounts[f - 3] - 1];
    SelectedArea = f;
    SelectCount = 1;
    SelectRect.x = Spots[f - 1].x;
    SelectRect.y = Spots[f - 1].y;
    SelectRect.w = Spots[f - 1].w;
    SelectRect.h = Spots[f - 1].h;
    DrawSelection();
    printf("Foundation %d  Card %d selected\n", SelectedArea - 2, SelectedCard);
  }
}

int GetCardColor(int acard)
{
  int result = -1;
  if (acard < 13)
    result = 0;
  else if (acard < 39)
    result = 1;
  else
    result = 0;
  return result;
}

int GetCardNumber(int acard)
{
  int result = -1;
  // get ordinal postion within suit..
  if (acard < 13)
    result = acard+2;
  else if (acard < 26)
    result = acard - 11;
  else if (acard < 39)
    result = acard - 24;
  else
    result = acard - 37;

   printf("Orig #: %d new #: %d\n",acard,result);   
 return result;   
}

bool CheckTableauMove(int a)
{
  // check for valid move
  bool result = false;
  // no cards on table, any card should do..
  if (TableauCounts[a - 7] == 0)
  {
    result = true;
    return result; // outa here
  }
  int pileColor = GetCardColor(Tableau[a - 7][TableauCounts[a - 7] - 1]);
  if (GetCardColor(SelectedCard) == pileColor)
  {
    int acolor = GetCardColor(SelectedCard);
    printf("wrong colors..pile color: %d  select color: %d\n", pileColor,acolor);
    result = false;
    return result;
  }
  int pileCard = GetCardNumber(Tableau[a - 7][TableauCounts[a - 7] - 1]);
  // next card should be one less than the current pile card..
  result = pileCard == (GetCardNumber(SelectedCard) + 1);
  if (!result) printf("wrong card # pile:%d  select:%d\n",pileCard,GetCardNumber(SelectedCard));
  return result;
}

void MoveToTableau(int a)
{
  if (SelectedArea == 2)
  {
    // moving from waste..
    Tableau[a - 7][TableauCounts[a - 7]] = Waste[WasteCount - 1];
    TableauCounts[a - 7]++;
    Waste[WasteCount - 1] = -1;
    WasteCount--;
    if (WasteCount < 1)
    {
      Sprite.fillRect(Spots[1].x, Spots[1].y, CardWidth, CardHeight, TFT_DARKGREEN);
      Sprite.drawRoundRect(Spots[1].x, Spots[1].y, CardWidth, CardHeight, 4, TFT_YELLOW);
    }
    else
    {
      Sprite.pushImage(Spots[1].x, Spots[1].y, CardWidth, CardHeight, card[Waste[WasteCount - 1]]);
      Sprite.drawRoundRect(Spots[1].x, Spots[1].y, CardWidth, CardHeight, 4, TFT_YELLOW);
    }
    int newy = CardOL * TableauCounts[a - 7];
    Spots[a - 1].h = CardHeight + newy;
    printf("Table Count: %d newy: %d\n", TableauCounts[a - 7], newy);
    Sprite.pushImage(Spots[a - 1].x, Spots[a - 1].y + newy, CardWidth, CardHeight, card[Tableau[a - 7][TableauCounts[a - 7] - 1]]);
    Sprite.drawRoundRect(Spots[a - 1].x, Spots[a - 1].y + newy, CardWidth, CardHeight, 4, TFT_YELLOW);
    SelectedCard = -1;
    SelectedArea = -1;
    SelectCount = 0;
    DrawSelection();
  }
  else if (SelectedArea > 2 && SelectedArea < 7)
  {
    // moving from foundations..
    Tableau[a - 7][TableauCounts[a - 7]] = Foundations[SelectedArea - 3][FoundationCounts[SelectedArea - 3] - 1];
    TableauCounts[a - 7]++;
    Foundations[SelectedArea - 3][FoundationCounts[SelectedArea - 3] - 1] = -1;
    FoundationCounts[SelectedArea - 3]--;
    if (FoundationCounts[SelectedArea - 3] < 1)
    {
      Sprite.fillRect(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y, CardWidth, CardHeight, TFT_DARKGREEN);
      Sprite.drawRoundRect(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y, CardWidth, CardHeight, 4, TFT_YELLOW);
    }
    else
    {
      Sprite.pushImage(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y, CardWidth, CardHeight, card[Foundations[SelectedArea - 3][FoundationCounts[SelectedArea - 3] - 1]]);
      Sprite.drawRoundRect(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y, CardWidth, CardHeight, 4, TFT_YELLOW);
    }
    int newy = CardOL * TableauCounts[a - 7];
    Spots[a - 1].h = CardHeight + newy;
    printf("Table Count: %d newy: %d\n", TableauCounts[a - 7], newy);
    Sprite.pushImage(Spots[a - 1].x, Spots[a - 1].y + newy, CardWidth, CardHeight, card[Tableau[a - 7][TableauCounts[a - 7] - 1]]);
    Sprite.drawRoundRect(Spots[a - 1].x, Spots[a - 1].y + newy, CardWidth, CardHeight, 4, TFT_YELLOW);
    SelectedCard = -1;
    SelectedArea = -1;
    SelectCount = 0;
    DrawSelection();
    //   Sprite.pushSprite(0, 0);
  }
  else if (SelectedArea > 6 && SelectedArea < 14 && SelectedArea != a)
  {
    // moving from pile to pile..
    int c = SelectCount;
    int newy;
    for (int i = 0; i < SelectCount; i++)
    {
      // add cards
      printf("Tab Count: %d  c: %d\n", TableauCounts[SelectedArea - 7], c);
      Tableau[a - 7][TableauCounts[a - 7]] = Tableau[SelectedArea - 7][(TableauCounts[SelectedArea - 7] - c)];
      TableauCounts[a - 7]++;
      newy = CardOL * TableauCounts[a - 7];
      Spots[a - 1].h = CardHeight + newy;
      printf("Table Count: %d newy: %d\n", TableauCounts[a - 7], newy);
      Sprite.pushImage(Spots[a - 1].x, Spots[a - 1].y + newy, CardWidth, CardHeight, card[Tableau[a - 7][TableauCounts[a - 7] - 1]]);
      Sprite.drawRoundRect(Spots[a - 1].x, Spots[a - 1].y + newy, CardWidth, CardHeight, 4, TFT_YELLOW);
      c--;
    }
    c = SelectCount;
   // newy = Spots[a-1].h;
    for (int i = 0; i < SelectCount; i++)
    {
      // remove cards
      Tableau[SelectedArea - 7][(TableauCounts[SelectedArea - 7] - c)] = -1;
      TableauCounts[SelectedArea - 7]--;
      newy = CardOL * TableauCounts[SelectedArea - 7];
     // newy-= CardOL;
     if (TableauCounts[SelectedArea -7]>1)
      Spots[SelectedArea - 1].h = CardHeight + newy; else
      Spots[SelectedArea - 1].h = CardHeight;
      printf("Table Count: %d newy: %d\n", TableauCounts[SelectedArea - 7], newy);
      // erase old card first
      Sprite.fillRect(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y + newy + CardOL, CardWidth, CardHeight, TFT_DARKGREEN);
      // redraw last card in pile..
      if (TableauCounts[SelectedArea - 7] > 0)
        Sprite.pushImage(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y + newy, CardWidth, CardHeight, card[Tableau[SelectedArea - 7][TableauCounts[SelectedArea - 7] - 1]]);
      else if (SelectedArea > 7 && HiddenCounts[SelectedArea - 7] > 0) // do we have something??
        Sprite.pushImage(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y + newy, CardWidth, CardHeight, card[CardBack]);
      Sprite.drawRoundRect(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y + newy, CardWidth, CardHeight, 4, TFT_YELLOW);
      c--;
    }
    SelectedCard = -1;
    SelectedArea = -1;
    SelectCount = 0;
    Sprite.pushSprite(0, 0);
  }
  else
  {
    SelectedCard = -1;
    SelectedArea = -1;
    SelectCount = 0;
    DrawSelection();
  }
}

void SelectTableau(int a, int y)
{
  if (TableauCounts[a - 7] > 0)
  {
    if (TableauCounts[a - 7] > 1)
    {
      int newy = Spots[a - 1].y + (TableauCounts[a - 7] * CardOL);
      for (int i = 0; i < TableauCounts[a - 7]; i++)
      {
        printf("NewY: %d  Y: %d\n", newy, y);
        if (y >= newy)
        {
          SelectedCard = Tableau[a - 7][(TableauCounts[a - 7] - 1) - i];
          SelectedArea = a;
          SelectCount = i + 1;
          printf("Multi-Selected Card : %d Num of Cards: %d\n", SelectedCard, SelectCount);
          break;
        }
        newy -= CardOL;
      }
      SelectRect.x = Spots[a - 1].x;
      SelectRect.y = Spots[a - 1].y + (CardOL * TableauCounts[a - 7]) - (SelectCount * CardOL) + CardOL;
      SelectRect.w = CardWidth;
      SelectRect.h = CardHeight + (CardOL * SelectCount) - CardOL;
      DrawSelection();
    }
    else
    {
      // only 1 card on pile..
      SelectedCard = Tableau[a - 7][TableauCounts[a - 7] - 1];
      SelectedArea = a;
      SelectCount = 1;
      SelectRect.x = Spots[a - 1].x;
      SelectRect.y = Spots[a - 1].y + CardOL;
      SelectRect.w = Spots[a - 1].w;
      SelectRect.h = CardHeight; // Spots[a - 1].h;
      DrawSelection();
      printf("Single-Selected Card : %d\n", SelectedCard);
    }
  }
  else
  {
    // no cards on tableau, see if we have any hidden..
    if (HiddenCounts[a - 7] > 0)
    {
      // flip the hidden card..
      Tableau[a - 7][0] = HiddenTabs[a - 8][HiddenCounts[a - 7] - 1];
      TableauCounts[a - 7] = 1;
      HiddenTabs[a - 8][HiddenCounts[a - 7] - 1] = -1;
      HiddenCounts[a - 7]--;
      int newy = 0;// CardOL * TableauCounts[a - 7];
      Spots[a - 1].h = CardHeight + newy;
      newy = CardOL;
      printf("Table Count: %d newy: %d\n", TableauCounts[a - 7], newy);
      if (HiddenCounts[a - 7] == 0)
      { // erase hidden placeholder..
        Sprite.fillRect(Spots[a - 1].x, Spots[a - 1].y, CardWidth, CardHeight, TFT_DARKGREEN);
        Sprite.drawRoundRect(Spots[a - 1].x, Spots[a - 1].y, CardWidth, CardHeight, 4, TFT_YELLOW);
      }
      Sprite.pushImage(Spots[a - 1].x, Spots[a - 1].y + newy, CardWidth, CardHeight, card[Tableau[a - 7][TableauCounts[a - 7] - 1]]);
      Sprite.drawRoundRect(Spots[a - 1].x, Spots[a - 1].y + newy, CardWidth, CardHeight, 4, TFT_YELLOW);
      Sprite.pushSprite(0, 0);
    }
  }
}

void CutDeck(int8_t *deck, int size){
  int8_t half[size / 2];
  /*
  printf("Deck Before Cut: ");
  for (int i = 0 ; i < size; i++){
   printf(" %d, ",deck[i]);
  }
  printf("\n");
  */
  memcpy(half,deck,sizeof(half));
  /*
  printf("Half: ");
  for (int i = 0 ; i < size /2; i++){
   printf(" %d, ",half[i]);
  }
  printf("\n");
  */
  memcpy(deck,&deck[(size / 2)],sizeof(half));
  memcpy(&deck[(size / 2)],half,sizeof(half));
  /*
  printf("Deck After Cut: ");
  for (int i = 0 ; i < size; i++){
   printf(" %d, ",deck[i]);
  }
  printf("\n");
  */
}

void shuffle(int8_t *array, int size)
{
  for (int i = size - 1; i > 0; i--)
  {
    int j = i + (rand() % (size - i));
    int8_t temp = array[i];
    array[i] = array[j];
    array[j] = temp;
  }
}

void DrawSelection()
{
  if (SelectedCard > -1)
  {
    // selecting
    Sprite.drawRoundRect(SelectRect.x + 1, SelectRect.y + 1, SelectRect.w - 3, SelectRect.h - 2, 4, TFT_GREEN);
    Sprite.drawRoundRect(SelectRect.x + 2, SelectRect.y + 2, SelectRect.w - 4, SelectRect.h - 3, 4, TFT_GREEN);
    Sprite.drawRoundRect(SelectRect.x, SelectRect.y, SelectRect.w, SelectRect.h, 4, TFT_GREEN);
  }
  else
  {
    Sprite.drawRoundRect(SelectRect.x + 1, SelectRect.y + 1, SelectRect.w - 3, SelectRect.h - 2, 4, TFT_WHITE);
    Sprite.drawRoundRect(SelectRect.x + 2, SelectRect.y + 2, SelectRect.w - 4, SelectRect.h - 3, 4, TFT_WHITE);
    Sprite.drawRoundRect(SelectRect.x, SelectRect.y, SelectRect.w, SelectRect.h, 4, TFT_YELLOW);
    // unselecting
  }
  Sprite.pushSprite(0, 0);
}

void UpdateBattDisplay(){
  //display battery information
  int x,y,w,h;
  bool isCharging = true;// M5.Power.isCharging();
  int battVolts =8138;// M5.Power.getBatteryVoltage();
  int battLevel = 75;// M5.Power.getBatteryLevel();

  x = BattLevelRect.x;
  y = BattLevelRect.y;
  w = BattLevelRect.w;
  h = BattLevelRect.h;
  Sprite.setFont(&fonts::FreeSansBold9pt7b);
  Sprite.setTextSize(1);
  Sprite.setTextColor(TFT_BLACK);
  Sprite.fillRoundRect(x,y,w,h,4,TFT_WHITE);
  Sprite.drawRoundRect(x,y,w,h,4,TFT_YELLOW);
   int nw = w-4;
   int cl = battLevel; // simulated batt level
   if (cl < 100)
    {
      float multi = cl / 100.0;
      nw = nw * multi;
    }
  Sprite.fillRect(x + 2, y + 2, nw, h - 4, TFT_GREEN);
  Sprite.drawNumber(cl, x + 10, y + 20);

  Sprite.setTextColor(TFT_BLACK);
  Sprite.setColor(TFT_WHITE);
  //Sprite.setTextFont(1);
  Sprite.setFont(&fonts::FreeSansBold9pt7b);
  Sprite.setTextSize(1);
  //Sprite.drawString("Is Charging",x+3,y+3);
  //Sprite.drawString("Yes",x+3,y+30);

  //x -= (200 + Gap);
  x = BattVoltageRect.x;
  y = BattVoltageRect.y;
  Sprite.fillRoundRect(x,y,w,h,4,TFT_WHITE);
  Sprite.drawRoundRect(x,y,w,h,4,TFT_YELLOW);
  Sprite.drawString("Voltage",x+3,y+3);
  Sprite.drawNumber(battVolts,x+3,y+30);
  x = BattChargingRect.x;
  y = BattChargingRect.y;
  Sprite.fillRoundRect(x,y,w,h,4,TFT_WHITE);
  Sprite.drawRoundRect(x,y,w,h,4,TFT_YELLOW);
  Sprite.drawString("Charging",x+3,y+3);
  if (isCharging)
  Sprite.drawString("Yes",x+3,y+30);
  else
  Sprite.drawString("No",x+3,y+30);
  
}

void setup()
{
  Display.init();
  Sprite.createSprite(1280, 720);
  Sprite.setSwapBytes(1);
  // init the deck..
  for (int i = 0; i < 52; i++)
    Deck[i] = i;
  // init random
  srand(time(0));
  // setup the table
  SetupTable();
}

void loop()
{
  now = millis();
 if (now - lastBattCheck >= battCheckInterval){
  lastBattCheck = now;
  UpdateBattDisplay();
 }


  lgfx::touch_point_t tp;
  if (Display.getTouch(&tp))
  {
    if (now - lastTouch >= touchDebounce)
    { // got a touch..
      lastTouch = now;
      CheckScreenTouch(tp.x, tp.y);
    }
  }
  lgfx::delay(10);
}

bool TouchArea(int px, int py, int x, int y, int w, int h)
{
  bool result = false;
  int x2 = x + w;
  int y2 = y + h;
  int touch_x = px;
  int touch_y = py;
  if ((touch_x >= x) && (touch_x <= x2) && (touch_y >= y) && (touch_y <= y2))
    result = true;
  if (debug)
  {
    printf("Touch X: %d  Y: %d\n", touch_x, touch_y);
    printf("X: %d , X2: %d, Y: %d, Y2: %d\n", x, x2, y, y2);
  }
  return result;
}

void CheckScreenTouch(int tx, int ty)
{
  printf("x: %d  y: %d \n", tx, ty);
  printf("Button x:%d y:%d w:%d h:%d\n",Button.x,Button.y,Button.w,Button.h);
  if (TouchArea(tx,ty,Button.x,Button.y,Button.w,Button.h)){
    printf("New Game\n");
   SetupTable();
  } else
   {
  for (int i = 0; i < sizeof(Spots) / sizeof(Spots[0]); i++)
  {
    if (TouchArea(tx, ty, Spots[i].x, Spots[i].y, Spots[i].w, Spots[i].h))
    {
      printf("Spot clicked:%d\n", i);
      HandleTouch(i, ty);
      break;
    }
  }
}
}

void HandleTouch(int spot, int y)
{

  switch (spot)
  {
  case 0:
    StockFlip();
    break;
  case 1:
    SelectWaste();
    break;
  case 2:
  case 3:
  case 4:
  case 5:
    if (SelectedCard > -1)
    {
      if (CheckFoundationMove(Spots[spot].area))
      {
        MoveToFoundations(Spots[spot].area);
      }
      else
      {
        // invalid move unselect the selection..
        SelectCount = 0;
        SelectedArea = 0;
        SelectedCard = -1;
        DrawSelection();
      }
    }
    else
    {
      SelectFoundation(Spots[spot].area);
    }
    break;
  case 6:
  case 7:
  case 8:
  case 9:
  case 10:
  case 11:
  case 12:
    if (SelectedCard > -1)
    {
      if (CheckTableauMove(Spots[spot].area))
      {
        MoveToTableau(Spots[spot].area);
      }
      else
      {
        // invalid move, unselect
        SelectCount = 0;
        SelectedArea = 0;
        SelectedCard = -1;
        DrawSelection();
      }
    }
    else
    {
      SelectTableau(Spots[spot].area, y);
    }
    break;
  default:
    break;
  }
}

here’s the contents of my CMakeLists.txt..

# See how to install sdl2: https://wiki.libsdl.org/SDL2/Installation
cmake_minimum_required (VERSION 3.10)
project(LGFX_SDL)

add_definitions(-DLGFX_SDL)

file(GLOB Target_Files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS 
    *.cpp
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/Fonts/efont/*.c
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/Fonts/IPA/*.c
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/utility/*.c
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/v1/*.cpp
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/v1/misc/*.cpp
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/v1/panel/Panel_Device.cpp
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/v1/panel/Panel_FrameBufferBase.cpp
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/v1/platforms/sdl/*.cpp
    )
add_executable (LGFX_SDL ${Target_Files})

target_include_directories(LGFX_SDL PUBLIC "/home/arduino/projects/libs/LovyanGFX/src/")

IF (CMAKE_SYSTEM_NAME MATCHES "Linux")


    target_include_directories(LGFX_SDL PUBLIC "/home/arduino/projects/libs/SDL2/include")
    target_include_directories(LGFX_SDL PUBLIC "/home/arduino/projects/libs/SDL2/src")
    target_link_libraries(LGFX_SDL PUBLIC -lpthread "/lib64/libSDL2-2.0.so.0.3200.4")
#    find_package(SDL2 REQUIRED SDL2)
#    include_directories(${SDL2_INCLUDE_DIRS})
#    target_link_libraries(LGFX_SDL -lpthread ${SDL2_LIBRARIES})

ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")

    target_include_directories(LGFX_SDL PUBLIC "C:/SDL2/include")

    target_link_libraries(LGFX_SDL PUBLIC "C:/SDL2/lib/x64/SDL2.lib")


    add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
    add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
    add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/Zc:__cplusplus>")

ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Darwin")

    find_package(SDL2 REQUIRED COMPONENTS SDL2)
    target_link_libraries(LGFX_SDL PRIVATE SDL2::SDL2)

ENDIF ()

target_compile_features(LGFX_SDL PUBLIC cxx_std_17)

can grb bigcards.h from my git here..

fun stuff.. ~q

so lots of progress yesterday but crashed early..

got mazes working on the q using a Modulino Movement on the mcu then using the spi lines between the mcu and mpu got my movements working nicely..

comment on the Modulino, let’s put them in nice cases, kind of scary holding/tilting a bare board to navigate, I think all the Modulino’s should be cased, just my opinion..

easy to hook up, plug, plug..

here’s the ino sketch for AppLab

#include "Modulino.h"
#include <SPI.h>
#include <zephyr/kernel.h>
#include <zephyr/drivers/spi.h>
#include <zephyr/device.h>

#define SPI3_NODE DT_NODELABEL(spi3)

#define DIR_STOP  0
#define DIR_UP    1
#define DIR_DWN   2
#define DIR_LEFT  3
#define DIR_RIGHT 4

ModulinoMovement imu;

char rx_buf[4];
char tx_buf[4] = {0xDE, 0xAD, 0xBE, 0xEF};

struct spi_config config = {
   .frequency = 4000000,
  .operation = SPI_OP_MODE_SLAVE | SPI_MODE_CPHA
     | SPI_TRANSFER_MSB | SPI_WORD_SET(8) | SPI_LINES_SINGLE,
   .slave = 0,
};

struct spi_buf spi_rx_buf[] = {
{
  .buf = rx_buf,
  .len = sizeof(rx_buf),
},
};

struct spi_buf spi_tx_buf[]{
  {
    .buf = tx_buf,
    .len = sizeof(tx_buf) / 2,
  },
{
   .buf = tx_buf + sizeof(tx_buf) / 2,
  .len = sizeof(tx_buf) /2,
},
};

struct spi_buf_set rx_set = {
  .buffers = spi_rx_buf,
   .count = sizeof(spi_rx_buf) / sizeof(spi_rx_buf[0]),
};


struct spi_buf_set tx_set = {
  .buffers = spi_tx_buf,
   .count = sizeof(spi_tx_buf) / sizeof(spi_tx_buf[0]),
};


const struct device *spi;

//IMU Values
float xValue = 0;
float yValue = 0;
//zero is not zero
float xZero,yZero;
//tilt threshold
const float thresh = 0.10;

void setup() {

  Serial.begin(115200);
  
  Serial.println("Mazes SPI IMU..");
   
  spi = DEVICE_DT_GET(SPI3_NODE);
  if (!device_is_ready(spi)){
    Serial.println("SPI not ready..");
  }

  Modulino.begin();
  imu.begin();
  delay(1000);
  imu.update();
  delay(1000);
  xZero = imu.getX();
  yZero = imu.getY();
  
  }

void loop(){

  imu.update();
  
  xValue = imu.getX();
  yValue = imu.getY();
  
  byte dir = DIR_STOP;
  
  if (xValue < (xZero - thresh)){
    //left
    dir = DIR_LEFT;
  } else if (xValue > (xZero + thresh)){
    //right
    dir = DIR_RIGHT;
  }
  if (dir == DIR_STOP){
    if (yValue < (yZero - thresh)){
      //down
      dir = DIR_DWN;
    } else if (yValue > (yZero + thresh)){
      //up
      dir = DIR_UP;
    }
  }

 for (int i = 0 ; i < 4; i++) tx_buf[i] = dir; 
  //blocking call..
 int nRet = spi_transceive(spi, &config, &tx_set, &rx_set); 
}

here’s the modified maze code for the mpu side..

/*
 * Nesso Mazes - SDL Linux UnoQ port
 * 1.14.2026 ~q
 * 
 * */

#define LGFX_USE_V1
#include <LovyanGFX.hpp>
#include <LGFX_AUTODETECT.hpp>
#include <stack>
#include <ctime>
#include <QSPI.h>


QSPI qspi;

// nessy
// LGFX Display( 135, 240 );
// tab5
LGFX Display(1280, 720);

#define HIGH 1
#define LOW 0

#define BLACK 0x0000
#define WHITE 0xFFFF
#define YELLOW 0xFFE0
#define GREEN 0x07E0

#define DIR_STOP 0
#define DIR_UP 1
#define DIR_DWN 2
#define DIR_LEFT 3
#define DIR_RIGHT 4
// max maze size
#define MAX_HEIGHT 40
#define MAX_WIDTH 60

int8_t LastDir = DIR_STOP;
int8_t CameFrom = DIR_STOP;
// size of the maze..
int8_t MazeWidth = 50;
int8_t MazeHeight = 28;
// cell size in pixels..
int8_t CellSize = 25;
// player size in pixels..
int8_t PlayerSize = 6;
// data that needs stacked..
struct MazeCell
{
  int8_t x;
  int8_t y;
  int8_t Dirs[4];
  int8_t DirStep;
};
// our cell..
MazeCell Cell;
// player position within the maze..
struct PosPlayer
{
  int8_t x;
  int8_t y;
};
PosPlayer PlayerPos;
// dir bit fields or'd into maze cells..
enum
{
  N = 1,
  E = 4,
  S = 2,
  W = 8
};
// directions
int8_t directions[4] = {N, E, S, W};
// direction movements..
int8_t DX[9];
int8_t DY[9];
// opposite directions
int8_t OPPS[9];
// maze Grid..
int8_t MAZE[MAX_WIDTH][MAX_HEIGHT];
int8_t SOL[MAX_WIDTH][MAX_HEIGHT];
// our stack of cells..
std::stack<MazeCell> q;
// need a gap to see outer walls..
int gap = CellSize / 2;
int border_x, border_y;

// IMU values
float xValue = 0;
float yValue = 0;
// zero might not be zero
float xZero, yZero;
// tilt threshold
const float thresh = 0.10;

// initial starting pos, top right, exit is bottom left..
int playerX = 0;
int playerY = 0;

unsigned long now, lastMove;
bool debug = false;
// maze speed, increase to 1000 when debugging..
unsigned long delayMove = 100;
enum statesSystem
{
  state_Splash = 0,
  state_Maze = 1,
  state_Info = 2,
  state_Wait = 3,
  state_WaitBtn = 4,
  state_Launch = 5
};

// current state
statesSystem stateSystem = state_Splash;
// the next state
statesSystem nextState = state_Maze;

struct ScreenButton
{
  int x;
  int y;
  int w;
  int h;
};

ScreenButton Buttons[3];

unsigned long waitStart;
unsigned long waitFor;

unsigned long lastButton;
unsigned long btnDebounce = 50;
int lastBtnState = HIGH;

unsigned long lastTouch;
unsigned long touchDebounce = 200;

uint8_t spiBuf[4];

// music player globals
int Music_Tempo = 240;
int Music_WholeNote = (60000 * 4) / Music_Tempo;
int Music_Note;
int Note_Divider = 0;
int CurrNote = -2;
bool NotePlaying = false;
unsigned long NoteStart, NoteDuration;
bool Music_Enabled = false;
int Music_Song = 0;

const int16_t MusicTempos[] = {150,
                               300,
                               600,
                               400,
                               400,
                               300,
                               300};

// forward declarations..
void ShuffleDirections(int8_t *dirs, int size);
void CarveMaze();
void SerialPrintMaze();
void DrawMaze(uint16_t color);
void LaunchMaze();
bool SolveMazeStep();
bool CheckDir(int dir);
void StepMaze();
void StepSolution();
void drawPlayer(uint16_t color);
void ScreenSplash();
void ScreenInfo();
bool TouchArea(int px, int py, int x, int y, int w, int h);
void CheckScreenTouch(int tx, int ty);
unsigned long millis();
int ReadImuQspi();

unsigned long millis()
{
  
  unsigned long ms = lgfx::millis();
  return ms;
}

//read imu data from mcu using qspi..
int ReadImuQspi(){
	int ret;
	spiBuf[0] = 0xdd;
	spiBuf[1] = 0xee;
	spiBuf[2] = 0xaa;
	spiBuf[3] = 0xdd;
	ret = qspi.transceive(spiBuf,sizeof(spiBuf));
	if (ret == 4){
		if (spiBuf[0] != 0xff){
			ret = spiBuf[0];
			} else ret = DIR_STOP;
		} else ret = DIR_STOP;
	return ret;
}


// Creates the maze..
void CreateMaze()
{
  // opposites
  OPPS[N] = S;
  OPPS[S] = N;
  OPPS[E] = W;
  OPPS[W] = E;
  // direction steps..
  DX[N] = 0;
  DX[E] = 1;
  DX[S] = 0;
  DX[W] = -1;
  DY[N] = -1;
  DY[E] = 0;
  DY[S] = 1;
  DY[W] = 0;
  // initialize random..
  // randomSeed(analogRead(0));
  srand(time(0));
  // out with the old..
  memset(&MAZE[0], 0, sizeof(MAZE));
  memset(SOL[0], 0, sizeof(SOL));
  // shuffle the directions..
  ShuffleDirections(directions, 4);
  // init our first cell..
  Cell.x = 0;
  Cell.y = 0;
  Cell.DirStep = 0;
  Cell.Dirs[0] = directions[0];
  Cell.Dirs[1] = directions[1];
  Cell.Dirs[2] = directions[2];
  Cell.Dirs[3] = directions[3];
  // push the cell to the stack
  q.push(Cell);
  // carve the maze passages..
  CarveMaze();
  // place our player into a maze cell..
  PlayerPos.x = 0;
  PlayerPos.y = 0;
}

// Shuffles a byte array..
void ShuffleDirections(int8_t *dirs, int size)
{
  for (int i = 0; i < size; i++)
  {
    int r = i + (rand() % (size - i));
    int8_t temp = dirs[i];
    dirs[i] = dirs[r];
    dirs[r] = temp;
  }
}

// Carves passages into the maze grid..
// a recursive backtracking algorythm..
// uses iteration in place of recursion..
void CarveMaze()
{
  int dx, dy, nx, ny, cx, cy;
  int step, i;
  // loop until stack is empty..
  while (not q.empty())
  {
    // get top cell..
    Cell = q.top();
    cx = Cell.x;
    cy = Cell.y;
    step = Cell.DirStep;
    for (i = 0; i < 4; i++)
      directions[i] = Cell.Dirs[i];
    // check all 4 directions..
    for (i = step; i < 4; i++)
    {
      dx = DX[directions[i]];
      dy = DY[directions[i]];
      nx = cx + dx;
      ny = cy + dy;
      // check valid grid cell..
      if (((nx < MazeWidth) & (nx >= 0)) & ((ny < MazeHeight) & (ny >= 0)))
      {
        // check if it empty..
        if (MAZE[nx][ny] == 0)
        {
          // valid cell, let's tunnel into it..
          MAZE[cx][cy] = (int8_t)((int8_t)MAZE[cx][cy] | (int8_t)directions[i]);
          MAZE[nx][ny] = (int8_t)((int8_t)MAZE[nx][ny] | (int8_t)OPPS[directions[i]]);
          // replace old cell..
          q.pop();
          // if we really need to come back here..
          if (i < 3)
          {
            Cell.DirStep = i;
            q.push(Cell);
          }
          // stack the new cell..
          Cell.x = nx;
          Cell.y = ny;
          Cell.DirStep = 0;
          // shuffle directions..
          ShuffleDirections(directions, 4);
          for (int j = 0; j < 4; j++)
            Cell.Dirs[j] = directions[j];
          q.push(Cell);
          // break out and tunnel into new cell..
          break;
        } // if empty cell
      } // valid grid pos
    } // for all directions..
    // pop the stack if we visited all dirs..
    if (i == 4)
      q.pop();
    // don't be a hog!!
    //  yield();
  } // while stack not empty..
}

// prints the maze in ascii to the serial monitor..
// don't look too hard, you may go cross eyed.. :)
void SerialPrintMaze()
{
  for (int x = 0; x < (MazeWidth * 2); x++)
    printf("_");
  printf("\n");
  for (int y = 0; y < MazeHeight; y++)
  {
    printf("|");
    for (int x = 0; x < MazeWidth; x++)
    {
      printf(((MAZE[x][y] & S) != 0) ? " " : "_");
      if ((MAZE[x][y] & E) != 0)
      {
        printf((((MAZE[x][y] | MAZE[x + 1][y]) & S) != 0) ? " " : "_");
      }
      else
      {
        printf("|");
      }
    }
    printf("\n");
  }
}

// draw the maze to the display..
// draws cell by cell..
void DrawMaze(uint16_t color)
{
  int x, y, posx, posy, ex, ey, cell;
  x = 0;
  y = 0;
  cell = 0;
  gap = CellSize / 2;
  border_y = Display.height() - (CellSize * MazeHeight);
  border_x = Display.width() - (CellSize * MazeWidth);
  border_y = border_y / 2;
  border_x = border_x / 2;
  posx = border_x;
  posy = border_y;
  ey = 1;
  ex = CellSize;
  Display.fillScreen(TFT_BLACK);
  for (y = 0; y < MazeHeight; y++)
  {
    for (x = 0; x < MazeWidth; x++)
    {
      posx = (x * CellSize) + border_x;
      posy = (y * CellSize) + border_y;
      ey = posy;
      ex = posx + CellSize;
      // top
      if ((MAZE[x][y] & N) == 0)
        Display.drawLine(posx, posy, ex, ey, color);
      ey = posy + CellSize;
      ex = posx;
      // left
      if ((MAZE[x][y] & W) == 0)
        Display.drawLine(posx, posy, ex, ey, color);
      posy = posy + CellSize;
      ex = posx + CellSize;
      ey = posy;
      // bottom
      if ((MAZE[x][y] & S) == 0)
        Display.drawLine(posx, posy, ex, ey, color);
      posx += CellSize;
      ex = posx;
      ey = posy - CellSize;
      // if not the exit..
      if ((x == MazeWidth - 1) && (y == MazeHeight - 1))
      {
        // if (debug) Serial.println("Door");
      }
      else
      {
        // right
        if ((MAZE[x][y] & E) == 0)
          Display.drawLine(posx, posy, ex, ey, color);
      }
    }
  }
}

void LaunchMaze()
{
  Display.fillScreen(TFT_BLACK);
  // speed check vars..
  unsigned long start, end;
  while (!q.empty())
    q.pop();
  // how much ram free before..
  // Serial.printf("Starting heap Available: %d\n", ESP.getFreeHeap());
  start = millis();
  CreateMaze();
  end = millis();
  // how long..
  printf("Maze Generation Completed Millis: %d\n", (end - start));
  // subtract from above, looks like about 356b, stays the same after
  // multiple maze generations..
  // Serial.printf("Ending heap Available: %d\n", ESP.getFreeHeap());
  // print it out to the serial monitor..
  SerialPrintMaze();
  // draw it on the screen..
  DrawMaze(YELLOW);

  // push the first cell into the q..
  // this is for the auto solve..
  directions[0] = N;
  directions[1] = E;
  directions[2] = S;
  directions[3] = W;
  Cell.x = 0;
  Cell.y = 0;
  Cell.DirStep = 0;
  for (int i = 0; i < 4; i++)
    Cell.Dirs[i] = directions[i];
  // push the cell to the stack
  q.push(Cell);

  stateSystem = state_Maze;
}

// solves a maze one step at a time..
// very simular to the maze construction..
bool SolveMazeStep()
{
  bool result = false;
  int dx, dy, nx, ny, cx, cy;
  int step, i;
  // if stack is not empty..
  if (!q.empty())
  {
    // get top cell..
    Cell = q.top();
    cx = Cell.x;
    cy = Cell.y;
    PlayerPos.x = cx;
    PlayerPos.y = cy;
    step = Cell.DirStep;
    // check all 4 directions..
    for (i = step; i < 4; i++)
    {
      // calc new pos
      dx = DX[directions[i]];
      dy = DY[directions[i]];
      nx = cx + dx;
      ny = cy + dy;
      if (((MAZE[cx][cy] & directions[i]) != 0) && (SOL[nx][ny] == 0))
      {
        SOL[nx][ny] = 1; // mark cell visited..
        // move into new cell..
        q.pop();
        // come back here..
        Cell.DirStep = i;
        q.push(Cell);
        PlayerPos.x = nx;
        PlayerPos.y = ny;
        // is it the exit..
        if (nx == MazeWidth && ny == MazeHeight)
        {
          // all done.. empty the q..
          while (!q.empty())
            q.pop();
          result = true;
          break;
        }
        // stack the new cell..
        Cell.x = nx;
        Cell.y = ny;
        Cell.DirStep = 0;
        q.push(Cell);
        // break out and tunnel into new cell..
        // printf("moving into new cell x: %d y: %d\n",nx,ny);
        break;
      }
    } // for all directions..
    // pop the stack if we visited all dirs..
    if (i == 4)
      q.pop();
    // don't be a hog!!
    //  yield();
  }
  else // if stack not empty..
    result = true;
  return result;
}

bool CheckDir(int dir)
{
  bool result = false;

  switch (dir)
  {
  case DIR_LEFT:
    if ((MAZE[PlayerPos.x][PlayerPos.y] & W) == 0)
      result = false;
    else
      result = true;
    break;
  case DIR_UP:
    if ((MAZE[PlayerPos.x][PlayerPos.y] & N) == 0)
      result = false;
    else
      result = true;
    break;
  case DIR_RIGHT:
    if ((MAZE[PlayerPos.x][PlayerPos.y] & E) == 0)
      result = false;
    else
      result = true;
    break;
  case DIR_DWN:
    if ((MAZE[PlayerPos.x][PlayerPos.y] & S) == 0)
      result = false;
    else
      result = true;
    break;
  }
  return result;
}

// step the maze solution..
void StepSolution()
{
  // move the user if allowed
  // erase last pos..
  playerX = PlayerPos.x;
  playerY = PlayerPos.y;
  SolveMazeStep();
  if (playerX != PlayerPos.x || playerY != PlayerPos.y)
  {
    int ny = PlayerPos.y;
    int nx = PlayerPos.x;
    PlayerPos.x = playerX;
    PlayerPos.y = playerY;
    drawPlayer(BLACK);
    PlayerPos.x = nx;
    PlayerPos.y = ny;
    drawPlayer(WHITE);
  }
}


//step the maze
void StepMaze(){
int dir = ReadImuQspi();
drawPlayer(WHITE);
  bool canMove = dir != DIR_STOP;
  canMove = CheckDir(dir);
  if (canMove){
	  int nextX = PlayerPos.x;
	  int nextY = PlayerPos.y;
	  //computer new position..
	  switch (dir){
		  case DIR_LEFT: nextX -= 1;
		    if (nextX < 0 ) canMove = false;
		    break;
		  case DIR_UP: nextY -= 1;
		  if (nextY < 0) canMove = false;
		   break;
		  case DIR_RIGHT: nextX += 1;
		    if (nextX > MazeWidth -1) canMove = false;
		    break;
		  case DIR_DWN: nextY += 1;
		    if (nextY > MazeHeight - 1) canMove = false;
		    break;     
	  }
	  if (canMove){
		  //erase player
		  drawPlayer(BLACK);
		  PlayerPos.x = nextX;
		  PlayerPos.y = nextY;
		  drawPlayer(WHITE);
		  }
	  }	
	
}

// draw player into a new cell of the maze..
// also checks for completion and creates new maze..
void drawPlayer(uint16_t color)
{
  int g = (CellSize - (PlayerSize * 2)) / 4;

  // are we done..
  if (PlayerPos.x == MazeWidth - 1 && PlayerPos.y == MazeHeight - 1)
  {
    LaunchMaze();
  }
  else
  {
    // translate grid to screen cords..
    playerX = ((PlayerPos.x * CellSize) + (CellSize / 2) + (PlayerSize / 2) + border_x) - g;
    playerY = ((PlayerPos.y * CellSize) + (CellSize / 2) + (PlayerSize / 2) + border_y) - g;
    // draw the player..
    Display.fillCircle(playerX, playerY, PlayerSize, color);
  }
}

void ScreenSplash()
{
  int tw, th, tx, ty, sh, sw;
  sh = Display.height();
  sw = Display.width();
  Display.fillScreen(TFT_BLACK);
  // bigger text for tab5
  if (sh > 500)
    Display.setTextSize(6);
  else
    Display.setTextSize(2);

  th = Display.fontHeight();
  tw = Display.textWidth("Q Mazes");
  tx = (Display.width() / 2) - (tw / 2);
  ty = (Display.height() / 2) - (th / 2);
  CreateMaze();
  DrawMaze(YELLOW);
  Display.fillRect(tx - 6, ty - 6, tw + 12, th + 12, BLACK);
  Display.drawRect(tx - 6, ty - 6, tw + 12, th + 12, YELLOW);
  Display.drawString("Q Mazes", tx, ty);
  waitStart = now;
  waitFor = 5000;
  stateSystem = state_Wait;
  nextState = state_Launch;
}

void ScreenInfo()
{
  int tw, th, tx, ty, gap, border, sh, sw, nw, cw, ch;

  sh = Display.height();
  sw = Display.width();
  printf("Screen H: %d W: %d\n", sh, sw);
  border = 2;
  gap = 2;

  Display.fillScreen(TFT_BLACK);
  if (sh > 500)
    Display.setTextSize(4);
  else
    Display.setTextSize(2);

  Display.setTextColor(WHITE, BLACK);
  // x,y
  tx = border;
  ty = border;
  // 3 cols 2 rows..
  cw = (sw - ((border * 2) + (gap * 2))) / 3;
  ch = (sh - ((border * 2) + (gap * 2))) / 2;
  printf("Cell H: %d W: %d\n", ch, cw);

  tw = Display.textWidth("Music");
  th = Display.fontHeight() + gap;
  Display.drawRect(tx, ty, cw, th, YELLOW);
  Display.drawString("Music", tx + 6, ty + 1);
  ty += th + gap;
  Display.drawRect(tx, ty, cw, ch - (th + gap), YELLOW);
  Buttons[0].x = tx;
  Buttons[0].y = ty;
  Buttons[0].w = cw;
  Buttons[0].h = ch - (th + gap);

  if (Music_Enabled)
  {
    nw = Display.textWidth("On");
    Display.drawString("On", (tx + 6) + (nw / 2), ty + 12);
  }
  else
  {
    nw = Display.textWidth("Off");
    Display.drawString("Off", (tx + 6) + (nw / 2), ty + 12);
  }
  tx += cw + gap;
  ty = border;
  Display.drawRect(tx, ty, cw, th, YELLOW);
  Display.drawString("Song", tx + 6, ty + 1);
  ty += th + gap;
  Display.drawRect(tx, ty, cw, ch - (th + gap), YELLOW);
  Buttons[1].x = tx;
  Buttons[1].y = ty;
  Buttons[1].w = cw;
  Buttons[1].h = ch - (th + gap);
  nw = Display.textWidth("0");

  Display.drawNumber(Music_Song + 1, tx + (nw / 2) + (tw / 2), ty + 12);
  tx += cw + gap;
  ty = border;
  Display.drawRect(tx, ty, cw, ch, YELLOW);
  Display.drawString("BattV", tx + 6, ty + 6);
  ty += th + gap;
  Display.drawRect(tx, ty, cw, ch - (th + gap), YELLOW);

  nw = Display.textWidth("9.9");
  // 3800 is milli volts..
  Display.drawFloat(3800 * 0.001, 1, (tx) + (nw / 2), ty + 12);

  tx = border;
  ty = ch + gap + border;
  Display.drawRect(tx, ty, sw - (tx * 2), ch - gap, YELLOW);
  Buttons[2].x = tx;
  Buttons[2].y = ty;
  Buttons[2].w = sw - (tx * 2);
  Buttons[2].h = (sh - ty) - 10;
  nw = (sw - (tx * 2)) - 4;
  int cl = 96; // simulated batt level
  if (cl < 100)
  {
    float multi = cl / 100.0;
    nw = nw * multi;
  }
  Display.fillRect(tx + 2, ty + 2, nw, ch - (gap * 2) - 2, GREEN);
  Display.drawNumber(cl, (sw / 2) - (tw / 2) + 5, ty + 12);
  stateSystem = state_WaitBtn;
}

bool TouchArea(int px, int py, int x, int y, int w, int h)
{
  bool result = false;
  int x2 = x + w;
  int y2 = y + h;
  int touch_x = px;
  int touch_y = py;
  if ((touch_x >= x) && (touch_x <= x2) && (touch_y >= y) && (touch_y <= y2))
    result = true;
  if (debug)
  {
    printf("X: %d , X1: %d, Y: %d, Y1: %d\n", touch_x, x, touch_y, y);
    printf("Matched :%d \n", result);
  }
  return result;
}

void CheckScreenTouch(int tx, int ty)
{
  int nw;
  // only have 1 screen to watch..
  if (TouchArea(tx, ty, Buttons[0].x, Buttons[0].y, Buttons[0].w, Buttons[0].h))
  {
    // touch on button 1 - music on/off toggle
    if (debug)
      printf("Button 1 touched..\n");
    Display.fillRect(Buttons[0].x + 2, Buttons[0].y + 2, Buttons[0].w - 4, Buttons[0].h - 4, BLACK);

    if (Music_Enabled)
    {
      Music_Enabled = false;
      // noTone(TONE_PIN);
      nw = Display.textWidth("Off");
      Display.setTextColor(WHITE, BLACK);
      Display.drawString("Off", Buttons[0].x + 6 + (nw / 2), Buttons[0].y + 12);
    }
    else
    {
      Music_Enabled = true;
      nw = Display.textWidth("On");
      Display.setTextColor(WHITE, BLACK);
      Display.drawString(" On", Buttons[0].x + 6 + (nw / 2), Buttons[0].y + 12);
    }
  }
  else if (TouchArea(tx, ty, Buttons[1].x, Buttons[1].y, Buttons[1].w, Buttons[1].h))
  {
    // touch on button 2 - song button select
    if (debug)
      printf("Button 2 touched..\n");
    bool isEnabled = Music_Enabled;
    Music_Enabled = false;
    Music_Song++;
    if (Music_Song > (sizeof(MusicTempos) / sizeof(MusicTempos[0])) - 1)
      Music_Song = 0;
    CurrNote = -2;
    Music_Enabled = isEnabled;
    // remove old text..
    printf("height : %d\n", Buttons[1].h);
    Display.fillRect(Buttons[1].x + 2, Buttons[1].y + 2, Buttons[1].w - 4, Buttons[1].h - 4, BLACK);
    nw = Display.textWidth("0");
    Display.setTextColor(WHITE, BLACK);
    Display.drawNumber(Music_Song + 1, Buttons[1].x + (nw / 2) + ((Buttons[1].w - 12) / 2), Buttons[1].y + 12);
  }
  else if (TouchArea(tx, ty, Buttons[2].x, Buttons[2].y, Buttons[2].w, Buttons[2].h))
  {
    // close the info screen on battery level touch..
    DrawMaze(YELLOW);
    stateSystem = state_Maze;
  }
}

void setup()
{
 //init the screen..
  Display.init();
  
  if (! qspi.begin()){
	  printf("spi failed to start..\n");
  }
  
 
}

void loop()
{

  now = millis();

  lgfx::touch_point_t tp;
  if (Display.getTouch(&tp))
  {
    if (now - lastTouch >= touchDebounce)
    {
      // got a touch..
      lastTouch = now;
      if (stateSystem == state_WaitBtn)
      {
        // info screen is up, process touches..
        CheckScreenTouch(tp.x, tp.y);
      }
      else if (stateSystem == state_Maze)
      {
        stateSystem = state_Info;
      }
    }
  }
  
  

  switch (stateSystem)
  {
  case state_Maze:
    if (now - lastMove >= delayMove)
    {
      lastMove = now;
      StepMaze();
    }
    break;
  case state_Splash:
    ScreenSplash();
    break;
  case state_Info:
    ScreenInfo();
    break;
  case state_Wait:
    if (now - waitStart >= waitFor)
    {
      stateSystem = nextState;
    }
    break;
  case state_Launch:
    LaunchMaze();
    break;
  }

  lgfx::delay(10);

}

CMakeFiles.txt for mpu code..

# See how to install sdl2: https://wiki.libsdl.org/SDL2/Installation
cmake_minimum_required (VERSION 3.10)
project(LGFX_SDL)

add_definitions(-DLGFX_SDL)


file(GLOB Target_Files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS 
    *.cpp
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/Fonts/efont/*.c
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/Fonts/IPA/*.c
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/utility/*.c
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/v1/*.cpp
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/v1/misc/*.cpp
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/v1/panel/Panel_Device.cpp
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/v1/panel/Panel_FrameBufferBase.cpp
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/v1/platforms/sdl/*.cpp
    /home/arduino/projects/libs/QSPI/*.cpp
    )
add_executable (LGFX_SDL ${Target_Files})

target_include_directories(LGFX_SDL PUBLIC "/home/arduino/projects/libs/LovyanGFX/src/")
target_include_directories(LGFX_SDL PUBLIC "/home/arduino/projects/libs/QSPI/")

IF (CMAKE_SYSTEM_NAME MATCHES "Linux")

# Linux;

    target_include_directories(LGFX_SDL PUBLIC "/home/arduino/projects/libs/SDL2/include")
    target_include_directories(LGFX_SDL PUBLIC "/home/arduino/projects/libs/SDL2/src")
    target_link_libraries(LGFX_SDL PUBLIC -lpthread "/lib64/libSDL2-2.0.so.0.3200.4")

ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")

# Windows;
    target_include_directories(LGFX_SDL PUBLIC "C:/SDL2/include")

    target_link_libraries(LGFX_SDL PUBLIC "C:/SDL2/lib/x64/SDL2.lib")


    add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
    add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
    add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/Zc:__cplusplus>")

ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Darwin")

# MacOS(Darwin);
    find_package(SDL2 REQUIRED COMPONENTS SDL2)
    target_link_libraries(LGFX_SDL PRIVATE SDL2::SDL2)

ENDIF ()

target_compile_features(LGFX_SDL PUBLIC cxx_std_17)

got some joysticks comming with my 4gb.. :P

Check this forum thread for the QSPI lib..

have fun.. ~q

was reading the manual.. :slight_smile:

should do it at some point right??

saw we got some onboard leds MPU side..

got them blinking..

another small lib..

QLEDS.h

#pragma once

#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/types.h>

#define LED1_R 0
#define LED1_G 1
#define LED1_B 2
#define LED2_R 3
#define LED2_G 4
#define LED2_B 5



static const char *leds[] = {{"/sys/class/leds/red:user/brightness"},
                             {"/sys/class/leds/green:user/brightness"},
                             {"/sys/class/leds/blue:user/brightness"},
                             {"/sys/class/leds/red:panic/brightness"},
                             {"/sys/class/leds/green:wlan/brightness"},
                             {"/sys/class/leds/blue:bt/brightness"},};






class QLEDS {
    public:
       ~QLEDS(){};
        QLEDS(){};
      bool setLed(uint8_t led,uint8_t val);      
};

QLEDS.cpp

/*
 * Quick led lib for onboard MPU leds
 * Created  1.15.2026 ~q
 * 
 * 
*/

#include "QLEDS.h"

bool QLEDS::setLed(uint8_t led, uint8_t val){
	
	int fd,ret;
	bool result = false;
	
	 fd = open(leds[led],O_WRONLY);
	 if (fd < 0){
		 printf("Failed to open led file %d",led);
		 return result;
	 }
	    val+=48; 
		uint8_t buf[3] ={val,10,13};
	  ret = write(fd, &buf,2);
    
	if (ret < 1){
		printf("failed to write led file %d\n",led);
		close(fd);
		return result;
	}
	
	close(fd);
	result = true; 
  return result;	 
}

usage example..

#define LGFX_USE_V1
#include <LovyanGFX.hpp>
#include <LGFX_AUTODETECT.hpp>
#include <QLEDS.h>

QLEDS qleds;

uint8_t ledStates[3] = {0,0,0};
unsigned long rateBlink = 1000;
unsigned long lastBlink;

void setup()
{
	printf("Testing MPU LEDS");
}

void loop()
{
unsigned long now = lgfx::millis();
if (now - lastBlink >= rateBlink){
	lastBlink = now;
 for (int i = 0 ; i < 3; i++){
  ledStates[i]++;
  if (ledStates[i] > 1) ledStates[i] = 0;	
   qleds.setLed(i, ledStates[i]);
   lgfx::delay(500);
 }
} 
lgfx::delay(10);
}

CMakeLists.txt

cmake_minimum_required (VERSION 3.10)
project(LGFX_SDL)

add_definitions(-DLGFX_SDL)

file(GLOB Target_Files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS 
    *.cpp
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/Fonts/efont/*.c
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/Fonts/IPA/*.c
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/utility/*.c
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/v1/*.cpp
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/v1/misc/*.cpp
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/v1/panel/Panel_Device.cpp
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/v1/panel/Panel_FrameBufferBase.cpp    
    /home/arduino/projects/libs/LovyanGFX/src/lgfx/v1/platforms/sdl/*.cpp
    /home/arduino/projects/libs/QLEDS/*.cpp
    )
add_executable (LGFX_SDL ${Target_Files})

target_include_directories(LGFX_SDL PUBLIC "/home/arduino/projects/libs/LovyanGFX/src/")
target_include_directories(LGFX_SDL PUBLIC "/home/arduino/projects/libs/LovyanGFX/src/lgfx/v1/platforms/sdl/")
target_include_directories(LGFX_SDL PUBLIC "/home/arduino/projects/libs/QLEDS/")

IF (CMAKE_SYSTEM_NAME MATCHES "Linux")


    target_include_directories(LGFX_SDL PUBLIC "/home/arduino/projects/libs/SDL2/include")
    target_include_directories(LGFX_SDL PUBLIC "/home/arduino/projects/libs/SDL2/src")
    target_link_libraries(LGFX_SDL PUBLIC "/lib64/libSDL2-2.0.so.0.3200.4")
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")

    target_include_directories(LGFX_SDL PUBLIC "C:/SDL2/include")
    target_link_libraries(LGFX_SDL PUBLIC "C:/SDL2/lib/x64/SDL2.lib")
    add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
    add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
    add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/Zc:__cplusplus>")

ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Darwin")

    find_package(SDL2 REQUIRED COMPONENTS SDL2)
    target_link_libraries(LGFX_SDL PRIVATE SDL2::SDL2)

ENDIF ()

target_compile_features(LGFX_SDL PUBLIC cxx_std_17)

more fun stuff.. ~q

just got my 4gb Q delivered, thank you!!

and 2 Modulino Joysticks..

gonna be a fun weekend.. :slight_smile:

~q

here’s the joystick sketch..

i flipped the x,y so it worked nice how I held it..

much easier than tilting an imu..


#include <zephyr/kernel.h>
#include <zephyr/drivers/spi.h>
#include <zephyr/device.h>
#include <Modulino.h>

#define DIR_STOP  0
#define DIR_UP    1
#define DIR_DWN   2
#define DIR_LEFT  3
#define DIR_RIGHT 4

#define SPI3_NODE DT_NODELABEL(spi3)

ModulinoJoystick stick;

const int8_t Thresh = 50;
uint8_t Dir = DIR_STOP;

char rx_buf[4];
char tx_buf[4] = {0xDE, 0xAD, 0xBE, 0xEF};

struct spi_config config = {
   .frequency = 4000000,
  .operation = SPI_OP_MODE_SLAVE | SPI_MODE_CPHA
     | SPI_TRANSFER_MSB | SPI_WORD_SET(8) | SPI_LINES_SINGLE,
   .slave = 0,
};

struct spi_buf spi_rx_buf[] = {
{
  .buf = rx_buf,
  .len = sizeof(rx_buf),
},
};

struct spi_buf spi_tx_buf[]{
  {
    .buf = tx_buf,
    .len = sizeof(tx_buf) / 2,
  },
{
   .buf = tx_buf + sizeof(tx_buf) / 2,
  .len = sizeof(tx_buf) /2,
},
};

struct spi_buf_set rx_set = {
  .buffers = spi_rx_buf,
   .count = sizeof(spi_rx_buf) / sizeof(spi_rx_buf[0]),
};


struct spi_buf_set tx_set = {
  .buffers = spi_tx_buf,
   .count = sizeof(spi_tx_buf) / sizeof(spi_tx_buf[0]),
};




const struct device *spi;

void setup() {
  // put your setup code here, to run once:
   Serial.begin(115200);
  spi = DEVICE_DT_GET(SPI3_NODE);
  if (!device_is_ready(spi)){
    Serial.println("SPI not ready..");
  }

  Modulino.begin();
  stick.begin();
  stick.setDeadZone(20);
  

}

void loop() {

if (stick.update()){
  int8_t y = stick.getX();
  int8_t x = stick.getY();
  
   Dir = DIR_STOP;
  if ( y > Thresh){
    Dir = DIR_DWN;
  } else if( y < -Thresh){
    Dir = DIR_UP;
  }
  if (Dir == DIR_STOP){
    if (x > Thresh){
      Dir = DIR_RIGHT;
    } else if ( x< -Thresh){
      Dir = DIR_LEFT;
    }
  }
  

for (int i = 0 ; i < 4; i++) tx_buf[i] = Dir; 
  //blocking call..
 int nRet = spi_transceive(spi, &config, &tx_set, &rx_set);

 }

}  

missing the verify button, all we get is a run..

i’m going to investigate cli..

have fun.. ~q

There is a formal feature request here:

Arduino CLI will be a good option for this. If you are working from a shell on the UNO Q's Linux machine, it is preinstalled there. If you are instead developing the sketch on a standard PC, then you can install Arduino CLI on that machine:

https://arduino.github.io/arduino-cli/latest/installation/

You can use the following command to compile the sketch:

arduino-cli compile -b arduino:zephyr:unoq

If you run it from the sketch folder, that is all you need, but if you are running it from another working directory, just pass the path of the sketch (e.g., ~/ArduinoApps/someapp/sketch) as an argument to the command.

Arduino CLI will automatically use the same build profile as it does when you compile the sketch through running the App, so it will have access to the identical library dependencies.

Diving more into the SDL2..

Saw I was missing some add ons..

Used the Synaptic package manager I added the following..

libsdl2-image-2.0-0
libsdl2-ttf-2.0-0
libsdl2-mixer-2.0-0

then downloaded the source tar.gz files to my libs folder..

image formats

SDL_image

ttf fonts

SDL_ttf

audio mixer

SDL_mixer

extract tar files
tar -xf filename.tar

i renamed the folders, looks like this..

went through Lazy Foo's SDL tutorials..

I right click, open in private window on most everything, keeps ads at bay..

here’s a CMakeFiles.txt that can be used with SDL2 only..

cmake_minimum_required (VERSION 3.10)

project(hello)


file(GLOB Target_Files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS 
    *.cpp
    )
    
add_executable (hello ${Target_Files})

# SDL sources..
target_include_directories(hello PUBLIC "/home/arduino/projects/libs/SDL2/include")
target_include_directories(hello PUBLIC "/home/arduino/projects/libs/SDL2/src")
target_include_directories(hello PUBLIC "/home/arduino/projects/libs/SDL_image/include")
target_include_directories(hello PUBLIC "/home/arduino/projects/libs/SDL_image/src")
target_include_directories(hello PUBLIC "/home/arduino/projects/libs/SDL_ttf/")
target_include_directories(hello PUBLIC "/home/arduino/projects/libs/SDL_mixer/include")
target_include_directories(hello PUBLIC "/home/arduino/projects/libs/SDL_mixer/src")
# link to our pre-installed libs..
target_link_libraries(hello PUBLIC "/lib64/libSDL2-2.0.so.0.3200.4")
target_link_libraries(hello PUBLIC "/lib64/libSDL2_image-2.0.so.0.800.8")
target_link_libraries(hello PUBLIC "/lib64/libSDL2_ttf-2.0.so.0.2400.0")
target_link_libraries(hello PUBLIC "/lib64/libSDL2_mixer-2.0.so.0.800.1")



target_compile_features(hello PUBLIC cxx_std_17)

targeting SDL2 alone makes a much smaller executable but none of the above is needed if you are going to stick with LovyanGFX..

~q

still using my 2g..

got 1.7g free in root..

user was just over 1g free but lost about 300mb after the last core update, strange..

when I first login I launch a terminal and issue these command..

xset s off -dpms
sudo service arduino-router stop

the first one stops the screen from blanking out..

the second shuts down the router so I can use Serial1 for my debugging purposes..

I loaded PuTTY and connect to /dev/ttyHS1..

Was able to integrate arduino-cli into Geany, now I can compile everything using one ide..

Then I use arduino-app-cli to start and stop mcu sketches..

had some fun with the matrix..

Sketch.ino

#include <SPI.h>
#include <zephyr/kernel.h>
#include <zephyr/drivers/spi.h>
#include <zephyr/device.h>

#define SPI3_NODE DT_NODELABEL(spi3)

#include <Arduino_LED_Matrix.h>

Arduino_LED_Matrix matrix;

uint8_t rx_buf[104];
uint8_t tx_buf[104];


struct spi_config config = {
   .frequency = 5000000,
  .operation = SPI_OP_MODE_SLAVE | SPI_MODE_CPHA
     | SPI_TRANSFER_MSB | SPI_WORD_SET(8) | SPI_LINES_SINGLE,
   .slave = 0,
};

struct spi_buf spi_rx_buf[] = {
{
  .buf = rx_buf,
  .len = sizeof(rx_buf),
},
};

struct spi_buf spi_tx_buf[]{
  {
    .buf = tx_buf,
    .len = sizeof(tx_buf) / 2,
  },
{
   .buf = tx_buf + sizeof(tx_buf) / 2,
  .len = sizeof(tx_buf) /2,
},
};

struct spi_buf_set rx_set = {
  .buffers = spi_rx_buf,
   .count = sizeof(spi_rx_buf) / sizeof(spi_rx_buf[0]),
};


struct spi_buf_set tx_set = {
  .buffers = spi_tx_buf,
   .count = sizeof(spi_tx_buf) / sizeof(spi_tx_buf[0]),
};


const struct device *spi;


uint8_t logo[104] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1,1,1,0,0,0,1,1,1,0,0,
0,1,0,0,0,1,0,1,0,0,0,1,0,
1,0,0,0,0,0,1,0,0,1,0,0,1,
1,0,1,1,1,0,1,0,1,0,1,0,1,
1,0,0,0,0,0,1,0,0,1,0,0,1,
0,1,0,0,0,1,0,1,0,0,0,1,0,
0,0,1,1,1,0,0,0,1,1,1,0,0
};





void setup() {

  Serial1.begin(115200);
  
  spi = DEVICE_DT_GET(SPI3_NODE);
  
  if (!device_is_ready(spi))
  {
    Serial1.println("SPI not ready..");
  }
  
  matrix.begin();
  matrix.setGrayscaleBits(1);
  matrix.draw(logo);
  Serial1.println("Matrix starting up..");
}

void loop() {
 int nRet = spi_transceive(spi, &config, &tx_set, &rx_set);
  if (nRet == 104)
  {
	if (rx_buf[0] != 0xFF) matrix.draw(rx_buf);	  
  } else{
	  Serial1.print("nRet not 104 :");
	  Serial1.println(nRet);
	  delay(1000);
  }
 delay(1);	  
}

a terminal program to drive it..

matrix.cpp

/*
 * UnoQ MCU Matrix demo..
 * 
 * 
 * driving the martix from linux using SPI
 * 
 * */
#include <chrono>
#include <thread>
#include <time.h>
#include <stdint.h>
#include <cstring>
#include <QSPI.h>
#include <QLEDS.h>


#define ROWS 8
#define COLS 13

QSPI qspi;
QLEDS qleds;

//allows for the 100ms lit..
using namespace std::chrono_literals;

//64 bits..
unsigned long long now;

//logo, sketch starts and ends
uint8_t logo[104] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1,1,1,0,0,0,1,1,1,0,0,
0,1,0,0,0,1,0,1,0,0,0,1,0,
1,0,0,0,0,0,1,0,0,1,0,0,1,
1,0,1,1,1,0,1,0,1,0,1,0,1,
1,0,0,0,0,0,1,0,0,1,0,0,1,
0,1,0,0,0,1,0,1,0,0,0,1,0,
0,0,1,1,1,0,0,0,1,1,1,0,0
};


//mpu leds
uint8_t ledStates[3] = {0,0,0};
unsigned long rateBlink = 1000;
unsigned long long lastBlink;
//spi buf
uint8_t buf[104];
//grid buf
uint8_t grid[104];

unsigned long long lastSpi;
unsigned long intervalSpi = 1000;


int lastStep;
int lastRow,lastCol,lastPixel;

int currentAni = 0;
int passes = 10;

//fills matrix left to right then right to left..
bool fillWave()
{
	bool result = false;
	switch (lastStep){
		case 0: //start of ani..
		//clear
		memset(buf,0,sizeof(buf));
		memset(grid,0,sizeof(grid));
		lastRow = 0;
		lastCol = 0;
		lastPixel = 0;
		for (int i = 0; i < ROWS; i++)
		{
			lastPixel = (i*13);
			grid[lastPixel] = 1;
			
		}
		lastStep++;
		result = true;
		break;
		case 1:
		lastPixel = 0;
		lastCol++;
		if (lastCol < COLS){
		  for (int i = 0 ; i < ROWS; i++)
		  {
		    lastPixel = lastCol + (i*13);
		    grid[lastPixel] = 1;	  
		  }
		result = true;	
		} else { lastCol = COLS;
			     lastStep++;
			     memset(grid,0,sizeof(grid));
			     result = true;
			 }
		break;
		case 2:
		  lastPixel = 0;
		  lastCol--;
		  if (lastCol > 0)
		  {
		    for (int i = 0 ; i < ROWS; i++)
		     {
			  lastPixel = lastCol + (i*13);
			  grid[lastPixel] = 1;
		     }
		     result = true;
		  } else result = false;
    }//end switch
   //if we got a frame, copy it to spi buf 
  if (result) memmove(buf,grid,sizeof(buf));
	
	return result;
}




//millis
uint64_t GetTickCount()
 {
	struct timespec ts;
	clock_gettime(CLOCK_MONOTONIC, &ts);
	return (uint64_t)(ts.tv_sec) * 1000 + (uint64_t)(ts.tv_nsec / 1000000);
 }


void toggleLed()
{	
if (now - lastBlink >= rateBlink){
	lastBlink = now;
  ledStates[0]++;
  if (ledStates[0] > 1) ledStates[0] = 0;	
   qleds.setLed(LED1_G, ledStates[0]);
 } 
}


int main(){
	
  printf("Matrix demo starting up..\n");
  
 if (!qspi.begin()){
	  printf("failed to begin spi..");
  }
 
     
   //loop for 10 passes..
    while (passes > 0)
    {
	 //update now..	
	 now = GetTickCount();
	 //blink mpu green led
	 toggleLed();		
	 //update the frame buffer..	
     switch (currentAni)
      { 
		 case 0:if (!fillWave())
		 {
			// currentAni++;
			 lastStep = 0;
			 passes--;
		 }
		 break;
	  }		
		//send the matrix frame to mcu..
	  int ret = qspi.transceive(buf,sizeof(buf));

	 //slow us down a bit..	
     std::this_thread::sleep_for(100ms);//delay
	}
  	
  	//put the logo back up..
	qspi.transceive(logo,sizeof(logo));
	
	//trun all leds off..
	for (int i = 0; i < 3; i++)qleds.setLed(i,0);
	//bye bye..
	return 0;
}

the CMakeLists.txt

cmake_minimum_required (VERSION 3.12)
project(Matrix)


file(GLOB Target_Files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS 
    *.cpp
    /home/arduino/projects/libs/QSPI/*.cpp
    /home/arduino/projects/libs/QLEDS/*.cpp
    )
add_executable (Matrix ${Target_Files})

target_include_directories(Matrix PUBLIC "/home/arduino/projects/libs/QSPI/")
target_include_directories(Matrix PUBLIC "/home/arduino/projects/libs/QLEDS/")


target_compile_features(Matrix PUBLIC cxx_std_17)

I did modify QSPI and added fixed buffers..

QSPI.h

#pragma once

#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/types.h>
#include <linux/spi/spidev.h>

#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))


static const char *devspi = "/dev/spidev0.0";

class QSPI {
    public:
       ~QSPI();
        QSPI();
      bool begin();
      bool end();
      int transceive(uint8_t * buf,uint16_t len);      
    private:
      int _fd;
      bool _ready;
      uint8_t _tx_buf[2048];
      uint8_t _rx_buf[2048];
      uint8_t _mode;
      uint8_t _bits;
      uint32_t _speed;
      uint16_t _delay;
      uint8_t _size;
};

QSPI.cpp

/*
 * Quick spi lib for unoq mcu to mpu
 * Created  1.13.2026 ~q
 * 
 * 
*/

#include "QSPI.h"
#include <cstring>

QSPI::~QSPI(){
	if (_ready){
	close(_fd);
		}
	}

QSPI::QSPI(){
  //init some vars..
  _mode = 0;
  _bits=8;
  _speed= 5000000;
  _delay=0;
  _size=0; 
  _ready = false;
}


bool QSPI::begin(){
	if (_ready){
	 printf("already begun.\n");
	 return false;	
		}
	
	bool result = false;
	int ret = 0;
	//open spi dev
	_fd = open(devspi, O_RDWR);
	 if (_fd < 0){
		 printf("failed to open spi device.\n");
		 return result;
	 }
   //spi mode..
   ret = ioctl(_fd, SPI_IOC_WR_MODE, &_mode);
     if (ret == -1){
	printf("failed to set spi write mode..\n");	 
	 close(_fd);
	  return result;
	 }	 
   ret = ioctl(_fd, SPI_IOC_RD_MODE, &_mode);
     if (ret == -1){
	printf("failed to set spi read mode..\n");
	close(_fd);
	 return result;	 
	 }	 
  //bits per word	 
  ret = ioctl(_fd, SPI_IOC_WR_BITS_PER_WORD, &_bits);
  	 if (ret == -1){
	printf("failed to set bits per word.\n");
	  close(_fd);
	    return result;	 
		 }
  ret = ioctl(_fd, SPI_IOC_RD_BITS_PER_WORD, &_bits);
    if (ret == -1){
		printf("failed to set bit per word.\n");
		close(_fd);
		return result;
		} 	
   // max speed hz
   ret = ioctl(_fd, SPI_IOC_WR_MAX_SPEED_HZ, &_speed);
     if (ret == -1){
		 printf("failed to set speed.\n");
		 close(_fd);
		 return result;
		 }			 
   ret = ioctl(_fd, SPI_IOC_RD_MAX_SPEED_HZ, &_speed);
     if (ret == -1){
		 printf("failed to set speed.\n");
		 close(_fd);
		 return result;
		 }		
			 
	_ready = true;
	result = true;
	return result;	 
	}
	
bool QSPI::end(){
  if (!_ready){
	printf("have not begun..\n");
	return false;  
  }
  _ready = false;
  close(_fd);
  return true;
}
//sends and receives, returns the ret and copies rx to buf..
int QSPI::transceive(uint8_t * buf, uint16_t len){
	int ret = -1;
	if (len > sizeof(_tx_buf)) return -1;
	if (!_ready) return -1;
	memset(_rx_buf,0,sizeof(_rx_buf));
	memmove(_tx_buf,buf,len);
	//uint8_t *rx = (uint8_t*)malloc(len);
	 struct spi_ioc_transfer tr = {
		 .tx_buf       = (unsigned long)_tx_buf,
		 .rx_buf       = (unsigned long)_rx_buf,
		 .len          = len,
		 .speed_hz     = _speed,
		 .delay_usecs  = _delay,
		 .bits_per_word = _bits,
	};
	
	  ret = ioctl(_fd,SPI_IOC_MESSAGE(1), &tr);
	  if (ret < 1){
		 printf("failed to send spi message.\n");
		// free(rx);
		 return ret; 
		  }
	//copy rx to buf..
	memmove(buf,_rx_buf,len);
	//clean up..
//	free(rx);
	return ret;	  
}
	

fun stuff.. ~q

setting up the new 4gb..
curious, it's a bit different..
but i did also figure out how i managed to get locked out the first time on the 2gb..
when you first boot linux prompts to change password, which i did..
the AppLab starts and again asks me to change my password but this time when i try to use what i normally use, what linux had already accepted, i'm told not enough characters, wtf..
so, whatever i satisfied AppLab, then exited it, and changed my password back..
then i tried to run the Synaptic Package Manager, trying to get set back up..
strange, it wouldn't run until i also set a root password too..
when i did finally get in there, i see my sdl lib was already installed, thank you..
just downloaded the source and gfx..
bombed out linking, seems /lib64/ is now /usr/aarch64-linux-gnu/ ??
made the changes in the cmake files and all good..

strange..~q

Been busy sorry..
Much further along now..

Added libsdl2-gfx-1.0-0 using the Synaptic package manager..
then git cloned SDL2_gfx github..
Gives us some primitive shapes..

Was able to pretty quickly port both mazes and solitaire to straight SDL code..
For mazes it allows me to be able to use keyboard keys to navigate..
Both apps compile to much smaller sizes as they don't carry in the simulator..
here's mazes.cpp

#include <SDL.h>
#include <SDL2_gfxPrimitives.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <ctime>
#include <cstring>

//window dimension..
const int SCREEN_WIDTH = 1280;
const int SCREEN_HEIGHT = 720;



SDL_Window* window = NULL;
SDL_Renderer * renderer = NULL;

#define HIGH 1
#define LOW 0

#define BLACK 0x0000
#define WHITE 0xFFFF
#define YELLOW 0xFFE0
#define GREEN 0x07E0

#define DIR_STOP 0
#define DIR_UP 1
#define DIR_DWN 2
#define DIR_LEFT 3
#define DIR_RIGHT 4
// max maze size
#define MAX_HEIGHT 40
#define MAX_WIDTH 60

int8_t LastDir = DIR_STOP;
int8_t CameFrom = DIR_STOP;
// size of the maze..
int8_t MazeWidth = 25;
int8_t MazeHeight = 14;
// cell size in pixels..
int8_t CellSize = 50;
// player size in pixels..
int8_t PlayerSize = 12;
// data that needs stacked..
struct MazeCell
{
  int8_t x;
  int8_t y;
  int8_t Dirs[4];
  int8_t DirStep;
};
// our cell..
MazeCell Cell;
// player position within the maze..
struct PosPlayer
{
  int8_t x;
  int8_t y;
};
PosPlayer PlayerPos;
// dir bit fields or'd into maze cells..
enum
{
  N = 1,
  E = 4,
  S = 2,
  W = 8
};
// directions
int8_t directions[4] = {N, E, S, W};
// direction movements..
int8_t DX[9];
int8_t DY[9];
// opposite directions
int8_t OPPS[9];
// maze Grid..
int8_t MAZE[MAX_WIDTH][MAX_HEIGHT];
int8_t SOL[MAX_WIDTH][MAX_HEIGHT];
// our stack of cells..
std::stack<MazeCell> q;
// need a gap to see outer walls..
int gap = CellSize / 2;
int border_x, border_y;

// IMU values
float xValue = 0;
float yValue = 0;
// zero might not be zero
float xZero, yZero;
// tilt threshold
const float thresh = 0.10;

// initial starting pos, top right, exit is bottom left..
int playerX = 0;
int playerY = 0;
int NewDir = DIR_STOP;

unsigned long now, lastMove;
// maze speed..
unsigned long delayMove = 100;
unsigned long waitStart;
unsigned long waitFor;


// forward declarations..
void ShuffleDirections(int8_t *dirs, int size);
void CarveMaze();
void SerialPrintMaze();
void DrawMaze(uint16_t color);
void LaunchMaze();
bool SolveMazeStep();
bool CheckDir(int dir);
void StepMaze();
void StepSolution();
void drawPlayer(uint16_t color);
unsigned long millis();
void delay(unsigned long milliseconds);
bool init();
void close();
void checkKeyState();
  
void delay(unsigned long milliseconds){
	SDL_Delay(milliseconds);
}



unsigned long millis()
{  
	return SDL_GetTicks();
	//struct timespec ts;
	//clock_gettime(CLOCK_MONOTONIC, &ts);
	//return (uint32_t)(ts.tv_sec) * 1000 + (uint32_t)(ts.tv_nsec / 1000000);
}


// Creates the maze..
void CreateMaze()
{
  // opposites
  OPPS[N] = S;
  OPPS[S] = N;
  OPPS[E] = W;
  OPPS[W] = E;
  // direction steps..
  DX[N] = 0;
  DX[E] = 1;
  DX[S] = 0;
  DX[W] = -1;
  DY[N] = -1;
  DY[E] = 0;
  DY[S] = 1;
  DY[W] = 0;
  // initialize random..
  // randomSeed(analogRead(0));
  srand(time(0));
  // out with the old..
  memset(&MAZE[0], 0, sizeof(MAZE));
  memset(SOL[0], 0, sizeof(SOL));
  // shuffle the directions..
  ShuffleDirections(directions, 4);
  // init our first cell..
  Cell.x = 0;
  Cell.y = 0;
  Cell.DirStep = 0;
  Cell.Dirs[0] = directions[0];
  Cell.Dirs[1] = directions[1];
  Cell.Dirs[2] = directions[2];
  Cell.Dirs[3] = directions[3];
  // push the cell to the stack
  q.push(Cell);
  // carve the maze passages..
  CarveMaze();
  // place our player into a maze cell..
  PlayerPos.x = 0;
  PlayerPos.y = 0;
}

// Shuffles a byte array..
void ShuffleDirections(int8_t *dirs, int size)
{
  for (int i = 0; i < size; i++)
  {
    int r = i + (rand() % (size - i));
    int8_t temp = dirs[i];
    dirs[i] = dirs[r];
    dirs[r] = temp;
  }
}

// Carves passages into the maze grid..
// a recursive backtracking algorythm..
// uses iteration in place of recursion..
void CarveMaze()
{
  int dx, dy, nx, ny, cx, cy;
  int step, i;
  // loop until stack is empty..
  while (not q.empty())
  {
    // get top cell..
    Cell = q.top();
    cx = Cell.x;
    cy = Cell.y;
    step = Cell.DirStep;
    for (i = 0; i < 4; i++)
      directions[i] = Cell.Dirs[i];
    // check all 4 directions..
    for (i = step; i < 4; i++)
    {
      dx = DX[directions[i]];
      dy = DY[directions[i]];
      nx = cx + dx;
      ny = cy + dy;
      // check valid grid cell..
      if (((nx < MazeWidth) & (nx >= 0)) & ((ny < MazeHeight) & (ny >= 0)))
      {
        // check if it empty..
        if (MAZE[nx][ny] == 0)
        {
          // valid cell, let's tunnel into it..
          MAZE[cx][cy] = (int8_t)((int8_t)MAZE[cx][cy] | (int8_t)directions[i]);
          MAZE[nx][ny] = (int8_t)((int8_t)MAZE[nx][ny] | (int8_t)OPPS[directions[i]]);
          // replace old cell..
          q.pop();
          // if we really need to come back here..
          if (i < 3)
          {
            Cell.DirStep = i;
            q.push(Cell);
          }
          // stack the new cell..
          Cell.x = nx;
          Cell.y = ny;
          Cell.DirStep = 0;
          // shuffle directions..
          ShuffleDirections(directions, 4);
          for (int j = 0; j < 4; j++)
            Cell.Dirs[j] = directions[j];
          q.push(Cell);
          // break out and tunnel into new cell..
          break;
        } // if empty cell
      } // valid grid pos
    } // for all directions..
    // pop the stack if we visited all dirs..
    if (i == 4)
      q.pop();
    // don't be a hog!!
    //  yield();
  } // while stack not empty..
}

// prints the maze in ascii to the serial monitor..
// don't look too hard, you may go cross eyed.. :)
void SerialPrintMaze()
{
  for (int x = 0; x < (MazeWidth * 2); x++)
    printf("_");
  printf("\n");
  for (int y = 0; y < MazeHeight; y++)
  {
    printf("|");
    for (int x = 0; x < MazeWidth; x++)
    {
      printf(((MAZE[x][y] & S) != 0) ? " " : "_");
      if ((MAZE[x][y] & E) != 0)
      {
        printf((((MAZE[x][y] | MAZE[x + 1][y]) & S) != 0) ? " " : "_");
      }
      else
      {
        printf("|");
      }
    }
    printf("\n");
  }
}

// draw the maze to the display..
// draws cell by cell..
void DrawMaze(uint16_t color)
{
  int x, y, posx, posy, ex, ey, cell;
  x = 0;
  y = 0;
  cell = 0;
  gap = CellSize / 2;
  border_y = SCREEN_HEIGHT - (CellSize * MazeHeight);
  border_x = SCREEN_WIDTH - (CellSize * MazeWidth);
  border_y = border_y / 2;
  border_x = border_x / 2;
  posx = border_x;
  posy = border_y;
  ey = 1;
  ex = CellSize;
  //Display.fillScreen(TFT_BLACK);
  
  for (y = 0; y < MazeHeight; y++)
  {
    for (x = 0; x < MazeWidth; x++)
    {
      posx = (x * CellSize) + border_x;
      posy = (y * CellSize) + border_y;
      ey = posy;
      ex = posx + CellSize;
      // top
      if ((MAZE[x][y] & N) == 0)
        //Display.drawLine(posx, posy, ex, ey, color);
        lineRGBA(renderer, posx, posy, ex, ey, 255, 255, 0, 255);
      ey = posy + CellSize;
      ex = posx;
      // left
      if ((MAZE[x][y] & W) == 0)
        //Display.drawLine(posx, posy, ex, ey, color);
        lineRGBA(renderer, posx, posy, ex, ey, 255, 255, 0, 255);
      posy = posy + CellSize;
      ex = posx + CellSize;
      ey = posy;
      // bottom
      if ((MAZE[x][y] & S) == 0)
        //Display.drawLine(posx, posy, ex, ey, color);
        lineRGBA(renderer, posx, posy, ex, ey, 255, 255, 0, 255);
      posx += CellSize;
      ex = posx;
      ey = posy - CellSize;
      // if not the exit..
      if ((x == MazeWidth - 1) && (y == MazeHeight - 1))
      {
        // if (debug) Serial.println("Door");
      }
      else
      {
        // right
        if ((MAZE[x][y] & E) == 0)
          lineRGBA(renderer, posx, posy, ex, ey, 255, 255, 0, 255);
          //Display.drawLine(posx, posy, ex, ey, color);
      }
    }
  }
}

void LaunchMaze()
{
//  Display.fillScreen(TFT_BLACK);
  SDL_SetRenderDrawColor( renderer, 0x00, 0x00, 0x00, 0xFF );
  SDL_RenderClear( renderer );

  // speed check vars..
  unsigned long start, end;
  while (!q.empty())
    q.pop();
  // how much ram free before..
  // Serial.printf("Starting heap Available: %d\n", ESP.getFreeHeap());
  start = millis();
  CreateMaze();
  end = millis();
  // how long..
  printf("Maze Generation Completed Millis: %d\n", (end - start));
  // subtract from above, looks like about 356b, stays the same after
  // multiple maze generations..
  // Serial.printf("Ending heap Available: %d\n", ESP.getFreeHeap());
  // print it out to the serial monitor..
  SerialPrintMaze();
  // draw it on the screen..
  DrawMaze(YELLOW);

  // push the first cell into the q..
  // this is for the auto solve..
  directions[0] = N;
  directions[1] = E;
  directions[2] = S;
  directions[3] = W;
  Cell.x = 0;
  Cell.y = 0;
  Cell.DirStep = 0;
  for (int i = 0; i < 4; i++)
    Cell.Dirs[i] = directions[i];
  // push the cell to the stack
  q.push(Cell);
}

// solves a maze one step at a time..
// very simular to the maze construction..
bool SolveMazeStep()
{
  bool result = false;
  int dx, dy, nx, ny, cx, cy;
  int step, i;
  // if stack is not empty..
  if (!q.empty())
  {
    // get top cell..
    Cell = q.top();
    cx = Cell.x;
    cy = Cell.y;
    PlayerPos.x = cx;
    PlayerPos.y = cy;
    step = Cell.DirStep;
    // check all 4 directions..
    for (i = step; i < 4; i++)
    {
      // calc new pos
      dx = DX[directions[i]];
      dy = DY[directions[i]];
      nx = cx + dx;
      ny = cy + dy;
      if (((MAZE[cx][cy] & directions[i]) != 0) && (SOL[nx][ny] == 0))
      {
        SOL[nx][ny] = 1; // mark cell visited..
        // move into new cell..
        q.pop();
        // come back here..
        Cell.DirStep = i;
        q.push(Cell);
        PlayerPos.x = nx;
        PlayerPos.y = ny;
        // is it the exit..
        if (nx == MazeWidth && ny == MazeHeight)
        {
          // all done.. empty the q..
          while (!q.empty())
            q.pop();
          result = true;
          break;
        }
        // stack the new cell..
        Cell.x = nx;
        Cell.y = ny;
        Cell.DirStep = 0;
        q.push(Cell);
        // break out and tunnel into new cell..
        // printf("moving into new cell x: %d y: %d\n",nx,ny);
        break;
      }
    } // for all directions..
    // pop the stack if we visited all dirs..
    if (i == 4)
      q.pop();
    // don't be a hog!!
    //  yield();
  }
  else // if stack not empty..
    result = true;
  return result;
}

bool CheckDir(int dir)
{
  bool result = false;

  switch (dir)
  {
  case DIR_LEFT:
    if ((MAZE[PlayerPos.x][PlayerPos.y] & W) == 0)
      result = false;
    else
      result = true;
    break;
  case DIR_UP:
    if ((MAZE[PlayerPos.x][PlayerPos.y] & N) == 0)
      result = false;
    else
      result = true;
    break;
  case DIR_RIGHT:
    if ((MAZE[PlayerPos.x][PlayerPos.y] & E) == 0)
      result = false;
    else
      result = true;
    break;
  case DIR_DWN:
    if ((MAZE[PlayerPos.x][PlayerPos.y] & S) == 0)
      result = false;
    else
      result = true;
    break;
  }
  return result;
}

// step the maze solution..
void StepSolution()
{
  // move the user if allowed
  // erase last pos..
  playerX = PlayerPos.x;
  playerY = PlayerPos.y;
  SolveMazeStep();
  if (playerX != PlayerPos.x || playerY != PlayerPos.y)
  {
    int ny = PlayerPos.y;
    int nx = PlayerPos.x;
    PlayerPos.x = playerX;
    PlayerPos.y = playerY;
    drawPlayer(BLACK);
    PlayerPos.x = nx;
    PlayerPos.y = ny;
    drawPlayer(WHITE);
  }
}


//step the maze
void StepMaze(){

int dir = NewDir;
drawPlayer(WHITE);
  bool canMove = dir != DIR_STOP;
  canMove = CheckDir(dir);
  if (canMove){
	  int nextX = PlayerPos.x;
	  int nextY = PlayerPos.y;
	  //computer new position..
	  switch (dir){
		  case DIR_LEFT: nextX -= 1;
		    if (nextX < 0 ) canMove = false;
		    break;
		  case DIR_UP: nextY -= 1;
		  if (nextY < 0) canMove = false;
		   break;
		  case DIR_RIGHT: nextX += 1;
		    if (nextX > MazeWidth -1) canMove = false;
		    break;
		  case DIR_DWN: nextY += 1;
		    if (nextY > MazeHeight - 1) canMove = false;
		    break;     
	  }
	  if (canMove){
		  //erase player
		  drawPlayer(BLACK);
		  PlayerPos.x = nextX;
		  PlayerPos.y = nextY;
		  drawPlayer(WHITE);
		  }
	  }	
	
}

// draw player into a new cell of the maze..
// also checks for completion and creates new maze..
void drawPlayer(uint16_t color)
{
  int g = (CellSize - (PlayerSize * 2)) / 4;

  // are we done..
  if (PlayerPos.x == MazeWidth - 1 && PlayerPos.y == MazeHeight - 1)
  {
    LaunchMaze();
  }
  else
  {
    // translate grid to screen cords..
    playerX = ((PlayerPos.x * CellSize) + (CellSize / 2) + (PlayerSize / 2) + border_x) - g;
    playerY = ((PlayerPos.y * CellSize) + (CellSize / 2) + (PlayerSize / 2) + border_y) - g;
    // draw the player..
    //Display.fillCircle(playerX, playerY, PlayerSize, color);
    //black
    if (color == BLACK)
	filledCircleRGBA(renderer, playerX, playerY, PlayerSize, 0x00, 0x00, 0x00, 255);
	else
	//white
	filledCircleRGBA(renderer, playerX, playerY, PlayerSize, 0xFF, 0xFF, 0xFF, 255);
  }
}






bool init()
{
	//Initialization flag
	bool success = true;

	//Initialize SDL
	if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
	{
		printf( "SDL could not initialize! SDL Error: %s\n", SDL_GetError() );
		success = false;
	}
	else
	{
		//Set texture filtering to linear
		if( !SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "1" ) )
		{
			printf( "Warning: Linear texture filtering not enabled!" );
		}

		//Create window
		window = SDL_CreateWindow( "Q-Mazes", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
		if( window == NULL )
		{
			printf( "Window could not be created! SDL Error: %s\n", SDL_GetError() );
			success = false;
		}
		else
		{
			//Create vsynced renderer for window
			renderer = SDL_CreateRenderer( window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC );
			if( renderer == NULL )
			{
				printf( "Renderer could not be created! SDL Error: %s\n", SDL_GetError() );
				success = false;
			}
			else
			{   //launch a maze..
	            LaunchMaze();
				//update screen..
				SDL_RenderPresent( renderer );
			}
		}
	}

	return success;
}


void close()
{

	//Destroy window	
	SDL_DestroyRenderer( renderer );
	SDL_DestroyWindow( window );
	window = NULL;
	renderer = NULL;

	//Quit SDL
	SDL_Quit();
}


void checkKeyState()
{
	NewDir = DIR_STOP;
	const Uint8* currentKeyStates = SDL_GetKeyboardState( NULL);
	if ( currentKeyStates[ SDL_SCANCODE_UP])
	{
		//printf("Up\n");
		NewDir= DIR_UP;
	}
	else if (currentKeyStates[ SDL_SCANCODE_DOWN])
		{
			//printf("down\n");
			NewDir = DIR_DWN;
		}
	else if ( currentKeyStates[ SDL_SCANCODE_LEFT ])
	{
		//printf("left\n");
		NewDir = DIR_LEFT;
	}
	else if ( currentKeyStates [ SDL_SCANCODE_RIGHT])
	{
		//printf("right\n");
		NewDir = DIR_RIGHT;
	}
}
	

int main( int argc, char* args[] )
{
	//Start up SDL and create window
	if( !init() )
	{
		printf( "Failed to initialize!\n" );
	}
	else
	{
			//Main loop flag
			bool quit = false;

			//Event handler
			SDL_Event e;

			//While application is running
			while( !quit )
			{
				now = millis();
				//Handle events on queue
				while( SDL_PollEvent( &e ) != 0 )
				{
					//User requests quit
					if( e.type == SDL_QUIT )
					{
						quit = true;
					}
				//check keyboard..	
				checkKeyState();					
				}
				
				//is it time for a step..
			 if (now - lastMove >=delayMove){	
				 lastMove = now;
				StepMaze();
				//Update screen
				SDL_RenderPresent( renderer );
			}
		 SDL_Delay(10);								
		}
	}

	//Free resources and close SDL
	close();

	return 0;
}

and sol.cpp

#include "bigcards.h"
#include <SDL.h>
#include <SDL2_gfxPrimitives.h>
#include <stdio.h>
#include <cstring>
#include <cstdint>
#include <ctime>
#include <thread>


#define SDL_WHITE  (SDL_Color){255,255,255,255}
#define SDL_BLACK  (SDL_Color){0,0,0,255}
#define SDL_RED    (SDL_Color){255,0,0,255}
#define SDL_GREEN  (SDL_Color){0,255,0,255}
#define SDL_LGREEN (SDL_Color){0,128,0,255}
#define SDL_BLUE   (SDL_Color){0,0,255,255}
#define SDL_YELLOW (SDL_Color){255,255,0,255}

#define TFT_YELLOW    SDL_YELLOW
#define TFT_DARKGREEN SDL_LGREEN
#define TFT_GREEN     SDL_GREEN
#define TFT_WHITE     SDL_WHITE


//Screen dimension constants
const int SCREEN_WIDTH = 1280;
const int SCREEN_HEIGHT = 720;


SDL_Window   *window   = NULL;
SDL_Renderer *renderer = NULL;
SDL_Texture  *texture  = NULL;

int8_t ButtonWidth = 60;
int8_t ButtonHeight = 30;
int8_t CardWidth = 72;
int8_t CardHeight = 110;
int8_t CardBack = 52;
int8_t CardOL = 30;
int8_t Border = 20;
int8_t Gap = 30;

int TableWidth = (CardWidth * 7) + (Gap * 6) + (Border * 2);
int TableHeight = (CardHeight * 2) + (Border * 2) + (CardOL * 12) + (Gap *2) + ButtonHeight;
int TableLeft = (SCREEN_WIDTH - TableWidth) / 2;
int TableTop = (SCREEN_HEIGHT - TableHeight) / 2;

int8_t Deck[52];

int8_t HiddenTabs[6][6];
int8_t Tableau[7][13];
int8_t Foundations[4][13];
int8_t Stock[24];
int8_t Waste[24];

int8_t StockCount = 0;
int8_t WasteCount = 0;
int8_t CurrentCard = 0;
int8_t TableauCounts[7] = {0, 0, 0, 0, 0, 0, 0};
int8_t HiddenCounts[7] = {0, 0, 0, 0, 0, 0, 0};
int8_t FoundationCounts[4] = {0, 0, 0, 0};
int8_t SelectedCard = -1;
int8_t SelectedArea = -1;
int8_t SelectCount = 0;

struct TouchSpot
{
  int x;
  int y;
  int w;
  int h;
  int area;
};

TouchSpot Spots[13];
TouchSpot Button;

struct SelectionRect
{
  int x;
  int y;
  int w;
  int h;
};

SelectionRect SelectRect;

unsigned long lastTouch;
unsigned long touchDebounce = 200;
unsigned long now;

bool debug = false;

// forward declarations..
void CutDeck(int8_t *deck, int size);
void shuffle(int8_t *array, int size);
unsigned long millis();
void SetupTable();
void StockFlip();
bool TouchArea(int px, int py, int x, int y, int w, int h);
void CheckScreenTouch(int tx, int ty);
void HandleTouch(int spot, int y);
bool CheckFoundationMove(int f);
void MoveToFoundations(int f);
void SelectFoundation(int f);
int  GetCardColor(int acard);
int  GetCardNumber(int acard);
bool CheckTableauMove(int a);
void MoveToTableau(int a);
void SelectTableau(int a, int y);
void DrawSelection();
void drawRect( int x, int y, int w, int h, SDL_Color c);
void fillRect( int x, int y, int w, int h, SDL_Color c);
//Starts up SDL and creates window
bool init();
void pushImage(int x, int y, int w, int h, int c);
//Frees media and shuts down SDL
void close();
//check keyboard..
void checkKeyState();

// implementation..

unsigned long millis()
{  
	return SDL_GetTicks();
}

void SetupTable()
{
  // clear out the old values..
  memset(HiddenTabs, -1, sizeof(HiddenTabs));
  memset(Tableau, -1, sizeof(Tableau));
  memset(Foundations, -1, sizeof(Foundations));
  memset(Stock, -1, sizeof(Stock));
  memset(Waste, -1, sizeof(Waste));
  memset(HiddenCounts, 0, sizeof(HiddenCounts));
  StockCount = 0;
  WasteCount = 0;
  CurrentCard = 0;
  for (int i = 0; i < sizeof(TableauCounts); i++)
  {
    TableauCounts[i] = 1;
    if (i < sizeof(FoundationCounts))
      FoundationCounts[i] = 0;
  }

  shuffle(Deck, sizeof(Deck));
  CutDeck(Deck,sizeof(Deck));
  shuffle(Deck, sizeof(Deck));
  CutDeck(Deck,sizeof(Deck));

  // fill the tableau
  int c = 0;
  for (int j = 0; j < 7; j++)
  {
    Tableau[j][0] = Deck[c];
    c++;
    for (int i = j; i < 6; i++)
    {
      HiddenTabs[i][j] = Deck[c];
      HiddenCounts[i + 1]++;
      c++;
    }
  }
  // fill stock
  StockCount = 52 - c;
  int p = 0;
  for (int i = c; i < 52; i++)
  {
    Stock[p] = Deck[c];
    p++;
    c++;
  }

  printf("Card #:%d \n", c);
  printf("Stock Count : %d \n", StockCount);
  printf("Size of HiddenTabs: %d \n", sizeof(HiddenTabs));
  printf("Size of spots: %d\n", sizeof(Spots) / sizeof(Spots[0]));
  for (int i = 0; i < sizeof(HiddenCounts); i++)
  {
    printf("Count # %d = %d\n", i + 1, HiddenCounts[i]);
  }

    //clear screen..  
  	SDL_SetRenderDrawColor( renderer, 0, 128, 0, 255 );
	SDL_RenderClear( renderer );


  int sw, sh, x, y;

  sw = SCREEN_WIDTH;
  sh = SCREEN_HEIGHT;

  
  x = Border + TableLeft;
  y = Border + TableTop;
  Button.x = x;
  Button.y = y;
  Button.w = ButtonWidth;
  Button.h = ButtonHeight;
  fillRect(x,y, ButtonWidth, ButtonHeight, SDL_BLUE);
  
  stringRGBA(renderer, x+20, y+10,"New\0",255,255,255,255);
  drawRect(x, y, ButtonWidth, ButtonHeight,TFT_YELLOW);
  y+=ButtonHeight+Gap;

  Spots[0].y = y;
  Spots[0].x = x;
  Spots[0].h = CardHeight;
  Spots[0].w = CardWidth;
  Spots[0].area = 1;
  
  pushImage(x, y, CardWidth, CardHeight, CardBack);
  drawRect(x, y, CardWidth, CardHeight, TFT_YELLOW);
  x += CardWidth + Gap;
  Spots[1].y = y;
  Spots[1].x = x;
  Spots[1].h = CardHeight;
  Spots[1].w = CardWidth;
  Spots[1].area = 2;
  drawRect(x, y, CardWidth, CardHeight, TFT_YELLOW);
  x += (CardWidth + Gap) * 2;

  for (int i = 0; i < 4; i++)
  {
    Spots[i + 2].y = y;
    Spots[i + 2].x = x;
    Spots[i + 2].h = CardHeight;
    Spots[i + 2].w = CardWidth;
    Spots[i + 2].area = i + 3;
    drawRect(x, y, CardWidth, CardHeight, TFT_YELLOW);
    x += CardWidth + Gap;
  }
  x = Border + TableLeft;
  y = CardHeight + Border + Gap + TableTop+ButtonHeight+Gap;

  for (int i = 0; i < 7; i++)
  {
    Spots[i + 6].y = y;
    Spots[i + 6].x = x;
    Spots[i + 6].h = CardHeight;
    Spots[i + 6].w = CardWidth;
    Spots[i + 6].area = i + 7;
    if (i > 0)
    {
      pushImage(x, y, CardWidth, CardHeight, CardBack);
    }
    drawRect(x, y, CardWidth, CardHeight, TFT_YELLOW);
    pushImage(x, y + CardOL, CardWidth, CardHeight, Tableau[i][0]);
    drawRect(x, y + CardOL, CardWidth, CardHeight, TFT_YELLOW);
    x += CardWidth + Gap;
  }
}

void StockFlip()
{
  if (SelectedCard > -1){
  SelectedCard = -1;
  SelectedArea = -1;
  SelectCount = 0;
  DrawSelection();
  }
  if (StockCount == 0)
  {
    // restock..
    int flip = WasteCount - 1;
    for (int i = 0; i < WasteCount; i++)
    {
      Stock[i] = Waste[flip--];
    }
    StockCount = WasteCount;
    WasteCount = 0;
    pushImage(Spots[0].x, Spots[0].y, CardWidth, CardHeight, CardBack);
    drawRect(Spots[0].x, Spots[0].y, CardWidth, CardHeight, TFT_YELLOW);
  }
  // flip the next stock card over..
  Waste[WasteCount] = Stock[StockCount - 1];
  WasteCount++;
  Stock[StockCount - 1] = -1;
  if (StockCount > 0)
    StockCount--;
  if (StockCount == 0)
  {
    // no more stock..
    fillRect(Spots[0].x, Spots[0].y, CardWidth, CardHeight, TFT_DARKGREEN);
    drawRect(Spots[0].x, Spots[0].y, CardWidth, CardHeight, TFT_YELLOW);
  }
  printf("card:%d\n", Waste[WasteCount - 1]);
  pushImage(Spots[1].x, Spots[1].y, CardWidth, CardHeight, Waste[WasteCount - 1]);
  drawRect(Spots[1].x, Spots[1].y, CardWidth, CardHeight, TFT_YELLOW);
}

void SelectWaste()
{
  if (WasteCount > 0)
  {
    printf("Waste Card Selected: %d\n", Waste[WasteCount - 1]);
    SelectedCard = Waste[WasteCount - 1];
    SelectedArea = 2;
    SelectCount = 1;
    SelectRect.x = Spots[1].x;
    SelectRect.y = Spots[1].y;
    SelectRect.w = Spots[1].w;
    SelectRect.h = Spots[1].h;
    DrawSelection();
  }
  else
    printf("No Waste..\n");
}

bool CheckFoundationMove(int f)
{
  bool result = false;
  int nextCard;
  if (FoundationCounts[f - 3] > 0)
  {
    if (FoundationCounts[f - 3] == 1)
    {
      // it's the ace..
      nextCard = Foundations[f - 3][FoundationCounts[f - 3] - 1] - 12;
    }
    else
    {
      nextCard = Foundations[f - 3][FoundationCounts[f - 3] - 1] + 1;
    }
    if (SelectedCard == nextCard)
      result = true;
  }
  else
  {
    // looking for an ace
    switch (SelectedCard)
    {
    case 12:
    case 25:
    case 38:
    case 51:
      result = true;
      break;
    }
  }
  return result;
}

void MoveToFoundations(int f)
{
  //
  printf("Move to Foundation. Card:%d  Area:%d\n", SelectedCard, SelectedArea);
  if (SelectedArea == 2 && SelectedCard > -1)
  {
    // move a waste card..
    Foundations[f - 3][FoundationCounts[f - 3]] = Waste[WasteCount - 1];
    FoundationCounts[f - 3]++;
    Waste[WasteCount - 1] = -1;
    WasteCount--;
    if (WasteCount < 1)
    {
      fillRect(Spots[1].x, Spots[1].y, CardWidth, CardHeight, TFT_DARKGREEN);
      drawRect(Spots[1].x, Spots[1].y, CardWidth, CardHeight, TFT_YELLOW);
    }
    else
    {
      pushImage(Spots[1].x, Spots[1].y, CardWidth, CardHeight, Waste[WasteCount - 1]);
      drawRect(Spots[1].x, Spots[1].y, CardWidth, CardHeight, TFT_YELLOW);
    }
    pushImage(Spots[f - 1].x, Spots[f - 1].y, CardWidth, CardHeight, Foundations[f - 3][FoundationCounts[f - 3] - 1]);
    drawRect(Spots[f - 1].x, Spots[f - 1].y, CardWidth, CardHeight, TFT_YELLOW);
    SelectedCard = -1;
    SelectedArea = -1;
    SelectCount = 0;
    DrawSelection();
  }
  else
  {
    if (SelectedArea > 6)
    {
      // moving from the tasbleau
      if (SelectedCard == Tableau[SelectedArea - 7][TableauCounts[SelectedArea - 7] - 1])
      {
        // can only move a top card..
        Foundations[f - 3][FoundationCounts[f - 3]] = Tableau[SelectedArea - 7][TableauCounts[SelectedArea - 7] - 1];
        FoundationCounts[f - 3]++;
        Tableau[SelectedArea - 7][TableauCounts[SelectedArea - 7] - 1] = -1;
        TableauCounts[SelectedArea - 7]--;

        int newy = CardOL * TableauCounts[SelectedArea - 7];
        Spots[SelectedArea - 1].h = CardHeight + newy;
        printf("Table Count: %d newy: %d\n", TableauCounts[SelectedArea - 7], newy);
        // erase old card first
        fillRect(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y + newy + CardOL, CardWidth, CardHeight, TFT_DARKGREEN);
        // redraw last card in pile..
        if (TableauCounts[SelectedArea - 7] > 0)
          pushImage(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y + newy, CardWidth, CardHeight, Tableau[SelectedArea - 7][TableauCounts[SelectedArea - 7] - 1]);
        else if (SelectedArea > 7 && HiddenCounts[SelectedArea - 7] > 0) // do we have something??
          pushImage(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y + newy, CardWidth, CardHeight, CardBack);
          drawRect(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y + newy, CardWidth, CardHeight, TFT_YELLOW);
        // draw card in foundation
        pushImage(Spots[f - 1].x, Spots[f - 1].y, CardWidth, CardHeight, Foundations[f - 3][FoundationCounts[f - 3] - 1]);
        drawRect(Spots[f - 1].x, Spots[f - 1].y, CardWidth, CardHeight, TFT_YELLOW);
        SelectedCard = -1;
        SelectedArea = -1;
      }
      else
      {
        // just unselect pile
        SelectedCard = -1;
        SelectedArea = -1;
        SelectCount = 0;
        DrawSelection();
      }
    }
    else
    {
      // just unselect pile
      SelectedCard = -1;
      SelectedArea = -1;
      SelectCount = 0;
      DrawSelection();
    }
  }
}

void SelectFoundation(int f)
{
  // select a foundation card..
  if (FoundationCounts[f - 3] > 0)
  {
    SelectedCard = Foundations[f - 3][FoundationCounts[f - 3] - 1];
    SelectedArea = f;
    SelectCount = 1;
    SelectRect.x = Spots[f - 1].x;
    SelectRect.y = Spots[f - 1].y;
    SelectRect.w = Spots[f - 1].w;
    SelectRect.h = Spots[f - 1].h;
    DrawSelection();
    printf("Foundation %d  Card %d selected\n", SelectedArea - 2, SelectedCard);
  }
}

int GetCardColor(int acard)
{
  int result = -1;
  if (acard < 13)
    result = 0;
  else if (acard < 39)
    result = 1;
  else
    result = 0;
  return result;
}

int GetCardNumber(int acard)
{
  int result = -1;
  // get ordinal postion within suit..
  if (acard < 13)
    result = acard+2;
  else if (acard < 26)
    result = acard - 11;
  else if (acard < 39)
    result = acard - 24;
  else
    result = acard - 37;

   printf("Orig #: %d new #: %d\n",acard,result);   
 return result;   
}

bool CheckTableauMove(int a)
{
  // check for valid move
  bool result = false;
  // no cards on table, any card should do..
  if (TableauCounts[a - 7] == 0)
  {
    result = true;
    return result; // outa here
  }
  int pileColor = GetCardColor(Tableau[a - 7][TableauCounts[a - 7] - 1]);
  if (GetCardColor(SelectedCard) == pileColor)
  {
    int acolor = GetCardColor(SelectedCard);
    printf("wrong colors..pile color: %d  select color: %d\n", pileColor,acolor);
    result = false;
    return result;
  }
  int pileCard = GetCardNumber(Tableau[a - 7][TableauCounts[a - 7] - 1]);
  // next card should be one less than the current pile card..
  result = pileCard == (GetCardNumber(SelectedCard) + 1);
  if (!result) printf("wrong card # pile:%d  select:%d\n",pileCard,GetCardNumber(SelectedCard));
  return result;
}

void MoveToTableau(int a)
{
  if (SelectedArea == 2)
  {
    // moving from waste..
    Tableau[a - 7][TableauCounts[a - 7]] = Waste[WasteCount - 1];
    TableauCounts[a - 7]++;
    Waste[WasteCount - 1] = -1;
    WasteCount--;
    if (WasteCount < 1)
    {
      fillRect(Spots[1].x, Spots[1].y, CardWidth, CardHeight, TFT_DARKGREEN);
      drawRect(Spots[1].x, Spots[1].y, CardWidth, CardHeight, TFT_YELLOW);
    }
    else
    {
      pushImage(Spots[1].x, Spots[1].y, CardWidth, CardHeight, Waste[WasteCount - 1]);
      drawRect(Spots[1].x, Spots[1].y, CardWidth, CardHeight,  TFT_YELLOW);
    }
    int newy = CardOL * TableauCounts[a - 7];
    Spots[a - 1].h = CardHeight + newy;
    printf("Table Count: %d newy: %d\n", TableauCounts[a - 7], newy);
    pushImage(Spots[a - 1].x, Spots[a - 1].y + newy, CardWidth, CardHeight, Tableau[a - 7][TableauCounts[a - 7] - 1]);
    drawRect(Spots[a - 1].x, Spots[a - 1].y + newy, CardWidth, CardHeight,  TFT_YELLOW);
    SelectedCard = -1;
    SelectedArea = -1;
    SelectCount = 0;
    DrawSelection();
  }
  else if (SelectedArea > 2 && SelectedArea < 7)
  {
    // moving from foundations..
    Tableau[a - 7][TableauCounts[a - 7]] = Foundations[SelectedArea - 3][FoundationCounts[SelectedArea - 3] - 1];
    TableauCounts[a - 7]++;
    Foundations[SelectedArea - 3][FoundationCounts[SelectedArea - 3] - 1] = -1;
    FoundationCounts[SelectedArea - 3]--;
    if (FoundationCounts[SelectedArea - 3] < 1)
    {
      fillRect(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y, CardWidth, CardHeight, TFT_DARKGREEN);
      drawRect(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y, CardWidth, CardHeight, TFT_YELLOW);
    }
    else
    {
      pushImage(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y, CardWidth, CardHeight, Foundations[SelectedArea - 3][FoundationCounts[SelectedArea - 3] - 1]);
      drawRect(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y, CardWidth, CardHeight, TFT_YELLOW);
    }
    int newy = CardOL * TableauCounts[a - 7];
    Spots[a - 1].h = CardHeight + newy;
    printf("Table Count: %d newy: %d\n", TableauCounts[a - 7], newy);
    pushImage(Spots[a - 1].x, Spots[a - 1].y + newy, CardWidth, CardHeight, Tableau[a - 7][TableauCounts[a - 7] - 1]);
    drawRect(Spots[a - 1].x, Spots[a - 1].y + newy, CardWidth, CardHeight, TFT_YELLOW);
    SelectedCard = -1;
    SelectedArea = -1;
    SelectCount = 0;
    DrawSelection();
  }
  else if (SelectedArea > 6 && SelectedArea < 14 && SelectedArea != a)
  {
    // moving from pile to pile..
    int c = SelectCount;
    int newy;
    for (int i = 0; i < SelectCount; i++)
    {
      // add cards
      printf("Tab Count: %d  c: %d\n", TableauCounts[SelectedArea - 7], c);
      Tableau[a - 7][TableauCounts[a - 7]] = Tableau[SelectedArea - 7][(TableauCounts[SelectedArea - 7] - c)];
      TableauCounts[a - 7]++;
      newy = CardOL * TableauCounts[a - 7];
      Spots[a - 1].h = CardHeight + newy;
      printf("Table Count: %d newy: %d\n", TableauCounts[a - 7], newy);
      pushImage(Spots[a - 1].x, Spots[a - 1].y + newy, CardWidth, CardHeight, Tableau[a - 7][TableauCounts[a - 7] - 1]);
      drawRect(Spots[a - 1].x, Spots[a - 1].y + newy, CardWidth, CardHeight,  TFT_YELLOW);
      c--;
    }
    c = SelectCount;
    for (int i = 0; i < SelectCount; i++)
    {
      // remove cards
      Tableau[SelectedArea - 7][(TableauCounts[SelectedArea - 7] - c)] = -1;
      TableauCounts[SelectedArea - 7]--;
      newy = CardOL * TableauCounts[SelectedArea - 7];
     // newy-= CardOL;
     if (TableauCounts[SelectedArea -7]>1)
      Spots[SelectedArea - 1].h = CardHeight + newy; else
      Spots[SelectedArea - 1].h = CardHeight;
      printf("Table Count: %d newy: %d\n", TableauCounts[SelectedArea - 7], newy);
      // erase old card first
      fillRect(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y + newy + CardOL, CardWidth, CardHeight, TFT_DARKGREEN);
      // redraw last card in pile..
      if (TableauCounts[SelectedArea - 7] > 0)
        pushImage(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y + newy, CardWidth, CardHeight, Tableau[SelectedArea - 7][TableauCounts[SelectedArea - 7] - 1]);
      else if (SelectedArea > 7 && HiddenCounts[SelectedArea - 7] > 0) // do we have something??
        pushImage(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y + newy, CardWidth, CardHeight, CardBack);
      drawRect(Spots[SelectedArea - 1].x, Spots[SelectedArea - 1].y + newy, CardWidth, CardHeight, TFT_YELLOW);
      c--;
    }
    SelectedCard = -1;
    SelectedArea = -1;
    SelectCount = 0;
  }
  else
  {
    SelectedCard = -1;
    SelectedArea = -1;
    SelectCount = 0;
    DrawSelection();
  }
}

void SelectTableau(int a, int y)
{
  if (TableauCounts[a - 7] > 0)
  {
    if (TableauCounts[a - 7] > 1)
    {
      int newy = Spots[a - 1].y + (TableauCounts[a - 7] * CardOL);
      for (int i = 0; i < TableauCounts[a - 7]; i++)
      {
        printf("NewY: %d  Y: %d\n", newy, y);
        if (y >= newy)
        {
          SelectedCard = Tableau[a - 7][(TableauCounts[a - 7] - 1) - i];
          SelectedArea = a;
          SelectCount = i + 1;
          printf("Multi-Selected Card : %d Num of Cards: %d\n", SelectedCard, SelectCount);
          break;
        }
        newy -= CardOL;
      }
      SelectRect.x = Spots[a - 1].x;
      SelectRect.y = Spots[a - 1].y + (CardOL * TableauCounts[a - 7]) - (SelectCount * CardOL) + CardOL;
      SelectRect.w = CardWidth;
      SelectRect.h = CardHeight + (CardOL * SelectCount) - CardOL;
      DrawSelection();
    }
    else
    {
      // only 1 card on pile..
      SelectedCard = Tableau[a - 7][TableauCounts[a - 7] - 1];
      SelectedArea = a;
      SelectCount = 1;
      SelectRect.x = Spots[a - 1].x;
      SelectRect.y = Spots[a - 1].y + CardOL;
      SelectRect.w = Spots[a - 1].w;
      SelectRect.h = CardHeight; // Spots[a - 1].h;
      DrawSelection();
      printf("Single-Selected Card : %d\n", SelectedCard);
    }
  }
  else
  {
    // no cards on tableau, see if we have any hidden..
    if (HiddenCounts[a - 7] > 0)
    {
      // flip the hidden card..
      Tableau[a - 7][0] = HiddenTabs[a - 8][HiddenCounts[a - 7] - 1];
      TableauCounts[a - 7] = 1;
      HiddenTabs[a - 8][HiddenCounts[a - 7] - 1] = -1;
      HiddenCounts[a - 7]--;
      int newy = 0;// CardOL * TableauCounts[a - 7];
      Spots[a - 1].h = CardHeight + newy;
      newy = CardOL;
      printf("Table Count: %d newy: %d\n", TableauCounts[a - 7], newy);
      if (HiddenCounts[a - 7] == 0)
      { // erase hidden placeholder..
        fillRect(Spots[a - 1].x, Spots[a - 1].y, CardWidth, CardHeight, TFT_DARKGREEN);
        drawRect(Spots[a - 1].x, Spots[a - 1].y, CardWidth, CardHeight, TFT_YELLOW);
      }
      pushImage(Spots[a - 1].x, Spots[a - 1].y + newy, CardWidth, CardHeight, Tableau[a - 7][TableauCounts[a - 7] - 1]);
      drawRect(Spots[a - 1].x, Spots[a - 1].y + newy, CardWidth, CardHeight, TFT_YELLOW);
    }
  }
}

void CutDeck(int8_t *deck, int size){
  int8_t half[size / 2];
  
  //lower half of deck
  memcpy(half,deck,sizeof(half));
  //move high half to lower..
  memcpy(deck,&deck[(size / 2)],sizeof(half));
  //copy lower back to high..
  memcpy(&deck[(size / 2)],half,sizeof(half));
  
}

//shuffle the deck..
void shuffle(int8_t *array, int size)
{
  for (int i = size - 1; i > 0; i--)
  {
    int j = i + (rand() % (size - i));
    int8_t temp = array[i];
    array[i] = array[j];
    array[j] = temp;
  }
}

void DrawSelection()
{
  if (SelectedCard > -1)
  {
    // selecting
    drawRect(SelectRect.x + 1, SelectRect.y + 1, SelectRect.w - 3, SelectRect.h - 2, TFT_GREEN);
    drawRect(SelectRect.x + 2, SelectRect.y + 2, SelectRect.w - 4, SelectRect.h - 3, TFT_GREEN);
    drawRect(SelectRect.x, SelectRect.y, SelectRect.w, SelectRect.h, TFT_GREEN);
  }
  else
  {
    drawRect(SelectRect.x + 1, SelectRect.y + 1, SelectRect.w - 3, SelectRect.h - 2, TFT_WHITE);
    drawRect(SelectRect.x + 2, SelectRect.y + 2, SelectRect.w - 4, SelectRect.h - 3, TFT_WHITE);
    drawRect(SelectRect.x, SelectRect.y, SelectRect.w, SelectRect.h,  TFT_YELLOW);
    // unselecting
  }
}






bool init()
{
	//Initialization flag
	bool success = true;

	//Initialize SDL
	if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
	{
		printf( "SDL could not initialize! SDL Error: %s\n", SDL_GetError() );
		success = false;
	}
	else
	{
		//Set texture filtering to linear
		if( !SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "1" ) )
		{
			printf( "Warning: Linear texture filtering not enabled!" );
		}

		//Create window
		window = SDL_CreateWindow( "Uno Q", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
		if( window == NULL )
		{
			printf( "Window could not be created! SDL Error: %s\n", SDL_GetError() );
			success = false;
		}
		else
		{
			//Create vsynced renderer for window
			renderer = SDL_CreateRenderer( window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC );
			if( renderer == NULL )
			{
				printf( "Renderer could not be created! SDL Error: %s\n", SDL_GetError() );
				success = false;
			}
			else
			{
				//Initialize renderer color
				SDL_SetRenderDrawColor( renderer, 0, 128, 0, 255 );
				//clear screen
				SDL_RenderClear( renderer );
				//setup the deck..
                for (int i = 0; i < 52; i++)
                Deck[i] = i;
                // init random
                srand(time(0));
				//our cardf image texture..
				texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB565,
				                                      SDL_TEXTUREACCESS_STREAMING,
				                                      CardWidth,
				                                      CardHeight);
				if (texture == NULL){
					printf("failed to create texture.. \n");
					success = false;
				}                                      
				//setup the table..
                SetupTable();
                //render it..
		        SDL_RenderPresent( renderer );
			}
		}
	}
	return success;
}

//renders a card image c is the card number in deck..
void pushImage(int x, int y, int w, int h, int c)
{
   //make sure card is valid..
    if (c < 0){
		printf("invalid card %d\n",c);
		return;
	}
	
	int success;
	void *m_pixels;
	int  pitch;
	success = SDL_LockTexture(texture, NULL, &m_pixels, &pitch);
	if (success == 0)
	 {
	  memcpy(m_pixels,card[c],CardWidth*CardHeight * sizeof(Uint16));
	  SDL_UnlockTexture(texture);
	  SDL_Rect dr = {x,y,w,h};
	  SDL_RenderCopy(renderer, texture,NULL ,&dr);
     } else printf("failed to lock texture..\n");
}

void drawRect( int x, int y, int w, int h, SDL_Color c)
{
  Uint8 *colo = (Uint8 *)&c;
  SDL_SetRenderDrawColor(renderer, colo[0],colo[1],colo[2],colo[3]);
  SDL_Rect r = {x,y,w,h};
  SDL_RenderDrawRect(renderer, &r);	
}

void fillRect( int x, int y, int w, int h, SDL_Color c)
{
  Uint8 *colo = (Uint8 *)&c;
  SDL_SetRenderDrawColor(renderer, colo[0],colo[1],colo[2],colo[3]);
  SDL_Rect r = {x,y,w,h};
  SDL_RenderFillRect(renderer, &r);	
}


void close()
{

	SDL_DestroyTexture ( texture );
	SDL_DestroyRenderer( renderer );
	SDL_DestroyWindow  ( window );
	texture  = NULL;
	window   = NULL;
	renderer = NULL;
	SDL_Quit();
}


void checkKeyState()
{
	const Uint8* currentKeyStates = SDL_GetKeyboardState( NULL);
	if ( currentKeyStates[ SDL_SCANCODE_UP])
	{
		printf("Up\n");
	}
	else if (currentKeyStates[ SDL_SCANCODE_DOWN])
		{
			printf("down\n");
		}
	else if ( currentKeyStates[ SDL_SCANCODE_LEFT ])
	{
		printf("left\n");
	}
	else if ( currentKeyStates [ SDL_SCANCODE_RIGHT])
	{
		printf("right\n");
	}
}


bool TouchArea(int px, int py, int x, int y, int w, int h)
{
  bool result = false;
  int x2 = x + w;
  int y2 = y + h;
  int touch_x = px;
  int touch_y = py;
  if ((touch_x >= x) && (touch_x <= x2) && (touch_y >= y) && (touch_y <= y2))
    result = true;
  if (debug)
  {
    printf("Touch X: %d  Y: %d\n", touch_x, touch_y);
    printf("X: %d , X2: %d, Y: %d, Y2: %d\n", x, x2, y, y2);
  }
  return result;
}

void CheckScreenTouch(int tx, int ty)
{
  printf("x: %d  y: %d \n", tx, ty);
  printf("Button x:%d y:%d w:%d h:%d\n",Button.x,Button.y,Button.w,Button.h);
  if (TouchArea(tx,ty,Button.x,Button.y,Button.w,Button.h)){
    printf("New Game\n");
   SetupTable();
  } else
   {
  for (int i = 0; i < sizeof(Spots) / sizeof(Spots[0]); i++)
  {
    if (TouchArea(tx, ty, Spots[i].x, Spots[i].y, Spots[i].w, Spots[i].h))
    {
      printf("Spot clicked:%d\n", i);
      HandleTouch(i, ty);
      break;
    }
  }
}
}

void HandleTouch(int spot, int y)
{

  switch (spot)
  {
  case 0:
    StockFlip();
    break;
  case 1:
    SelectWaste();
    break;
  case 2:
  case 3:
  case 4:
  case 5:
    if (SelectedCard > -1)
    {
      if (CheckFoundationMove(Spots[spot].area))
      {
        MoveToFoundations(Spots[spot].area);
      }
      else
      {
        // invalid move unselect the selection..
        SelectCount = 0;
        SelectedArea = 0;
        SelectedCard = -1;
        DrawSelection();
      }
    }
    else
    {
      SelectFoundation(Spots[spot].area);
    }
    break;
  case 6:
  case 7:
  case 8:
  case 9:
  case 10:
  case 11:
  case 12:
    if (SelectedCard > -1)
    {
      if (CheckTableauMove(Spots[spot].area))
      {
        MoveToTableau(Spots[spot].area);
      }
      else
      {
        // invalid move, unselect
        SelectCount = 0;
        SelectedArea = 0;
        SelectedCard = -1;
        DrawSelection();
      }
    }
    else
    {
      SelectTableau(Spots[spot].area, y);
    }
    break;
  default:
    break;
  }
}

	

int main( int argc, char* args[] )
{
	//Start up SDL and create window
	if( !init() )
	{
		printf( "Failed to initialize!\n" );
	}
	else
	{
			//Main loop flag
			bool quit = false;

			//Event handler
			SDL_Event e;

			//While application is running
			while( !quit )
			{
				now = millis();
				//Handle events on queue
				while( SDL_PollEvent( &e ) != 0 )
				{
					now = millis();
					//User requests quit
					if( e.type == SDL_QUIT )
					{
						quit = true;
					}
				if (e.type == SDL_MOUSEBUTTONUP)
				{
			  	 if (now - lastTouch >= touchDebounce)
				  {	
				   lastTouch = now;	
            	   int x,y;
		           SDL_GetMouseState( &x, &y);
		           CheckScreenTouch(x,y);
		           SDL_RenderPresent( renderer);
			      }
				}		
				std::this_thread::yield();
			  }
              SDL_Delay(10);
			}
	}

	//Free resources and close SDL
	close();

	return 0;
}

solitaire shows how to load images from a c array and track mouse clicks..
note it does use the same bigcards.h you can find at the top post..

here's the CMakeLists.txt for mazes sol is the same except for project instead of mazes I used sol.

cmake_minimum_required (VERSION 3.10)

project(mazes)


file(GLOB Target_Files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS 
    *.cpp
    )
    
add_executable (mazes ${Target_Files})

# SDL sources..
target_include_directories(mazes PUBLIC "/home/arduino/projects/libs/SDL2/include")
target_include_directories(mazes PUBLIC "/home/arduino/projects/libs/SDL2/src")
#target_include_directories(mazes PUBLIC "/home/arduino/projects/libs/SDL_image/include")
#target_include_directories(mazes PUBLIC "/home/arduino/projects/libs/SDL_image/src")
#target_include_directories(mazes PUBLIC "/home/arduino/projects/libs/SDL_ttf/")
#target_include_directories(mazes PUBLIC "/home/arduino/projects/libs/SDL_mixer/include")
#target_include_directories(mazes PUBLIC "/home/arduino/projects/libs/SDL_mixer/src")
target_include_directories(mazes PUBLIC "/home/arduino/projects/libs/SDL2_gfx/")

# link to our pre-installed libs..
target_link_libraries(mazes PUBLIC "/lib64/libSDL2-2.0.so.0.3200.4")
#target_link_libraries(mazes PUBLIC "/lib64/libSDL2_image-2.0.so.0.800.8")
#target_link_libraries(mazes PUBLIC "/lib64/libSDL2_ttf-2.0.so.0.2400.0")
#target_link_libraries(mazes PUBLIC "/lib64/libSDL2_mixer-2.0.so.0.800.1")
target_link_libraries(mazes PUBLIC "/lib64/libSDL2_gfx-1.0.so.0.0.2")




target_compile_features(mazes PUBLIC cxx_std_17)

'# is a comment and you'll notice most all subsystems in SDL are commented out, only using the base and gfx..

fun stuff.. ~q

was just missing the symbolic link, corrected this with..
sudo ln -s /usr/aarch64-linux-gnu/ ./lib64/
now i have a lib64 folder same as my 2g..
~q