void lcd_locate (
	uint8_t row,	/* Cursor row position (0.._LCD_ROWS-1) */
	uint8_t col		/* Cursor column position (0.._LCD_COLS-1) */
)
{
	Row = row; Column = col;

	if (row < _LCD_ROWS && col < _LCD_COLS) {
		if (_LCD_COLS >= 2 && (row & 1)) col += 0x40;
		if (LCD_IF_SPLIT && col >= _LCD_COLS / 2) col += 0x40 - _LCD_COLS / 2;
		if (LCD_IF_ALTROW && (row & 2)) col += _LCD_COLS;
		col |= 0x80;
	} else {
		col = 0x0C;
	}

#if LCD_IF_DUAL
	if (_USE_CURSOR && !(row &= 2)) row |= 4;
	lcd_write(row, col);
#if _USE_CURSOR
	if (col != 0x0C) lcd_write(row, Csr | 0x0C);
	row ^= 6;
	lcd_write(row, 0x0C);
#endif
#else
	lcd_write(0, col);
#if _USE_CURSOR
	if (col != 0x0C) lcd_write(0, Csr | 0x0C);
#endif
#endif
}
示例#2
0
void LCD::displayCursor(bool flag) {
	if(flag) {
		lcd_write(LCD_DISPLAYCONTROL | LCD_DISPLAYON |LCD_CURSORON, 0);
	} else {
		lcd_write(LCD_DISPLAYCONTROL | LCD_DISPLAYON |LCD_CURSOROFF, 0);
	}
}
示例#3
0
void lcd_init(){
	// Set LCD Pins as output
	DDRC |= (1 << PC1) | (1 << PC2) | (1 << PC3);
	DDRB |= (1 << PB3) | (1 << PB4) | (1 << PB5);
	
	// Pull RS Line low
	PORT_RS &= ~(1 << P_RS);
	
	_delay_ms(15); // power on delay
	
	// Init display
	PORT_D4 |= (1 << P_D4);
	PORT_D567 |= (1 << P_D5);
	
	LCD_STROBE;
	
	_delay_ms(5);
	
	LCD_STROBE;
	
	_delay_ms(100);
	
	LCD_STROBE;
	
	_delay_ms(5);
	PORT_D4 &= ~(1 << P_D4); // Set 4 bit mode
	
	LCD_STROBE;
	_delay_ms(40);
	
	lcd_write(0x28);// 4 bit mode, 1/16 duty, 5x8 font, 2lines
    lcd_write(0x0C);// display on
    lcd_write(0x06);// entry mode advance cursor
    lcd_write(0x01);// clear display and reset cursor
}
示例#4
0
/******************************************************************************
** Function name:		lcd_clear
**
** Descriptions:		erase the lcd display
**
** parameters:			None
** Returned value:		None
**
******************************************************************************/
void lcd_clear(void)
{
	  lcd_cursor(0,0);
	  lcd_write("                    ", 20);
	  lcd_cursor(1,0);
	  lcd_write("                    ", 20);
}
示例#5
0
static QState mmi_giga_pan(struct mmi_ao *me)
{
    char tmp[17];

    switch (Q_SIG(me)) {
    case Q_ENTRY_SIG:
        prog_init_giga_pan();
        lcd_clear();
        lcd_write(0, 0, "Giga pan", 0);
        snprintf(tmp, sizeof(tmp), "%dx%d tiles", giga_info.tiles.x, giga_info.tiles.y);
        lcd_write(0, 1, tmp, 0);
        return Q_HANDLED();
    case Q_EXIT_SIG:
        return Q_HANDLED();
    case Q_TIMEOUT_SIG:
        return Q_HANDLED();
    case SIG_KEY_PRESS:
        switch (Q_PAR(me)) {
        case KEY_ENTER:
            QActive_post((QActive *) &prog_ao, SIG_PROG_START, PROG_GIGA_PAN);
            return Q_TRAN(mmi_busy);
        case KEY_LEFT:
            return Q_TRAN(mmi_navigate);
        }
        return Q_HANDLED();;
    }

    return Q_SUPER(&QHsm_top);
}
示例#6
0
// Write register
void lcd_write_reg(int reg, int command)
{
    lcd_dma_ready();
    LCD_RS_LOW();
    lcd_write(reg);
    lcd_dma_ready();
    LCD_RS_HIGH();
    lcd_write(command);
}
示例#7
0
/*
 * Go to the specified position
 */
void
lcd_goto(unsigned char pos,unsigned char line)
{
    PORT_RS &= ~(1 << P_RS);
    if (line==0)
		lcd_write(0x80 + pos);
    else
		lcd_write(0x80 + pos+ 0x40);
}
示例#8
0
void lcd_putcharsmall(char c)
{
	int base;
	base = c - 32;
	base *= 4;	//CHANGED FROM 3 HOPEFULLY TO FIX font size
	lcd_write(fontsmall[base]);
	lcd_write(fontsmall[base + 1]);
	lcd_write(fontsmall[base + 2]);
	lcd_write(fontsmall[base + 3]);	//ADDED
}
void lcd_init (void)
{
	uint8_t d;
	
	E1_HIGH();
	DELAY_US(40000);
	E1_LOW();

//	IF_INIT();

//	DELAY_US(40000);
	lcd_write(8, 0x30);
	DELAY_US(4100);
	lcd_write(8, 0x30);
	DELAY_US(100);
	lcd_write(8, 0x30);

	d = (IF_BUS == 4 ? 0x20 : 0x30) | LCD_IF_2ROW;
	lcd_write(8, d);
#if IF_BUS == 4
	lcd_write(0, d);
#endif
	lcd_write(0, 0x08);
	lcd_write(0, 0x01);
	DELAY_US(LCD_DT1);
	lcd_write(0, 0x06);
	lcd_write(0, 0x0C);

	Row = Column = 0;
#if _USE_CURSOR
	Csr = 0;
#endif
}
示例#10
0
//==============================================================================
void re_draw_body( void )
{
  char temp[21] = {0, };
  sParam tempParam;
  sSignalParam tmpSig;

  // if we must draw body for measuring power
  if( 1 == is_meas_mode )
  {
    lcd_write( "P=     mW", 0, 1 );          
    lcd_write( "P=     mW", 11, 1 );
            
    lcd_write( "I=     mA", 0, 2 );
    lcd_write( "I=     mA", 11, 2 );
            
    lcd_write( "U=      V", 0, 3 );
    lcd_write( "U=      V", 11, 3 );
  }
  else if( 0 == is_meas_mode ) // if must draw body for generation
  {
    for(int k = 0; k < 2; k++)
    {
      tmpSig  = Channel[k].SignalParam[Channel[k].CurSigForm];
    	 
	  //����������, �� LCD, ��� �������� ������� k-������
      lcd_write("         ",  Channel[k].pos_x, tmpSig.name_pos_y);
      lcd_write(tmpSig.pname, Channel[k].pos_x, tmpSig.name_pos_y);
    	  
	  //����������, �� LCD, �������, � ������ ������, ��������� �������� ������� �������� ������     
      for(int i = 0; i < 6; i++)
      {
        tempParam = tmpSig.Param[i];
        if(tempParam.isVisible == 1)
        {
          *temp = 0;
          strncat(temp, tempParam.pacronym, strlen(tempParam.pacronym));
          sprintf(temp + strlen(tempParam.pacronym), tempParam.format, tempParam.cur);
	      
          //����������� ��� �������
		  if(tempParam.cur < 99999.0)
		    strncat(temp, tempParam.punit, strlen(tempParam.punit));
		  else
		    strncat(temp, tempParam.punit, strlen(tempParam.punit) - 1);

          lcd_write("         ", Channel[k].pos_x,  tempParam.bg_pos_y);
          lcd_write(temp, Channel[k].pos_x, tempParam.bg_pos_y);                 
        }
      }
    }//for(int k = 0; k < 2; k++)
  }// else if ( 0 == is_meas_mode )
}
void lcd_setcg (
	uint8_t chr,		/* Character code to be registered (0..7) */
	uint8_t n,			/* Number of characters to register */
	const uint8_t* p	/* Pointer to the character pattern (8 * n bytes) */
)
{
	lcd_write(0, 0x40 | chr * 8);
	n *= 8;
	do
		lcd_write(1, *p++);
	while (--n);

	lcd_locate(Row, Column);
}
示例#12
0
int main(int argc, char *argv[]) {
    struct usb_bus      *bus;
    struct usb_device   *dev;

    usb_init();

    usb_find_busses();
    usb_find_devices();

    for(bus = usb_get_busses(); bus; bus = bus->next) {
        for(dev = bus->devices; dev; dev = dev->next) {
            if((dev->descriptor.idVendor == LCD2USB_VID) && 
                    (dev->descriptor.idProduct == LCD2USB_PID)) {
                handle = usb_open(dev);
                break;
            }
        }
    }

    if(!handle) {
        fprintf(stderr, "Error: Could not find LCD2USB device\n");
        exit(-1);
    }

    lcd_clear();

    int i = 0;
    while (!feof(stdin)) {
        char line[1024];
        fgets(line, sizeof(line), stdin);
        if (feof(stdin)) break;
        line[strlen(line)-1] = '\0';
        if(strlen(line) == 0) {
            lcd_clear();
            lcd_clear();
            i = 0;
            continue;
        }
        lcd_write(line);
        i += strlen(line);
        while (i % 20 != 0) {
            lcd_write(" ");
            i++;
        }
    }

    usb_close(handle);

    return 0;
}
示例#13
0
// put string function
void LCD::lcd_display_string(std::string string, int line) {
	if(line == 1)
		lcd_write(0x80, 0);
	if (line == 2)
		lcd_write(0xC0, 0);
	if (line == 3)
    	lcd_write(0x94, 0);
	if (line == 4)
		lcd_write(0xD4, 0);

	for (int i = 0; i < string.length(); i++) {
		char x = string.at(i);
        lcd_write(x, Rs);
	}
}
示例#14
0
static void print_param(const struct param *param)
{
    char tmp[17];

    param_print(menu_cur->param, tmp, sizeof(tmp));
    lcd_write(0, 1, tmp, LCD_FILL_BLANK);
}
示例#15
0
static QState mmi_busy(struct mmi_ao *me)
{
    static const char busy_char[] = ". ";
    static uint8_t busy_index;

    switch (Q_SIG(me)) {
    case Q_ENTRY_SIG:
        // Print hello message
        lcd_clear();
        lcd_write(0, 0, "Busy ...", 0);
        QActive_arm((QActive *) me, TIMEOUT_BUSY);
        return Q_HANDLED();
    case Q_EXIT_SIG:
        QActive_disarm((QActive *) me);
        return Q_HANDLED();
    case Q_TIMEOUT_SIG:
        lcd_char(15, 0, busy_char[busy_index]);
        busy_index = (busy_index + 1) % (sizeof(busy_char) - 1);
        QActive_arm((QActive *) me, TIMEOUT_BUSY);
        return Q_HANDLED();
    case SIG_KEY_PRESS:
        if (Q_PAR(me) == KEY_LEFT) {
            QActive_post((QActive *) &prog_ao, SIG_PROG_STOP, 0);
            return Q_TRAN(mmi_navigate);
        }
        return Q_HANDLED();
    case SIG_PROG_DONE:
        return Q_TRAN(mmi_navigate);
    }

    return Q_SUPER(&QHsm_top);
}
示例#16
0
文件: main.c 项目: dalmirdasilva/lcd
void main() {
    int8_t i = 0;
    char c = 'A';
    char custom_chars[] = {
        0x00, 0x00, 0x00, 0x04,
        0x00, 0x00, 0x00, 0x00,
        
        0x00, 0x00, 0x0e, 0x0a,
        0x0e, 0x00, 0x00, 0x00,
        
        0x00, 0x1f, 0x11, 0x11,
        0x11, 0x1f, 0x00, 0x00
    };
    _asm bcf _WDTCON, 0 _endasm;
    init_io();
    
    lcd_init();
    
    lcd_custom_char_create(custom_chars, 0, 3);
    delay_ms(500);
    lcd_command(LCD_CMD_DISPLAY_CONTROL | LCD_CMD_DISPLAY_CONTROL_ON);
    //lcd_test_do();
    while(1) {
        lcd_position(0, 0);
        lcd_write(i++ % 3, LCD_RS_DATA, 2);
        delay_ms(150);
        PORTEbits.RE1 ^= 1;
    }
}
示例#17
0
// Allows us to fill the first 8 CGRAM locations
// with custom characters
void lcd_createChar(uint8_t location, uint8_t charmap[]) {
  location &= 0x7; // we only have 8 locations 0-7
  lcd_command(LCD_SETCGRAMADDR | (location << 3));
  for (int i=0; i<8; i++) {
    lcd_write(charmap[i]);
  }
}
示例#18
0
文件: lcd.c 项目: leckardt/glcd
void lcd_data_write(uint8_t data, uint8_t chip)
{
	wait_while_busy(chip);
	LOW(RW_PORT, RW_PIN);//write
	HIGH(RS_PORT, RS_PIN);//data
	lcd_write(data, chip);
}
示例#19
0
void
lcd_clear(void)
{
    PORT_RS &= ~(1 << P_RS);
    lcd_write(0x1);
    _delay_ms(2);
}
示例#20
0
文件: main.c 项目: xunil/battmeter
int main(void)
{
  int x, y;
  char c;
  char custom_char[] = {0x01, 0x03, 0x03, 0x07, 0x07, 0x0F, 0x0F, 0x1F};

  lcd_init();
  lcd_on();
  c = 0x1F;

  lcd_custom_char(0, custom_char);
  while(1){
    for(y = 0; y < 2; y++) {
      c++;
      if(c > 0xFE)
        c = 0x1F;
      for(x = 0; x < 16; x++) {
        lcd_moveto(x,y);
        //lcd_write(c);
        lcd_write(0x00);
      }
    }
    //lcd_clear();
    _delay_ms(500);
  }
  return 0;   /* never reached */
}
示例#21
0
/**
 * Fills the whole screen, leaving all pixels black unless screen is set in inverse mode
 */
void fill_screen()
{
	char i;
	for(i=0;i<MAX_X*MAX_Y;i++)
	{
		lcd_write(DATA,0xFF);
	}
}
示例#22
0
文件: lcd.c 项目: leckardt/glcd
void lcd_cmd_write(uint8_t cmd, uint8_t chip)
{
	wait_while_busy(chip);
	LOW(RW_PORT, RW_PIN);//write
	LOW(RS_PORT, RS_PIN);//instruction
	lcd_write(cmd, chip);

}
示例#23
0
void lcd_writePos(unsigned char inputData, unsigned char row, unsigned char col) {
	if(row >= LCD_NB_ROWS) {
		row = 0;
	}
	lcd_command(RowAddresses[row] + col);

	lcd_write(inputData);
}
示例#24
0
void screen_type_paint(Screen *scr, TxProfile *txp)
{
    // lcd_printfxy(5,0, "%-11s", _switch_names[txp->switch_a]);
    // lcd_printfxy(5,1, "%-11s", _switch_names[txp->switch_b]);

    lcd_cursor(6,0);
    lcd_write(_txtype_names[txp->tx_mode & 3]);
    if (txp->tx_mode != TX_MODE_ACRO) {
        lcd_printfxy(1,1, "%+04i %+04i %+04i", txp->swash[0], txp->swash[1], txp->swash[2]);
    }
    else {
        lcd_cursor(1,1);
        lcd_write("              ");
    }

    input_cursor();
}
示例#25
0
文件: lcd.c 项目: jcmvbkbc/stove
static void lcd_init_hints(void)
{
	static const uint8_t cg[] = {
		0x0, 0x2, 0x0, 0x2, 0x0, 0xa, 0x0, 0x0, /* all */
		0x0, 0x2, 0x0, 0x2, 0x0, 0x2, 0x0, 0x0, /* +/-/accept */
		0x0, 0x0, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, /* accept/cancel */

	};
	uint8_t i;

	lcd_write(0, 0x40);
	_delay_us(40);
	for (i = 0; i < sizeof(cg); ++i) {
		lcd_write(1, cg[i]);
		_delay_us(40);
	}
}
示例#26
0
// Write a command word
void lcd_write_cmd(int command)
{
    lcd_dma_ready();
    LCD_RS_LOW();
    lcd_write(command);
    lcd_dma_ready();
    LCD_RS_HIGH();
}
示例#27
0
/**********************************************************

* 主函数

**********************************************************/
void  main()
{
    uchar  m;

    lcd_init();                          //LCD1602初始化

    lcd_pos(0x00);                 //设置显示位置为第一行
    for(m=0;m<16;m++)
    lcd_write(1,cdis1[m]);


     lcd_pos(0x40);                //设置显示位置为第二行     
     for(m=0;m<16;m++) 
     lcd_write(1,cdis2[m]);

      while(1);
}
示例#28
0
文件: lcd.c 项目: rkrajnc/regulacija
void lcd_set_adr(uint8_t y, uint8_t x)
{
  const uint8_t y_off [] = { 0x00, 0x40, 0x14, 0x54 };
  uint8_t pos = y_off[y] + x;
  lcd_write(1, 0x80 | pos);
  
  lcd_pos = y * LCD_W + x;
}
示例#29
0
/**
 * In case you are not willing to send commands to set position, for example, within the same block, you can use this as a custom space.
 */
void clear_columns(char ncolumns)
{
	char i;
	for(i=0;i<ncolumns;i++)
	{
		lcd_write(DATA,0x00);
	}
}
示例#30
0
void get_NIST()
{

//  adding NIST read time code ========
    char myTime[80]={0};
    char *mysplit[10];
    //char *myTest;
    char *myTest=(char*)malloc(sizeof(char) * 80);
    char *pch;
    //char *pch = malloc(sizeof(char) * 80);
    int sizecheck;

/*** function pointer ***/
    //sizecheck = buf_pitime(myTime);

    alt_pitime= &buf_pitime;      // This uses socket for NIST
    //alt_pitime= &no_net_pitime;     // This bypasses socket items but returns a time

    sizecheck = alt_pitime(myTime);

    //char* testtest= pitime();

/*****
57523 16-05-15 00:58:16 50 0 0 257.3 UTC(NIST) *
len = 51
*****/

    //pch = strtok (myTest," ");
    pch = strtok (myTime," ");
    //pch = strtok (testtest," ");  // this works
    while (pch != NULL)
    {
        //printf ("%s\n",pch);
        mysplit[k]= (char*)malloc(strlen(pch+1));
        strcpy(mysplit[k],pch);
        pch = strtok (NULL, " ");
        k++;
    }
    // format for LCD
    strcat(str_filenm,mysplit[7]);      // UTC(NIST)
    strcat(str_filenm,"\n");
    strcat(str_filenm,mysplit[2]);      // Time
    strcat(str_filenm,"\n");
    strcat(str_filenm,mysplit[1]);      // date
    printf("strcat %s\n",str_filenm);

    char* mytest1 = myTest+15;
    *mytest1=NL;
    char* mytest3=myTest+7;

    char* mytest4= myTest+24;
    *mytest4=EL;

    myTest[0]=0x20;     // clear the new line from NIST return

    lcd_write(str_filenm);   //NIST
// ==== NIST end
}