Pages: 1 [2]   Go Down
Author Topic: Problem in LiquidCrystal lib (20x4)  (Read 2191 times)
0 Members and 1 Guest are viewing this topic.
Hertfordshire, U.K.
Offline Offline
Jr. Member
**
Karma: 1
Posts: 84
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 64
Posts: 6889
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Hertfordshire, U.K.
Offline Offline
Jr. Member
**
Karma: 1
Posts: 84
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 64
Posts: 6889
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Hertfordshire, U.K.
Offline Offline
Jr. Member
**
Karma: 1
Posts: 84
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 64
Posts: 6889
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
const int lcd_columns=20;
Logged


Hertfordshire, U.K.
Offline Offline
Jr. Member
**
Karma: 1
Posts: 84
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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 
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 64
Posts: 6889
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
Logged


Pages: 1 [2]   Go Up
Jump to: