Exemple #1
0
void LcdContrast (unsigned char contrast) 	//contrast -> Contrast value from 0x00 to 0x7F
        {
        if (contrast > 0x7F) return;
        LcdSend( 0x21, LCD_CMD );               //LCD Extended Commands
        LcdSend( 0x80 | contrast, LCD_CMD );    //Set LCD Vop (Contrast)
        LcdSend( 0x20, LCD_CMD );               //LCD Standard Commands,Horizontal addressing mode
        }
Exemple #2
0
void LcdUpdate (void)   //Copies the LCD cache into the device RAM
        {
        int i;
	#ifdef china
	char j;
	#endif

        LcdSend(0x80, LCD_CMD);		//команды установки указателя памяти дисплея на 0,0
        LcdSend(0x40, LCD_CMD);
        
        #ifdef china                    		//если китайский дисплей - грузим пустую строку
		for (j = Cntr_X_RES; j>0; j--) LcdSend(0, LCD_DATA);
	#endif

        for (i = 0; i < LCD_CACHE_SIZE; i++)		//грузим данные
                {
                LcdSend(LcdCache[i], LCD_DATA);
		#ifdef china				//если дисплей китайский - догружаем каждую строку до размера его буфера
		if (++j == LCD_X_RES) 
			{
			for (j = (Cntr_X_RES-LCD_X_RES); j>0; j--) LcdSend(0, LCD_DATA);
			j=0;
			}
		#endif 
                }
        }
Exemple #3
0
//
// Print a single tiny (3x5 px) digit on the display
//
void LcdTinyDigit(char ch) {
  uint16_t index;

  LcdSend(LCD_D, 0x00);
  for (index=0; index<3; index++) {
    LcdSend(LCD_D, font3px[ch-'0'][index]);
  }
}
Exemple #4
0
void LcdImage (flash unsigned char *imageData)	//вывод изображения
        {
        unsigned int i;
        
        LcdSend(0x80, LCD_CMD);		//ставим указатель на 0,0
        LcdSend(0x40, LCD_CMD);
        for (i = 0; i < LCD_CACHE_SIZE; i++) LcdCache[i] = imageData[i];	//грузим данные
        }
Exemple #5
0
//
// Print a single character on the display
//
void LcdCharacter(char ch) {
  uint16_t index;

  LcdSend(LCD_D, 0x00);
  for (index=0; index<5; index++) {
    LcdSend(LCD_D, font5px[ch-' '][index]);
  }
}
Exemple #6
0
void LcdInit ( void )	//инициализация SPI и дисплея
        {
        LCD_PORT.LCD_RST_PIN = 1;       //настроили порты ввода/вывода
        LCD_DDR.LCD_RST_PIN = LCD_DDR.LCD_DC_PIN = LCD_DDR.LCD_CE_PIN = LCD_DDR.SPI_MOSI_PIN = LCD_DDR.SPI_CLK_PIN = 1;
        delay_ms(1);
        SPCR = 0x50;
        LCD_PORT.LCD_RST_PIN = 0;       //дернули ресет
        delay_ms(10);
        LCD_PORT.LCD_RST_PIN = 1;
                            //Enable SPI port: No interrupt, MSBit first, Master mode, CPOL->0, CPHA->0, Clk/4

        LCD_PORT.LCD_CE_PIN = 1;        //Disable LCD controller

        LcdSend( 0b00100001, LCD_CMD ); 						//LCD Extended Commands
        LcdSend( 0b00000100+temp_control, LCD_CMD ); 					//Set Temp coefficent
        	#ifdef china
        LcdSend( 0b00001000|SPI_invert<<3, LCD_CMD ); 					//порядок битов в SPI
		#endif
        LcdSend( 0b00010000+bias, LCD_CMD ); 						//LCD bias mode 1:48
        	#ifdef china
        LcdSend( 0b01000000+shift, LCD_CMD ); 						//первая строка выше экрана, отображаем со второй
		#endif
	LcdSend( 0b10000000+Vop, LCD_CMD ); 						//Set LCD Vop (Contrast)
	
		#ifdef china
	LcdSend( 0x20|x_mirror<<5|y_mirror<<4|power_down<<3, LCD_CMD );			//LCD Standard Commands
        	#endif
                #ifndef china
        LcdSend( 0x20|power_down<<3|addressing<<2, LCD_CMD );				//LCD Standard Commands
                #endif
        LcdSend( 0b00001000|((disp_config<<1|disp_config)&0b00000101), LCD_CMD ); 	//LCD mode
        LcdClear();
        }
/*
 * Name         :  LcdContrast
 * Description  :  Set display contrast.
 * Argument(s)  :  contrast -> Contrast value from 0x00 to 0x7F.
 * Return value :  None.
 */
void LcdContrast ( byte contrast )
{
    /* LCD Extended Commands. */
    LcdSend( 0x21, LCD_CMD );

    /* Set LCD contrast level. */
    LcdSend( 0x80 | contrast, LCD_CMD );

    /* LCD Standard Commands, horizontal addressing mode. */
    LcdSend( 0x20, LCD_CMD );
}
/*--------------------------------------------------------------------------------------------------

  Name         :  LcdContrast

  Description  :  Set display contrast.

  Argument(s)  :  contrast -> Contrast value from 0x00 to 0x7F.

  Return value :  None.

  Notes        :  No change visible at ambient temperature.

--------------------------------------------------------------------------------------------------*/
void LcdContrast ( uint8_t Contrast )
{
    //  LCD Extended Commands.
  LcdSend( FUNCTION_SET|FUNCTION_EXT, LCD_CMD );  // LCD Extended Commands.

    // Set LCD Vop (Contrast).
    if ( Contrast > 90 ) /* Limit by 8.5 V */
      Contrast = 90;
  LcdSend( SET_VOP | Contrast, LCD_CMD );

    //  LCD Standard Commands, horizontal addressing mode.
  LcdSend( FUNCTION_SET, LCD_CMD );
}
//Clear display
void LcdClear()
{
	uint16_t j = 7;
  
	while ( j-- )
	{
      uint16_t i = 84;

      LcdSend(SET_Y|j, LCD_CMD ); 
      LcdSend(SET_X|0, LCD_CMD);
      while ( i-- )
      {
        LcdSend(0/*xff*/, LCD_DATA);
      }  
	}
}
Exemple #10
0
void LcdFill(void) {
  uint16_t i;
  LcdXY(0,0);
  for (i=0; i<96*9 ; i++) {
    LcdSend(LCD_D, 0xFF);
  }
}
Exemple #11
0
void LcdClear(void){
  uint16_t i;
  LcdXY(0,0);
  for (i=0; i<96*9 ; i++) {
    LcdSend(LCD_D, 0x00);
  }
}
Exemple #12
0
//
// Send all the required initialization commands to the display
//
void LcdInit(void) {
  LcdSend(LCD_C, 0xE2);  // Software Reset
  delay(1);
  LcdSend(LCD_C, 0x3D);  // Charge pump ON
  LcdSend(LCD_C, 0x01);  // Charge pump=4
  LcdSend(LCD_C, 0xA4);  // Display all points = OFF
  LcdSend(LCD_C, 0x2F);  // Booster=ON, Voltage Reg=ON, Voltage Follower=ON
  LcdSend(LCD_C, 0xAF);  // Display ON
  LcdSend(LCD_C, 0xA6);  // Normal display
  LcdSend(LCD_C, 0xC0);  // Normal screen up/down
  LcdSend(LCD_C, 0xA0);  // Normal screen left/right
  LcdClear();
}
Exemple #13
0
/*--------------------------------------------------------------------------------------------------

  Name         :  LcdInit

  Description  :  Performs PINS & LCD controller initialization.

  Argument(s)  :  None.

  Return value :  None.

--------------------------------------------------------------------------------------------------*/
void LcdInit ( uint8_t Contrast )
{
  RCC->APB2ENR |= RCC_APB2ENR_IOPBEN; /* Port B Clock */

  GPIOB->CRH &= ~(((GPIO_CRL_MODE0|GPIO_CRL_CNF0)<<(LCD_DC_PIN-8)*4) |
                  ((GPIO_CRL_MODE0|GPIO_CRL_CNF0)<<(LCD_IN_PIN-8)*4) |
                  ((GPIO_CRL_MODE0|GPIO_CRL_CNF0)<<(LCD_CLK_PIN-8)*4)|
                  ((GPIO_CRL_MODE0|GPIO_CRL_CNF0)<<(LCD_RST_PIN-8)*4) ); // Reset all pins


  GPIOB->CRH |=  (((GPIO_CRL_MODE0_1)<<(LCD_DC_PIN-8)*4) |
                  ((GPIO_CRL_MODE0_1)<<(LCD_IN_PIN-8)*4) |
                  ((GPIO_CRL_MODE0_1)<<(LCD_CLK_PIN-8)*4)|
                  ((GPIO_CRL_MODE0_1)<<(LCD_RST_PIN-8)*4) ); // Pins in push-pull 10MHz
    
  GPIOB->BRR = 1<<LCD_RST_PIN; /* RESET to 0 */
  if (Contrast == 0)
    Contrast = 60;
  if (Contrast > 90)
    Contrast = 90;
  /* Some delay */
  {
    __IO uint32_t Counter;
    for ( Counter = 0; Counter <10; Counter++)
      ; /* Blank */
  }
  GPIOB->BSRR = 1<<LCD_RST_PIN; /* RESET to 1 */
#define FUNCTION_SET 0x20
#define FUNCTION_PD  0x04
#define FUNCTION_V   0x02
#define FUNCTION_EXT 0x01
  LcdSend( FUNCTION_SET|FUNCTION_EXT, LCD_CMD );  // LCD Extended Commands.
#define SET_VOP      0x80
  LcdSend( SET_VOP|Contrast, LCD_CMD );  // Set LCD Vop (Contrast). 3.06+0.06*72=4.38V
#define TEMPERATURE_COEFFICIENT 0x4
  LcdSend( TEMPERATURE_COEFFICIENT | 2, LCD_CMD );  // Set Temp coefficent. 2 (0-3)
#define SET_BIAS 0x10
#define BIAS_1_10 0x07
#define BIAS_1_18 0x06
#define BIAS_1_24 0x05
#define BIAS_1_40 0x04
#define BIAS_1_48 0x03
#define BIAS_1_65 0x02
#define BIAS_1_80 0x01
#define BIAS_1_100 0x00
  LcdSend( SET_BIAS|BIAS_1_48, LCD_CMD );  // LCD bias mode 1:48.

  LcdSend( FUNCTION_SET, LCD_CMD );  // LCD Standard Commands, Horizontal addressing mode.
#define DISPLAY_CONTROL 0x08
#define DISPLAY_BLANK   0x00
#define DISPLAY_NORMAL  0x04
#define DISPLAY_ALLON   0x01
#define DISPLAY_INVERSE 0x05
  LcdSend( DISPLAY_CONTROL|DISPLAY_NORMAL, LCD_CMD );  // LCD in normal mode.

#define SET_Y 0x40 /* from 0 to 5 */
#define SET_X 0x80 /* from 0 to 83 */
//  LcdClear();
}
/*
 * Name         :  LcdInit
 * Description  :  Performs MCU SPI & LCD controller initialization.
 * Argument(s)  :  None.
 * Return value :  None.
 */
void LcdInit ( void )
{
    /* Pull-up on reset pin. */
    LCD_PORT |= _BV ( LCD_RST_PIN );

    /* Set output bits on LCD Port. */
    LCD_DDR |= _BV( LCD_RST_PIN ) | _BV( LCD_DC_PIN ) | _BV( LCD_CE_PIN ) | _BV( SPI_MOSI_PIN ) | _BV( SPI_CLK_PIN );

    Delay();

    /* Toggle display reset pin. */
    LCD_PORT &= ~( _BV( LCD_RST_PIN ) );
    Delay();
    LCD_PORT |= _BV ( LCD_RST_PIN );

    /* Enable SPI port:
    * No interrupt, MSBit first, Master mode, CPOL->0, CPHA->0, Clk/4
    */
    SPCR = 0x50;

    /* Disable LCD controller */
    LCD_PORT |= _BV( LCD_CE_PIN );

    LcdSend( 0x21, LCD_CMD ); /* LCD Extended Commands. */
    LcdSend( 0xC8, LCD_CMD ); /* Set LCD Vop (Contrast).*/
    LcdSend( 0x06, LCD_CMD ); /* Set Temp coefficent. */
    LcdSend( 0x13, LCD_CMD ); /* LCD bias mode 1:48. */
    LcdSend( 0x20, LCD_CMD ); /* LCD Standard Commands,Horizontal addressing mode */
    LcdSend( 0x0C, LCD_CMD ); /* LCD in normal mode. */

    /* Reset watermark pointers to empty */
    LoWaterMark = LCD_CACHE_SIZE;
    HiWaterMark = 0;

    /* Clear display on first time use */
    LcdClear();
    LcdUpdate();
}
Exemple #15
0
void LcdChr ( uint32_t Ctrl, const char* Str )
{
  unsigned char ch;
  uint8_t Inverse;
#if defined(BIG)
#define INTERNAL_BIG_DOWN
  uint32_t Big = Ctrl;
#endif  
  Inverse = ((Ctrl & INVERSE) != 0);
  LcdGotoXY((Ctrl/X_POSITION & 0x0F)*6 + ((Ctrl/X_OFFSET)& 0x3F), 
            (Ctrl/Y_POSITION) & 0x07);

  Ctrl = Ctrl & 0x7F; /* Only Len */
  while ( Ctrl != 0 )
  {
    const uint8_t* Start;

    if ( (ch = *Str) != 0)
      Str++;
    Ctrl--;
    if ( ch == 0 ) 
      ch = ' ';
    if ( (ch < 0x20) || (ch > 0x7b) )
    {
        //  Convert to a printable character.
        ch = 92;
    }
    ch = ch - 32;

    Start = &FontLookup[ch*4+ch];

#if defined(BIG)
    if ( (Big & (BIG_UP|BIG_DOWN)) == 0 )
#endif
    { 
      int i;
      for (i=0; i<=4; i++)
      {
        uint8_t E = Start[i];
        if ( Inverse )
        {
          E = ~E;
        }
        LcdSend( E, LCD_DATA );
      }
      if ( !Inverse )
        LcdSend( 0, LCD_DATA );
      else
        LcdSend( 0xFF, LCD_DATA );
    }
#if defined(BIG)
    else
    {
      int i;
      for (i=0; i<=4; i++)
      {
        uint8_t Element = 0;
        uint8_t E = Start[i];

        if ( Big & BIG_UP )
        {
          if(E & 0x01) Element |= 0x03;
          if(E & 0x02) Element |= 0x0C;
          if(E & 0x04) Element |= 0x30;
          if(E & 0x08) Element |= 0xC0;
        }
        else
        {
          if(E & 0x10) Element |= 0x03;
          if(E & 0x20) Element |= 0x0C;
          if(E & 0x40) Element |= 0x30;
          if(E & 0x80) Element |= 0xC0;
        }
        if (Inverse)
          Element = ~Element;
        LcdSend( Element, LCD_DATA );
        LcdSend( Element, LCD_DATA );
      } /* For */
      if ( !Inverse )
      {
        LcdSend( 0, LCD_DATA );
        LcdSend( 0, LCD_DATA );
      }
      else
      {
        LcdSend( 0xFF, LCD_DATA );
        LcdSend( 0xFF, LCD_DATA );
      }
    }
#endif /* BIG */
  }
}
Exemple #16
0
void LcdGotoXY(uint8_t X, uint8_t Y)
{
    LcdSend( SET_X|X, LCD_CMD );
    LcdSend( SET_Y|Y, LCD_CMD ); 
}
Exemple #17
0
void LcdPwrMode (void) 				//инвертирует состояние вкл/выкл дисплея
        {
        power_down = ~power_down;
        LcdSend( 0x20|power_down<<3, LCD_CMD );
        }
Exemple #18
0
//
// Set the cursor position for LcdCharacter()/LcdString()
// The x coordinate is in pixels, the y coordinate is the line
// ranging from 0 to 7
//
void LcdXY(uint8_t x, uint8_t y) {
  LcdSend(LCD_C,0xB0 | (y & 0x0F));
  LcdSend(LCD_C,0x10 | ((x >> 4) & 0x07));
  LcdSend(LCD_C,0x00 | (x & 0x0F));
}
Exemple #19
0
void OutOneColumn(Graph_t* Array, int8_t ColumnNum)
{
  int8_t OffsetMin,OffsetMax;
  uint32_t Column = 0;
  int8_t PrevMin;
  int8_t PrevMax;
  int8_t  Prev;
  int8_t  Next;

  Next = GraphCurrentPoint + 1;
  if ( Next >= GRAPH_SIZE)
    Next = 0;

  if( ColumnNum == Next)
  {
    Column = 0xFFFFFFFF;
    goto draw;
  }

  if ( ColumnNum%10 == 0)
  {
    Column = (1<<1)+(1<<3)+(1<<5)+(1<<7)+(1<<9)+(1<<11)+
            (1<<13)+(1<<15)+(1<<17)+(1<<19)+(1<<21)+(1<<23)+(1<<25)+(1<<27)+(1<<29)+(1u<<31);
  }
  if ( ColumnNum%2 == 0)
    Column |= (1<<1)+(1<<11)+(1<<21)+(1u<<31);
  
  Prev = ColumnNum - 1;
  if (Prev < 0)
    Prev = GRAPH_SIZE - 1;

  
  if ( Array[ColumnNum].Min != 32000)
  {
    int8_t Delta;

    OffsetMin = Offsetmin(Array, ColumnNum);
    OffsetMax = Offsetmax(Array, ColumnNum);
    if ( Array[Prev].Min != 32000)
    {
      PrevMin = Offsetmin(Array, Prev);
      PrevMax = Offsetmax(Array, Prev);
    }
    else
    {
      PrevMin = OffsetMin;
      PrevMax = OffsetMax;
    }
    
    Delta = OffsetMax - PrevMax - 1;
    while (Delta > 0)
    {
      Column |= (1<<(OffsetMax-Delta));
      Delta--;
    }

    Delta = PrevMin - OffsetMin - 1;
    while (Delta > 0)
    {
      Column |= (1<<(PrevMin-Delta));
      Delta--;
    }

    Delta = PrevMax - OffsetMax - 1;
    while (Delta > 0)
    {
      Column |= (1<<(PrevMax-Delta));
      Delta--;
    }

    Delta = OffsetMin - PrevMin - 1;
    while (Delta > 0)
    {
      Column |= (1<<(OffsetMin-Delta));
      Delta--;
    }

    Column |= (1<<OffsetMin);
    Column |= (1<<OffsetMax);
  }

draw:
  Column = __RBIT(Column);
  LcdGotoXY(ColumnNum, 5);
  LcdSend(Column>>24, LCD_DATA);
  LcdGotoXY(ColumnNum, 4);
  LcdSend(Column>>16, LCD_DATA);
  LcdGotoXY(ColumnNum, 3);
  LcdSend(Column>>8, LCD_DATA);
  LcdGotoXY(ColumnNum, 2);
  LcdSend(Column, LCD_DATA);
}
Exemple #20
0
void LcdMode (unsigned char mode) 		//режим дисплея: 0 - blank, 1 - all on, 2 - normal, 3 - inverse
        {
        if (mode > 3) return;
        LcdSend( 0b00001000|((mode<<1|mode)&0b00000101), LCD_CMD ); 	//LCD mode
        }