Тема: Термометр DS18B20 MX7219

Есть рабочий скетч, просто термометр на DS18b20 и MX7219. Всё прекрасно работает на 4х модулях mx7219. Но хочется собрать по компактнее на 3х модулях. Символ °С не нужен я его отключаю. И вот на пустое место надо сдвинуть всю информацию. Сам справиться не могу. Помогите пожалуйста.

#include "Arduino.h"      //CS 10; CLK 11; DIN 12.
#include "LedControl.h"
#include "OneWire.h"

OneWire ds(8);

LedControl lc = LedControl(12, 11, 10, 3);

byte Num0[8] =
{ B0000000,
B01110000,
B10001000,
B10001000,
B10001000,
B10001000,
B10001000,
B01110000 };

byte Num1[8] =
{ B00000000,
B01000000,
B11000000,
B01000000,
B01000000,
B01000000,
B01000000,
B11100000 };

byte Num2[8] =
{ B00000000,
B01110000,
B10001000,
B00001000,
B00010000,
B00100000,
B01000000,
B11111000 };

byte Num3[8] =
{ B00000000,
B11111000,
B00010000,
B00100000,
B00010000,
B00001000,
B10001000,
B01110000 };

byte Num4[8] =
{ B00000000,
B00010000,
B00110000,
B01010000,
B10010000,
B11111000,
B00010000,
B00010000 };

byte Num5[8] =
{ B00000000,
B11111000,
B10000000,
B11110000,
B00001000,
B00001000,
B10001000,
B01110000 };

byte Num6[8] =
{ B00000000,
B00110000,
B01000000,
B10000000,
B11110000,
B10001000,
B10001000,
B01110000 };

byte Num7[8] =
{ B00000000,
B11111000,
B00001000,
B00001000,
B00010000,
B00100000,
B01000000,
B01000000 };

byte Num8[8] =
{ B00000000,
B01110000,
B10001000,
B10001000,
B01110000,
B10001000,
B10001000,
B01110000 };

byte Num9[8] =
{ B00000000,
B01110000,
B10001000,
B10001000,
B01111000,
B00001000,
B00010000,
B01100000 };

byte Minus[8] =
{ B00000000,
B00000000,
B00000000,
B00000000,
B11100000,
B00000000,
B00000000,
B00000000 };

byte Plus[8] =
{ B00000000,
B00000000,
B00000000,
B01000000,
B11100000,
B01000000,
B00000000,
B00000000 };

byte Dot[8] =
{ B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B10000000 };

byte DegreeC[8] =
{ B01100000,
B10010000,
B10010110,
B01101001,
B00001000,
B00001000,
B00001001,
B00000110 };

byte Empty[8] =
{ B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000
};

byte ReadyDigit2[8]; // Include fragment of 1 digit and full 2 digit
byte BufferedDigit[8]; // Push to buffer 1 digit
uint8_t CurrentDigit2, intensity;

int HighByte, LowByte, TReading, SignBit, Tc_100, Whole, Fract;

unsigned long currentMillis, nowMillis;

void setup()
{
	Serial.begin(9600);

	intensity = 2;

	lc.shutdown(0, false);
	lc.setIntensity(0, intensity);
	lc.clearDisplay(0);

	lc.shutdown(1, false);
	lc.setIntensity(1, intensity);
	lc.clearDisplay(1);

	lc.shutdown(2, false);
	lc.setIntensity(2, intensity);
	lc.clearDisplay(2);

	lc.shutdown(3, false);
	lc.setIntensity(3, intensity);
	lc.clearDisplay(3);

	Degree();
}

void loop()
{
	String Sign;
	uint8_t ReadyFract;
	byte i;
	byte present = 0;
	byte data[12];
	byte addr[8];

  nowMillis = millis();

	if (nowMillis - currentMillis >= 100)
	{
		ds.reset_search();
		if (!ds.search(addr))
		{
			ds.reset_search();
			return;
		}
		ds.reset();
		ds.select(addr);
		ds.write(0x44, 1);

		currentMillis = millis();
	}

	present = ds.reset();
	ds.select(addr);
	ds.write(0xBE);

	for (i = 0; i < 9; i++)
	{
		data[i] = ds.read();
	}

	LowByte = data[0];
	HighByte = data[1];
	TReading = (HighByte << 8) + LowByte;
	SignBit = TReading & 0x8000;

	if (SignBit)
	{
		TReading = (TReading ^ 0xffff) + 1;
	}
	Tc_100 = (6 * TReading) + TReading / 4;
	Whole = Tc_100 / 100;
	Fract = Tc_100 % 100;

	if (SignBit)
	{
		Sign = "Minus";
	}
	else if (!SignBit && TReading != 0)
	{
		Sign = "Plus";
	}
	else if (TReading == 0)
	{
		Sign = "None";
	}

	if (Fract < 10)
	{
		ReadyFract = 0;
	}
	else if (Fract % 10 < 5)
	{
		ReadyFract = Fract / 10;
	}
	else if (Fract % 10 >= 5)
	{
		ReadyFract = (Fract / 10) + 1;
	}

	Digit1(Whole / 10, Sign);
	Digit2(Whole % 10);
	Digit3(ReadyFract, true);
}

void Digit1(uint8_t Dig, String Sign)
{
	switch (Dig)
	{
	case 0:
	{
		for (uint8_t i = 0; i < 8; i++)
		{
			BufferedDigit[i] = Empty[i];

          if (CurrentDigit2 == 0 && CurrentDigit2 != 0)
          {
            lc.setRow(2, i, BufferedDigit[i] << 4);
          }

          if (Sign == "Plus")
          {
            lc.setRow(3, i, Plus[i] >> 5);
          }
          else if (Sign == "Minus")
          {
            lc.setRow(3, i, Minus[i] >> 5);
          }
          else if (Sign == "None")
          {
            lc.setRow(3, i, Num0[i] >> 4);
          }
        }
		break;
	}
	case 1:
	{
		for (uint8_t i = 0; i < 8; i++)
		{
			BufferedDigit[i] = Num1[i] >> 2;

			if (CurrentDigit2 == 1 && CurrentDigit2 != 1)
			{
				lc.setRow(2, i, BufferedDigit[i] << 4);
			}

			if (Sign == "Plus")
			{
				lc.setRow(3, i, Num1[i] >> 6 | Plus[i]);
			}
			else if (Sign == "Minus")
			{
				lc.setRow(3, i, Num1[i] >> 6 | Minus[i]);
			}
			else if (Sign == "None")
			{
				lc.setRow(3, i, Num1[i] >> 6);
			}
		}
		break;
	}
	case 2:
	{
		for (uint8_t i = 0; i < 8; i++)
		{
			BufferedDigit[i] = Num2[i];

			if (CurrentDigit2 == 2 && CurrentDigit2 != 2)
			{
				lc.setRow(2, i, BufferedDigit[i] << 4);
			}

			if (Sign == "Plus")
			{
				lc.setRow(3, i, Num2[i] >> 4 | Plus[i]);
			}
			else if (Sign == "Minus")
			{
				lc.setRow(3, i, Num2[i] >> 4 | Minus[i]);
			}
			else if (Sign == "None")
			{
				lc.setRow(3, i, Num2[i] >> 4);
			}
		}
		break;
	}
	case 3:
	{
		for (uint8_t i = 0; i < 8; i++)
		{
			BufferedDigit[i] = Num3[i];

			if (CurrentDigit2 == 3 && CurrentDigit2 != 3)
			{
				lc.setRow(2, i, BufferedDigit[i] << 4);
			}

			if (Sign == "Plus")
			{
				lc.setRow(3, i, Num3[i] >> 4 | Plus[i]);
			}
			else if (Sign == "Minus")
			{
				lc.setRow(3, i, Num3[i] >> 4 | Minus[i]);
			}
			else if (Sign == "None")
			{
				lc.setRow(3, i, Num3[i] >> 4);
			}
		}
		break;
	}
	case 4:
	{
		for (uint8_t i = 0; i < 8; i++)
		{
			BufferedDigit[i] = Num4[i];

			if (CurrentDigit2 == 4 && CurrentDigit2 != 4)
			{
				lc.setRow(2, i, BufferedDigit[i] << 4);
			}

			if (Sign == "Plus")
			{
				lc.setRow(3, i, Num4[i] >> 4 | Plus[i]);
			}
			else if (Sign == "Minus")
			{
				lc.setRow(3, i, Num4[i] >> 4 | Minus[i]);
			}
			else if (Sign == "None")
			{
				lc.setRow(3, i, Num4[i] >> 4);
			}
		}
		break;
	}
	case 5:
	{
		for (uint8_t i = 0; i < 8; i++)
		{
			BufferedDigit[i] = Num5[i];

			if (CurrentDigit2 == 5 && CurrentDigit2 != 5)
			{
				lc.setRow(2, i, BufferedDigit[i] << 4);
			}

			if (Sign == "Plus")
			{
				lc.setRow(3, i, Num5[i] >> 4 | Plus[i]);
			}
			else if (Sign == "Minus")
			{
				lc.setRow(3, i, Num5[i] >> 4 | Minus[i]);
			}
			else if (Sign == "None")
			{
				lc.setRow(3, i, Num5[i] >> 4);
			}
		}
		break;
	}
	case 6:
	{
		for (uint8_t i = 0; i < 8; i++)
		{
			BufferedDigit[i] = Num6[i];

			if (CurrentDigit2 == 6 && CurrentDigit2 != 6)
			{
				lc.setRow(2, i, BufferedDigit[i] << 4);
			}

			if (Sign == "Plus")
			{
				lc.setRow(3, i, Num6[i] >> 4 | Plus[i]);
			}
			else if (Sign == "Minus")
			{
				lc.setRow(3, i, Num6[i] >> 4 | Minus[i]);
			}
			else if (Sign == "None")
			{
				lc.setRow(3, i, Num6[i] >> 4);
			}
		}
		break;
	}
	case 7:
	{
		for (uint8_t i = 0; i < 8; i++)
		{
			BufferedDigit[i] = Num7[i];

			if (CurrentDigit2 == 7 && CurrentDigit2 != 7)
			{
				lc.setRow(2, i, BufferedDigit[i] << 4);
			}

			if (Sign == "Plus")
			{
				lc.setRow(3, i, Num7[i] >> 4 | Plus[i]);
			}
			else if (Sign == "Minus")
			{
				lc.setRow(3, i, Num7[i] >> 4 | Minus[i]);
			}
			else if (Sign == "None")
			{
				lc.setRow(3, i, Num7[i] >> 4);
			}
		}
		break;
	}
	case 8:
	{
		for (uint8_t i = 0; i < 8; i++)
		{
			BufferedDigit[i] = Num8[i];

			if (CurrentDigit2 == 8 && CurrentDigit2 != 8)
			{
				lc.setRow(2, i, BufferedDigit[i] << 4);
			}

			if (Sign == "Plus")
			{
				lc.setRow(3, i, Num8[i] >> 4 | Plus[i]);
			}
			else if (Sign == "Minus")
			{
				lc.setRow(3, i, Num8[i] >> 4 | Minus[i]);
			}
			else if (Sign == "None")
			{
				lc.setRow(3, i, Num8[i] >> 4);
			}
		}
		break;
	}
	case 9:
	{
		for (uint8_t i = 0; i < 8; i++)
		{
			BufferedDigit[i] = Num9[i];

			if (CurrentDigit2 == 9 && CurrentDigit2 != 9)
			{
				lc.setRow(2, i, BufferedDigit[i] << 4);
			}

			if (Sign == "Plus")
			{
				lc.setRow(3, i, Num9[i] >> 4 | Plus[i]);
			}
			else if (Sign == "Minus")
			{
				lc.setRow(3, i, Num9[i] >> 4 | Minus[i]);
			}
			else if (Sign == "None")
			{
				lc.setRow(3, i, Num9[i] >> 4);
			}
		}
		break;
		default:
		Dig = 0;
	}
	}
}

void Digit2(uint8_t Dig)
{
	switch (Dig)
	{
	case 0:
	{
		CurrentDigit2 = 0;
		for (uint8_t i = 0; i < 8; i++)
		{
			ReadyDigit2[i] = (BufferedDigit[i] << 4) | (Num0[i] >> 2);
			lc.setRow(2, i, ReadyDigit2[i]);
		}
		break;
	}
	case 1:
	{
		CurrentDigit2 = 1;
		for (uint8_t i = 0; i < 8; i++)
		{
			ReadyDigit2[i] = (BufferedDigit[i] << 4) | (Num1[i] >> 3);
			lc.setRow(2, i, ReadyDigit2[i]);
		}
		break;
	}
	case 2:
	{
		CurrentDigit2 = 2;
		for (uint8_t i = 0; i < 8; i++)
		{
			ReadyDigit2[i] = (BufferedDigit[i] << 4) | (Num2[i] >> 2);
			lc.setRow(2, i, ReadyDigit2[i]);
		}
		break;
	}
	case 3:
	{
		CurrentDigit2 = 3;
		for (uint8_t i = 0; i < 8; i++)
		{
			ReadyDigit2[i] = (BufferedDigit[i] << 4) | (Num3[i] >> 2);
			lc.setRow(2, i, ReadyDigit2[i]);
		}
		break;
	}
	case 4:
	{
		CurrentDigit2 = 4;
		for (uint8_t i = 0; i < 8; i++)
		{
			ReadyDigit2[i] = (BufferedDigit[i] << 4) | (Num4[i] >> 2);
			lc.setRow(2, i, ReadyDigit2[i]);
		}
		break;
	}
	case 5:
	{
		CurrentDigit2 = 5;
		for (uint8_t i = 0; i < 8; i++)
		{
			ReadyDigit2[i] = (BufferedDigit[i] << 4) | (Num5[i] >> 2);
			lc.setRow(2, i, ReadyDigit2[i]);
		}
		break;
	}
	case 6:
	{
		CurrentDigit2 = 6;
		for (uint8_t i = 0; i < 8; i++)
		{
			ReadyDigit2[i] = (BufferedDigit[i] << 4) | (Num6[i] >> 2);
			lc.setRow(2, i, ReadyDigit2[i]);
		}
		break;
	}
	case 7:
	{
		CurrentDigit2 = 7;
		for (uint8_t i = 0; i < 8; i++)
		{
			ReadyDigit2[i] = (BufferedDigit[i] << 4) | (Num7[i] >> 2);
			lc.setRow(2, i, ReadyDigit2[i]);
		}
		break;
	}
	case 8:
	{
		CurrentDigit2 = 8;
		for (uint8_t i = 0; i < 8; i++)
		{
			ReadyDigit2[i] = (BufferedDigit[i] << 4) | (Num8[i] >> 2);
			lc.setRow(2, i, ReadyDigit2[i]);
		}
		break;
	}
	case 9:
	{
		CurrentDigit2 = 9;
		for (uint8_t i = 0; i < 8; i++)
		{
			ReadyDigit2[i] = (BufferedDigit[i] << 4) | (Num9[i] >> 2);
			lc.setRow(2, i, ReadyDigit2[i]);
		}
		break;
		default:
		Dig = 0;
	}
	}
}

void Digit3(uint8_t Dig, bool DotBool)
{
	switch (Dig)
	{
	case 0:
	{
		if (!DotBool)
		{
			for (uint8_t i = 0; i < 8; i++)
			{
				lc.setRow(1, i, Num0[i] >> 2);
			}
		}
		else
			for (uint8_t i = 0; i < 8; i++)
			{
				byte Num0Dot[8];
				Num0Dot[i] = (Num0[i] >> 2) | (Dot[i]);
				lc.setRow(1, i, Num0Dot[i]);
			}
		break;
	}
	case 1:
	{
		if (!DotBool)
		{
			for (uint8_t i = 0; i < 8; i++)
			{
				lc.setRow(1, i, Num1[i] >> 3);
			}
		}
		else
			for (uint8_t i = 0; i < 8; i++)
			{
				byte Num1Dot[8];
				Num1Dot[i] = (Num1[i] >> 3) | (Dot[i]);
				lc.setRow(1, i, Num1Dot[i]);
			}
		break;
	}
	case 2:
	{
		if (!DotBool)
		{
			for (uint8_t i = 0; i < 8; i++)
			{
				lc.setRow(1, i, Num2[i] >> 2);
			}
		}
		else
			for (uint8_t i = 0; i < 8; i++)
			{
				byte Num2Dot[8];
				Num2Dot[i] = (Num2[i] >> 2) | (Dot[i]);
				lc.setRow(1, i, Num2Dot[i]);
			}
		break;
	}
	case 3:
	{
		if (!DotBool)
		{

			for (uint8_t i = 0; i < 8; i++)
			{
				lc.setRow(1, i, Num3[i] >> 2);
			}
		}
		else
			for (uint8_t i = 0; i < 8; i++)
			{
				byte Num3Dot[8];
				Num3Dot[i] = (Num3[i] >> 2) | (Dot[i]);
				lc.setRow(1, i, Num3Dot[i]);
			}
		break;
	}
	case 4:
	{
		if (!DotBool)
		{

			for (uint8_t i = 0; i < 8; i++)
			{
				lc.setRow(1, i, Num4[i] >> 2);
			}
		}
		else
			for (uint8_t i = 0; i < 8; i++)
			{
				byte Num4Dot[8];
				Num4Dot[i] = (Num4[i] >> 2) | (Dot[i]);
				lc.setRow(1, i, Num4Dot[i]);
			}
		break;
	}
	case 5:
	{
		if (!DotBool)
		{
			for (uint8_t i = 0; i < 8; i++)
			{
				lc.setRow(1, i, Num5[i] >> 2);
			}
		}
		else
			for (uint8_t i = 0; i < 8; i++)
			{
				byte Num5Dot[8];
				Num5Dot[i] = (Num5[i] >> 2) | (Dot[i]);
				lc.setRow(1, i, Num5Dot[i]);
			}
		break;
	}
	case 6:
	{
		if (!DotBool)
		{
			for (uint8_t i = 0; i < 8; i++)
			{
				lc.setRow(1, i, Num6[i] >> 2);
			}
		}
		else
			for (uint8_t i = 0; i < 8; i++)
			{
				byte Num6Dot[8];
				Num6Dot[i] = (Num6[i] >> 2) | (Dot[i]);
				lc.setRow(1, i, Num6Dot[i]);
			}
		break;
	}
	case 7:
	{
		if (!DotBool)
		{
			for (uint8_t i = 0; i < 8; i++)
			{
				lc.setRow(1, i, Num7[i] >> 2);
			}
		}
		else
			for (uint8_t i = 0; i < 8; i++)
			{
				byte Num7Dot[8];
				Num7Dot[i] = (Num7[i] >> 2) | (Dot[i]);
				lc.setRow(1, i, Num7Dot[i]);
			}
		break;
	}
	case 8:
	{
		if (!DotBool)
		{
			for (uint8_t i = 0; i < 8; i++)
			{
				lc.setRow(1, i, Num8[i] >> 2);
			}
		}
		else
			for (uint8_t i = 0; i < 8; i++)
			{
				byte Num8Dot[8];
				Num8Dot[i] = (Num8[i] >> 2) | (Dot[i]);
				lc.setRow(1, i, Num8Dot[i]);
			}
		break;
	}
	case 9:
	{
		if (!DotBool)
		{
			for (uint8_t i = 0; i < 8; i++)
			{
				lc.setRow(1, i, Num9[i] >> 2);
			}
		}
		else
			for (uint8_t i = 0; i < 8; i++)
			{
				byte Num9Dot[8];
				Num9Dot[i] = (Num9[i] >> 2) | (Dot[i]);
				lc.setRow(1, i, Num9Dot[i]);
			}
		break;
		default:
		Dig = 0;
	}
	}
}

void Degree(void)
{
	for (uint8_t i = 0; i < 8; i++)
	{
		lc.setRow(0, i, DegreeC[i]);
	}
}

2

Re: Термометр DS18B20 MX7219

К сожалению у меня нет модулей MX7219, я ни когда с ними не работал, поэтому не смогу Вам помочь.

3 (2021-01-31 14:41:02 отредактировано S_Sergey_G)

Re: Термометр DS18B20 MX7219

Ребята с другого форума помогли. Вот код термометра на 3 матрицы с датчиком DS18B20:

#include "Arduino.h"      //CS 10; CLK 11; DIN 12.
#include "LedControl.h"
#include "OneWire.h"

OneWire ds(8);

LedControl lc = LedControl(12, 11, 10, 3);

byte Num0[8] =
{ B0000000,
B01110000,
B10001000,
B10001000,
B10001000,
B10001000,
B10001000,
B01110000 };

byte Num1[8] =
{ B00000000,
B01000000,
B11000000,
B01000000,
B01000000,
B01000000,
B01000000,
B11100000 };

byte Num2[8] =
{ B00000000,
B01110000,
B10001000,
B00001000,
B00010000,
B00100000,
B01000000,
B11111000 };

byte Num3[8] =
{ B00000000,
B11111000,
B00010000,
B00100000,
B00010000,
B00001000,
B10001000,
B01110000 };

byte Num4[8] =
{ B00000000,
B00010000,
B00110000,
B01010000,
B10010000,
B11111000,
B00010000,
B00010000 };

byte Num5[8] =
{ B00000000,
B11111000,
B10000000,
B11110000,
B00001000,
B00001000,
B10001000,
B01110000 };

byte Num6[8] =
{ B00000000,
B00110000,
B01000000,
B10000000,
B11110000,
B10001000,
B10001000,
B01110000 };

byte Num7[8] =
{ B00000000,
B11111000,
B00001000,
B00001000,
B00010000,
B00100000,
B01000000,
B01000000 };

byte Num8[8] =
{ B00000000,
B01110000,
B10001000,
B10001000,
B01110000,
B10001000,
B10001000,
B01110000 };

byte Num9[8] =
{ B00000000,
B01110000,
B10001000,
B10001000,
B01111000,
B00001000,
B00010000,
B01100000 };

byte Minus[8] =
{ B00000000,
B00000000,
B00000000,
B00000000,
B11100000,
B00000000,
B00000000,
B00000000 };

byte Plus[8] =
{ B00000000,
B00000000,
B00000000,
B01000000,
B11100000,
B01000000,
B00000000,
B00000000 };

byte Dot[8] =
{ B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B10000000 };

byte Empty[8] =
{ B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000
};

byte ReadyDigit2[8]; // Include fragment of 1 digit and full 2 digit
byte BufferedDigit[8]; // Push to buffer 1 digit
uint8_t CurrentDigit2, intensity;

int HighByte, LowByte, TReading, SignBit, Tc_100, Whole, Fract;

unsigned long currentMillis, nowMillis;

void setup()
{
    Serial.begin(9600);

    intensity = 2;

    lc.shutdown(0, false);
    lc.setIntensity(0, intensity);
    lc.clearDisplay(0);

    lc.shutdown(1, false);
    lc.setIntensity(1, intensity);
    lc.clearDisplay(1);

    lc.shutdown(2, false);
    lc.setIntensity(2, intensity);
    lc.clearDisplay(2);

    lc.shutdown(3, false);
    lc.setIntensity(3, intensity);
    lc.clearDisplay(3);
}

void loop()
{
    String Sign;
    uint8_t ReadyFract;
    byte i;
    byte present = 0;
    byte data[12];
    byte addr[8];

  nowMillis = millis();

    if (nowMillis - currentMillis >= 100)
    {
        ds.reset_search();
        if (!ds.search(addr))
        {
            ds.reset_search();
            return;
        }
        ds.reset();
        ds.select(addr);
        ds.write(0x44, 1);

        currentMillis = millis();
    }

    present = ds.reset();
    ds.select(addr);
    ds.write(0xBE);

    for (i = 0; i < 9; i++)
    {
        data[i] = ds.read();
    }

    LowByte = data[0];
    HighByte = data[1];
    TReading = (HighByte << 8) + LowByte;
    SignBit = TReading & 0x8000;

    if (SignBit)
    {
        TReading = (TReading ^ 0xffff) + 1;
    }
    Tc_100 = (6 * TReading) + TReading / 4;
    Whole = Tc_100 / 100;
    Fract = Tc_100 % 100;

    if (SignBit)
    {
        Sign = "Minus";
    }
    else if (!SignBit && TReading != 0)
    {
        Sign = "Plus";
    }
    else if (TReading == 0)
    {
        Sign = "None";
    }

    if (Fract < 10)
    {
        ReadyFract = 0;
    }
    else if (Fract % 10 < 5)
    {
        ReadyFract = Fract / 10;
    }
    else if (Fract % 10 >= 5)
    {
        ReadyFract = (Fract / 10) + 1;
    }

    Digit1(Whole / 10, Sign);
    Digit2(Whole % 10);
    Digit3(ReadyFract, true);
}

void Digit1(uint8_t Dig, String Sign)
{
    switch (Dig)
    {
    case 0:
    {
        for (uint8_t i = 0; i < 8; i++)
        {
            BufferedDigit[i] = Empty[i];

          if (CurrentDigit2 == 0 && CurrentDigit2 != 0)
          {
            lc.setRow(1, i, BufferedDigit[i] << 4);
          }

          if (Sign == "Plus")
          {
            lc.setRow(2, i, Plus[i] >> 5);
          }
          else if (Sign == "Minus")
          {
            lc.setRow(2, i, Minus[i] >> 5);
          }
          else if (Sign == "None")
          {
            lc.setRow(2, i, Num0[i] >> 4);
          }
        }
        break;
    }
    case 1:
    {
        for (uint8_t i = 0; i < 8; i++)
        {
            BufferedDigit[i] = Num1[i] >> 2;

            if (CurrentDigit2 == 1 && CurrentDigit2 != 1)
            {
                lc.setRow(1, i, BufferedDigit[i] << 4);
            }

            if (Sign == "Plus")
            {
                lc.setRow(2, i, Num1[i] >> 6 | Plus[i]);
            }
            else if (Sign == "Minus")
            {
                lc.setRow(2, i, Num1[i] >> 6 | Minus[i]);
            }
            else if (Sign == "None")
            {
                lc.setRow(2, i, Num1[i] >> 6);
            }
        }
        break;
    }
    case 2:
    {
        for (uint8_t i = 0; i < 8; i++)
        {
            BufferedDigit[i] = Num2[i];

            if (CurrentDigit2 == 2 && CurrentDigit2 != 2)
            {
                lc.setRow(1, i, BufferedDigit[i] << 4);
            }

            if (Sign == "Plus")
            {
                lc.setRow(2, i, Num2[i] >> 4 | Plus[i]);
            }
            else if (Sign == "Minus")
            {
                lc.setRow(2, i, Num2[i] >> 4 | Minus[i]);
            }
            else if (Sign == "None")
            {
                lc.setRow(2, i, Num2[i] >> 4);
            }
        }
        break;
    }
    case 3:
    {
        for (uint8_t i = 0; i < 8; i++)
        {
            BufferedDigit[i] = Num3[i];

            if (CurrentDigit2 == 3 && CurrentDigit2 != 3)
            {
                lc.setRow(1, i, BufferedDigit[i] << 4);
            }

            if (Sign == "Plus")
            {
                lc.setRow(2, i, Num3[i] >> 4 | Plus[i]);
            }
            else if (Sign == "Minus")
            {
                lc.setRow(2, i, Num3[i] >> 4 | Minus[i]);
            }
            else if (Sign == "None")
            {
                lc.setRow(2, i, Num3[i] >> 4);
            }
        }
        break;
    }
    case 4:
    {
        for (uint8_t i = 0; i < 8; i++)
        {
            BufferedDigit[i] = Num4[i];

            if (CurrentDigit2 == 4 && CurrentDigit2 != 4)
            {
                lc.setRow(1, i, BufferedDigit[i] << 4);
            }

            if (Sign == "Plus")
            {
                lc.setRow(2, i, Num4[i] >> 4 | Plus[i]);
            }
            else if (Sign == "Minus")
            {
                lc.setRow(2, i, Num4[i] >> 4 | Minus[i]);
            }
            else if (Sign == "None")
            {
                lc.setRow(2, i, Num4[i] >> 4);
            }
        }
        break;
    }
    case 5:
    {
        for (uint8_t i = 0; i < 8; i++)
        {
            BufferedDigit[i] = Num5[i];

            if (CurrentDigit2 == 5 && CurrentDigit2 != 5)
            {
                lc.setRow(1, i, BufferedDigit[i] << 4);
            }

            if (Sign == "Plus")
            {
                lc.setRow(2, i, Num5[i] >> 4 | Plus[i]);
            }
            else if (Sign == "Minus")
            {
                lc.setRow(2, i, Num5[i] >> 4 | Minus[i]);
            }
            else if (Sign == "None")
            {
                lc.setRow(2, i, Num5[i] >> 4);
            }
        }
        break;
    }
    case 6:
    {
        for (uint8_t i = 0; i < 8; i++)
        {
            BufferedDigit[i] = Num6[i];

            if (CurrentDigit2 == 6 && CurrentDigit2 != 6)
            {
                lc.setRow(1, i, BufferedDigit[i] << 4);
            }

            if (Sign == "Plus")
            {
                lc.setRow(2, i, Num6[i] >> 4 | Plus[i]);
            }
            else if (Sign == "Minus")
            {
                lc.setRow(2, i, Num6[i] >> 4 | Minus[i]);
            }
            else if (Sign == "None")
            {
                lc.setRow(2, i, Num6[i] >> 4);
            }
        }
        break;
    }
    case 7:
    {
        for (uint8_t i = 0; i < 8; i++)
        {
            BufferedDigit[i] = Num7[i];

            if (CurrentDigit2 == 7 && CurrentDigit2 != 7)
            {
                lc.setRow(1, i, BufferedDigit[i] << 4);
            }

            if (Sign == "Plus")
            {
                lc.setRow(2, i, Num7[i] >> 4 | Plus[i]);
            }
            else if (Sign == "Minus")
            {
                lc.setRow(2, i, Num7[i] >> 4 | Minus[i]);
            }
            else if (Sign == "None")
            {
                lc.setRow(2, i, Num7[i] >> 4);
            }
        }
        break;
    }
    case 8:
    {
        for (uint8_t i = 0; i < 8; i++)
        {
            BufferedDigit[i] = Num8[i];

            if (CurrentDigit2 == 8 && CurrentDigit2 != 8)
            {
                lc.setRow(1, i, BufferedDigit[i] << 4);
            }

            if (Sign == "Plus")
            {
                lc.setRow(2, i, Num8[i] >> 4 | Plus[i]);
            }
            else if (Sign == "Minus")
            {
                lc.setRow(2, i, Num8[i] >> 4 | Minus[i]);
            }
            else if (Sign == "None")
            {
                lc.setRow(2, i, Num8[i] >> 4);
            }
        }
        break;
    }
    case 9:
    {
        for (uint8_t i = 0; i < 8; i++)
        {
            BufferedDigit[i] = Num9[i];

            if (CurrentDigit2 == 9 && CurrentDigit2 != 9)
            {
                lc.setRow(1, i, BufferedDigit[i] << 4);
            }

            if (Sign == "Plus")
            {
                lc.setRow(2, i, Num9[i] >> 4 | Plus[i]);
            }
            else if (Sign == "Minus")
            {
                lc.setRow(2, i, Num9[i] >> 4 | Minus[i]);
            }
            else if (Sign == "None")
            {
                lc.setRow(2, i, Num9[i] >> 4);
            }
        }
        break;
        default:
        Dig = 0;
    }
    }
}

void Digit2(uint8_t Dig)
{
    switch (Dig)
    {
    case 0:
    {
        CurrentDigit2 = 0;
        for (uint8_t i = 0; i < 8; i++)
        {
            ReadyDigit2[i] = (BufferedDigit[i] << 4) | (Num0[i] >> 2);
            lc.setRow(1, i, ReadyDigit2[i]);
        }
        break;
    }
    case 1:
    {
        CurrentDigit2 = 1;
        for (uint8_t i = 0; i < 8; i++)
        {
            ReadyDigit2[i] = (BufferedDigit[i] << 4) | (Num1[i] >> 3);
            lc.setRow(1, i, ReadyDigit2[i]);
        }
        break;
    }
    case 2:
    {
        CurrentDigit2 = 2;
        for (uint8_t i = 0; i < 8; i++)
        {
            ReadyDigit2[i] = (BufferedDigit[i] << 4) | (Num2[i] >> 2);
            lc.setRow(1, i, ReadyDigit2[i]);
        }
        break;
    }
    case 3:
    {
        CurrentDigit2 = 3;
        for (uint8_t i = 0; i < 8; i++)
        {
            ReadyDigit2[i] = (BufferedDigit[i] << 4) | (Num3[i] >> 2);
            lc.setRow(1, i, ReadyDigit2[i]);
        }
        break;
    }
    case 4:
    {
        CurrentDigit2 = 4;
        for (uint8_t i = 0; i < 8; i++)
        {
            ReadyDigit2[i] = (BufferedDigit[i] << 4) | (Num4[i] >> 2);
            lc.setRow(1, i, ReadyDigit2[i]);
        }
        break;
    }
    case 5:
    {
        CurrentDigit2 = 5;
        for (uint8_t i = 0; i < 8; i++)
        {
            ReadyDigit2[i] = (BufferedDigit[i] << 4) | (Num5[i] >> 2);
            lc.setRow(1, i, ReadyDigit2[i]);
        }
        break;
    }
    case 6:
    {
        CurrentDigit2 = 6;
        for (uint8_t i = 0; i < 8; i++)
        {
            ReadyDigit2[i] = (BufferedDigit[i] << 4) | (Num6[i] >> 2);
            lc.setRow(1, i, ReadyDigit2[i]);
        }
        break;
    }
    case 7:
    {
        CurrentDigit2 = 7;
        for (uint8_t i = 0; i < 8; i++)
        {
            ReadyDigit2[i] = (BufferedDigit[i] << 4) | (Num7[i] >> 2);
            lc.setRow(1, i, ReadyDigit2[i]);
        }
        break;
    }
    case 8:
    {
        CurrentDigit2 = 8;
        for (uint8_t i = 0; i < 8; i++)
        {
            ReadyDigit2[i] = (BufferedDigit[i] << 4) | (Num8[i] >> 2);
            lc.setRow(1, i, ReadyDigit2[i]);
        }
        break;
    }
    case 9:
    {
        CurrentDigit2 = 9;
        for (uint8_t i = 0; i < 8; i++)
        {
            ReadyDigit2[i] = (BufferedDigit[i] << 4) | (Num9[i] >> 2);
            lc.setRow(1, i, ReadyDigit2[i]);
        }
        break;
        default:
        Dig = 0;
    }
    }
}

void Digit3(uint8_t Dig, bool DotBool)
{
    switch (Dig)
    {
    case 0:
    {
        if (!DotBool)
        {
            for (uint8_t i = 0; i < 8; i++)
            {
                lc.setRow(0, i, Num0[i] >> 2);
            }
        }
        else
            for (uint8_t i = 0; i < 8; i++)
            {
                byte Num0Dot[8];
                Num0Dot[i] = (Num0[i] >> 2) | (Dot[i]);
                lc.setRow(0, i, Num0Dot[i]);
            }
        break;
    }
    case 1:
    {
        if (!DotBool)
        {
            for (uint8_t i = 0; i < 8; i++)
            {
                lc.setRow(0, i, Num1[i] >> 3);
            }
        }
        else
            for (uint8_t i = 0; i < 8; i++)
            {
                byte Num1Dot[8];
                Num1Dot[i] = (Num1[i] >> 3) | (Dot[i]);
                lc.setRow(0, i, Num1Dot[i]);
            }
        break;
    }
    case 2:
    {
        if (!DotBool)
        {
            for (uint8_t i = 0; i < 8; i++)
            {
                lc.setRow(0, i, Num2[i] >> 2);
            }
        }
        else
            for (uint8_t i = 0; i < 8; i++)
            {
                byte Num2Dot[8];
                Num2Dot[i] = (Num2[i] >> 2) | (Dot[i]);
                lc.setRow(0, i, Num2Dot[i]);
            }
        break;
    }
    case 3:
    {
        if (!DotBool)
        {

            for (uint8_t i = 0; i < 8; i++)
            {
                lc.setRow(0, i, Num3[i] >> 2);
            }
        }
        else
            for (uint8_t i = 0; i < 8; i++)
            {
                byte Num3Dot[8];
                Num3Dot[i] = (Num3[i] >> 2) | (Dot[i]);
                lc.setRow(0, i, Num3Dot[i]);
            }
        break;
    }
    case 4:
    {
        if (!DotBool)
        {

            for (uint8_t i = 0; i < 8; i++)
            {
                lc.setRow(0, i, Num4[i] >> 2);
            }
        }
        else
            for (uint8_t i = 0; i < 8; i++)
            {
                byte Num4Dot[8];
                Num4Dot[i] = (Num4[i] >> 2) | (Dot[i]);
                lc.setRow(0, i, Num4Dot[i]);
            }
        break;
    }
    case 5:
    {
        if (!DotBool)
        {
            for (uint8_t i = 0; i < 8; i++)
            {
                lc.setRow(0, i, Num5[i] >> 2);
            }
        }
        else
            for (uint8_t i = 0; i < 8; i++)
            {
                byte Num5Dot[8];
                Num5Dot[i] = (Num5[i] >> 2) | (Dot[i]);
                lc.setRow(0, i, Num5Dot[i]);
            }
        break;
    }
    case 6:
    {
        if (!DotBool)
        {
            for (uint8_t i = 0; i < 8; i++)
            {
                lc.setRow(0, i, Num6[i] >> 2);
            }
        }
        else
            for (uint8_t i = 0; i < 8; i++)
            {
                byte Num6Dot[8];
                Num6Dot[i] = (Num6[i] >> 2) | (Dot[i]);
                lc.setRow(0, i, Num6Dot[i]);
            }
        break;
    }
    case 7:
    {
        if (!DotBool)
        {
            for (uint8_t i = 0; i < 8; i++)
            {
                lc.setRow(0, i, Num7[i] >> 2);
            }
        }
        else
            for (uint8_t i = 0; i < 8; i++)
            {
                byte Num7Dot[8];
                Num7Dot[i] = (Num7[i] >> 2) | (Dot[i]);
                lc.setRow(0, i, Num7Dot[i]);
            }
        break;
    }
    case 8:
    {
        if (!DotBool)
        {
            for (uint8_t i = 0; i < 8; i++)
            {
                lc.setRow(0, i, Num8[i] >> 2);
            }
        }
        else
            for (uint8_t i = 0; i < 8; i++)
            {
                byte Num8Dot[8];
                Num8Dot[i] = (Num8[i] >> 2) | (Dot[i]);
                lc.setRow(0, i, Num8Dot[i]);
            }
        break;
    }
    case 9:
    {
        if (!DotBool)
        {
            for (uint8_t i = 0; i < 8; i++)
            {
                lc.setRow(0, i, Num9[i] >> 2);
            }
        }
        else
            for (uint8_t i = 0; i < 8; i++)
            {
                byte Num9Dot[8];
                Num9Dot[i] = (Num9[i] >> 2) | (Dot[i]);
                lc.setRow(0, i, Num9Dot[i]);
            }
        break;
        default:
        Dig = 0;
    }
    }
}