main() { lcd_ini(); lcd_command(0x80); lcd_display('D'); lcd_display('I'); lcd_display('P'); lcd_display('A'); lcd_display('K'); while(1) { lcd_command(0x80); lcd_string("Hello world"); } }
void lcd_generatechar( uint8_t code, const uint8_t *data ) { // Startposition des Zeichens einstellen lcd_command( LCD_SET_CGADR | (code<<3) ); // Bitmuster übertragen for ( uint8_t i=0; i<8; i++ ) { lcd_data( data[i] ); } }
void lcd_init() { LCD_CONTROL_DDR |= (1 << LCD_RS) | (1 << LCD_RW) | (1 << LCD_EN); LCD_DATA_DDR = 0xFF; _delay_ms(20); /* configure the LCD for 8-bit mode and 2 line display */ lcd_command(0x38); _delay_ms(5); /* set cursor move direction to increment */ //lcd_command(0x06); _delay_ms(5); /* turn on the display with cursor disabled */ lcd_command(0x0C); _delay_ms(5); lcd_cgram_init(); /* clear the 16x2 character LCD screen */ lcd_command(0x01); _delay_ms(5); }
void set_cursor(int position) { /*werkt alleen als je 2 lines hebt. line 1 adressen: 0...15, line 2 adressen: 64...79*/ //if(position > 15) //{ //position -= 15; //position += 64; //} position += 128; lcd_command(position); }
static void customChar(DISPLAY* display, const uint8_t* pgm_def, uint8_t charNum){ LCD03_I2C* device = (LCD03_I2C*) display; if(wait(device,10)){ lcd_command(device, LCD_CUSTOM); sendRawByte(display, CUSTOM_START + charNum); for(uint8_t i=0; i<8; i++){ sendRawByte(display, CUSTOM_START | pgm_read_byte(&pgm_def[i])); } } }
/** Initialize the display */ void lcd_init() { // configure pins as output as_output(LCD_E); as_output(LCD_RW); as_output(LCD_RS); _lcd_mode = 1; // force data pins to output _lcd_mode_w(); // Magic sequence to invoke Cthulhu (or enter 4-bit mode) _delay_ms(16); _lcd_write_nibble(0b0011); _lcd_clk(); _delay_ms(5); _lcd_clk(); _delay_ms(5); _lcd_clk(); _delay_ms(5); _lcd_write_nibble(0b0010); _lcd_clk(); _delay_us(100); // Configure the display lcd_command(LCD_IFACE_4BIT_2LINE); lcd_command(LCD_DISABLE); lcd_command(LCD_CLEAR); lcd_command(LCD_MODE_INC); // mark as enabled lcd_enable(); _lcd_singleton.tx = &lcd_write; _lcd_singleton.rx = &lcd_read; // Stream lcd = &_lcd_singleton; _pos.x = 0; _pos.y = 0; _addrtype = TEXT; }
//initializes the LCD and loads custom glyphs void ui_init(){ uint8_t i; //LCD on lcd_init(LCD_DISP_ON); //load signal meter glyphs lcd_command(_BV(LCD_CGRAM)); for(i=0; i<SIG_METER_LEN; i++){ lcd_data(pgm_read_byte_near(&SIG_METER[i])); } }
void set_cursor(int position) { int i; for(i=0; i<position ; i++) { lcd_command(0x14); //This command tells the LCD to move its to the right by one. //It will be run until the preferred position is reached } //lcd_command(0x14); //lcd_command(0xF); }
/** * Clears the screen */ void lcd_clear() { // Start from (0,0). lcd_set_pos(0, 0); // Fill the whole screen with blank pixels. for (unsigned int i = 0; i < (LCDWIDTH * (LCDHEIGHT / 8)); i++) { lcd_command(0, 0); } // Go back to (0,0). lcd_set_pos(0, 0); }
/** * Clears a row of the display. * * @param row A display row (Y address). */ void lcd_clear_row(unsigned int row) { // Start from the beginning of the row. lcd_set_pos(0, row); // Fill the row with blank pixels. for (unsigned int i = 0; i < LCDWIDTH; i++) { lcd_command(0, 0); } // Go back to where everything started. lcd_set_pos(0, row); }
// ============================================================================ void lcd_define_char(const char *pc,char char_code) { char a , i; a = ((char_code<<3)|0x40) & 0xff; for (i = 0; i < 8 ;i++) { lcd_command(a++); clcd_Delay(); lcd_putchar(pc[i]); clcd_Delay(); } }
static void lcd_seek(int pos) { int i, j; if (lcd_position == -1) lcd_reset(); if (pos == lcd_position) { return; } lcd_command(HD44780_RET_HOME); for (i = 0; i < pos; i++) { lcd_command(HD44780_RIGHT); if (i == XILINX_LCD_MAX_POS / 2) { for (j = 0; j < (40 - XILINX_LCD_MAX_POS / 2); j++) lcd_command(HD44780_RIGHT); } } lcd_position = pos; }
main() { DDRC=255; lcd_init(); int j=0; int i=99999; eeprom_write_word(0x001,i); j=eeprom_read_word(0x001); lcd_command(0x8f); lcd_number(j); }
void lcd_init( void ) { LCD_DDR_D4 = 1; // enable output pins LCD_DDR_D5 = 1; LCD_DDR_D6 = 1; LCD_DDR_D7 = 1; LCD_DDR_RS = 1; LCD_DDR_E0 = 1; LCD_E0 = 0; LCD_RS = 0; // send commands _delay_ms( 15 ); lcd_nibble( 0x30 ); _delay_ms( 4.1 ); lcd_nibble( 0x30 ); _delay_us( 100 ); lcd_nibble( 0x30 ); _delay_us( LCD_TIME_DAT ); lcd_nibble( 0x20 ); // 4 bit mode _delay_us( LCD_TIME_DAT ); #if LCD_LINE == 1 lcd_command( 0x20 ); // 1 line #else lcd_command( 0x28 ); // 2 lines 5*7 #endif lcd_command( 0x08 ); // display off lcd_command( 0x01 ); // display clear lcd_command( 0x06 ); // cursor increment lcd_command( 0x0C ); // on, no cursor, no blink }
void disp_watch(_watch_state* watch_state) { int index; lcd_command(LCD_first); lcd_string(days[dayData[3]-1]); lcd_string(", "); sprintf(temp,"%x",dayData[4]); temp[2]='\0'; lcd_string(temp); lcd_string(" "); lcd_string(months[dayData[5]-1]); lcd_string(" 20"); sprintf(temp,"%x",dayData[6]); temp[2]='\0'; lcd_string(temp); lcd_command(LCD_last+4); sprintf(temp,"%x",dayData[2]); temp[2]='\0'; lcd_string(temp); lcd_string(":"); sprintf(temp,"%x",dayData[1]); temp[2]='\0'; lcd_string(temp); lcd_string(":"); sprintf(temp,"%x",dayData[0]); temp[2]='\0'; lcd_string(temp); if(watch_state->state != -1) { if(watch_state->disapp == 1) { lcd_command(LCD_first+first_offsets[watch_state->state]); for(index=0;index<lengths[watch_state->state];index++) { lcd_string(" "); } } } }
// initialize LCD pins and LCD controller void lcd_init(void) { // set direction of pins IO_OPF(C, 3); // CS/ pin IO_OP(E, 5); // DATA pin IO_OP(F, 4); // WR/ pin IO_OP(D, 2); // Backlight pin // set default values to pins CS1; WR1; DATA1; LCD_BCK0; // initialize timer 4 used to time WR/ signal BSET(CLK_PCKENR1, 4); // enable clock to TIM4 TIM4_CR1 = 0b00001100; // no auto-reload, one-pulse,URS-overflow, disable TIM4_IER = 0; // no interrupts TIM4_PSCR = 0; // prescaler = 1 TIM4_ARR = 24; // it will be about 600kHz for WR/ signal TIM4_CNTR = 0; // reset timer value // initialize HT1621B lcd_command(HT_BIAS_13 | (0b10 << HT_BIAS_SHIFT)); // BIAS 1/3, 4 COMs lcd_command(HT_RC_256K); // clock RC 256kHz lcd_command(HT_SYS_DIS); // OSC+BIAS off lcd_command(HT_WDT_DIS); // disable WDT lcd_command(HT_SYS_EN); // OSC on lcd_command(HT_LCD_ON); // BIAS on // initialize LCD task, will be used when sending following lcd_command-s build(LCD); activate(LCD, lcd_loop); sleep(LCD); // no work yet }
//==================================================================== // MAIN FUNCTION //==================================================================== void main (void){ init_LCD(); init_GPIO(); //Get operating CLK freq RCC_ClocksTypeDef CLK; RCC_GetClocksFreq(&CLK); sysclock= (CLK.SYSCLK_Frequency)/((float)(pow(10,6))); //Sys clocks in MHz sprintf(lcdstring,"CLK %d MHz",sysclock); lcd_putstring(lcdstring); lcd_command(LINE_TWO); lcd_putstring("Servo Step Test, SW0"); //Init procedure waits for SW0 while(GPIO_ReadInputData(GPIOA)&GPIO_IDR_0){} lcd_command(CLEAR); init_ADC(); init_EXTI(); init_USART1(); init_TIM2(); init_TIM3(); init_TIM14(); init_TIM17(); for(;;){ while(TIM3OC2<=3800){ TIM3OC2++; TIM_SetCompare2(TIM3,TIM3OC2); for(int x=0;x<=255;x++){ for(int y=0;y<=255;y++){} } } lcd_command(CURSOR_HOME); sprintf(lcdstring,"ADC:%d ",(int) ADCval); lcd_putstring(lcdstring); lcd_command(LINE_TWO); sprintf(lcdstring,"TIM:%d ",(int) TIM2->CCR3);//TIMcmp); //TIM_SetCompare2(TIM3,(int)(64000*((0.9+1.1*ADCval/2047.0)/20.0))); lcd_putstring(lcdstring); } } // End of main
// Intialise the display static void init(DISPLAY* display){ LCD03_I2C* device = (LCD03_I2C*) display; // wait for splash screen to show delay_ms(500); // try to establish connection for(uint8_t i=0; i < 50; i++){ if(wait(device,64)){ break; } delay_ms(10); } lcd_command(device,LCD_CURSOR_OFF); }
void lcd_control(enum lcd_control_mode_t mode) { uint8_t cmd = LCD_CMD_DISPLAY_CONTROL; if(mode & LCD_CONTROL_MODE_ON) { cmd |= LCD_CMD_DISPLAY_CONTROL_ON; } if(mode & LCD_CONTROL_MODE_UNDERLINE) { cmd |= LCD_CMD_DISPLAY_CONTROL_UNDERLINE; } if(mode & LCD_CONTROL_MODE_BLINK) { cmd |= LCD_CMD_DISPLAY_CONTROL_BLINK; } lcd_command(cmd); }
void lcd_writeText(char* inputText,unsigned char row, unsigned char col) { unsigned int currentColumn = col; if(row >= LCD_NB_ROWS) { row = 0; } lcd_command(RowAddresses[row] + col); while(*inputText) { lcd_write(*inputText++); currentColumn++; if(currentColumn >= LCD_ROW_SIZE) { currentColumn = 0; row++; if(row >= LCD_NB_ROWS) { row = 0; } lcd_command(RowAddresses[row] + col); } } }
/** * Initializes the LCD with some defaults. */ void lcd_init() { lcd_command(PCD8544_FUNCTIONSET | PCD8544_EXTINSTRUCTIONS, 0); lcd_command(PCD8544_SETVOP | 0x3F, 0); lcd_command(PCD8544_SETTEMP | 0x02, 0); lcd_command(PCD8544_SETBIAS | 0x03, 0); lcd_command(PCD8544_FUNCTIONSET, 0); lcd_command(PCD8544_DISPLAYCONTROL | PCD8544_DISPLAYNORMAL, 0); }
void lcd_init(void) { LCD_DDR = LCD_DDR | 0x0F | (1<<LCD_RS) | (1<<LCD_EN); // Port auf Ausgang schalten // muss 3mal hintereinander gesendet werden zur Initialisierung _delay_ms(15); LCD_PORT &= 0xF0; LCD_PORT |= 0x03; LCD_PORT &= ~(1<<LCD_RS); // RS auf 0 lcd_enable(); _delay_ms(5); lcd_enable(); _delay_ms(1); lcd_enable(); _delay_ms(1); // 4 Bit Modus aktivieren LCD_PORT &= 0xF0; LCD_PORT |= 0x02; lcd_enable(); _delay_ms(1); // 4Bit / 2 Zeilen / 5x7 lcd_command(0x28); // Display ein / Cursor aus / kein Blinken lcd_command(0x0C); // inkrement / kein Scrollen lcd_command(0x06); // lcd_command(CLEAR_DISPLAY); // _delay_ms(5); }
void displayTime(int m, int s, int h){ lcd_command(0x01); // clears display delay_millisec(2); lcd_putchar(div(m)); lcd_putchar(mod(m)); lcd_putchar(':'); lcd_putchar(div(s)); lcd_putchar(mod(s)); lcd_putchar(':'); lcd_putchar(div(h)); lcd_putchar(mod(h)); }
uint8_t lcd_set_courser(uint8_t x, uint8_t y) { if (x > 15) { return 0xFE; } switch (y) { case 1: lcd_command(x + LCD_ADRESS_LINE_1); break; case 2: lcd_command(x + LCD_ADRESS_LINE_2); break; case 3: lcd_command(x + LCD_ADRESS_LINE_3); break; case 4: lcd_command(x + LCD_ADRESS_LINE_4); break; default: return 0xFF; } return 0; }
void printPresetMenu(void) { lcd_goto(1, 2); lcd_print("Bank Num "); lcd_print(saveLoad ? "Save" : "Load"); lcd_goto(1, 1); lcd_command(curBank + 'A', 1); if (curPreset < 10) lcd_print(" "); lcd_printnbr(curPreset); lcd_print("-"); lcd_print(" "); lcd_goto(5, 1); printName(&presets[curBank][curPreset][14]); }
void lcdMapCustomChar(uint8_t romCharNum, uint8_t lcdCharNum) { register uint8_t i; // EEPROM よりデータを取り出す。 eeprom_busy_wait(); eeprom_read_block(&rCustom, (void *)(sizeof(custom_char_t)*romCharNum),sizeof(custom_char_t)); eeprom_busy_wait(); // set CG RAM アドレス設定 lcd_command((1<<LCD_CGRAM) | (lcdCharNum << 3)); for (i=0; i<8; i++) { lcd_data(rCustom[i]); } }
static void lcd_set_line (lcd_t * lcd, int line) { unsigned char pos; //debug_printf ("set line %d\n", line); lcd->line = line; lcd->col = 0; switch (line) { case 0: pos = 0x00; break; case 1: pos = 0x40; break; case 2: pos = 0x14; break; case 3: pos = 0x54; break; default: return; } lcd_command (LCD_CMD_DDRAM_ADDR | pos); }
void lcd_putchar( uint8_t d ) { LCD_RS = 1; lcd_byte( d ); switch( ++lcd_pos ){ case LCD_LINE1 + LCD_COLUMN: d = LCD_LINE2; break; case LCD_LINE2 + LCD_COLUMN: d = LCD_LINE1; break; default: return; } lcd_command( d ); }
// ============================================================================ void lcd_gotoxy(char y, char x) //Cursor to X Y position { char DDRAMAddr; x=x-1; // remap lines into proper order switch(y) { case 1: DDRAMAddr = 0x00+x; break; case 2: DDRAMAddr = 0x40+x; break; case 3: DDRAMAddr = 0x14+x; break; case 4: DDRAMAddr = 0x54+x; break; default: DDRAMAddr = 0x00+x; } // set data address lcd_command(1<<7 | DDRAMAddr); }
/** * Move cursor to a given location */ void lcd_goto(unsigned char row, unsigned char col) { unsigned char addr; switch (row) { case 3: // fall through case 4: addr = ((row - 3) * 0x40) + 0x14 + col - 1; break; default: // rows 1 and 2 addr = ((row - 1) * 0x40) + col - 1; break; } lcd_command(SET_DDRAM_ADDR | addr); }