Skip to content

Commit

Permalink
added method to reverse colors
Browse files Browse the repository at this point in the history
  • Loading branch information
lbarthon authored and lsongdev committed Aug 20, 2019
1 parent f5d296f commit 5790d0c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ _.BEEP = '\x1b\x42', // Printer Buzzer pre hex
*/
_.COLOR = {
0: '\x1b\x72\x00', // black
1: '\x1b\x72\x01' // red
1: '\x1b\x72\x01', // red
REVERSE: '\x1dB1', // Reverses the colors - white text on black background
UNREVERSE: '\x1dB0' // Default: undo the reverse - black text on white background
};

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "escpos",
"version": "2.5.1",
"version": "2.5.2",
"description": "ESC/POS Printer driver for nodejs",
"main": "index.js",
"scripts": {
Expand Down
10 changes: 10 additions & 0 deletions printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,16 @@ Printer.prototype.color = function (color) {
return this;
};

/**
* [reverse colors, if your printer supports it]
* @param {Boolean} bool - True for reverse, false otherwise
* @return {[Printer]} printer [the escpos printer instance]
*/
Printer.prototype.setReverseColors = function (bool) {
this.buffer.write(bool ? _.COLOR.REVERSE : _.COLOR.UNREVERSE);
return this;
};

/**
* [exports description]
* @type {[type]}
Expand Down

0 comments on commit 5790d0c

Please sign in to comment.