SLP440
This is an SLP 440:
It's a label printer that can be operated both by serial and USB. Since the serial interface is simpler than the USB, I chose to use the serial.
Hardware
In order to allow the mbed to communicate via serial, an RS232 level shifter must be made. The mbed can then be connected through the level shifter to a male D-connector, which in turn connects to the printer. The default baud rate of the SLP440 is 115,200. Make sure you wire up the serial port correctly: the red PCB you can see in the picture is printed wrongly, as it is in fact for the other gender of plug. As a result, I initially wired it up incorrectly and could not work out what was wrong.

Notice the sticker on the chip produced with the printer.
The printer sends XON/XOFF signals to tell the mbed whether it'll recieve any more input.
Software
A detailed documentation of the printer can be found on the manufacturers website (or at the bottom of this page). Each command was laboriously turned into a member function of the class SLP440, to allow easy calling. By combining this library with the BitmapFile library, bitmaps stored on the chip can be printed to the printer. Color images are first converted (poorly) to black and white, since the printer is not color.
Sample program
This program loads a bitmap named "mbed.bmp" stored in the flash memory, then prints it out onto a label. This is how the label on my chip was printed.
#include "mbed.h" #include "SLP440.h" #include "BitmapFile.h" Serial pc(USBTX, USBRX); SLP440 printer(28,27); LocalFileSystem local("local"); int main() { BitmapFile MyBitmap("/local/mbed.bmp"); for(int row = MyBitmap.getHeight()-1; row >=0 ; row--) { char *bitstream = MyBitmap.getRowBitstream(row,false); /* these lines used to invert picture */ int bytes = (MyBitmap.getWidth()+7)/8; for(int col=0; col<bytes; col++) { bitstream[col] = ~bitstream[col]; if(col+1 == bytes) { bitstream[col] ^= 0xFF>>(8-(bytes*8-MyBitmap.getWidth())); } } /* end of picture inversion */ printer.Print(bytes,bitstream); delete [] bitstream; } MyBitmap.close(); printer.FeedLabel(); }
Here is the image I used on my chip:
API
The library is avaliable from:
| SLP440 | A class to use an SLP440 label printer. |
| Functions | |
| WaitForEmptyBuffer | Waits for the printer to accept data. |
| SLP440 | Creates an instance of the SLP440 class. |
| Print literal (binary) data | |
| PrintRLE | Print compressed (RLE) data |
| SetMargin | Set offset (in mm) from left side |
| RepeatPrint | Repeat last print command |
| Tab | Tab a number of dots to the right |
| LineFeed | Feed label one dot |
| VTab | Feed label a number of dots |
| FeedLabel | feed to top of next label |
| SetSpeed | Set printer speed mode |
| SetDensity | Set printer density |
| Reset | Reset printer |
| ReverseFeed | Feed paper backwards a number of dots |
| Checkpoint | send checkpoint response |
| GetModelNum | Request printer model number |
| SetIndent | Set image offset in dots from left side |
| SetFineMode | Set anti-banding mode on/off |
| SetXOFFThreshold | Set XOFF threshold |
| SetXONThreshold | Set XON threshold |
| EnableDiagnostics | Enable diagnostic mode |
| SetSerialNo | Set serial number |
| SetOptions | Change option settings |
| GetOptions | Request option settings |
| SetMode | Set printer mode |
| GetMode | Get printer mode |
| SetLabelLength | Set the label length in millimeters |
| CheckBaudRate | Check for correct baud rate |
A class to use an SLP440 label printer.
class SLP440
Waits for the printer to accept data.
void WaitForEmptyBuffer()
Creates an instance of the SLP440 class.
SLP440( int tx, int rx )
Attachments
-
SLP Technical Specification.pdf
(1.0 MB) - added by eric07@…
14 months ago.
Technical specification of the SLP440
-
Board.jpg
(88.1 kB) - added by eric07@…
14 months ago.
Image showing thesetup of the mbed
-
mbed.JPG
(76.3 kB) - added by eric07@…
14 months ago.
Detail of the RS232 level shifter
-
schematic.bmp
(74.0 kB) - added by eric07@…
14 months ago.
RS232 level shife



