Go Down

Topic: Problem in LiquidCrystal lib (20x4) (Read 2 times) previous topic - next topic

jimford


If all you need right now is the scrolling text, you can just put this together with the previous code, and replace wait_on_escape(250) by delay(250):

Code: [Select]
void scroll_text(char * src, char * dst, char dst_len, short pos)
{
  for (byte j=0;j<dst_len;j++)
  {
    if ((pos<0)||(pos>strlen(src)-1))
    {
      dst[j]=' ';
    }
    else dst[j]=src[pos];
    pos++;
  }
  dst[dst_len]=0;
}


That will get you started.

The wait_on_escape(250) is a delay while polling all buttons so it quits after time expires or button presses. These buttons are discrete tactile buttons hooked to digital pins.



Just what I needed - it works perfectly!

Although I can usually cobble together a working C/C++ program, I'm not a programmer and got stuck on this problem. I'll sit and digest how your routine works - and learn something!

Thanks again.

Jim

liudr

Jim, You are very welcome. As always, spreading the words of these libraries/codes is always welcome too.

jimford


Jim, You are very welcome. As always, spreading the words of these libraries/codes is always welcome too.


And good for business too!

I followed the link to your site and was impressed enough by your 'phi 2 shield' to order one. I look forward to having a play!

;^)

Jim

liudr

Great! Let me know if you have any questions on the shield. FYI, I'm reorganizing source codes. I'm getting out of my current web host (mediafire.com, like a spam place) and try to move all codes to google code. Let me know if you see broken links.

jimford


FYI, I'm reorganizing source codes.


One point regarding your library:

I had a browse and see that you use #defines. I thought they were deprecated in C++ and consts were what should be used. Is there any reason why you use #define?

Jim

liudr



FYI, I'm reorganizing source codes.


One point regarding your library:

I had a browse and see that you use #defines. I thought they were deprecated in C++ and consts were what should be used. Is there any reason why you use #define?

Jim


Just being old-fashion. How do you use consts? Like this?

Code: [Select]
const int lcd_columns=20;

jimford




FYI, I'm reorganizing source codes.


One point regarding your library:

I had a browse and see that you use #defines. I thought they were deprecated in C++ and consts were what should be used. Is there any reason why you use #define?

Jim


Just being old-fashion. How do you use consts? Like this?

Code: [Select]
const int lcd_columns=20;



Yes, that's the way I'm doing it.

I must admit I prefer the look of #define, as it stands out more, but switched to const because of a macro 'gotcha' I got caught out with using #define (can't remember what it was though, but it put me right off #define!).

Jim 

liudr

I agree, macros are sources of hidden mistakes. If you #define a -5 and forget to put a in a pair of parentheses then sometimes it works and sometimes it doesn't :)

Go Up