Shop OBEX P1 Docs P2 Docs Learn Events
serial "print" failing to uLCD-32PTU, anyone?? — Parallax Forums

serial "print" failing to uLCD-32PTU, anyone??

NeilRogersNeilRogers Posts: 12
edited 2014-07-13 21:39 in Propeller 1
i have not gotten responses before, so trying again.

I have a propeller activity board and a microLCD Picaso display. i am trying to use dprint(LCD, [command]); and not response.

i have gotten:
serial *lcd = fdserial_open(14, 13, 0, 9600);
fdserial_txChar(lcd, 0xFF);
fdserial_txChar(lcd, 0xCD);
ch=fdserial_rxReady(lcd);

to work. the problem is that just clears the screen, to make a button that says PROD:

c=fdserial_txChar(lcd1, 0x00);
c=fdserial_txChar(lcd1, 0x11);
c=fdserial_txChar(lcd1, 0x00);
c=fdserial_txChar(lcd1, 0x00);
c=fdserial_txChar(lcd1, 0x00);
c=fdserial_txChar(lcd1, 0x00);
c=fdserial_txChar(lcd1, 0x00);
c=fdserial_txChar(lcd1, 0x00);
c=fdserial_txChar(lcd1, 0xC6);
c=fdserial_txChar(lcd1, 0x18);
c=fdserial_txChar(lcd1, 0xFA);
c=fdserial_txChar(lcd1, 0x20);
c=fdserial_txChar(lcd1, 0x00);
c=fdserial_txChar(lcd1, 0x01);
c=fdserial_txChar(lcd1, 0x00);
c=fdserial_txChar(lcd1, 0x04);
c=fdserial_txChar(lcd1, 0x00);
c=fdserial_txChar(lcd1, 0x03);
//c=fdserial_txChar(lcd, 0x00); //"
c=fdserial_txChar(lcd1, 'P'); //P
c=fdserial_txChar(lcd1, 'R'); //R
c=fdserial_txChar(lcd1, 'O'); //O
c=fdserial_txChar(lcd1, 'D'); //D
c=fdserial_txChar(lcd1, 0x00); //'"'); //0x22); //"
pause(1000);
ch=fdserial_rxReady(lcd1);

(passed to a function, called lcd1 in the function)

so that all works, but i need a way to read in a touch, that is better than this:
c=fdserial_txChar(lcd1, 0xFF);
c=fdserial_txChar(lcd1, 0x37);
c=fdserial_txChar(lcd1, 0x00);
c=fdserial_txChar(lcd1, 0x01);
ch=0;
for(int x=0; x<=2; x=x+1) {
ch=fdserial_rxReady(lcd1);
//ch=fdserial_rxChar(lcd);
// pause(1000);
print("X= %d,loop= %d \n",ch,x);
ch=0;
}

that is my bigger problem. Thoughts?

Neil

Comments

  • jazzedjazzed Posts: 11,803
    edited 2014-07-13 09:05
    It is not clear exactly what is not working, but it seems you are having rx trouble.

    Use fdserial_rxReady(lcd) to see if a byte is available. If you know a byte should be coming, don't don't bother, but it could be used for a timeout.
    // code not compiled ....
    #include "simpletools.h"
    #include "fdserial.h"
    
    void some_function(void)
    {
      int n = 0;
      char buffer[20]; // space for 20 bytes
    
      int timeout = 10; // wait up to 1 second for first byte
    
      while(!fdserial_rxReady(lcd) && --timeout > 0) {
        pause(100);
      }
    
      if(timeout > 0) {
        // expecting 3 bytes?
        for(n = 0; n < 3; n++) {
          // readChar(lcd) is like fdserial_rxChar(lcd)
          buffer[n] = readChar(lcd);
        }
        // do something with buffered bytes
      }
    }
    
  • NeilRogersNeilRogers Posts: 12
    edited 2014-07-13 15:10
    that does look a little better that what i was doing...

    well i am being whiny about having to have 10+ lines of code for everything on the screen, rather than just a "string" of hex codes or command with arguments. :)

    i am concerned that i am not reading the x/y position consistently, most of the time it does not register a press, never seen it see a release. i have done the fdserial_rxReady(lcd); and fdserial_rxChar(lcd); with mixed results.

    I am wondering if i would be better to program the display with the 4dLabs stuff, then communicate what is done. (basically starting it all over, i am not that far so it would not be a huge deal) the other advantage of that would be i am at 16,688 bytes with a clear screen and three buttons.. that code and images can all be on the display's 2 gb card.
    or
    do i switch to ardino for display purposes, since i have examples for that.

    Neil
  • jazzedjazzed Posts: 11,803
    edited 2014-07-13 21:39
    The original code can be optimized if an array is used for holding the command sequences. The fdserial.h library is pretty solid. It's hard to tell what could be going wrong just looking at your code. I suggest closely reading the specification.

    I don't have one of these LCDs, and don't plan to buy one. They are an attractive light-switch panel replacement for home automation though ....
Sign In or Register to comment.