FM6126A init function optimized
some research on brightness control noted in FM6126A.md Signed-off-by: Emil Muratov <gpm@hotplug.ru>
This commit is contained in:
parent
32f5cbab73
commit
7d5f445629
2 changed files with 88 additions and 61 deletions
|
@ -791,91 +791,50 @@ void MatrixPanel_I2S_DMA::shiftDriver(const shift_driver _drv, const int dma_r1_
|
|||
#if SERIAL_DEBUG
|
||||
Serial.println( F("MatrixPanel_I2S_DMA - initializing FM6124 driver..."));
|
||||
#endif
|
||||
int C12[16] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
int C13[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0};
|
||||
bool REG1[16] = {0,0,0,0,0, 1,1,1,1,1,1, 0,0,0,0,0}; // this sets global matrix brighness power
|
||||
bool REG2[16] = {0,0,0,0,0, 0,0,0,0,1,0, 0,0,0,0,0}; // a single bit enables the matrix output
|
||||
|
||||
pinMode(dma_r1_pin, OUTPUT);
|
||||
pinMode(dma_g1_pin, OUTPUT);
|
||||
pinMode(dma_b1_pin, OUTPUT);
|
||||
pinMode(dma_r2_pin, OUTPUT);
|
||||
pinMode(dma_g2_pin, OUTPUT);
|
||||
pinMode(dma_b2_pin, OUTPUT);
|
||||
pinMode(dma_a_pin, OUTPUT);
|
||||
pinMode(dma_b_pin, OUTPUT);
|
||||
pinMode(dma_c_pin, OUTPUT);
|
||||
pinMode(dma_d_pin, OUTPUT);
|
||||
pinMode(dma_e_pin, OUTPUT);
|
||||
pinMode(dma_clk_pin, OUTPUT);
|
||||
pinMode(dma_lat_pin, OUTPUT);
|
||||
pinMode(dma_oe_pin, OUTPUT);
|
||||
for (uint8_t _pin:{dma_r1_pin, dma_r2_pin, dma_g1_pin, dma_g2_pin, dma_b1_pin, dma_b2_pin, dma_clk_pin, dma_lat_pin, dma_oe_pin})
|
||||
pinMode(_pin, OUTPUT);
|
||||
|
||||
// Send Data to control register 11
|
||||
digitalWrite(dma_oe_pin, HIGH); // Display reset
|
||||
digitalWrite(dma_oe_pin, HIGH); // Disable Display
|
||||
digitalWrite(dma_lat_pin, LOW);
|
||||
digitalWrite(dma_clk_pin, LOW);
|
||||
|
||||
// Send Data to control register REG1
|
||||
// this sets the matrix brightness actually
|
||||
for (int l = 0; l < MATRIX_WIDTH; l++){
|
||||
int y = l % 16;
|
||||
digitalWrite(dma_r1_pin, LOW);
|
||||
digitalWrite(dma_g1_pin, LOW);
|
||||
digitalWrite(dma_b1_pin, LOW);
|
||||
digitalWrite(dma_r2_pin, LOW);
|
||||
digitalWrite(dma_g2_pin, LOW);
|
||||
digitalWrite(dma_b2_pin, LOW);
|
||||
for (uint8_t _pin:{dma_r1_pin, dma_r2_pin, dma_g1_pin, dma_g2_pin, dma_b1_pin, dma_b2_pin})
|
||||
digitalWrite(_pin, REG1[l%16]); // we have 16 bits shifters and write the same value all over the matrix array
|
||||
|
||||
if (C12[y] == 1){
|
||||
digitalWrite(dma_r1_pin, HIGH);
|
||||
digitalWrite(dma_g1_pin, HIGH);
|
||||
digitalWrite(dma_b1_pin, HIGH);
|
||||
digitalWrite(dma_r2_pin, HIGH);
|
||||
digitalWrite(dma_g2_pin, HIGH);
|
||||
digitalWrite(dma_b2_pin, HIGH);
|
||||
}
|
||||
|
||||
if (l > MATRIX_WIDTH - 12){
|
||||
if (l > MATRIX_WIDTH - 12){ // pull the latch 12 clocks before the end of matrix so that REG1 starts counting to save the value
|
||||
digitalWrite(dma_lat_pin, HIGH);
|
||||
} else {
|
||||
digitalWrite(dma_lat_pin, LOW);
|
||||
}
|
||||
|
||||
digitalWrite(dma_clk_pin, HIGH);
|
||||
digitalWrite(dma_clk_pin, HIGH); // 1-clock pulse
|
||||
digitalWrite(dma_clk_pin, LOW);
|
||||
}
|
||||
|
||||
// drop the latch and save data to the REG1 all over the FM6124 chips
|
||||
digitalWrite(dma_lat_pin, LOW);
|
||||
digitalWrite(dma_clk_pin, LOW);
|
||||
|
||||
// Send Data to control register 12
|
||||
// Send Data to control register REG2 (enable LED output)
|
||||
for (int l = 0; l < MATRIX_WIDTH; l++){
|
||||
int y = l % 16;
|
||||
digitalWrite(dma_r1_pin, LOW);
|
||||
digitalWrite(dma_g1_pin, LOW);
|
||||
digitalWrite(dma_b1_pin, LOW);
|
||||
digitalWrite(dma_r2_pin, LOW);
|
||||
digitalWrite(dma_g2_pin, LOW);
|
||||
digitalWrite(dma_b2_pin, LOW);
|
||||
for (uint8_t _pin:{dma_r1_pin, dma_r2_pin, dma_g1_pin, dma_g2_pin, dma_b1_pin, dma_b2_pin})
|
||||
digitalWrite(_pin, REG2[l%16]); // we have 16 bits shifters and we write the same value all over the matrix array
|
||||
|
||||
if (C13[y] == 1){
|
||||
digitalWrite(dma_r1_pin, HIGH);
|
||||
digitalWrite(dma_g1_pin, HIGH);
|
||||
digitalWrite(dma_b1_pin, HIGH);
|
||||
digitalWrite(dma_r2_pin, HIGH);
|
||||
digitalWrite(dma_g2_pin, HIGH);
|
||||
digitalWrite(dma_b2_pin, HIGH);
|
||||
}
|
||||
|
||||
if (l > MATRIX_WIDTH - 13){
|
||||
if (l > MATRIX_WIDTH - 13){ // pull the latch 13 clocks before the end of matrix so that reg2 stars counting to save the value
|
||||
digitalWrite(dma_lat_pin, HIGH);
|
||||
} else {
|
||||
digitalWrite(dma_lat_pin, LOW);
|
||||
}
|
||||
digitalWrite(dma_clk_pin, HIGH);
|
||||
digitalWrite(dma_clk_pin, HIGH); // 1-clock pulse
|
||||
digitalWrite(dma_clk_pin, LOW);
|
||||
}
|
||||
|
||||
// drop the latch and save data to the REG1 all over the FM6126 chips
|
||||
digitalWrite(dma_lat_pin, LOW);
|
||||
digitalWrite(dma_clk_pin, LOW);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SHIFT:
|
||||
default:
|
||||
break;
|
||||
|
|
68
FM6126A.md
Normal file
68
FM6126A.md
Normal file
|
@ -0,0 +1,68 @@
|
|||
## The mystery of control registers for FM6126A chips
|
||||
|
||||
|
||||
|
||||
Datasheet for this chis chip is in chineese and does not shed a light on what those two control regs are.
|
||||
|
||||
An excellent insight could be found here
|
||||
|
||||
https://github.com/hzeller/rpi-rgb-led-matrix/issues/746#issuecomment-453860510
|
||||
|
||||
|
||||
|
||||
|
||||
So there are two regs - **REG1** and **REG1**,
|
||||
|
||||
one could be written with 12 clock pusles (and usually called reg12, dunno why :))
|
||||
|
||||
the other one could be written with 13 clock pusles (and usually called reg13, dunno why :))
|
||||
|
||||
|
||||
|
||||
So I've done some measurmens on power consumption while toggling bits of **REG1** and it looks that it could provide a fine grained brighness control over matrix.
|
||||
|
||||
There are 6 bits (6 to 11) giving an increased brighness (compared to all-zeroes) and 4 bits (2-5) giving decreased brighness!!!
|
||||
|
||||
|
||||
|
||||
So it seems that the most bright (and hungry for power) value is
|
||||
|
||||
bool REG1[16] = {0,0,0,0,0, 1,1,1,1,1,1, 0,0,0,0,0}; and not {0,1,1,1,1, 1,1,1,1,1,1, 1,1,1,1,1} as it is usually used.
|
||||
|
||||
I'm not sure about bit 1 - it is either not used or I was unable to measure it's influence to brightness/power.
|
||||
|
||||
|
||||
|
||||
Giving at least 10 bits of hardware brightness control opens pretty nice options for offloading. Should dig into this more deeper.
|
||||
|
||||
|
||||
|
||||
Here are some of the measurments I've took for 2 64x64 panels filled with white color - reg value and corresponding current drain in amps.
|
||||
|
||||
|
||||
|
||||
|REG1 |bit value|Current, amps |
|
||||
|--|--|--|
|
||||
|REG1| 0111111 00000| >5 amps|
|
||||
|REG1| 0100010 00000| 3.890 amp|
|
||||
|REG1| 0100000 00000| 3.885 amp|
|
||||
|REG1| 0011110 00000| 3.640 amp|
|
||||
|REG1| 0011100 00000| 3.620 amp|
|
||||
|REG1| 0011000 00000| 3.240 amp|
|
||||
|REG1| 0010010 00000| 2.520 amp|
|
||||
|REG1| 0010001 00000| 2.518 amp|
|
||||
|REG1| 0010001 10000| 2.493 amp|
|
||||
|REG1| 0010000 00000| 2.490 amp|
|
||||
|REG1| 0010000 11110| 2.214 amp|
|
||||
|REG1| 0001100 00000| 2.120 amp|
|
||||
|REG1| 0001000 00000| 1.750 amp|
|
||||
|REG1| 0000100 00000| 1.375 amp|
|
||||
|REG1| 0000010 00000| 1.000 amp|
|
||||
|REG1| **0000000 00000**| 0.995 amp|
|
||||
|REG1| 0000001 11111| 0.700 amp|
|
||||
|REG1| 0000000 01111| 0.690 amp|
|
||||
|REG1| 0000000 10000| 0.690 amp|
|
||||
|REG1| 0000000 11110| 0.686 amp|
|
||||
|
||||
|
||||
/Vortigont/
|
Loading…
Reference in a new issue