ciaa-nxp/board_ciaa_edu_4337/src/ponchos/LCD4Bit.c
// initiatize lcd after a short pause
//while there are hard-coded details here of lines, cursor and blink settings, you can override these original settings after calling .init()
initiatize lcd after a short pause
while there are hard-coded details here of lines, cursor and blink settings, you can override these original settings after calling .init()
initiatize lcd after a short pause while there are hard - coded details here of lines cursor and blink settings you can override these original settings after calling . init ()
void LCD4Bit_init (int num_lines,int dotFormat) {
  g_num_lines = num_lines;
  if (g_num_lines < 1 || g_num_lines > 4)
  {
    g_num_lines = 1;
  }
  LCD4Bit_delay(50);
  LCD4Bit_commandWriteNibble(0x03);
  LCD4Bit_delay(5);
  LCD4Bit_commandWriteNibble(0x03);
  LCD4Bit_delayMicroseconds(100);
  LCD4Bit_commandWriteNibble(0x03);
  LCD4Bit_delay(5);
  LCD4Bit_commandWriteNibble(0x02);
  LCD4Bit_commandWriteNibble(0x02);
  int num_lines_ptn;
  if (g_num_lines==1)
	num_lines_ptn = (0) << 3;
  else
  	num_lines_ptn = (1) << 3;
  int dot_format_ptn = 0x00;      
  if(dotFormat==DOT_FORMAT_5x10)
	dot_format_ptn = 0x04;
  LCD4Bit_commandWriteNibble(num_lines_ptn | dot_format_ptn);
  LCD4Bit_delayMicroseconds(60);
  LCD4Bit_commandWrite(0x0C);
  LCD4Bit_delayMicroseconds(60);
  LCD4Bit_commandWrite(0x01);
  LCD4Bit_delay(3);
  LCD4Bit_commandWrite(0x06);
  currentLineNumber=0;
  LCD4Bit_delay(1);
}
void LCD4Bit_init ( int num_lines , int dotFormat ) { g_num_lines = num_lines ; if ( g_num_lines < 1 || g_num_lines > 4 ) { g_num_lines = 1 ; } LCD4Bit_delay ( 50 ) ; LCD4Bit_commandWriteNibble ( 0x03 ) ; LCD4Bit_delay ( 5 ) ; LCD4Bit_commandWriteNibble ( 0x03 ) ; LCD4Bit_delayMicroseconds ( 100 ) ; LCD4Bit_commandWriteNibble ( 0x03 ) ; LCD4Bit_delay ( 5 ) ; LCD4Bit_commandWriteNibble ( 0x02 ) ; LCD4Bit_commandWriteNibble ( 0x02 ) ; int num_lines_ptn ; if ( g_num_lines == 1 ) num_lines_ptn = ( 0 ) << 3 ; else num_lines_ptn = ( 1 ) << 3 ; int dot_format_ptn = 0x00 ; if ( dotFormat == DOT_FORMAT_5x10 ) dot_format_ptn = 0x04 ; LCD4Bit_commandWriteNibble ( num_lines_ptn | dot_format_ptn ) ; LCD4Bit_delayMicroseconds ( 60 ) ; LCD4Bit_commandWrite ( 0x0C ) ; LCD4Bit_delayMicroseconds ( 60 ) ; LCD4Bit_commandWrite ( 0x01 ) ; LCD4Bit_delay ( 3 ) ; LCD4Bit_commandWrite ( 0x06 ) ; currentLineNumber = 0 ; LCD4Bit_delay ( 1 ) ; }
initiatize lcd after a short pause
while there are hard-coded details here of lines, cursor and blink settings, you can override these original settings after calling .init()
initiatize lcd after a short pause while there are hard - coded details here of lines cursor and blink settings you can override these original settings after calling . init ()
//The first 4 nibbles and timings are not in my DEM16217 SYH datasheet, but apparently are HD44780 standard... // needed by the LCDs controller //this being 2 sets up 4-bit mode. //todo: make configurable by the user of this library. //NFXX where //N = num lines (0=1 line or 1=2 lines). //F= format (number of dots (0=5x7 or 1=5x10)). //X=don't care //5x7 dots.  0x04 is 5x10 //The rest of the init is not specific to 4-bit mode. //NOTE: we're writing full bytes now, not nibbles. // display control: // turn display on, cursor off, no blinking //clear display // entry mode set: 06 // increment automatically, display shift, entire shift off //TODO: remove unnecessary delays