Giter Site home page Giter Site logo

thermalprinter_sm1-21's Introduction

ThermalPrinter_SM1-21

三栄電機 SM1-21用の簡易的なライブラリです。

Python library to manipulate SANEI SM1-21.

結構うろ覚えなのであしからず。気が向いたらライブラリ含め書き直します。

参考までに高専カンファレンスlolのブース発表で使用したプログラム(lol.py)を入れておきました。こちらに関しては、このライブラリは使ってません。tweepyがないと動作しませんのであしからず。

使い方

前提条件として、PIL(Pillow)とnumpyとpySerialがインストールされているものとします。

SM1_21.SM1_21(port, baud)

プリンタの初期設定としてシリアルポートの接続開始及び、Shift-JIS使用のためのコマンドをプリンタに送信します。

  • port : デバイスファイルの指定(初期:/dev/ttyS0)

  • baud : ボーレートの指定(初期:115200[bps])

command(text)

プリンタにコマンドを送信します。

コマンドの詳細に関しては以下のページを参考にしてください。

http://www.sanei-elec.co.jp/downloads/command.html

  • text : 送りたいコマンド('\x00\x00'のように指定)

text(text, flag, bold)

プリンタに文字列を送信します。

  • text : 印刷したい文字列

  • flag : 値が1の場合は印字を行います。0の場合はバッファに記録のみ。

  • bold : 太字指定です。1の場合のみ太字。

output()

バッファに保存された文字列の印字を行います。

tab()

水平タブを挿入します。(動作未確認)

image(img_path, threshould, pitch)

画像の印刷を行います。PCのスペックによっては時間かかる。

  • img_path : 画像のパスを指定

  • threshould : 濃淡の閾値を指定(初期は200、少し濃淡の閾値を変えたいときは適宜変えるといいかも)

  • pitch : 1回に処理を行う縦方向のドット数(初期は200、変更しないことを推奨します)

thermalprinter_sm1-21's People

Contributors

unicore32 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.