Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need some help to display a big font clock

Status
Not open for further replies.

ADGAN

Full Member level 5
Full Member level 5
Joined
Oct 9, 2013
Messages
295
Helped
4
Reputation
8
Reaction score
4
Trophy points
18
Visit site
Activity points
1,837
Hi! I'm doing a small project as a hobby which displays time in a big font and date. I'm using DS1307, PIC18F45K22 and 20x4 LCD. The clock is working fine. But I have some issues when displaying the time using a big font. Some digits are not displaying properly. Also I want to display time in 12 hr mode and display AM/PM depending on the time. I'm bit stuck on how to do it.

Code:
#include "customChars.h"

// LCD module connections
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;

sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections


unsigned char txt1[] = "Hello";
unsigned char txt2[] = "20";
unsigned char txt3[] = "AM";
unsigned char txt4[] = "PM";
unsigned char txt[14];
/*******************************************************************************
* DS1307 Functions
*******************************************************************************/

// RTC Definitions
#define RTC_ADDR  0xD0

// Global date/time variables
unsigned short int seconds, minutes, hours,  day, week, month, year;

/*******************************************************************************
* Read time from RTC DS1307
* input : pointer to variables where RTC data will be stored
* output: variables with RTC data
*******************************************************************************/

void Read_Time(unsigned short int *hours, unsigned short int *minutes,
unsigned short int *seconds,unsigned short int *day, unsigned short int *week,
unsigned short int *month, unsigned short int *year){

  I2C1_Start();              // Issue start signal
  I2C1_Wr(RTC_ADDR);         // Address DS1307, see DS1307 datasheet
  I2C1_Wr(0);                // Start from address 0
  I2C1_Repeated_Start();     // Issue repeated start signal
  I2C1_Wr(RTC_ADDR + 1);     // Address DS1307 for reading R/W=1

  *seconds = I2C1_Rd(1);     // Read seconds byte
  *minutes = I2C1_Rd(1);     // Read minutes byte
  *hours = I2C1_Rd(1);       // Read hours byte
  *week =I2C1_Rd(1);         // Read week day byte
  *day =I2C1_Rd(1);          // Read day byte
  *month =I2C1_Rd(1);        // Read month byte
  *year =I2C1_Rd(0);         // Read year byte

  I2C1_Stop();               // Issue stop signal
}

/*******************************************************************************
* Write time to RTC DS1307
* input : variables with RTC data
*******************************************************************************/
void Write_Time(unsigned short int hours, unsigned short int minutes,
unsigned short int seconds,unsigned short int day, unsigned short int week,
unsigned short int month, unsigned short int year){

    unsigned char tmp1, tmp2;

    tmp1 = minutes / 10;               //Write tens of minute
    tmp2 = minutes % 10;               //Write unit of minute
    minutes = tmp1 * 16 + tmp2;        //Includes all value

    tmp1 = hours / 10;                 //Write tens of hour
    tmp2 = hours % 10;                 //Write unit of hour
    hours = tmp1 * 16 + tmp2;          //Includes all value

    tmp1 = week / 10;              //Write tens of weekday
    tmp2 =  week % 10;             //Write unit of weekday
    week = tmp1 *16 +tmp2;         //Includes all value

    tmp1 = day / 10;                  //Write tens of day
    tmp2 =  day % 10;                 //Write unit of day
    day = tmp1 *16 +tmp2;             //Includes all value

    tmp1 = month / 10;                //Write tens of month
    tmp2 =  month % 10;               //Write unit of month
    month = tmp1 *16 +tmp2;           //Includes all value

    tmp1 = year / 10;                 //Write tens of year
    tmp2 =  year % 10;                //Write unit of year
    year = tmp1 *16 +tmp2;            //Includes all value

   I2C1_Start();                 // issue start signal
   I2C1_Wr(RTC_ADDR);            // address DS1307
   I2C1_Wr(0);                   // start from word at address (REG0)
   I2C1_Wr(0x80);                // write $80 to REG0. (pause counter + 0 sec)

   I2C1_Wr(minutes);             // write 0 to minutes word to (REG1)
   I2C1_Wr(hours);               // write 17 to hours word (24-hours mode)(REG2)
   I2C1_Wr(week);                // write 2 - Monday (REG3)
   I2C1_Wr(day);                 // write 4 to date word (REG4)
   I2C1_Wr(month);               // write 5 (May) to month word (REG5)
   I2C1_Wr(year);                // write 01 to year word (REG6)
   I2C1_Stop();                  // issue stop signal

   I2C1_Start();                 // issue start signal
   I2C1_Wr(RTC_ADDR);            // address DS1307
   I2C1_Wr(0);                   // start from word at address 0
   I2C1_Wr(0 | seconds);         // write 0 to REG0 (enable counting + 0 sec)
   I2C1_Stop();                  // issue stop signal
}
unsigned char h1,h2,s1,s2;
unsigned char Dsec;
/*******************************************************************************
* Show on the LCD display
* input : variables with RTC data
*******************************************************************************/

void Show_Time(){
  char *txt;
  
  if(hours & 0x20 == 0x20)Lcd_out(3,16,txt4);
  else Lcd_out(3,16,txt3);
  
  //Converts variables in BCD format to Decimal
  seconds  =  ((seconds & 0x70) >> 4)*10 + (seconds & 0x0F);  //seconds
  minutes  =  ((minutes & 0xF0) >> 4)*10 + (minutes & 0x0F);  //minutes
  hours    =  ((hours & 0x30) >> 4)*10 + (hours & 0x0F);      //hours
  week     =  (week & 0x07);                                  //week
  day      =  ((day & 0xF0) >> 4)*10 + (day & 0x0F);          //day
  month    =  ((month & 0x10) >> 4)*10 + (month & 0x0F);      //month
  year     =  ((year & 0xF0)>>4)*10+(year & 0x0F);            //year
  
  switch(week)
  {
    case 1: txt="Sun"; break;
    case 2: txt="Mon"; break;
    case 3: txt="Tue"; break;
    case 4: txt="Wed"; break;
    case 5: txt="Thu"; break;
    case 6: txt="Fri"; break;
    case 7: txt="Sat"; break;
  }
  Lcd_Out(2,4,txt);                     //Display the current day
  Lcd_Chr(2, 8, (day / 10)   + 48);     //Print tens digit of day variable
  Lcd_Chr(2, 9, (day % 10)   + 48);     //Print ones digit of day variable
  Lcd_Chr_CP('/');                      //Print '/' character on cursor position
  Lcd_Chr(2, 11, (month / 10) + 48);    //Print tens digit of month variable
  Lcd_Chr(2,12, (month % 10) + 48);     //Print oness digit of month variable
  Lcd_Chr_CP('/');                      //Print '/' character on cursor position
  Lcd_Chr(2,16, (year / 10)  + 48);     //Print tenss digit of year variable
  Lcd_Chr(2,17, (year % 10)  + 48);     //Print oness digit of year variable
  
  h1 = hours/10;
  h2 = hours%10;
  s1 = minutes/10;
  s2 = minutes%10;
  switch(h1){
   case 0:zero(3,2);break;
   case 1:one(3,2);break;
   case 2:two(3,2);break;
   case 3:three(3,2);break;
   case 4:four(3,2);break;
   case 5:five(3,2);break;
   case 6:six(3,2);break;
   case 7:seven(3,2);break;
   case 8:eight(3,2);break;
   case 9:nine(3,2);break;
   Delay_ms(100);
  }
  switch(h2){
   case 0:zero(3,5);break;
   case 1:one(3,5);break;
   case 2:two(3,5);break;
   case 3:three(3,5);break;
   case 4:four(3,5);break;
   case 5:five(3,5);break;
   case 6:six(3,5);break;
   case 7:seven(3,5);break;
   case 8:eight(3,5);break;
   case 9:nine(3,5);break;
   Delay_ms(100);
  }
  switch(s1){
   case 0:zero(3,9);break;
   case 1:one(3,9);break;
   case 2:two(3,9);break;
   case 3:three(3,9);break;
   case 4:four(3,9);break;
   case 5:five(3,9);break;
   case 6:six(3,9);break;
   case 7:seven(3,9);break;
   case 8:eight(3,9);break;
   case 9:nine(3,9);break;
   Delay_ms(100);
  }
  switch(s2){
   case 0:zero(3,13);break;
   case 1:one(3,13);break;
   case 2:two(3,13);break;
   case 3:three(3,13);break;
   case 4:four(3,13);break;
   case 5:five(3,13);break;
   case 6:six(3,13);break;
   case 7:seven(3,13);break;
   case 8:eight(3,13);break;
   case 9:nine(3,13);break;
   Delay_ms(100);
  }

  Lcd_Chr(4,16, (seconds / 10)  + 48);     //Print tenss digit of year variable
  Lcd_Chr(4,17, (seconds % 10)  + 48);     //Print oness digit of year variable

}




/*******************************************************************************
* Main function
*******************************************************************************/
void main()
{
     ANSELA = 0;                        // Configure PORTA pins as digital
     ANSELB = 0;                        // Configure PORTB pins as digital
     ANSELC = 0;                        // Configure PORTC pins as digital
     ANSELE = 0;                        // Configure PORTE pins as digital
     SLRCON = 0;                        // Configure all PORTS at the standard Slew
     
     ADCON1 |= 0x0F;                  // Configure AN pins as digital
     C1ON_bit = 0;   // Disable comparators
     C2ON_bit = 0;   //
     TRISA = 0;      //PortA configured as output
     PORTA = 0;
     LATA = 0;
     TRISB = 0;      //PortB confgured as output
     PORTB = 0;      //Reset PORTB
     LATB = 0;
     TRISC = 0x18;   //T1CKI, SCL, SDA and RX set as input
     PORTC = 0;      //Reset PORTC
     TRISD = 0;
     PORTD = 0;
     LATC = 0;
     TRISE = 0xFF;
     LATE = 0;
     PORTE = 0;
     Lcd_Init();              //Initialize the LCD
     Delay_ms(100);           // Delay 100ms
     Lcd_Cmd(_LCD_CURSOR_OFF);//Cursor off
     Lcd_Cmd(_LCD_CLEAR);     //Clear the LCD
     I2C1_Init(100000);       //Initialize at 100KHz
     Delay_ms (100);     //Delay 100ms
     
     LCD_Out(1,5,txt1);
     LCD_Out(2,14,txt2);

      while(1){
      Read_Time(&hours, &minutes, &seconds, &day, &week, &month, &year);
      Show_Time();
      Delay_ms(100);
      
      LATD.F3 = 1;
      LATD.F4 = 1;
      Delay_ms(100);
     
}

The header file which includes the big fonts
Code:
char i;
const char character0_0[] = {7,15,31,31,31,31,31,31};
const char character0_1[] = {31,31,0,0,0,0,0,0};
const char character0_2[] = {28,30,31,31,31,31,31,31};
const char character0_3[] = {31,31,31,31,31,31,30,28};
const char character0_4[] = {0,0,0,0,0,0,31,31};
const char character0_5[] = {31,31,31,31,31,31,15,7};
const char character1_2[] = {31,31,31,31,31,31,31,31};
const char character5_1[] = {31,31,0,0,0,0,31,31};
const char character5_4[] = {31,0,0,0,0,0,31,31};
const char character8_0[] = {7,15,30,28,30,31,15,7};
const char character8_1[] = {31,31,0,0,0,0,0,31};
const char character8_2[] = {28,30,15,7,15,31,30,28};
const char character8_3[] = {28,30,15,7,15,31,30,28};
const char character8_4[] = {31,0,0,0,0,0,31,31};
const char character8_5[] = {7,15,30,28,30,31,15,7};
const char character9_4[] = {31,0,0,0,0,0,0,0};


void zero(char pos_row, char pos_char) {

    Lcd_Cmd(64);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_0[i]);
    LCD_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char, 0);

    Lcd_Cmd(72);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_1[i]);
    LCD_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char+1, 1);

    Lcd_Cmd(80);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_2[i]);
    LCD_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char+2, 2);

    Lcd_Cmd(88);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_3[i]);
    //LCD_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char+2, 3);

    Lcd_Cmd(96);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_4[i]);
   // LCD_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char+1, 4);

    Lcd_Cmd(104);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_5[i]);
   // LCD_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char, 5);
}

void one(char pos_row, char pos_char){

    Lcd_Cmd(64);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_1[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char, 0);

    Lcd_Cmd(72);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_2[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char+1, 1);

    Lcd_Cmd(80);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character1_2[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char+1, 2);

}

void two(char pos_row, char pos_char){

    Lcd_Cmd(64);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_1[i]);
    LCD_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char, 0);

    Lcd_Cmd(64);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_1[i]);
    LCD_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char+1, 0);

    Lcd_Cmd(72);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_2[i]);
    LCD_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char+2, 1);

    Lcd_Cmd(80);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character5_4[i]);
    LCD_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char+2, 2);

    Lcd_Cmd(80);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character5_4[i]);
    LCD_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char+1, 2);

    Lcd_Cmd(88);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character1_2[i]);
    LCD_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char, 3);

}

void three(char pos_row, char pos_char){

    Lcd_Cmd(64);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character5_4[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char, 0);

    Lcd_Cmd(64);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character5_4[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char+1, 0);

    Lcd_Cmd(72);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_2[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char+2, 1);

    Lcd_Cmd(80);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_3[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char+2, 2);

    Lcd_Cmd(88);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character8_4[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char+1, 3);

    Lcd_Cmd(88);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character8_4[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char, 3);

}

void four(char pos_row, char pos_char){

    Lcd_Cmd(64);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_5[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char, 0);

    Lcd_Cmd(72);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_4[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char+1, 1);

    Lcd_Cmd(80);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_2[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char+2, 2);

    Lcd_Cmd(88);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character1_2[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char+2, 3);

}
void five(char pos_row, char pos_char){

    Lcd_Cmd(64);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character1_2[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char, 0);

    Lcd_Cmd(72);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character5_1[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char+1, 1);

    Lcd_Cmd(72);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character5_1[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char+2, 1);

    Lcd_Cmd(80);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_3[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char+2, 2);

    Lcd_Cmd(88);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character5_4[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char+1, 3);

    Lcd_Cmd(88);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character5_4[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char, 3);



}
void six(char pos_row, char pos_char){

    Lcd_Cmd(64);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_0[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char, 0);

    Lcd_Cmd(72);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character8_1[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char+1, 1);

    Lcd_Cmd(80);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_1[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char+2, 2);

    Lcd_Cmd(88);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_3[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char+2, 3);

    Lcd_Cmd(96);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character8_4[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char+1, 4);

    Lcd_Cmd(104);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_5[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char, 5);
}

void seven(char pos_row, char pos_char){

    Lcd_Cmd(64);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_1[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char, 0);

    Lcd_Cmd(64);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_1[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char+1, 0);

    Lcd_Cmd(72);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_2[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char+2, 1);

    Lcd_Cmd(80);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_0[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char+1, 2);
}

void eight(char pos_row, char pos_char){

    Lcd_Cmd(64);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character8_0[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char, 0);

    Lcd_Cmd(72);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character8_1[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char+1, 1);

    Lcd_Cmd(80);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character8_2[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char+2, 2);

    Lcd_Cmd(88);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character8_3[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char+2, 3);

    Lcd_Cmd(96);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character8_4[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char+1, 4);

    Lcd_Cmd(104);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character8_5[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char, 5);

}

void nine(char pos_row, char pos_char){

    Lcd_Cmd(64);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_0[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char, 0);

    Lcd_Cmd(72);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character8_1[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char+1, 1);

    Lcd_Cmd(80);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character0_2[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row, pos_char+2, 2);

    Lcd_Cmd(88);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character1_2[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char+2, 3);

    Lcd_Cmd(96);
    for (i = 0; i<=7; i++) Lcd_Chr_CP(character9_4[i]);
    Lcd_Cmd(_LCD_RETURN_HOME);
    Lcd_Chr(pos_row+1, pos_char+1, 4);

}

This is how 10:13 is displayed :(
Untitled.jpg
 

you can do it by setting the DS1307 time format for 12 hour mode as per your picture its looks like you configured it in 24 hour mode.

And for display big custom characters first test your all custom char logic by displaying them at same row and column address. if they display correct then its is just matter of changing the address for time display.
 

Thank you. But how do I set it in the program since I'm writing time as a variable. Is it correct if I add 0b100000 to the hour and write it in the register. Regarding the big fonts do I need to use a new CGRAM address for each new character?
 

The DS1307 can be run in either 12-hour or 24-hour mode. Bit 6 of the hours register is defined as the 12- or 24-hour mode select bit. When high, the 12-ho
ur mode is selected. In the 12-hour mode, bit 5 is the AM/PM bit with logic high being PM. In the 24-hour mode, bit 5 is the second 10 hour bit (20-23 hours).

For the customize character you do need separate font array as you declare in your code.Try the attached library.
 

Attachments

  • phi_big_font 20120322.zip
    6 KB · Views: 109
Last edited:

I read the datasheet. I tried to do like this.
I2C1_Wr(0x20 & hours + hours);
or else how do i do it?
Is this the correct way to know AM and PM?
if(hours & 0x20 == 0x20)Lcd_out(3,16,txt3);
else Lcd_out(3,16,txt4);
 

I read the datasheet. I tried to do like this.
I2C1_Wr(0x20 & hours + hours);
or else how do i do it?
Is this the correct way to know AM and PM?
if(hours & 0x20 == 0x20)Lcd_out(3,16,txt3);
else Lcd_out(3,16,txt4);

Ya it should work you doing it right.
 

AM/PM seems to be working properly. But still its not working in 12hr mode. :sad: When these big fonts are tested separately they work fine. I tried to display something like a counter. 1,2,3,4,5,...... But in some cases like 4, 7, 9 some segments of the previous number is also displaying.
 

I tried to display something like a counter. 1,2,3,4,5,...... But in some cases like 4, 7, 9 some segments of the previous number is also displaying.

Tried to display counter use clear or space after one number display for e.g display 0 then display space(blank) or clear LCD so it works fine..

What is time you get after modifying the code for 12 hr mode ?with the same logic in your previous post #5.
 

I think the problem is resolved. But I need to run some more test. I think it has a problem of identifying whether the time is AM or PM when writing. Thanks. I also want to display a : when for each second. Do you know any method of achieving it? I thought of using the SQW pin
 

I think the problem is resolved. But I need to run some more test. I think it has a problem of identifying whether the time is AM or PM when writing. Thanks. I also want to display a : when for each second. Do you know any method of achieving it? I thought of using the SQW pin

You can do printing : and space each for 500ms with your second veriable.
 

I printed a blank before printing the number. But still a similar problem is there :sad:
 

I printed a blank before printing the number. But still a similar problem is there :sad:

what problem you have still do print : then delay 500ms then blank char delay500ms and do check your second variable is updated if yes then repeat the first two steps again.

Please provide the problematic output you are getting now.
 

No I mean displaying numbers. Not the ':'.

This how number 2 displayed after displaying number 1
1.jpg
 

did you try with clear lcd after printing the number 1 try that print number 1 clear lcd print number 2
 

try reset whole lcd and if possible try the library i attached
 

Do I need to use a new CGRAM address for each new character I have created ?
 

yes you can do that way or try to make array of fonts and print like a image
 
  • Like
Reactions: ADGAN

    ADGAN

    Points: 2
    Helpful Answer Positive Rating
I wrote the fonts using two dimension array. That method was very convenient. Thanks. Now the number print properly. But when I print hour and minutes, the same digit print in those 4 places. After that 2nd digit of hours print on all 4 places. It goes on like that. Any idea what the issue is?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top