API Documentation
API documentation is a crucial resource for developers, providing detailed information about the functions, classes, and methods available in a programming environment. In the context of hardware hacking with JavaScript, understanding the API documentation is essential for effectively controlling and interacting with hardware components.
Espruino's API Documentation
Espruino's API documentation is a comprehensive resource that includes both standard JavaScript classes and Espruino-specific classes tailored for hardware interaction. Familiar JavaScript classes such as String, Math, Boolean, and JSON are documented alongside Espruino-specific classes like I2C, SPI, and WLAN. These classes are essential for interfacing with various hardware components and performing operations such as data transmission and network communication.
In addition to classes, Espruino's documentation lists hardware functions like digitalWrite(), which is used to control the state of a digital pin, and standard JavaScript global functions like setTimeout() and eval(). These functions are integral to writing scripts that interact with hardware in real-time.
The documentation also covers the API available to all Espruino devices, including specific capabilities for devices like the Puck, which are exposed on the Puck global object. This allows developers to leverage device-specific features and optimize their applications for particular hardware.
Figure 10.10. Espruino’s API documentation at www.espruino.com/Reference
API Documentation for Raspberry Pi
When working with a Raspberry Pi, there is no single source of API documentation due to the multitude of ways to control hardware. Instead, developers often rely on a combination of resources, including Johnny-Five, Node.js, and the raspi-io I/O plugin. Each of these tools has its own set of documentation that developers should keep handy as they explore hardware projects.
Johnny-Five is a JavaScript robotics and IoT platform that provides a high-level API for interacting with hardware. Node.js, a JavaScript runtime, is often used in conjunction with Johnny-Five to run scripts on the Raspberry Pi. The raspi-io plugin acts as an I/O interface, allowing Johnny-Five to communicate with the Raspberry Pi's GPIO pins.
By utilizing these resources, developers can effectively control and interact with hardware components on the Raspberry Pi, creating a wide range of applications from simple LED blinkers to complex IoT devices.
FAQ (Frequently asked questions)
What JavaScript classes are included in Espruino's API documentation?
What hardware-specific classes does Espruino's API documentation include?
What functions are listed in Espruino's API documentation?
Where can I find Espruino's API documentation?
Is there a single source of API documentation for controlling hardware with a Pi?
What documentation should I refer to when using Johnny-Five, Node.js, and the raspi-io plugin?
What does Espruino's API documentation cover?