Skip to content

Commit

Permalink
docs(added): add docs for addText, disconnect, addFeedLine methods
Browse files Browse the repository at this point in the history
  • Loading branch information
tr3v3r committed May 11, 2024
1 parent 862821b commit a59014d
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 1 deletion.
32 changes: 31 additions & 1 deletion docs/printer/Printer.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const printer = new Printer({

## Methods

### [connect(`timeout: string`): `Promise<void>`](./connect.md)
### [connect(`timeout?: string`): `Promise<void>`](./connect.md)

Starts communication with the printer.

Expand All @@ -27,3 +27,33 @@ Starts communication with the printer.
await printerInstance.connect();
```
---

### [disconnect(): `Promise<void>`](./disconnect.md)

Ends communication with the printer.

#### Example

```typescript
await printerInstance.disconnect();
```
---
### [addText(`text: string`): `Promise<void>`](./addText.md)

Adds a character print command to the command buffer.

#### Example

```typescript
await printerInstance.addText("Hello, World!");
```
---
### [addFeedLine(`line?: number`): `Promise<void>`](./addFeedLine.md)

Adds a paper-feed-by-line command to the command buffer.

#### Example

```typescript
await printerInstance.addFeedLine(3);
```
33 changes: 33 additions & 0 deletions docs/printer/addFeedLine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## addFeedLine

Adds a paper-feed-by-line command to the command buffer.

### Parameters

#### line *(optional)*

- `number`

Specifies the paper feed amount (in lines).

| **Value** | **Description** | **Default** |
| --- | --- | --- |
| 0 to 255 | Paper feed amount (in lines) | 1 |

### Returns

`Promise<void>`

### Errors

| **Error status** | **Description** |
| --- | --- |
| ERR_PARAM | An invalid parameter was passed. |
| ERR_TIMEOUT | Failed to communicate with the devices within the specified time. |
| ERR_MEMORY | Necessary memory could not be allocated. |

### Supplementary explanation


- Calling this API causes the printer positioned at "the beginning of the line."

37 changes: 37 additions & 0 deletions docs/printer/addText.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## addText

Adds a character print command to the command buffer.

### Parameters

#### text

- `string`

Specifies the string to print.
Use the following escape sequences for a horizontal tab and line feed.

| **String** | **Description** |
| --- | --- |
|`\t` | Horizontal tab (HT)|
| `\n` | Line feed (LF)
| `\\` | Backslash |

### Returns

`Promise<void>`

### Errors

| **Error status** | **Description** |
| --- | --- |
| ERR_PARAM | An invalid parameter was passed. |
| ERR_TIMEOUT | Failed to communicate with the devices within the specified time. |
| ERR_MEMORY | Necessary memory could not be allocated. |

### Supplementary explanation


- To print data other than text after printing text, feed a line or page.
A line which does not end with a line feed will be discarded as unfixed data by the next [sendData](./sendData.md).

17 changes: 17 additions & 0 deletions docs/printer/disconnect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## disconnect

Ends communication with the printer.

### Returns

`Promise<void>`

### Errors

| **Error status** | **Description** |
| --- | --- |
| ERR_MEMORY | Necessary memory could not be allocated. |
| ERR_FAILURE | An unknown error occurred. |
| ERR_PROCESSING | Could not run the process. |
| ERR_DISCONNECT | Failed to disconnect the device. Tried to terminate communication with a printer during reconnection process. |

0 comments on commit a59014d

Please sign in to comment.