Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

What to use as EOL?

Pommie

Well-Known Member
Most Helpful Member
I've written an I²C backpack (pic16F18854) for an LCD and a library for the Arduino.

All works fine except for EOL.

If I use println it sends 0x0d and 0x0a, if I stream it from littleFS then depending on what system it was saved on it might send any combination of the two.

Has anyone come up with a solution for this? I'm thinking I might need a flag so if either (or both) are present it goes to a new line. But, this seems messy and not elegant.

Thanks,

Mike.
 
Use sprintf() to capture the line then test last bytes for formatting and adjust
as necessary ?


Regards, Dana.
 
The problem is that I don't know where the data is coming from. It could be an Arduino, a PC, a Pic etc.
It depends on the person using it.

I'm thinking a flag might be the way to go.

Mike.
 
I've ended up with,
Code:
void writeChar(unsigned char chr){
    if((chr==0x0d || chr==0x0a) && !EOLflag){
        x=0;            //start of line
        y++;            //next line
        setCursor();
        EOLflag=true;   //ignore next time
    }else{
        EOLflag=false;
    }
Hopefully this will take care of all possibilities.

Mike.
 
An update. The above didn't fix it as I still got spurious line feeds. Turns out it was a totally unrelated bug - the file contained lines longer than 20 (screen width) which caused wrap around followed by an EOL leaving blank lines.

The screen width is 20 so I allow x to go to position 20 which is off screen and then do the (Automatic) linefeed when another character is printed. This allows printing to the whole screen without it scrolling up. I can then have a file which is 80 characters (20x4) long which can be copied to the screen.

My file had the top line 21 characters long followed by a CrLf combo hence creating a blank line on line two.

I'm always learning and will (hopfully) never stop.

Mike.
 
Hi,

This has been a problem in Windows programming too for some time.
Some controls want both 0x13 followed by 0x0A while others want just 0x0A.
If you use just 0x0A to interface with some Windows API controls, it will not be recognized so there will never be a new line, just one long, continuous line. With other controls it works fine. It's another dumb thing.
 

Latest threads

New Articles From Microcontroller Tips

Back
Top