Page 1 of 1

LCD_LINE#

Posted: 18 Nov 2012, 17:31
by cpapple123
How can I Right text to the LCD using a Variable Line #
I'm building a fun little project and will be trying to build a menu to jog 6 motors. Axis 1-6. My plan is to use the Enter BTN to select what axis the arrow buttons will drive

> Axis 1
Axis 2
Axis 3
Axis 4
Axis 5
Axis 6

I'm still early in the code Maybe I'm going the totally wrong way

Code: Select all

int currentline;            //Current line pointer Memory

task myDrawScreen()
{
 ClearScreen();
 TextOut(12, LCD_LINE1, "6 Axis Robot" , 0x0000);
 TextOut(1, LCD_LINE2, "> Axis 1" , 0x0000);
 TextOut(1, LCD_LINE3, "  Axis 2" , 0x0000);
 TextOut(1, LCD_LINE4, "  Axis 3" , 0x0000);
 TextOut(1, LCD_LINE5, "  Axis 4" , 0x0000);
 TextOut(1, LCD_LINE6, "  Axis 5" , 0x0000);
 TextOut(1, LCD_LINE7, "  Axis 6" , 0x0000);
 currentline =2;
 }

task myMenuPointer()
{
     while (true)
     {
           if (ButtonPressed(BTNCENTER, true))
              {Wait(1000);
              TextOut(1, LCD_LINE2, "  Axis 1" , 0x0000);
              TextOut(1, LCD_LINE3, "> Axis 2" , 0x0000);
      
              currentline = currentline +1;
              NumOut(1, LCD_LINE8, currentline , 0x0000);
              }

      }
}

task main()
{
 Precedes(myDrawScreen, myMenuPointer);
}

Re: LCD_LINE#

Posted: 18 Nov 2012, 17:55
by HaWe
for a variable line number I am using an array
char LCDline[]={56,48,40,32,24,16,8,0}; // counting 0...7

so you can jump to the line you want to write to by
char i;
TextOut(0, LCD_LINE,.....);

Re: LCD_LINE#

Posted: 18 Nov 2012, 21:53
by cpapple123
Thank you. I will play some with you code. I did find a temporarily solution. I use a case statement and hard coded the 6 scenarios.

Code: Select all

sub myClearline(int i)
{
 switch (i)
 {
   case 1 :
   TextOut(1, LCD_LINE2, "  Axis 1" );
   TextOut(1, LCD_LINE3, "> Axis 2" );
   break;
   case 2 :
   TextOut(1, LCD_LINE3, "  Axis 2" );
   TextOut(1, LCD_LINE4, "> Axis 3" );
   break;
   case 3 :
   TextOut(1, LCD_LINE4, "  Axis 3" );
   TextOut(1, LCD_LINE5, "> Axis 4" );
   break;
   case 4 :
   TextOut(1, LCD_LINE5, "  Axis 4" );
   TextOut(1, LCD_LINE6, "> Axis 5" );
   break;
   case 5 :
   TextOut(1, LCD_LINE6, "  Axis 5" );
   TextOut(1, LCD_LINE7, "> Axis 6" );
   break;
   case 6 :
   TextOut(1, LCD_LINE7, "  Axis 6" );
   TextOut(1, LCD_LINE2, "> Axis 1" );
   break;
 }
}

Re: LCD_LINE#

Posted: 18 Nov 2012, 22:35
by cpapple123
Much cleaner Thank you. Plus got some good practice on arrays :)

Code: Select all

task myMenuPointer()
{
 while (true)
 {
 if (ButtonPressed(BTNCENTER, true))
    {
    Wait(1000);
    TextOut(1, LCDline[currentline], StrCat("  Axis ", NumToStr(currentline)));

    if (currentline<6)
    TextOut(1, LCDline[currentline+1], StrCat("> Axis ", NumToStr(currentline+1)));
    else
    TextOut(1, LCDline[1], StrCat("> Axis ", NumToStr(1)));

    if (currentline<6)
      currentline = currentline+1;
    else
      currentline = 1;
    NumOut(1, LCD_LINE8, currentline );
    }
 }
}

Re: LCD_LINE#

Posted: 19 Nov 2012, 23:22
by mattallen37
I use:

Code: Select all

LCD_LINE1 - (line * 8)
For the x axis, I use:

Code: Select all

column * 6