or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

data-management.mdexception-handling.mdindex.mdmulti-message.mdserial-communication.mdvisualization.md

index.mddocs/

0

# PanamaHitek Arduino

1

2

PanamaHitek_Arduino is a comprehensive Java library that provides a simple framework for handling serial communication between Java applications and Arduino boards. It includes three main classes for managing serial connections and communication, processing multiple simultaneous messages, and organizing data with table visualization and Excel export capabilities. The library also features specialized real-time graphical charting capabilities using JFreeChart components.

3

4

## Package Information

5

6

- **Package Name**: PanamaHitek_Arduino

7

- **Package Type**: Maven (JAR)

8

- **Language**: Java

9

- **Group ID**: com.panamahitek

10

- **Artifact ID**: PanamaHitek_Arduino

11

- **Version**: 3.2.1

12

- **Installation**:

13

14

### Maven

15

Add dependency to `pom.xml`:

16

17

```xml

18

<dependency>

19

<groupId>com.panamahitek</groupId>

20

<artifactId>PanamaHitek_Arduino</artifactId>

21

<version>3.2.1</version>

22

</dependency>

23

```

24

25

### Alternative Installation

26

For manual installation, download the latest JAR from the [GitHub releases page](https://github.com/PanamaHitek/PanamaHitek_Arduino/releases) and add it to your project classpath.

27

28

## Core Imports

29

30

```java

31

import com.panamahitek.PanamaHitek_Arduino;

32

import com.panamahitek.ArduinoException;

33

import com.panamahitek.PanamaHitek_MultiMessage;

34

import com.panamahitek.PanamaHitek_DataBuffer;

35

```

36

37

For chart functionality:

38

39

```java

40

import com.panamahitek.liveinterfaces.*;

41

```

42

43

For event handling and serial communication:

44

45

```java

46

import com.panamahitek.events.*;

47

import jssc.SerialPortEvent;

48

import jssc.SerialPortEventListener;

49

import jssc.SerialPortException;

50

```

51

52

## Basic Usage

53

54

```java

55

import com.panamahitek.PanamaHitek_Arduino;

56

import com.panamahitek.ArduinoException;

57

import jssc.SerialPortEvent;

58

import jssc.SerialPortEventListener;

59

import jssc.SerialPortException;

60

61

public class ArduinoExample {

62

63

private PanamaHitek_Arduino arduino = new PanamaHitek_Arduino();

64

65

public void setupConnection() throws ArduinoException {

66

// For receiving data from Arduino

67

arduino.arduinoRX("COM3", 9600, new SerialPortEventListener() {

68

@Override

69

public void serialEvent(SerialPortEvent event) {

70

try {

71

if (arduino.isMessageAvailable()) {

72

String message = arduino.printMessage();

73

System.out.println("Received: " + message);

74

}

75

} catch (SerialPortException | ArduinoException ex) {

76

ex.printStackTrace();

77

}

78

}

79

});

80

}

81

82

public void sendData() throws ArduinoException, SerialPortException {

83

// For bidirectional communication

84

arduino.arduinoRXTX("COM3", 9600, new SerialPortEventListener() {

85

@Override

86

public void serialEvent(SerialPortEvent event) {

87

// Handle incoming data events

88

}

89

});

90

arduino.sendData("Hello Arduino!");

91

}

92

93

public void cleanup() throws ArduinoException {

94

arduino.killArduinoConnection();

95

}

96

}

97

```

98

99

## Architecture

100

101

The library is organized into four main functional areas:

102

103

1. **Core Communication** - Serial port management and basic Arduino communication

104

2. **Multi-Message Handling** - Processing multiple simultaneous data streams

105

3. **Data Management** - Structured data storage, visualization, and export

106

4. **Real-time Visualization** - Live charting components for data display

107

108

## Capabilities

109

110

### Serial Communication

111

112

Core Arduino serial communication functionality with configurable connection parameters and data transmission methods.

113

114

```java { .api }

115

public class PanamaHitek_Arduino {

116

public PanamaHitek_Arduino();

117

public void arduinoTX(String PORT_NAME, int DATA_RATE) throws ArduinoException;

118

public void arduinoRX(String PORT_NAME, int DATA_RATE, SerialPortEventListener events) throws ArduinoException, SerialPortException;

119

public void arduinoRXTX(String PORT_NAME, int DATA_RATE, SerialPortEventListener events) throws ArduinoException;

120

public void sendData(String data) throws ArduinoException, SerialPortException;

121

public byte[] receiveData() throws ArduinoException, SerialPortException;

122

public void killArduinoConnection() throws ArduinoException;

123

}

124

```

125

126

[Serial Communication](./serial-communication.md)

127

128

### Exception Handling

129

130

Comprehensive error management with multilingual support for Arduino communication errors.

131

132

```java { .api }

133

public class ArduinoException extends Exception {

134

public ArduinoException(String portName, String methodName, String exceptionType);

135

public static void setLanguage(boolean englishLanguage);

136

public static String getExceptionMessage(String exceptionType);

137

}

138

```

139

140

[Exception Handling](./exception-handling.md)

141

142

### Multi-Message Processing

143

144

Handle reception of multiple simultaneous data messages from Arduino without complex logical sequences.

145

146

```java { .api }

147

public class PanamaHitek_MultiMessage {

148

public PanamaHitek_MultiMessage(int inputMessages, PanamaHitek_Arduino arduinoObject);

149

public boolean dataReceptionCompleted() throws ArduinoException, SerialPortException;

150

public String getMessage(int index) throws IndexOutOfBoundsException;

151

public List<String> getMessageList();

152

}

153

```

154

155

[Multi-Message Processing](./multi-message.md)

156

157

### Data Management & Export

158

159

Data organization with table visualization and Excel export capabilities including event-driven data insertion.

160

161

```java { .api }

162

public class PanamaHitek_DataBuffer {

163

public PanamaHitek_DataBuffer();

164

public void addColumn(int index, String variableName, Object dataType);

165

public void addValue(int column, Object value) throws Exception;

166

public void exportExcelFile() throws FileNotFoundException, IOException;

167

public void exportExcelFile(String path);

168

public JTable getTable();

169

}

170

```

171

172

[Data Management](./data-management.md)

173

174

### Real-time Visualization

175

176

Live charting components for real-time data display including dial charts, thermometer displays, and time-series plots.

177

178

```java { .api }

179

public class PanamaHitek_SingleDialChart {

180

public PanamaHitek_SingleDialChart(int chartType);

181

public void setValue(double value);

182

public void createArduinoFollowUp(String PORT_NAME, int DATA_RATE) throws ArduinoException, SerialPortException;

183

public JPanel getChartPanel();

184

}

185

186

public class PanamaHitek_TimeLineChart {

187

public PanamaHitek_TimeLineChart();

188

public void setDataBuffer(PanamaHitek_DataBuffer buffer) throws Exception;

189

public JPanel getChartPanel();

190

}

191

```

192

193

[Real-time Visualization](./visualization.md)

194

195

## Core Types

196

197

```java { .api }

198

// Chart type constants

199

public static final int ROUND_DIAL_CHART = 1;

200

public static final int HORIZONTAL_DIAL_CHART = 2;

201

public static final int VERTICAL_DIAL_CHART = 3;

202

203

// Dial position constants

204

public static final int OUTER_DIAL = 1;

205

public static final int INNER_DIAL = 2;

206

public static final int LEFT_DIAL = 1;

207

public static final int RIGHT_DIAL = 2;

208

209

// Event handling interface

210

public interface DataInsertionListener {

211

void onDataInsertion(DataInsertionEvent ev);

212

}

213

```