Skip to content

Commit b232fb0

Browse files
author
Louis Beaudoin
committed
Add PANEL_USES_ALT_ADDRESSING_MODE support to ESP32 (with and without latch), and to MultiRowRefreshMapping example
1 parent 8948bbe commit b232fb0

File tree

3 files changed

+69
-60
lines changed

3 files changed

+69
-60
lines changed

examples/MultiRowRefreshMapping/MultiRowRefreshMapping.ino

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@
4545
* {6, 56, 8},
4646
* {0, 0, 0} // last entry is all zeros
4747
*
48+
* Panels Using Alt Addressing:
49+
* If you see a column of pixels (2 or 4) lighting up, instead of a single pixel, your panel likely uses an alt addressing mode (where instead
50+
* of the address being output binary encoded over the address lines, each address line corresponds to a row, and you ground a single
51+
* address line to select a row). This has only been seen on /2 and /4 panels. Choose a panel type with alt addressing,
52+
* e.g. SMARTMATRIX_HUB75_4ROW_MOD2SCAN_ALT_ADDX for reverse engineering, and you should see only one pixel light up instead of a column at a time.
53+
* If your panel uses alt addressing, make sure you follow the step for PANEL_USES_ALT_ADDRESSING_MODE when you add a new map.
54+
*
4855
* How to add a map and new panel config to SmartMatrix Library
4956
* - Open SmartMatrixCommonHub75.h, add a new definition at the top for your panel. Give it the format
5057
* - SM_PANELTYPE_NUMROW_NUMCOL_MODNSCAN filling in NUMROW, NUMCOL, MODNSCAN
@@ -53,6 +60,7 @@
5360
* - CONVERT_PANELTYPE_TO_MATRIXROWPAIROFFSET - HUB75 panels fill two rows in parallel, what's the spacing? (normally half of panel height)
5461
* - CONVERT_PANELTYPE_TO_MATRIXSCANMOD - This is just the MOD_N_SCAN value for your panel
5562
* - CONVERT_PANELTYPE_TO_MATRIXPANELWIDTH - What's the width of your panel? (This doesn't have to be exact for non-multi-row-scan panels, 32 is used by default)
63+
* - If your panel uses alt addressing (see above), add your panel to PANEL_USES_ALT_ADDRESSING_MODE, otherwise leave it alone
5664
* - Open PanelMaps.cpp
5765
* - Add your map with a unique name
5866
* - Add new case for your new panelType to getMultiRowRefreshPanelMap(), returning your new panelMap
@@ -91,11 +99,13 @@
9199
#if (SKETCH_MODE == MODE_MAP_REVERSE_ENGINEERING)
92100
const uint16_t kMatrixWidth = 128; // must be multiple of 8
93101
const uint16_t kMatrixHeight = 4;
94-
const uint8_t kPanelType = SM_PANELTYPE_HUB75_4ROW_MOD2SCAN; // Use this to reverse engineer mapping for a MOD2 panel
95-
//const uint8_t kPanelType = SM_PANELTYPE_HUB75_8ROW_MOD4SCAN; // Use this to reverse engineer mapping for a MOD4 panel
96-
//const uint8_t kPanelType = SM_PANELTYPE_HUB75_16ROW_MOD8SCAN; // Use this to reverse engineer mapping for a MOD8 panel
97-
//const uint8_t kPanelType = SM_PANELTYPE_HUB75_32ROW_MOD16SCAN; // Use this to reverse engineer mapping for a MOD16 panel
98-
//const uint8_t kPanelType = SM_PANELTYPE_HUB75_64ROW_MOD32SCAN; // Use this to reverse engineer mapping for a MOD32 panel
102+
//const uint8_t kPanelType = SM_PANELTYPE_HUB75_4ROW_MOD2SCAN; // Use this to reverse engineer mapping for a MOD2 panel
103+
//const uint8_t kPanelType = SM_PANELTYPE_HUB75_8ROW_MOD4SCAN; // Use this to reverse engineer mapping for a MOD4 panel
104+
//const uint8_t kPanelType = SM_PANELTYPE_HUB75_16ROW_MOD8SCAN; // Use this to reverse engineer mapping for a MOD8 panel
105+
//const uint8_t kPanelType = SM_PANELTYPE_HUB75_32ROW_MOD16SCAN; // Use this to reverse engineer mapping for a MOD16 panel
106+
//const uint8_t kPanelType = SM_PANELTYPE_HUB75_64ROW_MOD32SCAN; // Use this to reverse engineer mapping for a MOD32 panel
107+
//const uint8_t kPanelType = SM_PANELTYPE_HUB75_4ROW_MOD2SCAN_ALT_ADDX; // Use this to reverse engineer mapping for a MOD2 panel that uses alt addressing
108+
//const uint8_t kPanelType = SM_PANELTYPE_HUB75_8ROW_MOD4SCAN_ALT_ADDX; // Use this to reverse engineer mapping for a MOD4 panel that uses alt addressing
99109
#endif
100110

101111
#if (SKETCH_MODE == MODE_MAP_TESTING)

src/MatrixCommonHub75.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@
4040
#define SM_PANELTYPE_HUB75_32ROW_64COL_MOD8SCAN 10
4141
#define SM_PANELTYPE_HUB75_64ROW_64COL_MOD16SCAN 11
4242
#define SM_PANELTYPE_HUB75_16ROW_32COL_MOD4SCAN_V3 12
43-
#define SM_PANELTYPE_HUB75_16ROW_32COL_MOD4SCAN_V4 13 // Applied patch from https://community.pixelmatix.com/t/mapping-assistance-32x16-p10/889/23 not fully integrated (ESP32 only)
43+
#define SM_PANELTYPE_HUB75_16ROW_32COL_MOD4SCAN_V4 13
4444
#define SM_PANELTYPE_HUB75_16ROW_32COL_MOD2SCAN_V2 14
45+
#define SM_PANELTYPE_HUB75_4ROW_MOD2SCAN_ALT_ADDX 15
46+
#define SM_PANELTYPE_HUB75_8ROW_MOD4SCAN_ALT_ADDX 16
4547

4648
#define SMARTMATRIX_HUB75_32ROW_MOD16SCAN SM_PANELTYPE_HUB75_32ROW_MOD16SCAN
4749
#define SMARTMATRIX_HUB75_16ROW_MOD8SCAN SM_PANELTYPE_HUB75_16ROW_MOD8SCAN
@@ -58,13 +60,17 @@
5860
#define SMARTMATRIX_HUB75_16ROW_32COL_MOD4SCAN_V3 SM_PANELTYPE_HUB75_16ROW_32COL_MOD4SCAN_V3
5961
#define SMARTMATRIX_HUB75_16ROW_32COL_MOD4SCAN_V4 SM_PANELTYPE_HUB75_16ROW_32COL_MOD4SCAN_V4
6062
#define SMARTMATRIX_HUB75_16ROW_32COL_MOD2SCAN_V2 SM_PANELTYPE_HUB75_16ROW_32COL_MOD2SCAN_V2
63+
#define SMARTMATRIX_HUB75_4ROW_MOD2SCAN_ALT_ADDX SM_PANELTYPE_HUB75_4ROW_MOD2SCAN_ALT_ADDX
64+
#define SMARTMATRIX_HUB75_8ROW_MOD4SCAN_ALT_ADDX SM_PANELTYPE_HUB75_8ROW_MOD4SCAN_ALT_ADDX
6165

6266
#define CONVERT_PANELTYPE_TO_MATRIXPANELHEIGHT(x) ((x == SMARTMATRIX_HUB75_32ROW_MOD16SCAN ? 32 : 0) | \
6367
(x == SMARTMATRIX_HUB75_64ROW_64COL_MOD16SCAN ? 64 : 0) | \
6468
(x == SMARTMATRIX_HUB75_16ROW_MOD8SCAN ? 16 : 0) | \
6569
(x == SMARTMATRIX_HUB75_16ROW_32COL_MOD2SCAN ? 16 : 0) | \
6670
(x == SMARTMATRIX_HUB75_4ROW_MOD2SCAN ? 4 : 0) | \
6771
(x == SMARTMATRIX_HUB75_8ROW_MOD4SCAN ? 8 : 0) | \
72+
(x == SMARTMATRIX_HUB75_4ROW_MOD2SCAN_ALT_ADDX ? 4 : 0) | \
73+
(x == SMARTMATRIX_HUB75_8ROW_MOD4SCAN_ALT_ADDX ? 8 : 0) | \
6874
(x == SMARTMATRIX_HUB12_16ROW_32COL_MOD4SCAN ? 16*2 : 0) | \
6975
(x == SMARTMATRIX_HUB75_32ROW_64COL_MOD8SCAN ? 32 : 0) | \
7076
(x == SMARTMATRIX_HUB75_16ROW_32COL_MOD4SCAN ? 16 : 0) | \
@@ -81,6 +87,8 @@
8187
(x == SMARTMATRIX_HUB75_16ROW_32COL_MOD2SCAN ? 8 : 0) | \
8288
(x == SMARTMATRIX_HUB75_4ROW_MOD2SCAN ? 2 : 0) | \
8389
(x == SMARTMATRIX_HUB75_8ROW_MOD4SCAN ? 4 : 0) | \
90+
(x == SMARTMATRIX_HUB75_4ROW_MOD2SCAN_ALT_ADDX ? 2 : 0) | \
91+
(x == SMARTMATRIX_HUB75_8ROW_MOD4SCAN_ALT_ADDX ? 4 : 0) | \
8492
(x == SMARTMATRIX_HUB75_32ROW_64COL_MOD8SCAN ? 16 : 0) | \
8593
(x == SMARTMATRIX_HUB12_16ROW_32COL_MOD4SCAN ? 8*2 : 0) | \
8694
(x == SMARTMATRIX_HUB75_16ROW_32COL_MOD4SCAN ? 8 : 0) | \
@@ -97,6 +105,8 @@
97105
(x == SMARTMATRIX_HUB75_16ROW_32COL_MOD2SCAN ? 2 : 0) | \
98106
(x == SMARTMATRIX_HUB75_4ROW_MOD2SCAN ? 2 : 0) | \
99107
(x == SMARTMATRIX_HUB75_8ROW_MOD4SCAN ? 4 : 0) | \
108+
(x == SMARTMATRIX_HUB75_4ROW_MOD2SCAN_ALT_ADDX ? 2 : 0) | \
109+
(x == SMARTMATRIX_HUB75_8ROW_MOD4SCAN_ALT_ADDX ? 4 : 0) | \
100110
(x == SMARTMATRIX_HUB12_16ROW_32COL_MOD4SCAN ? 4 : 0) | \
101111
(x == SMARTMATRIX_HUB75_16ROW_32COL_MOD4SCAN ? 4 : 0) | \
102112
(x == SMARTMATRIX_HUB75_16ROW_32COL_MOD4SCAN_V2 ? 4 : 0) | \
@@ -113,6 +123,8 @@
113123
(x == SMARTMATRIX_HUB75_16ROW_32COL_MOD2SCAN ? 32 : 0) | \
114124
(x == SMARTMATRIX_HUB75_4ROW_MOD2SCAN ? DEFAULT_PANEL_WIDTH_FOR_LINEAR_PANELS : 0) | \
115125
(x == SMARTMATRIX_HUB75_8ROW_MOD4SCAN ? DEFAULT_PANEL_WIDTH_FOR_LINEAR_PANELS : 0) | \
126+
(x == SMARTMATRIX_HUB75_4ROW_MOD2SCAN_ALT_ADDX ? DEFAULT_PANEL_WIDTH_FOR_LINEAR_PANELS : 0) | \
127+
(x == SMARTMATRIX_HUB75_8ROW_MOD4SCAN_ALT_ADDX ? DEFAULT_PANEL_WIDTH_FOR_LINEAR_PANELS : 0) | \
116128
(x == SMARTMATRIX_HUB12_16ROW_32COL_MOD4SCAN ? 32 : 0) | \
117129
(x == SMARTMATRIX_HUB75_32ROW_64COL_MOD8SCAN ? 64 : 0) | \
118130
(x == SMARTMATRIX_HUB75_16ROW_32COL_MOD4SCAN ? 32 : 0) | \
@@ -125,7 +137,9 @@
125137

126138
// Some panels (usually MOD2/MOD4 panels) use an alt address mode and ground one address line per row, instead of using all the bits. Identify those panels here. Thanks to Eric: https://community.pixelmatix.com/t/mapping-assistance-32x16-p10/889/23
127139
#define PANEL_USES_ALT_ADDRESSING_MODE(x) ((x == SMARTMATRIX_HUB75_16ROW_32COL_MOD4SCAN_V4 ? 1 : 0) | \
128-
(x == SMARTMATRIX_HUB75_16ROW_32COL_MOD2SCAN_V2 ? 1 : 0))
140+
(x == SMARTMATRIX_HUB75_16ROW_32COL_MOD2SCAN_V2 ? 1 : 0) | \
141+
(x == SMARTMATRIX_HUB75_4ROW_MOD2SCAN_ALT_ADDX ? 1 : 0) | \
142+
(x == SMARTMATRIX_HUB75_8ROW_MOD4SCAN_ALT_ADDX ? 1 : 0))
129143

130144
#define MATRIX_PANEL_HEIGHT (CONVERT_PANELTYPE_TO_MATRIXPANELHEIGHT(panelType))
131145
#define MATRIX_STACK_HEIGHT (matrixHeight / MATRIX_PANEL_HEIGHT)

src/MatrixEsp32Hub75Calc_Impl.h

Lines changed: 38 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -623,27 +623,16 @@ INLINE void SmartMatrixHub75Calc<refreshDepth, matrixWidth, matrixHeight, panelT
623623
int gpioRowAddress = currentRow;
624624
// normally output current rows ADDX, special case for LSB, output previous row's ADDX (as previous row is being displayed for one latch cycle)
625625
if(j == 0)
626-
gpioRowAddress = currentRow-1;
627-
628-
if (panelType != SMARTMATRIX_HUB75_16ROW_32COL_MOD4SCAN_V4) {
629-
if (gpioRowAddress & 0x01) v|=BIT_A;
630-
if (gpioRowAddress & 0x02) v|=BIT_B;
631-
if (gpioRowAddress & 0x04) v|=BIT_C;
632-
if (gpioRowAddress & 0x08) v|=BIT_D;
633-
if (gpioRowAddress & 0x10) v|=BIT_E;
634-
} else {
635-
if (gpioRowAddress ==-1){
636-
v|= ( (BIT_A) | ( BIT_B) | ( BIT_C) | ( BIT_D) | ( BIT_E) );
637-
}
638-
else {
639-
switch (gpioRowAddress % 4){
640-
case 0 : v|= ( (!BIT_A) | ( BIT_B) | ( BIT_C) | ( BIT_D)); break;
641-
case 1 : v|= ( ( BIT_A) | (!BIT_B) | ( BIT_C) | ( BIT_D)); break;
642-
case 2 : v|= ( ( BIT_A) | ( BIT_B) | (!BIT_C) | ( BIT_D)); break;
643-
case 3 : v|= ( ( BIT_A) | ( BIT_B) | ( BIT_C) | (!BIT_D)); break;
644-
}
645-
}
646-
}
626+
gpioRowAddress = (currentRow-1 + MATRIX_SCAN_MOD) % MATRIX_SCAN_MOD;
627+
628+
if(PANEL_USES_ALT_ADDRESSING_MODE(panelType))
629+
gpioRowAddress = ~(0x01 << gpioRowAddress);
630+
631+
if (gpioRowAddress & 0x01) v|=BIT_A;
632+
if (gpioRowAddress & 0x02) v|=BIT_B;
633+
if (gpioRowAddress & 0x04) v|=BIT_C;
634+
if (gpioRowAddress & 0x08) v|=BIT_D;
635+
if (gpioRowAddress & 0x10) v|=BIT_E;
647636

648637
// need to disable OE after latch to hide row transition
649638
if((refreshBufferPosition) == 0) v|=BIT_OE;
@@ -770,11 +759,16 @@ INLINE void SmartMatrixHub75Calc<refreshDepth, matrixWidth, matrixHeight, panelT
770759

771760
// set ADDX values to high while latch is high, keep them high while latch drops to clock it in to ADDX latch
772761
if(k >= PIXELS_PER_LATCH) {
773-
if (currentRow & 0x01) v|=BIT_R1;
774-
if (currentRow & 0x02) v|=BIT_G1;
775-
if (currentRow & 0x04) v|=BIT_B1;
776-
if (currentRow & 0x08) v|=BIT_R2;
777-
if (currentRow & 0x10) v|=BIT_G2;
762+
int gpioRowAddress = currentRow;
763+
764+
if(PANEL_USES_ALT_ADDRESSING_MODE(panelType))
765+
gpioRowAddress = ~(0x01 << gpioRowAddress);
766+
767+
if (gpioRowAddress & 0x01) v|=BIT_R1;
768+
if (gpioRowAddress & 0x02) v|=BIT_G1;
769+
if (gpioRowAddress & 0x04) v|=BIT_B1;
770+
if (gpioRowAddress & 0x08) v|=BIT_R2;
771+
if (gpioRowAddress & 0x10) v|=BIT_G2;
778772
// reserve B2 for OE SWITCH
779773
#ifdef OEPWM_TEST_ENABLE
780774
//if(j == 0) {
@@ -940,29 +934,16 @@ INLINE void SmartMatrixHub75Calc<refreshDepth, matrixWidth, matrixHeight, panelT
940934
int gpioRowAddress = currentRow;
941935
// normally output current rows ADDX, special case for LSB, output previous row's ADDX (as previous row is being displayed for one latch cycle)
942936
if(j == 0)
943-
gpioRowAddress = currentRow-1;
937+
gpioRowAddress = (currentRow-1 + MATRIX_SCAN_MOD) % MATRIX_SCAN_MOD;
944938

939+
if(PANEL_USES_ALT_ADDRESSING_MODE(panelType))
940+
gpioRowAddress = ~(0x01 << gpioRowAddress);
945941

946-
// Applied patch from https://community.pixelmatix.com/t/mapping-assistance-32x16-p10/889/23 not fully integrated (ESP32 only)
947-
if (panelType != SMARTMATRIX_HUB75_16ROW_32COL_MOD4SCAN_V4) {
948-
if (gpioRowAddress & 0x01) v|=BIT_A;
949-
if (gpioRowAddress & 0x02) v|=BIT_B;
950-
if (gpioRowAddress & 0x04) v|=BIT_C;
951-
if (gpioRowAddress & 0x08) v|=BIT_D;
952-
if (gpioRowAddress & 0x10) v|=BIT_E;
953-
} else {
954-
if (gpioRowAddress ==-1){
955-
v|= ( (BIT_A) | ( BIT_B) | ( BIT_C) | ( BIT_D) | ( BIT_E) );
956-
}
957-
else {
958-
switch (gpioRowAddress % 4){
959-
case 0 : v|= ( (!BIT_A) | ( BIT_B) | ( BIT_C) | ( BIT_D)); break;
960-
case 1 : v|= ( ( BIT_A) | (!BIT_B) | ( BIT_C) | ( BIT_D)); break;
961-
case 2 : v|= ( ( BIT_A) | ( BIT_B) | (!BIT_C) | ( BIT_D)); break;
962-
case 3 : v|= ( ( BIT_A) | ( BIT_B) | ( BIT_C) | (!BIT_D)); break;
963-
}
964-
}
965-
}
942+
if (gpioRowAddress & 0x01) v|=BIT_A;
943+
if (gpioRowAddress & 0x02) v|=BIT_B;
944+
if (gpioRowAddress & 0x04) v|=BIT_C;
945+
if (gpioRowAddress & 0x08) v|=BIT_D;
946+
if (gpioRowAddress & 0x10) v|=BIT_E;
966947

967948
// need to disable OE after latch to hide row transition
968949
if((refreshBufferPosition) == 0) v|=BIT_OE;
@@ -1069,12 +1050,16 @@ INLINE void SmartMatrixHub75Calc<refreshDepth, matrixWidth, matrixHeight, panelT
10691050

10701051
// set ADDX values to high while latch is high, keep them high while latch drops to clock it in to ADDX latch
10711052
if(k >= PIXELS_PER_LATCH) {
1072-
if (currentRow & 0x01) v|=BIT_R1;
1073-
if (currentRow & 0x02) v|=BIT_G1;
1074-
if (currentRow & 0x04) v|=BIT_B1;
1075-
if (currentRow & 0x08) v|=BIT_R2;
1076-
if (currentRow & 0x10) v|=BIT_G2;
1077-
// reserve B2 for OE SWITCH
1053+
int gpioRowAddress = currentRow;
1054+
1055+
if(PANEL_USES_ALT_ADDRESSING_MODE(panelType))
1056+
gpioRowAddress = ~(0x01 << gpioRowAddress);
1057+
1058+
if (gpioRowAddress & 0x01) v|=BIT_R1;
1059+
if (gpioRowAddress & 0x02) v|=BIT_G1;
1060+
if (gpioRowAddress & 0x04) v|=BIT_B1;
1061+
if (gpioRowAddress & 0x08) v|=BIT_R2;
1062+
if (gpioRowAddress & 0x10) v|=BIT_G2;
10781063
}
10791064

10801065
if(optionFlags & SMARTMATRIX_OPTIONS_HUB12_MODE) {

0 commit comments

Comments
 (0)