Skip to content

Commit

Permalink
added method to reverse colors
Browse files Browse the repository at this point in the history
lbarthon authored and lsongdev committed Aug 20, 2019

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent 8501d5d commit b05089a
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
@@ -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
};

/**
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": {
10 changes: 10 additions & 0 deletions printer.js
Original file line number Diff line number Diff line change
@@ -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]}

0 comments on commit b05089a

Please sign in to comment.