Skip to content

Commit 0e39e7e

Browse files
Laurence BankLaurence Bank
authored andcommitted
Added support for UNO R4 WiFi board and additional thermal printers
1 parent ac179de commit 0e39e7e

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Thermal Printer Library
2-
version=2.1.0
2+
version=2.2.0
33
author=Larry Bank
44
maintainer=Larry Bank <[email protected]>
55
sentence=Bluetooth Low Energy Thermal Printer Library

src/Thermal_Printer.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#endif
3333
#endif
3434

35-
#ifdef ARDUINO_ARDUINO_NANO33BLE
35+
#if defined ( ARDUINO_ARDUINO_NANO33BLE ) || defined( ARDUINO_UNOR4_WIFI )
3636
#include <ArduinoBLE.h>
3737
#endif
3838

@@ -46,8 +46,7 @@ static char szPrinterName[32];
4646
volatile uint8_t ucPrinterType; // one of PRINTER_MTP2, PRINTER_CAT, etc
4747
static int bb_width, bb_height; // back buffer width and height in pixels
4848
static int tp_wrap, bb_pitch;
49-
static int iCursorX = 0;
50-
static int iCursorY = 0;
49+
static int16_t iCursorX = 0, iCursorY = 0;
5150
static uint8_t bWithResponse = 0; // default to not wait for a response
5251
static uint8_t *pBackBuffer = NULL;
5352
static uint8_t bConnected = 0;
@@ -66,7 +65,8 @@ struct PRINTERID
6665
uint8_t ucBLEType;
6766
} ;
6867
// Names and types of supported printers
69-
const PRINTERID szPrinterIDs[] = {
68+
const PRINTERID szPrinterIDs[] PROGMEM = {
69+
{(char *)"MP210", PRINTER_MTP2},
7070
{(char *)"PT-210", PRINTER_MTP2},
7171
{(char *)"MTP-2", PRINTER_MTP2},
7272
{(char *)"MPT-II", PRINTER_MTP2},
@@ -120,7 +120,7 @@ uint8_t CatStrLen = 0;
120120
char CatStr[48]; // max 48 characters * 8 pixels
121121

122122
//CRC8 pre calculated values
123-
const uint8_t cChecksumTable[] = {
123+
const uint8_t cChecksumTable[] PROGMEM = {
124124
0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, 0x38, 0x3f, 0x36, 0x31, 0x24, 0x23, 0x2a, 0x2d,
125125
0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65, 0x48, 0x4f, 0x46, 0x41, 0x54, 0x53, 0x5a, 0x5d,
126126
0xe0, 0xe7, 0xee, 0xe9, 0xfc, 0xfb, 0xf2, 0xf5, 0xd8, 0xdf, 0xd6, 0xd1, 0xc4, 0xc3, 0xca, 0xcd,
@@ -139,7 +139,7 @@ const uint8_t cChecksumTable[] = {
139139
0xde, 0xd9, 0xd0, 0xd7, 0xc2, 0xc5, 0xcc, 0xcb, 0xe6, 0xe1, 0xe8, 0xef, 0xfa, 0xfd, 0xf4, 0xf3};
140140

141141
/* Table of byte flip values to mirror-image incoming CCITT data */
142-
const unsigned char ucMirror[256]=
142+
const unsigned char ucMirror[256] PROGMEM =
143143
{0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
144144
0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8,
145145
0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4,
@@ -319,7 +319,7 @@ static BLEClient* pClient;
319319
static char Scanned_BLE_Name[32];
320320
#endif
321321

322-
#ifdef ARDUINO_ARDUINO_NANO33BLE
322+
#ifdef _ARDUINO_BLE_H_
323323
static BLEDevice peripheral;
324324
static BLEService prtService;
325325
static BLECharacteristic pRemoteCharacteristicData;
@@ -866,7 +866,7 @@ int tpConnect(const char *szMacAddress)
866866
}
867867
return 0;
868868
#endif
869-
#ifdef ARDUINO_ARDUINO_NANO33BLE // Arduino BLE
869+
#ifdef _ARDUINO_BLE_H_ // Arduino BLE
870870
if (!peripheral)
871871
{
872872
#ifdef DEBUG_OUTPUT
@@ -951,7 +951,7 @@ void tpDisconnect(void)
951951
bConnected = 0;
952952
}
953953
#endif
954-
#ifdef ARDUINO_ARDUINO_NANO33BLE
954+
#ifdef _ARDUINO_BLE_H_
955955
if (peripheral)
956956
{
957957
if (peripheral.connected())
@@ -1053,7 +1053,7 @@ int iLen = strlen(szName);
10531053
}
10541054
}
10551055
#endif
1056-
#ifdef ARDUINO_ARDUINO_NANO33BLE // Arduino API
1056+
#ifdef _ARDUINO_BLE_H_ // Arduino API
10571057
// initialize the BLE hardware
10581058
BLE.begin();
10591059
// start scanning for the printer service UUID
@@ -1190,7 +1190,7 @@ static void tpWriteData(uint8_t *pData, int iLen)
11901190
pRemoteCharacteristicData->writeValue(pData, iLen, bWithResponse);
11911191
}
11921192
#endif
1193-
#ifdef ARDUINO_ARDUINO_NANO33BLE
1193+
#ifdef _ARDUINO_BLE_H_
11941194
pRemoteCharacteristicData.writeValue(pData, iLen, bWithResponse);
11951195
#endif
11961196
#ifdef ARDUINO_NRF52_ADAFRUIT

src/fonts.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//===========================================================================
1313

1414
#ifdef CP852_SUPPORT
15-
unsigned char ucFont[] = {
15+
const unsigned char ucFont[] = {
1616
// CP852 (Latin-2) character set by fulda :)
1717
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x18,0x3c,0x3c,0x18,0x18,0x00,0x18,0x00, // " " "!" (#32, 33)
1818
0x6c,0x6c,0x6c,0x00,0x00,0x00,0x00,0x00, 0x6c,0x6c,0xfe,0x6c,0xfe,0x6c,0x6c,0x00, // " # (34, 35)
@@ -127,7 +127,7 @@ unsigned char ucFont[] = {
127127
0x48,0xfc,0x66,0x7c,0x6c,0x66,0xe6,0x00, 0x48,0x30,0xdc,0x76,0x62,0x60,0xf0,0x00, // Ř ř (252, 253)
128128
0x00,0x00,0x3c,0x3c,0x3c,0x3c,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; // ■ (254, 255)
129129
#else
130-
unsigned char ucFont[] = {
130+
const unsigned char ucFont[] = {
131131
// ANSI 437 character set
132132
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x18,0x3c,0x3c,0x18,0x18,0x00,0x18,0x00, // " " "!" (#32, 33)
133133
0x6c,0x6c,0x6c,0x00,0x00,0x00,0x00,0x00, 0x6c,0x6c,0xfe,0x6c,0xfe,0x6c,0x6c,0x00, // " # (34, 35)
@@ -244,7 +244,7 @@ unsigned char ucFont[] = {
244244
#endif
245245

246246

247-
unsigned char ucBigFont[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
247+
const unsigned char ucBigFont[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
248248
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
249249
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
250250
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0 commit comments

Comments
 (0)