More QR code auto calculation, use ascii() for chars in hex

This commit is contained in:
Deon George 2020-10-31 22:20:35 +11:00
parent fe24c7ebf7
commit fe21ee5379
2 changed files with 13 additions and 9 deletions

View File

@ -39,7 +39,7 @@ function sqrllogin() {
.map(function(x) {return x.charCodeAt(0)}); .map(function(x) {return x.charCodeAt(0)});
var qr = qrcodegen.QrCode.encodeBinary(data,qrcodegen.QrCode.Ecc.LOW); var qr = qrcodegen.QrCode.encodeBinary(data,qrcodegen.QrCode.Ecc.LOW);
var subframe = new Frame(38,2,43,22,BG_BLACK|LIGHTGRAY); var subframe = new Frame((viewdata ? VIEWDATA_FRAME_WIDTH : ANSI_FRAME_WIDTH-qr.size-2),2,(viewdata ? qr.size/2 : qr.size+2),22,BG_BLACK|LIGHTGRAY);
fo.qrcode(qr,subframe); fo.qrcode(qr,subframe);
fo.sendBaseline('CANCEL_MSG',false); fo.sendBaseline('CANCEL_MSG',false);

View File

@ -6,14 +6,15 @@ var VIEWDATA_FRAME_HEADER = 23; /* Size of page owner (length) */
var VIEWDATA_FRAME_PAGENUM = 11; /* Size of page number (length with a-z) */ var VIEWDATA_FRAME_PAGENUM = 11; /* Size of page number (length with a-z) */
var VIEWDATA_FRAME_COST = 3; /* Size of cost (length without unit) */ var VIEWDATA_FRAME_COST = 3; /* Size of cost (length without unit) */
var VIEWDATA_HOME = "\x1e"; var VIEWDATA_LEFT = ascii(0x08);
var VIEWDATA_CLS = "\x0c"; var VIEWDATA_RIGHT = ascii(0x09);
var VIEWDATA_UP = "\x0b"; var VIEWDATA_DOWN = ascii(0x0a);
var VIEWDATA_DOWN = "\x0a"; var VIEWDATA_UP = ascii(0x0b);
var VIEWDATA_COFF = "\x14"; var VIEWDATA_CLS = ascii(0x0c);
var VIEWDATA_CON = "\x11"; var VIEWDATA_CR = ascii(0x0d);
var VIEWDATA_RIGHT = "\x09"; var VIEWDATA_CON = ascii(0x11);
var VIEWDATA_LEFT = "\x08"; var VIEWDATA_COFF = ascii(0x14);
var VIEWDATA_HOME = ascii(0x1e);
var VIEWDATA_MOSIAC_RED = ascii(27)+ascii(0x51); var VIEWDATA_MOSIAC_RED = ascii(27)+ascii(0x51);
var VIEWDATA_MOSIAC_GREEN = ascii(27)+ascii(0x52); var VIEWDATA_MOSIAC_GREEN = ascii(27)+ascii(0x52);
var VIEWDATA_MOSIAC_YELLOW = ascii(27)+ascii(0x53); var VIEWDATA_MOSIAC_YELLOW = ascii(27)+ascii(0x53);
@ -449,6 +450,9 @@ function VIEWDATAFrame() {
repeat_count = VIEWDATA_FRAME_WIDTH-Math.ceil(qr.size/2)-offset-(offset ? 1 : 2)-(y%2 == 1 ? 0 : 1); repeat_count = VIEWDATA_FRAME_WIDTH-Math.ceil(qr.size/2)-offset-(offset ? 1 : 2)-(y%2 == 1 ? 0 : 1);
qrcode += line+' '.repeat(repeat_count > 0 ? repeat_count : 0); qrcode += line+' '.repeat(repeat_count > 0 ? repeat_count : 0);
// To fix some terminals where moving right from col 40 doesnt advance to col 1 on the next line
qrcode +=VIEWDATA_LEFT+VIEWDATA_CR+VIEWDATA_DOWN;
} }
log(LOG_DEBUG,'WIDTH:'+VIEWDATA_FRAME_WIDTH); log(LOG_DEBUG,'WIDTH:'+VIEWDATA_FRAME_WIDTH);