text: 
  #include "max7219.h"
  
  static void _MAX7219_Send_Command(BYTE reg, BYTE data)
  {
  	SPI_Send_Byte(reg);
  	SPI_Send_Byte(data);
  }
  
  void MAX7219_Set_Decode_Mode(BYTE decode_mode)
  {
  	_MAX7219_Send_Command(0x09, decode_mode);
  }
  
  void MAX7219_Set_Num_Of_Involved_Digits(BYTE num_of_involved_digits)
  {
  	_MAX7219_Send_Command(0x0B, num_of_involved_digits);
  }
  
  void MAX7219_Set_Enable(BYTE is_enable)
  {
  	if (is_enable)
  	{
  		_MAX7219_Send_Command(0x0C, 0x01);
  	}
  	else
  	{
  		_MAX7219_Send_Command(0x0C, 0x00);
  	}
  }
  
  void MAX7219_Set_Brightness(BYTE brightness_coef)
  {
  	_MAX7219_Send_Command(0x0A, brightness_coef);
  }
  
  void MAX7219_Display_Test()
  {
  	_MAX7219_Send_Command(0x0F, 0x0F);
  }
  
  void MAX7219_Set_Digit(BYTE single_digit_pos, BYTE digit_value)
  {
  	_MAX7219_Send_Command((single_digit_pos + 1), digit_value);
  }
  
  void MAX7219_Clear_Single_Digit(BYTE single_digit_pos)
  {
  	_MAX7219_Send_Command((single_digit_pos + 1), 0x00);
  }
  
  void MAX7219_Clear_All(BYTE num_of_involved_digits)
  {
  	while (num_of_involved_digits--)
  	{
  		_MAX7219_Send_Command(num_of_involved_digits, 0x00);
  	}
  }
  
  void MAX7219_Decode_Mode_Clear_Single_Digit(BYTE single_digit_pos)
  {
  	_MAX7219_Send_Command((single_digit_pos + 1), 0x0F);
  }
  
  void MAX7219_Decode_Mode_Clear_All(BYTE num_of_involved_digits)
  {
  	while (num_of_involved_digits--)
  	{
  		_MAX7219_Send_Command(num_of_involved_digits, 0x0F);
  	}
  }