Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Bunch o' changes #3

Closed
wants to merge 29 commits into
from

Conversation

Projects
None yet
4 participants
Contributor

lazyatom commented Jan 20, 2012

Hi there,

I've been tinkering with this library, and have come up with a few changes that you might be interested in. In summary, they revolve around:

  • removing some of the duplicate handing for ARDUINO >= 100 vs older libraries
  • using the print mode mask to set some of the formatting (I'm not sure why there are two ways of doing this as outlined in the datasheet, but there you go...)
  • improve the printBitmap support and add some scripts to help people produce bitmaps.

Let me know what you think - I won't be offended if you disapprove :)

lazyatom added some commits Jan 18, 2012

@lazyatom lazyatom Allow flushing of print data.
This is useful when, for example, debugging, if you want to ensure that something is printed without sending a line feed.
31a1100
@lazyatom lazyatom Clean up whitespace.
Delete trailing whitespace and change tabs into spaces.
ae5984d
@lazyatom lazyatom Avoid repetition for Serial definition. d57130c
@lazyatom lazyatom Use a macro to abstract Arduino version differences. 2757dcb
@lazyatom lazyatom More whitespace tweaks. db63559
@lazyatom lazyatom Reset the printer using the direct mechanism. 4e6325a
@lazyatom lazyatom Add normal() method.
I'm just following what's in the codesheet, really.
8f1e6c9
@lazyatom lazyatom Use printMode mask to consistently set formatting.
I've also added upside-down, strike and double width modes this way.
294d8fb
@lazyatom lazyatom Allow printing of larger bitmaps.
The maximum number of rows that can be printed at one time is 255 (since this is the byte limit), so we can print larger bitmaps by splitting them into chunks.
6010b56
@lazyatom lazyatom We can control underline weight. eed4f41
@lazyatom lazyatom Add helper script for producing bitmaps. 346206d
@lazyatom lazyatom Add a script to help generate custom bitmaps.
Sometimes you want the bitmap to be pixel-perfect.
d5fdbf2
@lazyatom lazyatom More compact underline definition. 93aee69
@lazyatom lazyatom Minor refactoring of underline.
I don't believe sending the byte 10 (newline) is necessary, partially because sending even the remaining bytes seems to result in a newline.
8bdd3d4
@lazyatom lazyatom Misc fixes.
I forgot to include definitions for strike methods, and this default argument should be in the cpp implementation.
c8fac10
@lazyatom lazyatom Removed incorrect comment.
I believe an older copy of this library hanging around was causing me to see incoherent behaviour.
bdb2803
@lazyatom lazyatom Don't print a newline when stopping bold.
It's useful to be able to make only certain words bold without interupting a sentence.
8e98391
@lazyatom lazyatom Add a command to feed by pixel rows.
And an explanation of why the normal feed doesn't use the command in the datasheet.
6698e8c
@lazyatom lazyatom Add more clarity to wake/sleep/offline/online.
It's not clear from the datasheet if putting the printer offline also puts the board into a low power consumption mode, so I've renamed the methods to more closely correspond to the guidlines of the datasheet.
771810b
@lazyatom lazyatom No reason not to use writeBytes here. 4e71ae6
@lazyatom lazyatom Add a command to print the built-in test page. eb23fc1
@lazyatom lazyatom The rows are bytes, not bits. 0cc508a
@lazyatom lazyatom Allow subclasses to use these methods and variables. 968502e

kabrio commented Feb 7, 2012

cool, thanks for tinkering!

printing larger images works now! nearly, cause now there seems to be a problem with images larger than 255 in height.
it prints but image is scrambled as soon as it gets over the 255th pixel.
i've seen you made some more changes recently, maybe you already fixed it, will check and report!

Contributor

lazyatom commented Feb 7, 2012

Yeah, I believe I fixed that in commit 0cc508a (it was a simple mistake really!). If you're still having problems with the latest commit, let me know and we can investigate.

kabrio commented Feb 7, 2012

Will let you know! Thx alot!

Best,
J

Am 07.02.2012 um 19:55 schrieb James Adamreply@reply.github.com:

Yeah, I believe I fixed that in commit 0cc508a (it was a simple mistake really!). If you're still having problems with the latest commit, let me know and we can investigate.


Reply to this email directly or view it on GitHub:
https://github.com/adafruit/Thermal-Printer-Library/pull/3#issuecomment-3853814

kabrio commented Feb 16, 2012

printing images works great now, thanks for the fix!

mezelve commented Feb 22, 2012

I have some problems generating bitmaps. Any pointers for OS X without ruby? Maybe a sample .cpp file? thanks

Contributor

lazyatom commented Feb 22, 2012

OSX should have ruby built in, although you will need to install
bundler (gem install bundler) and then run bundle install where
the ruby scripts are. Are you 100% sure that your computer doesn't
have ruby?

On 22 February 2012 17:35, mezelve
reply@reply.github.com
wrote:

I have some problems generating bitmaps. Any pointers for OS X without ruby? Maybe a sample .cpp file? thanks


Reply to this email directly or view it on GitHub:
#3 (comment)

mezelve commented Feb 22, 2012

of course I have ruby but I'm not an 'user'.
but I managed to get it working on OS X Lion.
I've generated a few files and I'll print them first thing in the morning.
thank you.

what's the maximum width and height for bitmaps?
did anyone test it to the extreme?

Contributor

lazyatom commented Feb 23, 2012

Glad to hear you made progress.

The maximum width is 384 pixels; the maximum height is theoretically unlimited, but if you're printing from data stored in the sketch it's probably around 384x400 before the sketch becomes too big for the 32k memory. I'm working on an SD library to print from files to get around this.

of course I have ruby but I'm not an 'user'.
but I managed to get it working on OS X Lion.
I've generated a few files and I'll print them first thing in the morning.
thank you.

what's the maximum width and height for bitmaps?
did anyone test it to the extreme?


Reply to this email directly or view it on GitHub:
#3 (comment)

mezelve commented Feb 23, 2012

Bitmaps up to 256 px wide are no problem. http://instagr.am/p/HWLvpEs0NN/
But when I try to print wider ones in 8px increments, I get broken results.
It prints a few line ok, but the rest is just random characters.
One last hint?

I'll try out your SD lib as soon as I can.

mezelve commented Feb 23, 2012

update:
the error occurs with large (+256px wide) dark (a lot of black) bitmaps.
light images print perfectly.

kabrio commented Feb 23, 2012

did you try lazyatoms fork:
https://github.com/lazyatom/Thermal-Printer-Library

i had problems printing wide images with the adafruit lib...

Contributor

lazyatom commented Feb 23, 2012

@mezelve if you send me the CPP file of the image you're seeing problems with, I'll try and replicate it on my printer soon...

@lazyatom lazyatom closed this Feb 23, 2012

@lazyatom lazyatom reopened this Feb 23, 2012

Contributor

lazyatom commented Feb 23, 2012

It would be great to hear from @adafruit about their thoughts regarding this pull request; I know they've made some recent changes that would at least require a rebase, and some of the other changes might also not be in line with their thinking.

mezelve commented Feb 23, 2012

@kabrio that's the lib I'm using.

@lazyatom I don't have the CPP file at hand. It basically my avatar (https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-snc6/167530_10150179702008709_612493708_8754841_8375756_n.jpg). I resized the image to 384x384 and then converted it with image_to_bytes.

@lazyatom lazyatom Include printing from a Stream instance.
This allows us to print from (for example) an SD file, or an Ethernet client, without
needing to require either.

The new  method expects the width and height to be
encoded in the first four bytes of the stream - see  for an example.
82dacbd
Contributor

lazyatom commented Mar 8, 2012

@mezelve I've just tried printing your avatar, and it seemed to work fine for me (see http://dl.dropbox.com/u/327514/mezeive_avatar_printer.jpg for the output). Perhaps you can put your sketch in a gist for me to check? Incidentally, I think this should probably be an issue on my fork, rather than a conversation in the pull request.

lazyatom added some commits Mar 8, 2012

@lazyatom lazyatom Allow setting of heat time by users.
If this is too high, certain papers (like the one from Staples) will stick against the
print head, spoiling printouts.
1eeac27
@lazyatom lazyatom Whoops, typo. c45699a
@lazyatom lazyatom Make dithering optional, and improve image output.
Using pixel intensity is more sensible, and not dithering images that are already monochrome also increasing picture quality.

We can also handle an optional output filename.
33b8e97
Owner

PaintYourDragon commented Apr 5, 2012

Merged the lot. Thanks for all your improvements...and your patience!

Contributor

lazyatom commented Apr 5, 2012

Great! :D

On 5 April 2012 18:49, Paint Your Dragon
reply@reply.github.com
wrote:

Merged the lot. Thanks for all your improvements...and your patience!


Reply to this email directly or view it on GitHub:
#3 (comment)

kabrio commented on 82dacbd May 2, 2013

See where for example??

How do you encode width and height into the first four bytes.

Explanations would be superhelpful!

Owner

lazyatom replied May 7, 2013

Apologies, it looks like the commit message got screwed up. The last line should read:

The new printBitmap(Stream *stream) method expects the width and height to be
encoded in the first four bytes of the stream - see image_to_file for an example.

In other words, the Ruby script at the bottom of this commit includes the example of encoding the width and height.

great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment