0

Weird upside down behaviour
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Weird upside down behaviour

by miss_n on Thu Dec 07, 2017 8:23 pm

Hi, so I'm trying to make a thermal printer print upside down, but the library was not working properly. This is on an adafruit feather huzzah. I found this pull request: https://github.com/adafruit/Adafruit-Th ... l/22/files

implemented the changes and it sort of worked, except now its printing multilines backwards? eg: If my scentance is:

"Watch out for a stranger standing
in the shadow of Casa Loma"

it will print

"in the shadow of Casa Loma.
Watch out for a stranger standing"

What else should I change?

Thanks!

miss_n
 
Posts: 57
Joined: Mon Dec 17, 2012 8:21 pm

Re: Weird upside down behaviour

by pburgess on Sat Dec 16, 2017 11:53 pm

Hey, I apologize for the delayed response, this got lost in some mail.

Although the printer can flip individual lines, it's not able to do this with an indeterminate and ongoing amount of text, most likely due to the limited serial buffer. What you'd need is a function to issue lines to the printer in reverse order, maybe buffered in RAM, memory permitting.

Here's the relevant page from the datasheet, showing that the 180° flip is indeed on a per-line basis:
upside-down.png
upside-down.png (86.44 KiB) Viewed 75 times

pburgess
 
Posts: 3895
Joined: Sun Oct 26, 2008 2:29 am

Re: Weird upside down behaviour

by miss_n on Wed Jan 03, 2018 3:23 pm

Sorry. Coming back to this super late because of holidays.

Do you have an example of a function like this? Right now I just feed the message in their own lines:

Code: Select all | TOGGLE FULL SIZE
printer.println(newMsg);
         printer.feed(1);
         printer.println(newMsg2);
         printer.feed(1);
         printer.println(newMsg3);
         printer.feed(1);
         printer.println(newMsg4);


Would I be looking at something like: EEPROM.write() ? I am using a feather huzzah, so I feel it won't have a lot of room to play around in.

miss_n
 
Posts: 57
Joined: Mon Dec 17, 2012 8:21 pm

Re: Weird upside down behaviour

by pburgess on Wed Jan 03, 2018 4:30 pm

I don't have an example function handy...but the C strrchr() function might be part of what you need (this searches a string backwards for the last occurrence of a character, e.g. '\n' for newline). Maybe have a loop that scans backwards and prints the sections between each newline character.

pburgess
 
Posts: 3895
Joined: Sun Oct 26, 2008 2:29 am

Please be positive and constructive with your questions and comments.