From b05089ac47013b249d6f34290ae7bde3c8c7fed4 Mon Sep 17 00:00:00 2001 From: lbarthon Date: Tue, 13 Aug 2019 12:27:00 +0200 Subject: [PATCH] added method to reverse colors --- commands.js | 4 +++- package.json | 2 +- printer.js | 10 ++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/commands.js b/commands.js index 33be743..58cbc74 100644 --- a/commands.js +++ b/commands.js @@ -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 }; /** diff --git a/package.json b/package.json index 62361ad..7220b14 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/printer.js b/printer.js index feb73aa..9ad3d7b 100644 --- a/printer.js +++ b/printer.js @@ -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]}