mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 11:46:31 +00:00
Chage MAX7219 8 digit hard limit
This commit is contained in:
parent
2a94554cf1
commit
7c56a0f151
@ -225,7 +225,14 @@ void TM1637Init(void)
|
|||||||
else if (PinUsed(GPIO_MAX7219DIN) && PinUsed(GPIO_MAX7219CLK) && PinUsed(GPIO_MAX7219CS))
|
else if (PinUsed(GPIO_MAX7219DIN) && PinUsed(GPIO_MAX7219CLK) && PinUsed(GPIO_MAX7219CS))
|
||||||
{
|
{
|
||||||
TM1637Data.display_type = MAX7219;
|
TM1637Data.display_type = MAX7219;
|
||||||
Settings->display_width = 8;
|
if (Settings->display_width)
|
||||||
|
{
|
||||||
|
Settings->display_width = (Settings->display_width / 8) * 8;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Settings->display_width = 8;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -254,8 +261,11 @@ void TM1637Init(void)
|
|||||||
else if (MAX7219 == TM1637Data.display_type)
|
else if (MAX7219 == TM1637Data.display_type)
|
||||||
{
|
{
|
||||||
strcpy_P(TM1637Data.model_name, PSTR("MAX7219"));
|
strcpy_P(TM1637Data.model_name, PSTR("MAX7219"));
|
||||||
max7219display = new LedControl(Pin(GPIO_MAX7219DIN), Pin(GPIO_MAX7219CLK), Pin(GPIO_MAX7219CS), 1);
|
max7219display = new LedControl(Pin(GPIO_MAX7219DIN), Pin(GPIO_MAX7219CLK), Pin(GPIO_MAX7219CS), Settings->display_width / 8);
|
||||||
max7219display->shutdown(MAX7219_ADDR, false);
|
for (dev_addr = 0; dev_addr < Settings->display_width / 8; dev_addr++)
|
||||||
|
{
|
||||||
|
max7219display->shutdown(MAX7219_ADDR + dev_addr, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
TM1637ClearDisplay();
|
TM1637ClearDisplay();
|
||||||
TM1637Dim();
|
TM1637Dim();
|
||||||
@ -266,15 +276,13 @@ void TM1637Init(void)
|
|||||||
// Function to display specified ascii char at specified position for MAX7219
|
// Function to display specified ascii char at specified position for MAX7219
|
||||||
void displayMAX7219ASCII(uint8_t pos, char c)
|
void displayMAX7219ASCII(uint8_t pos, char c)
|
||||||
{
|
{
|
||||||
pos = 7 - pos;
|
max7219display->setChar(MAX7219_ADDR + (pos / 8), 7 - (pos % 8), c, false);
|
||||||
max7219display->setChar(MAX7219_ADDR, pos, c, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to display specified ascii char with dot at specified position for MAX7219
|
// Function to display specified ascii char with dot at specified position for MAX7219
|
||||||
void displayMAX7219ASCIIwDot(uint8_t pos, char c)
|
void displayMAX7219ASCIIwDot(uint8_t pos, char c)
|
||||||
{
|
{
|
||||||
pos = 7 - pos;
|
max7219display->setChar(MAX7219_ADDR + (pos / 8), 7 - (pos % 8), c, true);
|
||||||
max7219display->setChar(MAX7219_ADDR, pos, c, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to display raw segments at specified position for MAX7219
|
// Function to display raw segments at specified position for MAX7219
|
||||||
@ -292,8 +300,7 @@ void displayMAX72197Seg(uint8_t pos, uint8_t seg)
|
|||||||
}
|
}
|
||||||
seg = reverse_num;
|
seg = reverse_num;
|
||||||
|
|
||||||
pos = 7 - pos;
|
max7219display->setRow(MAX7219_ADDR + (pos / 8), 7 - (pos % 8), seg);
|
||||||
max7219display->setRow(MAX7219_ADDR, pos, seg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to fix order of hardware digits for different TM1637 variants
|
// Function to fix order of hardware digits for different TM1637 variants
|
||||||
@ -379,7 +386,7 @@ bool CmndTM1637Number(bool clear)
|
|||||||
tm1638display->displayASCII(i, pad);
|
tm1638display->displayASCII(i, pad);
|
||||||
else if (MAX7219 == TM1637Data.display_type)
|
else if (MAX7219 == TM1637Data.display_type)
|
||||||
{
|
{
|
||||||
if (i > 7)
|
if (i > Settings->display_width - 1)
|
||||||
break;
|
break;
|
||||||
displayMAX7219ASCII(i, pad);
|
displayMAX7219ASCII(i, pad);
|
||||||
}
|
}
|
||||||
@ -400,7 +407,7 @@ bool CmndTM1637Number(bool clear)
|
|||||||
tm1638display->displayASCII(i, txt[j]);
|
tm1638display->displayASCII(i, txt[j]);
|
||||||
else if (MAX7219 == TM1637Data.display_type)
|
else if (MAX7219 == TM1637Data.display_type)
|
||||||
{
|
{
|
||||||
if (i > 7)
|
if (i > Settings->display_width - 1)
|
||||||
break;
|
break;
|
||||||
if (txt[j] == 0)
|
if (txt[j] == 0)
|
||||||
break;
|
break;
|
||||||
@ -505,7 +512,7 @@ bool CmndTM1637Float(bool clear)
|
|||||||
{
|
{
|
||||||
for (uint32_t i = 0, j = 0; i < length; i++, j++)
|
for (uint32_t i = 0, j = 0; i < length; i++, j++)
|
||||||
{
|
{
|
||||||
if ((j + position) > 7)
|
if ((j + position) > Settings->display_width - 1)
|
||||||
break;
|
break;
|
||||||
if (txt[i] == 0)
|
if (txt[i] == 0)
|
||||||
break;
|
break;
|
||||||
@ -553,7 +560,10 @@ void TM1637ClearDisplay(void)
|
|||||||
}
|
}
|
||||||
else if (MAX7219 == TM1637Data.display_type)
|
else if (MAX7219 == TM1637Data.display_type)
|
||||||
{
|
{
|
||||||
max7219display->clearDisplay(MAX7219_ADDR);
|
for (dev_addr = 0; dev_addr < Settings->display_width / 8; dev_addr++)
|
||||||
|
{
|
||||||
|
max7219display->clearDisplay(MAX7219_ADDR + dev_addr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -821,7 +831,7 @@ bool CmndTM1637Raw(void)
|
|||||||
{
|
{
|
||||||
for (uint32_t i = position; i < position + length; i++)
|
for (uint32_t i = position; i < position + length; i++)
|
||||||
{
|
{
|
||||||
if (i > 7)
|
if (i > Settings->display_width - 1)
|
||||||
break;
|
break;
|
||||||
displayMAX72197Seg(i, DATA[i - position]);
|
displayMAX72197Seg(i, DATA[i - position]);
|
||||||
}
|
}
|
||||||
@ -921,7 +931,7 @@ bool CmndTM1637Text(bool clear)
|
|||||||
uint8_t rawBytes[1];
|
uint8_t rawBytes[1];
|
||||||
for (uint32_t j = 0; i < position + length; i++, j++)
|
for (uint32_t j = 0; i < position + length; i++, j++)
|
||||||
{
|
{
|
||||||
if (i > 7)
|
if (i > Settings->display_width - 1)
|
||||||
break;
|
break;
|
||||||
if (sString[j] == 0)
|
if (sString[j] == 0)
|
||||||
break;
|
break;
|
||||||
@ -1102,7 +1112,10 @@ void TM1637Dim(void)
|
|||||||
}
|
}
|
||||||
else if (MAX7219 == TM1637Data.display_type)
|
else if (MAX7219 == TM1637Data.display_type)
|
||||||
{
|
{
|
||||||
max7219display->setIntensity(MAX7219_ADDR, brightness); // 0 - 7
|
for (dev_addr = 0; dev_addr < Settings->display_width / 8; dev_addr++)
|
||||||
|
{
|
||||||
|
max7219display->setIntensity(MAX7219_ADDR, brightness); // 0 - 7
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user