Add CHAIN_TOP_RIGHT_DOWN_ZZ

This commit is contained in:
mrfaptastic 2023-03-15 13:46:43 +00:00
parent e15f11ac46
commit 1d21b165df
4 changed files with 90 additions and 14 deletions

View file

@ -57,7 +57,8 @@ enum PANEL_CHAIN_TYPE
CHAIN_TOP_LEFT_DOWN, CHAIN_TOP_LEFT_DOWN,
CHAIN_TOP_RIGHT_DOWN, CHAIN_TOP_RIGHT_DOWN,
CHAIN_BOTTOM_LEFT_UP, CHAIN_BOTTOM_LEFT_UP,
CHAIN_BOTTOM_RIGHT_UP CHAIN_BOTTOM_RIGHT_UP,
CHAIN_TOP_RIGHT_DOWN_ZZ /// ZigZag chaining. Might need a big ass cable to do this, all panels right way up.
}; };
#ifdef USE_GFX_ROOT #ifdef USE_GFX_ROOT
@ -275,6 +276,20 @@ inline VirtualCoords VirtualMatrixPanel::getCoords(int16_t &virt_x, int16_t &vir
} }
break; break;
case CHAIN_TOP_RIGHT_DOWN_ZZ:
{
// Right side up. Starting from top left all the way down.
// Connected in a Zig Zag manner = some long ass cables being used potentially
//Serial.printf("Condition 2, row %d ", row);
coords.x = ((vmodule_rows - (row+1))*virtualResX)+virt_x;
coords.y = virt_y % panelResY;
}
default: default:

View file

@ -1,5 +1,5 @@
Sample app to simulate the VirtualMatrixPanel class for testing / optimisation, without having to test with physical panels. Sample app to simulate the VirtualMatrixPanel class for testing / optimisation, without having to test with physical panels.
``` ```
g++ -o myapp.exe testing.cpp g++ -o myapp.exe virtual.cpp
``` ```

View file

@ -5,7 +5,7 @@
* Not thread safe, but not a concern for ESP32 sketch anyway... I think. * Not thread safe, but not a concern for ESP32 sketch anyway... I think.
*/ */
// DO NOT CHANGE // DO NOT CHANGE
inline VirtualCoords VirtualMatrixPanelTest::getCoords_WorkingBaslineMarch2023(int16_t &virt_x, int16_t &virt_y) inline VirtualCoords VirtualMatrixPanelTest::getCoords_WorkingBaslineMarch2023(int16_t virt_x, int16_t virt_y)
{ {
coords.x = coords.y = -1; // By defalt use an invalid co-ordinates that will be rejected by updateMatrixDMABuffer coords.x = coords.y = -1; // By defalt use an invalid co-ordinates that will be rejected by updateMatrixDMABuffer

View file

@ -28,7 +28,8 @@ enum PANEL_CHAIN_TYPE
CHAIN_TOP_LEFT_DOWN, CHAIN_TOP_LEFT_DOWN,
CHAIN_TOP_RIGHT_DOWN, CHAIN_TOP_RIGHT_DOWN,
CHAIN_BOTTOM_LEFT_UP, CHAIN_BOTTOM_LEFT_UP,
CHAIN_BOTTOM_RIGHT_UP CHAIN_BOTTOM_RIGHT_UP,
CHAIN_TOP_RIGHT_DOWN_ZZ /// ZigZag chaining. Might need a big ass cable to do this, all panels right way up.
}; };
@ -70,6 +71,10 @@ public:
chain_type_str = "CHAIN_TOP_RIGHT_DOWN"; chain_type_str = "CHAIN_TOP_RIGHT_DOWN";
break; break;
case CHAIN_TOP_RIGHT_DOWN_ZZ:
chain_type_str = "CHAIN_TOP_RIGHT_DOWN_ZZ";
break;
case CHAIN_BOTTOM_RIGHT_UP: case CHAIN_BOTTOM_RIGHT_UP:
chain_type_str = "CHAIN_BOTTOM_RIGHT_UP"; chain_type_str = "CHAIN_BOTTOM_RIGHT_UP";
break; break;
@ -95,9 +100,9 @@ public:
std::string chain_type_str = "UNKNOWN"; std::string chain_type_str = "UNKNOWN";
// Internal co-ord conversion function // Internal co-ord conversion function
VirtualCoords getCoords_Dev(int16_t &x, int16_t &y); VirtualCoords getCoords_Dev(int16_t x, int16_t y);
VirtualCoords getCoords_WorkingBaslineMarch2023(int16_t &x, int16_t &y); VirtualCoords getCoords_WorkingBaslineMarch2023(int16_t x, int16_t y);
VirtualCoords coords; VirtualCoords coords;
@ -127,7 +132,7 @@ private:
/** /**
* Development version for testing. * Development version for testing.
*/ */
inline VirtualCoords VirtualMatrixPanelTest::getCoords_Dev(int16_t &virt_x, int16_t &virt_y) inline VirtualCoords VirtualMatrixPanelTest::getCoords_Dev(int16_t virt_x, int16_t virt_y)
{ {
coords.x = coords.y = -1; // By defalt use an invalid co-ordinates that will be rejected by updateMatrixDMABuffer coords.x = coords.y = -1; // By defalt use an invalid co-ordinates that will be rejected by updateMatrixDMABuffer
@ -246,6 +251,18 @@ inline VirtualCoords VirtualMatrixPanelTest::getCoords_Dev(int16_t &virt_x, int1
} }
break; break;
case CHAIN_TOP_RIGHT_DOWN_ZZ:
{
// Right side up. Starting from top left all the way down.
// Connected in a Zig Zag manner = some long ass cables being used potentially
//Serial.printf("Condition 2, row %d ", row);
coords.x = ((vmodule_rows - (row+1))*virtualResX)+virt_x;
coords.y = virt_y % panelResY;
}
default: default:
@ -309,6 +326,23 @@ inline VirtualCoords VirtualMatrixPanelTest::getCoords_Dev(int16_t &virt_x, int1
return coords; return coords;
} }
bool check(VirtualCoords expected, VirtualCoords result, int x = -1, int y = -1)
{
if ( result.x != expected.x || result.y != expected.y )
{
std::printf("Requested (%d, %d) -> expecting physical (%d, %d) got (%d, %d).", x, y, expected.x, expected.y, result.x, result.y);
std::cout << "\t *** FAIL ***\n ";
std::cout << "\n";
return false;
}
else
{
return true;
}
}
main(int argc, char* argv[]) main(int argc, char* argv[])
{ {
@ -343,13 +377,11 @@ main(int argc, char* argv[])
{ {
VirtualCoords expected = test.getCoords_WorkingBaslineMarch2023(x,y); VirtualCoords expected = test.getCoords_WorkingBaslineMarch2023(x,y);
VirtualCoords result = test.getCoords_Dev(x,y); VirtualCoords result = test.getCoords_Dev(x,y);
bool chk_result = check(expected, result, x, y);
if ( result.x != expected.x || result.y != expected.y ) if ( chk_result )
{ {
std::printf("Requested (%d, %d) -> expecting physical (%d, %d) got (%d, %d).", x, y, expected.x, expected.y, result.x, result.y);
std::cout << "\t *** FAIL ***\n ";
std::cout << "\n";
fail_counter++; fail_counter++;
} }
else else
@ -366,7 +398,36 @@ main(int argc, char* argv[])
} }
} // end chain type test list } // end chain type test list
std::cout << "Performing NON-SERPENTINE (ZIG ZAG) TEST";
rows = 3;
cols = 1;
panel_width_x = 64;
panel_height_y = 64;
VirtualMatrixPanelTest test = VirtualMatrixPanelTest(rows,cols,panel_width_x,panel_height_y, CHAIN_TOP_RIGHT_DOWN_ZZ);
// CHAIN_TOP_RIGHT_DOWN_ZZ test 1
// (x,y)
VirtualCoords result = test.getCoords_Dev(0,0);
VirtualCoords expected; expected.x = 64*2; expected.y = 0;
std::printf("Expected physical (%d, %d) got (%d, %d).\n", expected.x, expected.y, result.x, result.y);
// CHAIN_TOP_RIGHT_DOWN_ZZ test 2
result = test.getCoords_Dev(10,64*3-1);
expected.x = 10; expected.y = 63;
std::printf("Expected physical (%d, %d) got (%d, %d).\n", expected.x, expected.y, result.x, result.y);
// CHAIN_TOP_RIGHT_DOWN_ZZ test 3
result = test.getCoords_Dev(16,64*2-1);
expected.x = 80; expected.y = 63;
std::printf("Expected physical (%d, %d) got (%d, %d).\n", expected.x, expected.y, result.x, result.y);
std::cout << "\n\n";
return 0; return 0;
} }