LCD Display easy C v4 cortex

I was wondering if anyone would help me and post a copy of code for easy c v4 for cortex with the basic LCD display stuff. I want to use it to select different autonomouses on the field. The rest (number of codes, ext.) is up to you, be creative. I would just like to experiment with the basics.

Did you look at the “Uart 1&2 LCD Test” in the Samples included with EasyC 4.x??


#include "Main.h"

void main ( void )
{
      unsigned char button1_LCD1 = 0; 
      unsigned char button2_LCD1 = 0; 
      unsigned char button3_LCD1 = 0; 
      unsigned char button1_LCD2 = 0; 
      unsigned char button2_LCD2 = 0; 
      unsigned char button3_LCD2 = 0; 

      InitLCD ( 1 ) ; // Initialize LCD Screen on UART port 1
      InitLCD ( 2 ) ; // Initialize LCD Screen on UART port 2
      SetLCDLight ( 1 , 1 ) ; // Sets the LCD light connected to UART port 1 ON or OFF;  0 = LCD light OFF, 1 = LCD light ON
      SetLCDLight ( 2 , 1 ) ; // Sets the LCD light connected to UART port 2 ON or OFF;  0 = LCD light OFF, 1 = LCD light ON
      SetLCDText ( 1 , 1 , "" ) ; // Clear LCD screen connected to UART port 1
      SetLCDText ( 1 , 2 , "" ) ; // Clear LCD screen connected to UART port 1
      SetLCDText ( 2 , 1 , "" ) ; // Clear LCD screen connected to UART port 2
      SetLCDText ( 2 , 2 , "" ) ; // Clear LCD screen connected to UART port 2
      StartLCDButtonsWatcher ( 1 ) ; // Start watching for buttons pressed on UART port 1
      StartLCDButtonsWatcher ( 2 ) ; // Start watching for buttons pressed on UART port 2
      while ( 1 ) // repeat forever
      {
            GetLCDButtonsWatcher ( 1 , &button1_LCD1 , &button2_LCD1 , &button3_LCD1 ) ; // Check if the buttons from the LCD screen connected tu UART 1 are pressed or not
            GetLCDButtonsWatcher ( 2 , &button1_LCD2 , &button2_LCD2 , &button3_LCD2 ) ; // Check if the buttons from the LCD screen connected tu UART 2 are pressed or not
            if ( button1_LCD1 == 1 ) // Displays on the LCD screen the following:
            {
                  SetLCDText ( 1 , 1 , "Button 1 LCD 1" ) ;
                  SetLCDText ( 2 , 1 , "Button 1 LCD 1" ) ;
            }
            else if ( button1_LCD2 == 1 ) // Displays on the LCD screen the following:
            {
                  SetLCDText ( 1 , 1 , "Button 1 LCD 2" ) ;
                  SetLCDText ( 2 , 1 , "Button 1 LCD 2" ) ;
            }
            else if ( button2_LCD1  == 1 ) // Displays on the LCD screen the following:
            {
                  SetLCDText ( 1 , 1 , "" ) ;
                  SetLCDText ( 2 , 1 , "" ) ;
                  SetLCDText ( 1 , 2 , "Button 2 LCD1" ) ;
                  SetLCDText ( 2 , 2 , "Button 2 LCD1" ) ;
            }
            else if ( button2_LCD2 == 1 ) // Displays on the LCD screen the following:
            {
                  SetLCDText ( 2 , 1 , "" ) ;
                  SetLCDText ( 1 , 1 , "" ) ;
                  SetLCDText ( 2 , 2 , "Button 2 LCD 2" ) ;
                  SetLCDText ( 1 , 2 , "Button 2 LCD 2" ) ;
            }
            else if ( button3_LCD1  == 1 ) // Displays on the LCD screen the following:
            {
                  SetLCDText ( 1 , 1 , "" ) ;
                  SetLCDText ( 2 , 1 , "" ) ;
                  SetLCDText ( 1 , 2 , "Button 3 LCD1" ) ;
                  SetLCDText ( 2 , 2 , "Button 3 LCD1" ) ;
            }
            else if ( button3_LCD2  == 1 ) // Displays on the LCD screen the following:
            {
                  SetLCDText ( 2 , 1 , "" ) ;
                  SetLCDText ( 1 , 1 , "" ) ;
                  SetLCDText ( 2 , 2 , "Button 3 LCD2" ) ;
                  SetLCDText ( 1 , 2 , "Button 3 LCD2" ) ;
            }
            else // Displays on the LCD screen the following:
            {
                  SetLCDText ( 1 , 2 , "" ) ;
                  SetLCDText ( 1 , 1 , "Press a button" ) ;
                  SetLCDText ( 2 , 2 , "" ) ;
                  SetLCDText ( 2 , 1 , "Press a button" ) ;
            }
      }
}


unrelated but how could i get an extension for the lcd? can i use regular 3 wires then into the y cable?

Yes… Nothing Special…

The Serial should be good for a few Feet (Meter) of Distance…

thanks for the code. I am sure to try this tomorrow. If anyone else has a different approch I would like to see it. I am trying to learn many methonds to programming as a middle schooler. :wink:

thanks my lcd is just alittle to far away>.<

Alternatively, you can use the 4-wire extension cable between the Cortex (or VEXpro) and the Y cable.

Thought I’d point that out in case you have some already.

Cheers,

  • Dean

So… If I may ask… How Far Away is your LCD???

I would think that 5-10 Feet would still be acceptable for TTL Serial, but I have heard of some systems that go 50 Feet or so…

the wire is 2 inches too short

Pull out the Vex Kit “Wire Stretcher” and… NO!!! ( That WAS a Joke… )

Do you have anymore Cable Extensions??? Can you Re-Route the Cable so that the Distance is Shorter??? Move the LCD or the Controller??

lol cable extensions? the 3 wire ones yes

OK… So use two of the 3 Wire Extenders… One on the TX and One on the RX… They’re just wires… If Current is involved, like with a Motor, Wire Size can be important, but I believe that the 3 Wire Extenders and be user on Any 3 Wire device…

The Worst that will happen is it Won’t Work… The Best, it Works Perfectly. :wink:

We also might get “DQed”, for taking this Thread, off ( the Original ) Topic… :wink:

Although this discussion, is kind of related to the OP’s Question…

MarkO,
were would I put this into my program?
(intelize, utonomous, operator control)?:confused:

Using a Competition Project for the Field:

The **LCD **Initialize and LCD Backlight function calls would be placed in the void Initialize ( void ) function, since it ONLY needs to be done Once…

The Start Buttons Watcher function call might possibly be placed in the void Initialize ( void ) function, as well, since it ONLY needs to be done Once… But it might need to be set in the function where the Buttons are read… You will need to try that yourself, if I don’t get to it first…

The Set Display Text function is called, whenever you want to change the Message on the LCD Display, and the Get Buttons Watcher function is called whenever you want to detect Button Presses.

So a simple example is using the Display and the Buttons to let you Select a particular Autonomous Mode…
In this case, the Set Display Text the Get Buttons Watcher function calls will need to be in the void Initialize ( void ) function, so that you can look at you Autonomous Mode Choices, and Select the One that you need.

You might chose to call the Set Display Text function from the Autonomous (0) function and the OperatorControl ( 0 ) function to provide Feedback, even though you most likely won’t be able to read or even see them…