Skip to content

Add compatibility with old POS printers + add example #9

Open
marcteys wants to merge 4 commits into
BinaryWorlds:masterfrom
marcteys:master
Open

Add compatibility with old POS printers + add example #9
marcteys wants to merge 4 commits into
BinaryWorlds:masterfrom
marcteys:master

Conversation

@marcteys

Copy link
Copy Markdown

Summary

Add ESP32 example for downloading and printing BMP images from URLs. This new example combines WiFi/HTTPS downloading with a full BMP parser to enable direct printing of web-hosted images on thermal printers.

Changes

New Example: download_bmp_print

  • Complete ESP32 sketch demonstrating BMP download and printing

Key Features

  • Full BMP Parser: Supports multiple BMP formats (1-bit, 4-bit, 8-bit paletted, 24-bit, 32-bit)
  • Color Conversion: Automatic color-to-monochrome conversion (threshold-based)
  • Memory Efficient: Streaming architecture processes images without loading entire file
  • Format Handling: Supports both top-down and bottom-up BMP storage formats
  • Auto-sizing: Automatically limits image width to printer capability (384 pixels)
  • Proper Color Mapping: Bit 1 = black (print), Bit 0 = white (no print)

Technical Implementation

BMP Parsing Functions:

  • read16(), read32() - Read BMP header values with proper byte ordering
  • skip() - Efficiently skip bytes in stream with timeout protection
  • read8n() - Buffered pixel data reading with connection monitoring
  • downloadAndPrintBMP() - Main function orchestrating download, parse, and print

Architecture:

  • Streams BMP data directly from HTTPS response
  • Converts pixels to monochrome bitmap on-the-fly
  • Uses configurable input buffer (800 bytes) for efficient memory usage
  • Handles color palettes for indexed color BMPs
  • Respects BMP row padding (4-byte alignment)

Documentation Updates

  • Added new section to README: "Download and print BMP images from URL"
  • Included feature list, requirements, and usage examples
  • Added to table of contents

Hardware Requirements

  • ESP32 board (uses WiFi, HTTPClient, WiFiClientSecure libraries)
  • Internet connection
  • Thermal printer compatible with TPrinter library

Notes

  • Example uses printBitmapOld() function (GS v 0 ESC/POS command)
  • WiFi credentials need to be updated before use

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant