unirpi-io 0.0.0-stage → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CODE_OF_CONDUCT.md +12 -0
- package/CONTRIBUTING.md +33 -0
- package/LICENSE +21 -0
- package/README.md +63 -3
- package/index.js +22 -0
- package/package.json +29 -4
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
## Code of Conduct
|
|
2
|
+
|
|
3
|
+
As a contributor to this project, you are expected to adhere to the following code of conduct:
|
|
4
|
+
|
|
5
|
+
- Be respectful, kind, and patient
|
|
6
|
+
- Welcome feedback constructively
|
|
7
|
+
- Avoid offensive or discriminatory language
|
|
8
|
+
- Focus on collaboration
|
|
9
|
+
- Properly credit contributors
|
|
10
|
+
- Report concerns privately
|
|
11
|
+
|
|
12
|
+
Failure to adhere to this code of conduct may result in removal from the project and reporting to GitHub if necessary.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Anyone is welcome to contribute to this project.
|
|
4
|
+
Please make sure to follow these steps thoroughly to contribute :
|
|
5
|
+
|
|
6
|
+
1. **Fork the repository:** Click the Fork button on GitHub to create your copy.
|
|
7
|
+
|
|
8
|
+
2. **Clone your fork:**
|
|
9
|
+
```bash
|
|
10
|
+
git clone https://github.com/your-username/your-fork.git
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
3. **Create a branch for your feature:**
|
|
14
|
+
```bash
|
|
15
|
+
git checkout -b feat/your-feature
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
4. **Set up the environment:** Follow the setup instructions in the README.
|
|
19
|
+
|
|
20
|
+
5. **Use clear commit messages:**
|
|
21
|
+
- `feat:` – New feature
|
|
22
|
+
- `fix:` – Bug fix
|
|
23
|
+
- `docs:` – Documentation update
|
|
24
|
+
- `refactor:` – Code restructuring
|
|
25
|
+
|
|
26
|
+
6. **Submit a Pull Request (PR):**
|
|
27
|
+
|
|
28
|
+
Include:
|
|
29
|
+
- Description of the changes
|
|
30
|
+
- References to issues (e.g., Closes #12)
|
|
31
|
+
- Screenshots or examples (if applicable)
|
|
32
|
+
|
|
33
|
+
7. **Participate in the code review:** Be collaborative and responsive.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Noah Bleau
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,63 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# UniRPI-IO (Universal Raspberry Pi I/O)
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
A mock implementation of [RPI-IO](https://github.com/gdorbes/rpi-io) to use a fake instance of Raspberry Pi GPIO's on any platform for Node.js
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
Before installing, make sure you have [Node.js](https://nodejs.org/) installed on your system.
|
|
11
|
+
|
|
12
|
+
Install the package using npm:
|
|
13
|
+
```bash
|
|
14
|
+
npm install unirpi-io --save-optional
|
|
15
|
+
npm install rpi-io --save-optional
|
|
16
|
+
```
|
|
17
|
+
*The `--save-optional` flag ensures that the packages are listed under `optionalDependencies` in your `package.json` file.*
|
|
18
|
+
|
|
19
|
+
Make sure both **UniRPI-IO** and **RPI-IO** are listed in `optionalDependencies` in your `package.json` file to prevent installation issues :
|
|
20
|
+
```json
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"dotenv": "^18.0.5",
|
|
23
|
+
...
|
|
24
|
+
},
|
|
25
|
+
"optionalDependencies": {
|
|
26
|
+
"unirio": "^1.0.0",
|
|
27
|
+
"unirpi-io": "^1.0.0"
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
In your project, you can now use a basic `if/else` statement to conditionally require **UniRPI-IO** or **RPI-IO** based on the platform:
|
|
32
|
+
```javascript
|
|
33
|
+
let GPIO; // Variable for the GPIO module
|
|
34
|
+
if (process.platform === 'linux') {
|
|
35
|
+
// Using RPI-IO for Linux platforms
|
|
36
|
+
GPIO = require('rpi-io').RIO;
|
|
37
|
+
} else {
|
|
38
|
+
// Using UniRPI-IO on others platforms
|
|
39
|
+
GPIO = require('unirpi-io').URIO;
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
> [!Note]
|
|
44
|
+
> **RPI-IO has it's own system to detect if the system is running on a Raspberry Pi on Linux**, this package won't perform any such detection for other platforms.
|
|
45
|
+
|
|
46
|
+
## Contributing
|
|
47
|
+
|
|
48
|
+
Please make sure to follow the contribution guidelines before submitting any changes.
|
|
49
|
+
|
|
50
|
+
See the [CONTRIBUTING.md](https://github.com/noahbleau/UniRPI-IO/blob/main/CONTRIBUTING.md) file for contribution instructions.
|
|
51
|
+
|
|
52
|
+
## Code of Conduct
|
|
53
|
+
|
|
54
|
+
Please make sure to read and follow the code of conduct before contributing to the project.
|
|
55
|
+
|
|
56
|
+
See the [CODE_OF_CONDUCT.md](https://github.com/noahbleau/UniRPI-IO/blob/main/CODE_OF_CONDUCT.md) file for the code of conduct.
|
|
57
|
+
|
|
58
|
+
## License
|
|
59
|
+
|
|
60
|
+
This project is licensed under the MIT license, please make sure to read and understand the terms before reusing the code.
|
|
61
|
+
Read more about Licensing in Open Source projects : [What are Open Source Licenses?](https://www.blackduck.com/glossary/what-are-open-source-licenses.html)
|
|
62
|
+
|
|
63
|
+
See the [LICENSE](https://github.com/noahbleau/UniRPI-IO/blob/main/LICENSE) file for more details.
|
package/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// UniRPI-IO library for handling GPIO pins in a mock environment
|
|
2
|
+
class URIO {
|
|
3
|
+
// Initialize the instance with the specified pin, mode, and options
|
|
4
|
+
constructor(pin, mode, options = {}) {
|
|
5
|
+
console.log('\x1b[36m%s\x1b[0m', `[UniRPI-IO] Using UniRPI-IO on pin ${pin}`);
|
|
6
|
+
this.pin = pin;
|
|
7
|
+
this.mode = mode;
|
|
8
|
+
this.isMock = true;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Write a value to the specified pin
|
|
12
|
+
write(value) {
|
|
13
|
+
console.log('\x1b[36m%s\x1b[0m', `[UniRPI-IO] Writing value ${value} on pin ${this.pin}`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Close the specified pin
|
|
17
|
+
close() {
|
|
18
|
+
console.log('\x1b[36m%s\x1b[0m', `[UniRPI-IO] Closing pin ${this.pin}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = { URIO };
|
package/package.json
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unirpi-io",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "A mock implementation of RPI-IO (by gdorbes) to use a fake instance of Raspberry Pi GPIO's on any platform for Node.js",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"unirpi-io",
|
|
7
|
+
"rpi-io",
|
|
8
|
+
"mock",
|
|
9
|
+
"gpio",
|
|
10
|
+
"rpi",
|
|
11
|
+
"raspberry-pi"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/noahbleau/UniRPI-IO#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/noahbleau/UniRPI-IO/issues"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/noahbleau/UniRPI-IO.git"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"author": "Noah Bleau <noah@hexoraw.com>",
|
|
23
|
+
"type": "commonjs",
|
|
24
|
+
"main": "index.js",
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
30
|
+
}
|
|
31
|
+
}
|