two GLCD display

Beta Testing discussion on mikroBasic PRO for PIC.
Post Reply
Author
Message
speedy08fr
Posts: 21
Joined: 17 Nov 2010 15:02
Location: france (ardenne)

two GLCD display

#1 Post by speedy08fr » 03 Mar 2014 16:51

hello how to run two lcd 128 * 64
two diferent afichage on the same pic1xfxxx
mercie
google translation thank you

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: two GLCD display

#2 Post by petar.timotijevic » 03 Mar 2014 17:04

Hello,

Please see this product:

This board allows you to enrich your device with 128x64px graphical display or LCD 2x16 or 4x20 character display using 4-wire SPI interface

Serial LCD/GLCD Adapter Board
http://www.mikroe.com/add-on-boards/dis ... d-adapter/

Image

You need uC with two SPI ports.


Best regards,
Peter

speedy08fr
Posts: 21
Joined: 17 Nov 2010 15:02
Location: france (ardenne)

Re: two GLCD display

#3 Post by speedy08fr » 03 Mar 2014 17:13

hello how to run two glcd 128 * 64
two diferent afichage on the same pic1xfxxx
mercie
google translation thank you

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: two GLCD display

#4 Post by petar.timotijevic » 03 Mar 2014 17:36

Hello,

I have not tested this but I have to admit that it is interesting. I will certainly make a test.

SPI Graphic Lcd Library
http://www.mikroe.com/download/eng/docu ... ibrary.htm

or

One GLCD can go over SPI and one on standard way. But we need few pins more. :)


Best regards,
Peter

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: two GLCD display

#5 Post by petar.timotijevic » 05 Mar 2014 02:12

Hello,

Please see code example for two GLCD 128x64 with PIC18F45K22.
One GLCD is connected on EasyPICv7 GLCD socket and second is connected over Serial LCD/GLCD display adapter using SPI on PortC :

Code: Select all

/*
 * Project name:
     SPI_Glcd (Demonstration of using Spi_Glcd Library)
 * Copyright:
     (c) MikroElektronika, 2012.
 * Revision History:
     20080930:
       - initial release;
     20111012;
       - revision (JK);
 * Description:
     This is a simple demonstration of the serial Glcd library routines:
     - Init and Clear (pattern fill)
     - Image display
     - Drawing shapes
     - Writing text           
 * Test configuration:
     MCU:             PIC18F45K22
                      http://ww1.microchip.com/downloads/en/DeviceDoc/41412D.pdf
     Dev.Board:       EasyPIC7
                      http://www.mikroe.com/easypic/
     Oscillator:      HS-PLL, 32.00000 MHz
     Ext. Modules:    ac:Serial_GLCD_128x64_Adapter_Board on PORTC, Glcd 128x64(KS108/107 controller)
     SW:              mikroC PRO for PIC
                      http://www.mikroe.com/mikroc/pic/
 * Notes:
     None.
*/

// Glcd module connections
char GLCD_DataPort at PORTD;
sbit GLCD_CS1 at LATB0_bit;
sbit GLCD_CS2 at LATB1_bit;
sbit GLCD_RS  at LATB2_bit;
sbit GLCD_RW  at LATB3_bit;
sbit GLCD_EN  at LATB4_bit;
sbit GLCD_RST at LATB5_bit;
sbit GLCD_CS1_Direction at TRISB0_bit;
sbit GLCD_CS2_Direction at TRISB1_bit;
sbit GLCD_RS_Direction  at TRISB2_bit;
sbit GLCD_RW_Direction  at TRISB3_bit;
sbit GLCD_EN_Direction  at TRISB4_bit;
sbit GLCD_RST_Direction at TRISB5_bit;
// End Glcd module connections

const code char truck_bmp[1024];

// Port Expander module connections
sbit  SPExpanderRST at RC0_bit;
sbit  SPExpanderCS  at RC1_bit;
sbit  SPExpanderRST_Direction at TRISC0_bit;
sbit  SPExpanderCS_Direction  at TRISC1_bit;
// End Port Expander module connections

void Delay2s(){                         // 2 seconds delay function
  Delay_ms(2000);
}

void main() {

  unsigned short counter;
  char *someText;

  ANSELC = 0;          // Configure PORTC pins as digital
  ANSELB = 0;          // Configure PORTB pins as digital
  ANSELD = 0;          // Configure PORTD pins as digital
  SLRCON = 0;          // Set output slew rate on all ports at standard rate

  // If Port Expander Library uses SPI1 module
  SPI1_Init();                                         // Initialize SPI module used with PortExpander

  //  // If Port Expander Library uses SPI2 module
  //  SPI2_Init();                                     // Initialize SPI module used with PortExpander

  SPI_Glcd_Init(0);            // Initialize Glcd via SPI
  SPI_Glcd_Fill(0x00);         // Clear Glcd

  Glcd_Init();                 // Initialize GLCD
  Glcd_Fill(0x00);             // Clear GLCD

  while(1) {
    SPI_Glcd_Image(truck_bmp);                         // Draw image
    Delay2s(); Delay2s();
    SPI_Glcd_fill(0x00);                               // Clear GLCD
    SPI_Glcd_PartialImage(0,0,68,30,128,64,truck_bmp); // Partial image
    Delay_ms(500);
    SPI_Glcd_PartialImage(24,16,68,30,128,64,truck_bmp);
    Delay_ms(500);
    SPI_Glcd_PartialImage(56,34,68,30,128,64,truck_bmp);
    Delay2s(); Delay2s();
    SPI_Glcd_Fill(0x00);                               // Clear GLCD

    Glcd_Image(truck_bmp);                            // Draw image
    Delay2s(); Delay2s();
    Glcd_fill(0x00);                                  // Clear GLCD
    Glcd_PartialImage(0,0,68,30,128,64,truck_bmp);    // Partial image
    Delay_ms(500);
    Glcd_PartialImage(24,16,68,30,128,64,truck_bmp);
    Delay_ms(500);
    Glcd_PartialImage(56,34,68,30,128,64,truck_bmp);
    Delay2s(); Delay2s();
    Glcd_Fill(0x00);                             // Clear GLCD

    SPI_Glcd_Box(62,40,124,56,1);                    // Draw box
    SPI_Glcd_Rectangle(5,5,84,35,1);                 // Draw rectangle
    Delay_ms(1000);
    SPI_Glcd_Rectangle_Round_Edges(2,2,87,38,7,1);
    Delay_ms(1000);
    SPI_Glcd_Line(0, 0, 127, 63, 1);                 // Draw line
    Delay2s();

    Glcd_Box(62,40,124,56,1);                    // Draw box
    Glcd_Rectangle(5,5,84,35,1);                 // Draw rectangle
    Delay_ms(1000);
    Glcd_Rectangle_Round_Edges(2,2,87,38,7,1);
    Delay_ms(1000);
    Glcd_Rectangle_Round_Edges_Fill(8,8,81,32,12,1);
    Delay_ms(1000);
    Glcd_Line(0, 0, 127, 63, 1);                 // Draw line
    Delay2s();

    for(counter = 5; counter < 60; counter+=5 )
        {     // Draw horizontal and vertical lines
        Delay_ms(250);
        SPI_Glcd_V_Line(2, 54, counter, 1);
        SPI_Glcd_H_Line(2, 120, counter, 1);
        }
    Delay2s();
  
    SPI_Glcd_Fill(0x00);                             // Clear Glcd

    for(counter = 5; counter < 60; counter+=5 )
        { // Draw horizontal and vertical lines
        Delay_ms(250);
        Glcd_V_Line(2, 54, counter, 1);
        Glcd_H_Line(2, 120, counter, 1);
        }
    Delay2s();

    Glcd_Fill(0x00);                             // Clear Glcd

    for (counter = 1; counter <= 10; counter++)      // Draw circles
        SPI_Glcd_Circle(63,32, 3*counter, 1);
    Delay2s();

    SPI_Glcd_Circle_Fill(63,32, 30, 1);              // Draw circles
    Delay2s();

    SPI_Glcd_Box(12,20, 70,57, 2);                   // Draw box
    Delay2s();

    SPI_Glcd_Fill(0xFF);                             // Fill Glcd

    for (counter = 1; counter <= 10; counter++)  // Draw circles
      Glcd_Circle(63,32, 3*counter, 1);
    Delay2s();

    for (counter = 1; counter <= 10; counter++)  // Draw circles
      Glcd_Circle_Fill(63,32, 3*counter, 1);
    Delay2s();

    Glcd_Box(12,20, 70,57, 2);                   // Draw box
    Delay2s();

    Glcd_Fill(0xFF);                             // Fill Glcd

    SPI_Glcd_Set_Font(Character8x7, 8, 7, 32);       // Choose font, see __Lib_GLCDFonts.c in Uses folder
    SPI_Glcd_Write_Text("TEXT DEMO", 24, 3, 2);      // Write string
    Delay2s();
    SPI_Glcd_Fill(0x00);                             // Clear Glcd

    SPI_Glcd_Set_Font(Character8x7, 8, 7, 32);       // Change font
    someText = "8x7 Font";
    SPI_Glcd_Write_Text(someText, 5, 0, 2);          // Write string
    Delay2s();

    SPI_Glcd_Set_Font(System3x5, 3, 5, 32);          // Change font
    someText = "3X5 CAPITALS ONLY";
    SPI_Glcd_Write_Text(someText, 60, 2, 2);         // Write string
    Delay2s();

    SPI_Glcd_Set_Font(font5x7, 5, 7, 32);            // Change font
    someText = "5x7 Font";
    SPI_Glcd_Write_Text(someText, 5, 4, 2);          // Write string
    Delay2s();

    SPI_Glcd_Set_Font(FontSystem5x7_v2, 5, 7, 32);   // Change font
    someText = "5x7 Font (v2)";
    SPI_Glcd_Write_Text(someText, 50, 6, 2);         // Write string
    Delay2s();
 
 Glcd_Set_Font(Character8x7, 8, 7, 32);       // Choose font, see __Lib_GLCDFonts.c in Uses folder
    Glcd_Write_Text("TEXT DEMO", 24, 3, 2);      // Write string
    Delay2s();
    Glcd_Fill(0x00);                             // Clear Glcd

    Glcd_Set_Font(Character8x7, 8, 7, 32);       // Change font
    someText = "8x7 Font";
    Glcd_Write_Text(someText, 5, 0, 2);          // Write string
    Delay2s();

    Glcd_Set_Font(System3x5, 3, 5, 32);          // Change font
    someText = "3X5 CAPITALS ONLY";
    Glcd_Write_Text(someText, 60, 2, 2);         // Write string
    Delay2s();

    Glcd_Set_Font(font5x7, 5, 7, 32);            // Change font
    someText = "5x7 Font";
    Glcd_Write_Text(someText, 5, 4, 2);          // Write string
    Delay2s();

    Glcd_Set_Font(FontSystem5x7_v2, 5, 7, 32);   // Change font
    someText = "5x7 Font (v2)";
    Glcd_Write_Text(someText, 50, 6, 2);         // Write string
    Delay2s();

  }
}

Best regards,
Peter

speedy08fr
Posts: 21
Joined: 17 Nov 2010 15:02
Location: france (ardenne)

Re: two GLCD display

#6 Post by speedy08fr » 07 Mar 2014 16:13

hello

2 glcd spi not

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: two GLCD display

#7 Post by petar.timotijevic » 08 Mar 2014 17:29

speedy08fr wrote:hello

2 glcd spi not
Hello,

Two SPI ports is possible but requires changes.

For now use the solution described earlier.

Also if you want to use SPI2 port with PIC18F45K22 EasyPICv7 and LCD/GLCD Adapter (HW Ver 1.02) you need to make some changes in connections.


Best regards,
Peter

Post Reply

Return to “mikroBasic PRO for PIC Beta Testing”