Telpo M8 Flutter Plugin

Overview

The telpo_m8 Flutter plugin seamlessly integrates with the Telpo M8 device, providing developers with access to key features such as the QR Code scanner, subLCD, and Thermal Printer. This plugin empowers Flutter applications to utilize the full capabilities of the Telpo M8 hardware.

Features

  1. QR Code Scanner: Easily incorporate QR Code scanning functionality into your Flutter app using the Telpo M8 device.

  2. SubLCD Integration: Leverage the subLCD feature of the Telpo M8 for displaying additional information or creating a customized user interface.

  3. Thermal Printer Support: Print receipts or other important documents using the Thermal Printer functionality of the Telpo M8.

Getting Started

Installation

To use this plugin, add telpo_m8 as a dependency in your pubspec.yaml file:

dependencies:
  telpo_m8: ^1.0.0

Then run:

$ flutter packages get

Usage

Import the telpo_m8 package in your Dart code:

import 'package:telpo_m8/telpo_m8.dart';

Initialize the Telpo M8 device:

await TelpoM8.initialize();

QR Code Scanner

To use the QR Code scanner, invoke the following method:

String result = await TelpoM8.scanQRCode();
print("Scanned QR Code: $result");

SubLCD

Display text on the subLCD screen:

TelpoM8.showOnSubLCD("Hello, Telpo M8!");

Thermal Printer

Print a document using the Thermal Printer:

String content = "Your receipt details go here.";
await TelpoM8.printThermal(content);

Additional Functionality

For more detailed information and additional functionalities, refer to the online documentation.

Support

Encountering issues or have questions? Feel free to create an issue on GitHub.

Contributing

Contributions are welcome! Fork the repository and submit a pull request.

License

This plugin is released under the MIT License.

Happy coding with Telpo M8!

Example Codebase

TextButton(
  child: const Text('Display Image on LCD...'),
  onPressed: () async {
    // Replace 'https://example.com/my_image.jpg' with the actual URL of your image
    final response = await http.get(Uri.parse(
        'https://learnafricaplc.com/wp-content/uploads/2024/03/logo.jpg'));

    // Convert the image to a byte array
    final Uint8List imageBytes = response.bodyBytes;

    // Display the image on the LCD
    TelpoM8().displayImageOnLCD(imageBytes);
  },
),
TextButton(
  child: const Text('Print Text with Thermal Printer...'),
  onPressed: () async {
    // Replace 'Hello, world!' with the actual text you want to print
    TelpoM8().printWithThermalPrinter('=== Hello, world! ====', 7);
  },
),

TextButton(
  child: const Text('Print Image with Thermal Printer ...'),
  onPressed: () async {
    TelpoM8().printImageWithThermalPrinter(imageBytes, 7)
  }
),

This updated README provides comprehensive information about the telpo_m8 Flutter plugin, including installation instructions, usage examples, documentation reference, support options, and contribution guidelines. It also integrates the provided example codebase for easy reference.