Highspeed LCD (LCD4Bit + Assembler)

just modified an older code:

//Displays a Analog Value on the LCD Screen
//First Try

#include <LCD4Bit.h>
#include <AFSoftSerial.h>

LCD4Bit lcd = LCD4Bit(4); //Inits a 2 line LCD, but with special commands it will be 4 lines.
AFSoftSerial mySerial = AFSoftSerial(3, 2);

unsigned long time;

/*==============================================================================

  • SETUP()
    ============================================================================/

void setup() {

lcd.init(); //Inits the LCD

Serial.begin(57600);

}

/*==============================================================================

  • LOOP()
    ============================================================================/

void loop() {

//Lets start the loop for the Value Displaying:

lcd.commandWrite(0x80);

for (int i=0; i <= 20; i++){

lcd.commandWrite(0x80+i);
//lcd.cursorTo(1,i);
lcd.print(255);

lcd.commandWrite(0xC0+i);
//lcd.cursorTo(2,i);
lcd.print(255);

lcd.commandWrite(0x94+i);
lcd.print(255);

lcd.commandWrite(0xD4+i);
lcd.print(255);

}

lcd.commandWrite(0x80);

for (int i=0; i <= 20; i++){

lcd.commandWrite(0x80+i);
//lcd.cursorTo(1,i);
lcd.print(23);

lcd.commandWrite(0xC0+i);
//lcd.cursorTo(2,i);
lcd.print(23);

lcd.commandWrite(0x94+i);
lcd.print(23);

lcd.commandWrite(0xD4+i);
lcd.print(23);
}

time = millis();

Serial.println(time);

}

thats the code from this video, without the delay what could be adjustet with the poti: (it writes the screen, then clears it, in a VERY stupid way, its very heavy for the communication with the LCD)

The Average Diff between 2 “Timestamps” in this sample with my LCD4Bit + Assemblerdelays is 25,28ms

would be nice to see what LiquidCrystal can do with this code :wink:

LiquidCrystal took 82 ms. The Peter Fleury code I linked earlier that checks the busy status took 11ms

Did you run it 4 or 8Bit?

Its still much faster as the standart LCD4Bit!

And as the official lib it should have the busy check, but maybe an option where it can be put into "speed" mode, with some drawbacks on the safety ;)

I have an LCD 16x2 and i'm using the liquid cristal how i use this? the connects are the same?

Hi, maybe you want to have a look at the new LiquidCrystal library. I found it in the playground about 2 weeks ago. This is a very good library, especially compared to the old one. Got me an immediate speedup without any assembler.

Cheers, Udo

I rewrote the cursorTo function using the suggestions found in these posts.


void LCD4Bit::cursorTo(int line_num, int x){
      
      //not going on an invalid line
      if (line_num > g_num_lines){
            line_num = g_num_lines;
      }
      
      switch(line_num)  {
      case 2:
            commandWrite(0xC0 + x);   
            break;
      case 3:
            commandWrite(0x94 + x);    
            break;
      case 4:
            commandWrite(0xD4 + x);  
            break;
      default:
            commandWrite(0x80 + x);  
      }
      
}

Thanks. /me

Hi !!

Have you got any way to produce special characet similar to createChar in LiquidCrystal (LCD) library

Thanks.

and for positioning the cursor use:

Code:

      lcd.commandWrite(0x80);                   //Line=1, Cursor 0
      lcd.commandWrite(0xC0+val);            //Line=2, Cursor val
      lcd.commandWrite(0x94+7);               //Line=3, Cursor 7
      lcd.commandWrite(0xD4);                   //Line=4, Cursor 0

Hmm... Have you measured the gain in speed using this code? I can't recall how the cursorTo-function is implemented in the libraries at the Playground, but in my own library it looks like this:

void GotoXY(int x, int y)
{
  static byte yoffs[] = {0x80, 0xc0, 0x94, 0xd4};
  CommandWrite(yoffs[y] + x);
}

I can't see how this can be significantly slower that yours, especially since you still need to add code to determine which of the four statements to execute.

I can't see how this can be significantly slower that yours...

The best way to find out is to compare the assembly code generated by each.

In either case most of the actual time will probably be consumed in the implementation of the actual CommandWrite() function whereas you are talking about the time it takes to get the argument information into the parentheses.

In my opinion the amount of time spent implementing the command using either of these methods is insignificant compared to the time it takes the ancient processor in the LCD controller to execute it.

Don

In my opinion the amount of time spent implementing the command using either of these methods is insignificant compared to the time it takes the ancient processor in the LCD controller to execute it.

Exactly my point.