Go Down

Topic: Large Characters/Font 16x2 Serial LCD (Read 1 time) previous topic - next topic

deaurgtehne

Does anybody know of library that can display large characters on a Sparkfun Serial(3 wire) 16x2 LCD?

I found a few libs, but not for a Serial 16x2 LCD.  Any ideas?

johnwasser

http://www.instructables.com/id/Custom-Large-Font-For-16x2-LCDs/step6/More-Efficient-Sketch/
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

deaurgtehne


http://www.instructables.com/id/Custom-Large-Font-For-16x2-LCDs/step6/More-Efficient-Sketch/


I have a Serial LCD...

johnwasser



http://www.instructables.com/id/Custom-Large-Font-For-16x2-LCDs/step6/More-Efficient-Sketch/


I have a Serial LCD...


Adapt it.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

liudr

In another way (yes, it's the same as adapting John, just a bit more detailed :)), replace lcd.print, lcd.write, lcd.setCursor, and lce.CreateChar with the right serLCD commands you get a working piece.

deaurgtehne


In another way (yes, it's the same as adapting John, just a bit more detailed :)), replace lcd.print, lcd.write, lcd.setCursor, and lce.CreateChar with the right serLCD commands you get a working piece.


OK, I have done that and I have a working prototype, but it is terribly slow, i.e. erasing a char and replacing it, because I am literally printing blank and then writing a new char.  I need to do this with bitwise logic, but I cannot seem to figure out a way to do this properly and fast.  So next is? direct interrupts? I can code, but I have little knowledge of arduino/sparkfun16x2 lcd, so I guess it is time to do some reading?

deaurgtehne

To clarify, I am writing 6 blank block of 5x8.  So obviously that is very slow.  I now need to blank out individual pixels, rather that "space sweeping" the 3(5x8)x2 arrays.

Anyway... any ideas or existing libs are welcome - my quest is not to conquer a serial 16x2 display(it is already not the ideal display), see : http://arduino.cc/forum/index.php/topic,106345.0.html

deaurgtehne

Please just ignore the quality of the code(the functions, etc.) this was just all hack of existing code to get it going, but this is what I currently have.  It works, but it is slow, especially clearing the last digit.  Like I said, many bugs, very inefficient code, horrible style... it is just a start.

Code: [Select]

#include <SoftwareSerial.h>
#include <serLCD.h>

int pin = 2;

serLCD lcd(pin);

int x = 0;
// the 8 arrays that form each segment of the custom numbers
byte LT[8] =
{
  B00011,
  B01111,
  B01111,
  B01111,
  B01111,
  B01111,
  B01111,
  B01111
};
byte UB[8] =
{
  B11111,
  B11111,
  B11111,
  B00000,
  B00000,
  B00000,
  B00000,
  B00000
};
byte RT[8] =
{
  B11000,
  B11110,
  B11110,
  B11110,
  B11110,
  B11110,
  B11110,
  B11110
};
byte LL[8] =
{
  B01111,
  B01111,
  B01111,
  B01111,
  B01111,
  B01111,
  B01111,
  B00011
};
byte LB[8] =
{
  B00000,
  B00000,
  B00000,
  B00000,
  B00000,
  B11111,
  B11111,
  B11111
};
byte LR[8] =
{
  B11110,
  B11110,
  B11110,
  B11110,
  B11110,
  B11110,
  B11110,
  B11000
};
byte MB[8] =
{
  B11111,
  B11111,
  B11111,
  B00000,
  B00000,
  B00000,
  B11111,
  B11111
};
byte block[8] =
{
  B01111,
  B01111,
  B01111,
  B01111,
  B01111,
  B01111,
  B01111,
  B01111
};

// loop counter
int count = 0;

void setup()
{
  // assignes each segment a write number
  lcd.createChar(1,LT);
  lcd.createChar(2,UB);
  lcd.createChar(3,RT);
  lcd.createChar(4,LL);
  lcd.createChar(5,LB);
  lcd.createChar(6,LR);
  lcd.createChar(7,MB);
  lcd.createChar(8,block);

  // sets the LCD's rows and colums:
  //lcd.begin(16, 2);

}

void custom0()
{ // uses segments to build the number 0
  lcd.setCursor(1,x+1); // set cursor to column 0, line 0 (first row)
  lcd.printCustomChar(1);  // call each segment to create
  lcd.printCustomChar(2);  // top half of the number
  lcd.printCustomChar(3);
  lcd.setCursor(2,x+1); // set cursor to colum 0, line 1 (second row)
  lcd.printCustomChar(4);  // call each segment to create
  lcd.printCustomChar(5);  // bottom half of the number
  lcd.printCustomChar(6);
}

void custom1()
{
  lcd.setCursor(1,x+1);
  lcd.printCustomChar(2);
  lcd.printCustomChar(3);
  lcd.setCursor(2,x+1);
  lcd.printCustomChar(5);
  lcd.printCustomChar(8);
  lcd.printCustomChar(5);
}

void custom2()
{
  lcd.setCursor(1,x+1);
  lcd.printCustomChar(7);
  lcd.printCustomChar(7);
  lcd.printCustomChar(3);
  lcd.setCursor(2, x+1);
  lcd.printCustomChar(4);
  lcd.printCustomChar(5);
  lcd.printCustomChar(5);
}

void custom3()
{
  lcd.setCursor(1,x+1);
  lcd.printCustomChar(7);
  lcd.printCustomChar(7);
  lcd.printCustomChar(3);
  lcd.setCursor(2, x+1);
  lcd.printCustomChar(5);
  lcd.printCustomChar(5);
  lcd.printCustomChar(6);
}

void custom4()
{
  lcd.setCursor(1,x+1);
  lcd.printCustomChar(4);
  lcd.printCustomChar(5);
  lcd.printCustomChar(8);
  lcd.setCursor(2, x+3);
  lcd.printCustomChar(8);
}

void custom5()
{
  lcd.setCursor(1,x+1);
  lcd.printCustomChar(4);
  lcd.printCustomChar(7);
  lcd.printCustomChar(7);
  lcd.setCursor(2,x+1);
  lcd.printCustomChar(5);
  lcd.printCustomChar(5);
  lcd.printCustomChar(6);
}

void custom6()
{
  lcd.setCursor(1,x+1);
  lcd.printCustomChar(1);
  lcd.printCustomChar(7);
  lcd.printCustomChar(7);
  lcd.setCursor(2,x+1);
  lcd.printCustomChar(4);
  lcd.printCustomChar(5);
  lcd.printCustomChar(6);
}

void custom7()
{
  lcd.setCursor(1,x+1);
  lcd.printCustomChar(2);
  lcd.printCustomChar(2);
  lcd.printCustomChar(3);
  lcd.setCursor(2, x+3);
  lcd.printCustomChar(8);
}

void custom8()
{
  lcd.setCursor(1,x+1);
  lcd.printCustomChar(1);
  lcd.printCustomChar(7);
  lcd.printCustomChar(3);
  lcd.setCursor(2,x+1);
  lcd.printCustomChar(4);
  lcd.printCustomChar(5);
  lcd.printCustomChar(6);
}

void custom9()
{
  lcd.setCursor(1,x+1);
  lcd.printCustomChar(1);
  lcd.printCustomChar(7);
  lcd.printCustomChar(3);
  lcd.setCursor(2,x+3);
  lcd.printCustomChar(8);
}

void clearNumber(int pos)
{ // clears the area the custom number is displayed in
  lcd.setCursor(1,pos);
  lcd.print("   ");
  lcd.setCursor(2,pos);
  lcd.print("   ");
}

int ones = 0;
int tens = 0;
int hundreds = 0;
int thousands = 0;

void printNumber(int number) {

  if ((number / 1000) != thousands) clearNumber(1);
  if ((number % 1000) / 100 != hundreds) clearNumber(4);
  if ((number % 100) / 10 != tens) clearNumber(7);
  if ((number % 100) != ones) clearNumber(10);
 
  thousands = number / 1000;
  hundreds = (number % 1000) / 100;
  tens = (number % 100) / 10;
  ones = (number % 10);
 
  byte nums[4] = {
    thousands, hundreds, tens, ones    };

  for (int i = 0; i < 4; i ++) {
    printNumberChar(nums[i], (i*3));
  }

}


void printNumberChar(int number, int pos) {
  x = pos;
  switch(number) {
  case 0 :
    {
      custom0();
      break;
    }
  case 1 :
    {
      custom1();
      break;
    }
  case 2 :
    {
      custom2();
      break;
    }
  case 3 :
    {
      custom3();
      break;
    }
  case 4 :
    {
      custom4();
      break;
    }
  case 5 :
    {
      custom5();
      break;
    }
  case 6 :
    {
      custom6();
      break;
    }
  case 7 :
    {
      custom7();
      break;
    }
  case 8 :
    {
      custom8();
      break;
    }
  case 9 :
    {
      custom9();
      break;
    }
  }
}

void loop() {
  for (int i = 0; i < 1000; i++) {
    printNumber(i);
    delay(150);  // delay 1 second
  }

}

liudr

Can you adjust baud rate to a higher number? I can't find any other way except, you buffer locally and only write changes to the display (requires a fair amount of additional code).

Go Up