diff --git a/src/ESP32-VirtualMatrixPanel-I2S-DMA.h b/src/ESP32-VirtualMatrixPanel-I2S-DMA.h index 93b35a0..6408a30 100644 --- a/src/ESP32-VirtualMatrixPanel-I2S-DMA.h +++ b/src/ESP32-VirtualMatrixPanel-I2S-DMA.h @@ -57,7 +57,8 @@ enum PANEL_CHAIN_TYPE CHAIN_TOP_LEFT_DOWN, CHAIN_TOP_RIGHT_DOWN, 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 @@ -275,6 +276,20 @@ inline VirtualCoords VirtualMatrixPanel::getCoords(int16_t &virt_x, int16_t &vir } 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: diff --git a/testing/README.md b/testing/README.md index 3efe11a..fe6137f 100644 --- a/testing/README.md +++ b/testing/README.md @@ -1,5 +1,5 @@ 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 ``` \ No newline at end of file diff --git a/testing/baseline.hpp b/testing/baseline.hpp index 417409b..43d13e7 100644 --- a/testing/baseline.hpp +++ b/testing/baseline.hpp @@ -5,7 +5,7 @@ * Not thread safe, but not a concern for ESP32 sketch anyway... I think. */ // 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 diff --git a/testing/virtual.cpp b/testing/virtual.cpp index b367c40..f13b2ea 100644 --- a/testing/virtual.cpp +++ b/testing/virtual.cpp @@ -28,7 +28,8 @@ enum PANEL_CHAIN_TYPE CHAIN_TOP_LEFT_DOWN, CHAIN_TOP_RIGHT_DOWN, 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"; break; + case CHAIN_TOP_RIGHT_DOWN_ZZ: + chain_type_str = "CHAIN_TOP_RIGHT_DOWN_ZZ"; + break; + case CHAIN_BOTTOM_RIGHT_UP: chain_type_str = "CHAIN_BOTTOM_RIGHT_UP"; break; @@ -95,9 +100,9 @@ public: std::string chain_type_str = "UNKNOWN"; // 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; @@ -127,7 +132,7 @@ private: /** * 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 @@ -246,6 +251,18 @@ inline VirtualCoords VirtualMatrixPanelTest::getCoords_Dev(int16_t &virt_x, int1 } 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: @@ -309,6 +326,23 @@ inline VirtualCoords VirtualMatrixPanelTest::getCoords_Dev(int16_t &virt_x, int1 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[]) { @@ -343,13 +377,11 @@ main(int argc, char* argv[]) { VirtualCoords expected = test.getCoords_WorkingBaslineMarch2023(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 ) - { - 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"; - + if ( chk_result ) + { fail_counter++; } else @@ -366,7 +398,36 @@ main(int argc, char* argv[]) } } // 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; } \ No newline at end of file