Barmaja-PyArduino 2.0.0__py3-none-any.whl

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.
Files changed (87) hide show
  1. Barmaja_PyArduino/BARMAJA_PyArduino.ico +0 -0
  2. Barmaja_PyArduino/__init__.py +528 -0
  3. Barmaja_PyArduino/__init__.pyi +331 -0
  4. Barmaja_PyArduino/__main__.py +2 -0
  5. Barmaja_PyArduino/adapters/__init__.py +35 -0
  6. Barmaja_PyArduino/api_registry.py +459 -0
  7. Barmaja_PyArduino/backend/__init__.py +3 -0
  8. Barmaja_PyArduino/backend/uno_cpp.py +1680 -0
  9. Barmaja_PyArduino/board.py +80 -0
  10. Barmaja_PyArduino/cli.py +223 -0
  11. Barmaja_PyArduino/compiler.py +1721 -0
  12. Barmaja_PyArduino/console.py +217 -0
  13. Barmaja_PyArduino/device_packs.py +367 -0
  14. Barmaja_PyArduino/device_packs_builtin/Button/arduino/Barmaja_Button/library.properties +9 -0
  15. Barmaja_PyArduino/device_packs_builtin/Button/arduino/Barmaja_Button/src/Barmaja_Button.h +18 -0
  16. Barmaja_PyArduino/device_packs_builtin/Button/example.py +10 -0
  17. Barmaja_PyArduino/device_packs_builtin/Button/pack.json +40 -0
  18. Barmaja_PyArduino/device_packs_builtin/ClockDS3231/arduino/Barmaja_ClockDS3231/library.properties +9 -0
  19. Barmaja_PyArduino/device_packs_builtin/ClockDS3231/arduino/Barmaja_ClockDS3231/src/Barmaja_ClockDS3231.h +20 -0
  20. Barmaja_PyArduino/device_packs_builtin/ClockDS3231/example.py +8 -0
  21. Barmaja_PyArduino/device_packs_builtin/ClockDS3231/pack.json +136 -0
  22. Barmaja_PyArduino/device_packs_builtin/DistanceVL53L0X/arduino/Barmaja_DistanceVL53L0X/library.properties +9 -0
  23. Barmaja_PyArduino/device_packs_builtin/DistanceVL53L0X/arduino/Barmaja_DistanceVL53L0X/src/Barmaja_DistanceVL53L0X.h +12 -0
  24. Barmaja_PyArduino/device_packs_builtin/DistanceVL53L0X/example.py +8 -0
  25. Barmaja_PyArduino/device_packs_builtin/DistanceVL53L0X/pack.json +48 -0
  26. Barmaja_PyArduino/device_packs_builtin/LCDParallel/arduino/Barmaja_LCDParallel/library.properties +9 -0
  27. Barmaja_PyArduino/device_packs_builtin/LCDParallel/arduino/Barmaja_LCDParallel/src/Barmaja_LCDParallel.h +17 -0
  28. Barmaja_PyArduino/device_packs_builtin/LCDParallel/example.py +10 -0
  29. Barmaja_PyArduino/device_packs_builtin/LCDParallel/pack.json +137 -0
  30. Barmaja_PyArduino/device_packs_builtin/LoadCellHX711/arduino/Barmaja_LoadCellHX711/library.properties +9 -0
  31. Barmaja_PyArduino/device_packs_builtin/LoadCellHX711/arduino/Barmaja_LoadCellHX711/src/Barmaja_LoadCellHX711.h +16 -0
  32. Barmaja_PyArduino/device_packs_builtin/LoadCellHX711/example.py +11 -0
  33. Barmaja_PyArduino/device_packs_builtin/LoadCellHX711/pack.json +74 -0
  34. Barmaja_PyArduino/device_packs_builtin/NeoPixelStrip/arduino/Barmaja_NeoPixelStrip/library.properties +9 -0
  35. Barmaja_PyArduino/device_packs_builtin/NeoPixelStrip/arduino/Barmaja_NeoPixelStrip/src/Barmaja_NeoPixelStrip.h +15 -0
  36. Barmaja_PyArduino/device_packs_builtin/NeoPixelStrip/example.py +13 -0
  37. Barmaja_PyArduino/device_packs_builtin/NeoPixelStrip/pack.json +114 -0
  38. Barmaja_PyArduino/device_packs_builtin/OLEDText/arduino/Barmaja_OLEDText/library.properties +9 -0
  39. Barmaja_PyArduino/device_packs_builtin/OLEDText/arduino/Barmaja_OLEDText/src/Barmaja_OLEDText.h +21 -0
  40. Barmaja_PyArduino/device_packs_builtin/OLEDText/example.py +9 -0
  41. Barmaja_PyArduino/device_packs_builtin/OLEDText/pack.json +103 -0
  42. Barmaja_PyArduino/device_packs_builtin/PressureBMP280/arduino/Barmaja_PressureBMP280/library.properties +9 -0
  43. Barmaja_PyArduino/device_packs_builtin/PressureBMP280/arduino/Barmaja_PressureBMP280/src/Barmaja_PressureBMP280.h +16 -0
  44. Barmaja_PyArduino/device_packs_builtin/PressureBMP280/example.py +8 -0
  45. Barmaja_PyArduino/device_packs_builtin/PressureBMP280/pack.json +92 -0
  46. Barmaja_PyArduino/device_packs_builtin/RotaryEncoder/arduino/Barmaja_RotaryEncoder/library.properties +9 -0
  47. Barmaja_PyArduino/device_packs_builtin/RotaryEncoder/arduino/Barmaja_RotaryEncoder/src/Barmaja_RotaryEncoder.h +18 -0
  48. Barmaja_PyArduino/device_packs_builtin/RotaryEncoder/example.py +10 -0
  49. Barmaja_PyArduino/device_packs_builtin/RotaryEncoder/pack.json +44 -0
  50. Barmaja_PyArduino/device_packs_builtin/ServoDriverPCA9685/arduino/Barmaja_ServoDriverPCA9685/library.properties +9 -0
  51. Barmaja_PyArduino/device_packs_builtin/ServoDriverPCA9685/arduino/Barmaja_ServoDriverPCA9685/src/Barmaja_ServoDriverPCA9685.h +15 -0
  52. Barmaja_PyArduino/device_packs_builtin/ServoDriverPCA9685/example.py +10 -0
  53. Barmaja_PyArduino/device_packs_builtin/ServoDriverPCA9685/pack.json +117 -0
  54. Barmaja_PyArduino/device_packs_builtin/ShiftRegister595/arduino/Barmaja_ShiftRegister595/library.properties +9 -0
  55. Barmaja_PyArduino/device_packs_builtin/ShiftRegister595/arduino/Barmaja_ShiftRegister595/src/Barmaja_ShiftRegister595.h +14 -0
  56. Barmaja_PyArduino/device_packs_builtin/ShiftRegister595/example.py +9 -0
  57. Barmaja_PyArduino/device_packs_builtin/ShiftRegister595/pack.json +83 -0
  58. Barmaja_PyArduino/device_packs_builtin/TemperatureDS18B20/arduino/Barmaja_TemperatureDS18B20/library.properties +9 -0
  59. Barmaja_PyArduino/device_packs_builtin/TemperatureDS18B20/arduino/Barmaja_TemperatureDS18B20/src/Barmaja_TemperatureDS18B20.h +16 -0
  60. Barmaja_PyArduino/device_packs_builtin/TemperatureDS18B20/example.py +8 -0
  61. Barmaja_PyArduino/device_packs_builtin/TemperatureDS18B20/pack.json +63 -0
  62. Barmaja_PyArduino/doctor.py +406 -0
  63. Barmaja_PyArduino/environment.py +595 -0
  64. Barmaja_PyArduino/errors.py +166 -0
  65. Barmaja_PyArduino/flow.py +754 -0
  66. Barmaja_PyArduino/frontend.py +611 -0
  67. Barmaja_PyArduino/installer.py +151 -0
  68. Barmaja_PyArduino/ir.py +660 -0
  69. Barmaja_PyArduino/library_adder.py +440 -0
  70. Barmaja_PyArduino/live.py +859 -0
  71. Barmaja_PyArduino/lowering.py +596 -0
  72. Barmaja_PyArduino/numeric.py +748 -0
  73. Barmaja_PyArduino/pack_builder.py +544 -0
  74. Barmaja_PyArduino/py.typed +0 -0
  75. Barmaja_PyArduino/serial_monitor.py +172 -0
  76. Barmaja_PyArduino/source.py +184 -0
  77. Barmaja_PyArduino/stubgen.py +148 -0
  78. Barmaja_PyArduino/symbols.py +646 -0
  79. Barmaja_PyArduino/target.py +1631 -0
  80. Barmaja_PyArduino/toolchain.py +506 -0
  81. Barmaja_PyArduino/typesys.py +917 -0
  82. Barmaja_PyArduino/workflow.py +213 -0
  83. barmaja_pyarduino-2.0.0.dist-info/METADATA +39 -0
  84. barmaja_pyarduino-2.0.0.dist-info/RECORD +87 -0
  85. barmaja_pyarduino-2.0.0.dist-info/WHEEL +5 -0
  86. barmaja_pyarduino-2.0.0.dist-info/licenses/LICENSE.txt +7 -0
  87. barmaja_pyarduino-2.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,114 @@
1
+ {
2
+ "schema": 1,
3
+ "class": "NeoPixelStrip",
4
+ "title": "WS2812 / NeoPixel RGB LED strip or ring",
5
+ "status": "compile-verified",
6
+ "boards": [
7
+ "uno",
8
+ "nano"
9
+ ],
10
+ "constructor": [
11
+ {
12
+ "name": "pin",
13
+ "type": "Int",
14
+ "rule": "digital_pin"
15
+ },
16
+ {
17
+ "name": "count",
18
+ "type": "Int",
19
+ "range": [
20
+ 1,
21
+ 120
22
+ ]
23
+ }
24
+ ],
25
+ "methods": {
26
+ "begin": {
27
+ "params": [],
28
+ "returns": "Void",
29
+ "starts": true
30
+ },
31
+ "setPixel": {
32
+ "params": [
33
+ {
34
+ "name": "index",
35
+ "type": "Int",
36
+ "range": [
37
+ 0,
38
+ "count-1"
39
+ ]
40
+ },
41
+ {
42
+ "name": "red",
43
+ "type": "Int",
44
+ "range": [
45
+ 0,
46
+ 255
47
+ ]
48
+ },
49
+ {
50
+ "name": "green",
51
+ "type": "Int",
52
+ "range": [
53
+ 0,
54
+ 255
55
+ ]
56
+ },
57
+ {
58
+ "name": "blue",
59
+ "type": "Int",
60
+ "range": [
61
+ 0,
62
+ 255
63
+ ]
64
+ }
65
+ ],
66
+ "returns": "Void"
67
+ },
68
+ "setBrightness": {
69
+ "params": [
70
+ {
71
+ "name": "level",
72
+ "type": "Int",
73
+ "range": [
74
+ 0,
75
+ 255
76
+ ]
77
+ }
78
+ ],
79
+ "returns": "Void"
80
+ },
81
+ "clear": {
82
+ "params": [],
83
+ "returns": "Void"
84
+ },
85
+ "show": {
86
+ "params": [],
87
+ "returns": "Void"
88
+ }
89
+ },
90
+ "resources": [
91
+ "interrupts"
92
+ ],
93
+ "warnings": [
94
+ "show() briefly disables interrupts (millis/Servo/SoftwareSerial may jitter). Power more than ~8 LEDs from an external 5 V supply with common GND."
95
+ ],
96
+ "adapter": {
97
+ "library": "Barmaja_NeoPixelStrip",
98
+ "header": "Barmaja_NeoPixelStrip.h"
99
+ },
100
+ "dependencies": [
101
+ {
102
+ "id": "adafruit-neopixel",
103
+ "name": "Adafruit NeoPixel",
104
+ "version": "1.15.5",
105
+ "header": "Adafruit_NeoPixel.h",
106
+ "license": "LGPL-3.0",
107
+ "source": "https://github.com/adafruit/Adafruit_NeoPixel",
108
+ "tag": "1.15.5",
109
+ "library_folder": "Adafruit_NeoPixel"
110
+ }
111
+ ],
112
+ "liverun": false,
113
+ "example": "from Barmaja_PyArduino import *\nupload()\n\nring = NeoPixelStrip(6, 8)\nring.begin()\nring.setBrightness(40)\ni = 0\nwhile True:\n ring.clear()\n ring.setPixel(i, 0, 120, 255)\n ring.show()\n i = (i + 1) % 8\n delay(100)\n"
114
+ }
@@ -0,0 +1,9 @@
1
+ name=Barmaja_OLEDText
2
+ version=1.1.0
3
+ author=BARMAJA
4
+ maintainer=BARMAJA
5
+ sentence=BARMAJA PyArduino device-pack adapter: SSD1306 128x64 I2C OLED display, text mode (low memory)
6
+ paragraph=
7
+ category=Device Control
8
+ url=
9
+ architectures=avr
@@ -0,0 +1,21 @@
1
+ #pragma once
2
+ #include <Arduino.h>
3
+ #include <Wire.h>
4
+ #include <SSD1306Ascii.h>
5
+ #include <SSD1306AsciiWire.h>
6
+ // Text-only driver: no 1 KB screen buffer, so it fits beside other libraries on an Uno.
7
+ // setCursor(column_pixels 0..127, text_row 0..7). Inherits Print (print/println/f-strings).
8
+ class OLEDText : public Print {
9
+ public:
10
+ explicit OLEDText(uint8_t address = 0x3C): address_(address) {}
11
+ void begin() { Wire.begin(); Wire.setClock(400000L); oled_.begin(&Adafruit128x64, address_); oled_.setFont(Adafruit5x7); oled_.clear(); }
12
+ void clear() { oled_.clear(); }
13
+ void setCursor(int column, int row) { oled_.setCursor((uint8_t)column, (uint8_t)row); }
14
+ void setLarge(bool on) { if (on) oled_.set2X(); else oled_.set1X(); }
15
+ size_t write(uint8_t c) override { return oled_.write(c); }
16
+ using Print::print;
17
+ using Print::println;
18
+ private:
19
+ uint8_t address_;
20
+ SSD1306AsciiWire oled_;
21
+ };
@@ -0,0 +1,9 @@
1
+ from Barmaja_PyArduino import *
2
+ upload()
3
+
4
+ screen = OLEDText(0x3C)
5
+ screen.begin()
6
+ while True:
7
+ screen.setCursor(0, 0)
8
+ screen.print(f"Light: {analogRead(A0)} ")
9
+ delay(300)
@@ -0,0 +1,103 @@
1
+ {
2
+ "schema": 1,
3
+ "class": "OLEDText",
4
+ "title": "SSD1306 128x64 I2C OLED display, text mode (low memory)",
5
+ "status": "compile-verified",
6
+ "boards": [
7
+ "uno",
8
+ "nano"
9
+ ],
10
+ "constructor": [
11
+ {
12
+ "name": "address",
13
+ "type": "Int",
14
+ "range": [
15
+ 60,
16
+ 61
17
+ ],
18
+ "default": 60
19
+ }
20
+ ],
21
+ "methods": {
22
+ "begin": {
23
+ "params": [],
24
+ "returns": "Void",
25
+ "starts": true
26
+ },
27
+ "clear": {
28
+ "params": [],
29
+ "returns": "Void"
30
+ },
31
+ "setCursor": {
32
+ "params": [
33
+ {
34
+ "name": "column",
35
+ "type": "Int",
36
+ "range": [
37
+ 0,
38
+ 127
39
+ ]
40
+ },
41
+ {
42
+ "name": "row",
43
+ "type": "Int",
44
+ "range": [
45
+ 0,
46
+ 7
47
+ ]
48
+ }
49
+ ],
50
+ "returns": "Void"
51
+ },
52
+ "setLarge": {
53
+ "params": [
54
+ {
55
+ "name": "on",
56
+ "type": "Bool"
57
+ }
58
+ ],
59
+ "returns": "Void"
60
+ },
61
+ "print": {
62
+ "params": [
63
+ {
64
+ "name": "value",
65
+ "type": "Scalar"
66
+ }
67
+ ],
68
+ "returns": "Void"
69
+ },
70
+ "println": {
71
+ "params": [
72
+ {
73
+ "name": "value",
74
+ "type": "Scalar",
75
+ "default": 0
76
+ }
77
+ ],
78
+ "returns": "Void"
79
+ }
80
+ },
81
+ "resources": [
82
+ "i2c"
83
+ ],
84
+ "warnings": [],
85
+ "adapter": {
86
+ "library": "Barmaja_OLEDText",
87
+ "header": "Barmaja_OLEDText.h"
88
+ },
89
+ "dependencies": [
90
+ {
91
+ "id": "greiman-ssd1306ascii",
92
+ "name": "SSD1306Ascii",
93
+ "version": "1.3.5",
94
+ "header": "SSD1306AsciiWire.h",
95
+ "license": "MIT",
96
+ "source": "https://github.com/greiman/SSD1306Ascii",
97
+ "tag": "1.3.5",
98
+ "library_folder": "SSD1306Ascii"
99
+ }
100
+ ],
101
+ "liverun": false,
102
+ "example": "from Barmaja_PyArduino import *\nupload()\n\nscreen = OLEDText(0x3C)\nscreen.begin()\nwhile True:\n screen.setCursor(0, 0)\n screen.print(f\"Light: {analogRead(A0)} \")\n delay(300)\n"
103
+ }
@@ -0,0 +1,9 @@
1
+ name=Barmaja_PressureBMP280
2
+ version=1.1.0
3
+ author=BARMAJA
4
+ maintainer=BARMAJA
5
+ sentence=BARMAJA PyArduino device-pack adapter: BMP280 temperature + air-pressure + altitude sensor (I2C)
6
+ paragraph=
7
+ category=Device Control
8
+ url=
9
+ architectures=avr
@@ -0,0 +1,16 @@
1
+ #pragma once
2
+ #include <Arduino.h>
3
+ #include <Wire.h>
4
+ #include <Adafruit_BMP280.h>
5
+ // Most purple GY-BMP280 boards use address 0x76 (118); Adafruit boards use 0x77 (119).
6
+ class PressureBMP280 {
7
+ public:
8
+ explicit PressureBMP280(uint8_t address = 0x76): address_(address) {}
9
+ bool begin() { return bmp_.begin(address_); }
10
+ float readTemperature() { return bmp_.readTemperature(); }
11
+ float readPressure() { return bmp_.readPressure() / 100.0f; }
12
+ float readAltitude(float seaLevelHpa = 1013.25f) { return bmp_.readAltitude(seaLevelHpa); }
13
+ private:
14
+ uint8_t address_;
15
+ Adafruit_BMP280 bmp_;
16
+ };
@@ -0,0 +1,8 @@
1
+ from Barmaja_PyArduino import *
2
+ upload()
3
+
4
+ air = PressureBMP280(0x76)
5
+ air.begin()
6
+ while True:
7
+ print("T =", air.readTemperature(), "C P =", air.readPressure(), "hPa")
8
+ delay(1000)
@@ -0,0 +1,92 @@
1
+ {
2
+ "schema": 1,
3
+ "class": "PressureBMP280",
4
+ "title": "BMP280 temperature + air-pressure + altitude sensor (I2C)",
5
+ "status": "compile-verified",
6
+ "boards": [
7
+ "uno",
8
+ "nano"
9
+ ],
10
+ "constructor": [
11
+ {
12
+ "name": "address",
13
+ "type": "Int",
14
+ "range": [
15
+ 118,
16
+ 119
17
+ ],
18
+ "default": 118
19
+ }
20
+ ],
21
+ "methods": {
22
+ "begin": {
23
+ "params": [],
24
+ "returns": "Bool",
25
+ "starts": true
26
+ },
27
+ "readTemperature": {
28
+ "params": [],
29
+ "returns": "Float"
30
+ },
31
+ "readPressure": {
32
+ "params": [],
33
+ "returns": "Float",
34
+ "doc": "hPa"
35
+ },
36
+ "readAltitude": {
37
+ "params": [
38
+ {
39
+ "name": "sea_level_hpa",
40
+ "type": [
41
+ "Float",
42
+ "Int"
43
+ ],
44
+ "default": 1013.25
45
+ }
46
+ ],
47
+ "returns": "Float"
48
+ }
49
+ },
50
+ "resources": [
51
+ "i2c"
52
+ ],
53
+ "warnings": [],
54
+ "adapter": {
55
+ "library": "Barmaja_PressureBMP280",
56
+ "header": "Barmaja_PressureBMP280.h"
57
+ },
58
+ "dependencies": [
59
+ {
60
+ "id": "adafruit-unified-sensor",
61
+ "name": "Adafruit Unified Sensor",
62
+ "version": "1.1.15",
63
+ "header": "Adafruit_Sensor.h",
64
+ "license": "Apache-2.0",
65
+ "source": "https://github.com/adafruit/Adafruit_Sensor",
66
+ "library_folder": "Adafruit_Sensor",
67
+ "bundled": true
68
+ },
69
+ {
70
+ "id": "adafruit-busio",
71
+ "name": "Adafruit BusIO",
72
+ "version": "1.17.4",
73
+ "header": "Adafruit_I2CDevice.h",
74
+ "license": "MIT",
75
+ "source": "https://github.com/adafruit/Adafruit_BusIO",
76
+ "tag": "1.17.4",
77
+ "library_folder": "Adafruit_BusIO"
78
+ },
79
+ {
80
+ "id": "adafruit-bmp280",
81
+ "name": "Adafruit BMP280 Library",
82
+ "version": "3.0.0",
83
+ "header": "Adafruit_BMP280.h",
84
+ "license": "MIT",
85
+ "source": "https://github.com/adafruit/Adafruit_BMP280_Library",
86
+ "tag": "3.0.0",
87
+ "library_folder": "Adafruit_BMP280_Library"
88
+ }
89
+ ],
90
+ "liverun": false,
91
+ "example": "from Barmaja_PyArduino import *\nupload()\n\nair = PressureBMP280(0x76)\nair.begin()\nwhile True:\n print(\"T =\", air.readTemperature(), \"C P =\", air.readPressure(), \"hPa\")\n delay(1000)\n"
92
+ }
@@ -0,0 +1,9 @@
1
+ name=Barmaja_RotaryEncoder
2
+ version=1.1.0
3
+ author=BARMAJA
4
+ maintainer=BARMAJA
5
+ sentence=BARMAJA PyArduino device-pack adapter: Rotary encoder knob (KY-040 style) read by polling
6
+ paragraph=
7
+ category=Device Control
8
+ url=
9
+ architectures=avr
@@ -0,0 +1,18 @@
1
+ #pragma once
2
+ #include <Arduino.h>
3
+ // Call position() often (every loop) so no steps are missed. Uses INPUT_PULLUP.
4
+ class RotaryEncoder {
5
+ public:
6
+ RotaryEncoder(uint8_t clk, uint8_t dt): clk_(clk), dt_(dt) {}
7
+ long position() {
8
+ setup();
9
+ uint8_t a = digitalRead(clk_);
10
+ if (a != lastA_ && a == LOW) { if (digitalRead(dt_) != a) pos_++; else pos_--; }
11
+ lastA_ = a;
12
+ return pos_;
13
+ }
14
+ void reset() { pos_ = 0; }
15
+ private:
16
+ void setup() { if (!ready_) { pinMode(clk_, INPUT_PULLUP); pinMode(dt_, INPUT_PULLUP); lastA_ = digitalRead(clk_); ready_ = true; } }
17
+ uint8_t clk_, dt_, lastA_ = HIGH; bool ready_ = false; long pos_ = 0;
18
+ };
@@ -0,0 +1,10 @@
1
+ from Barmaja_PyArduino import *
2
+ upload()
3
+
4
+ knob = RotaryEncoder(2, 3)
5
+ last = 0
6
+ while True:
7
+ p = knob.position()
8
+ if p != last:
9
+ print("Position:", p)
10
+ last = p
@@ -0,0 +1,44 @@
1
+ {
2
+ "schema": 1,
3
+ "class": "RotaryEncoder",
4
+ "title": "Rotary encoder knob (KY-040 style) read by polling",
5
+ "status": "prototype",
6
+ "boards": [
7
+ "uno",
8
+ "nano"
9
+ ],
10
+ "constructor": [
11
+ {
12
+ "name": "clk_pin",
13
+ "type": "Int",
14
+ "rule": "digital_pin"
15
+ },
16
+ {
17
+ "name": "dt_pin",
18
+ "type": "Int",
19
+ "rule": "digital_pin"
20
+ }
21
+ ],
22
+ "methods": {
23
+ "position": {
24
+ "params": [],
25
+ "returns": "Int",
26
+ "requires_begin": false
27
+ },
28
+ "reset": {
29
+ "params": [],
30
+ "returns": "Void",
31
+ "requires_begin": false
32
+ }
33
+ },
34
+ "resources": [],
35
+ "warnings": [],
36
+ "adapter": {
37
+ "library": "Barmaja_RotaryEncoder",
38
+ "header": "Barmaja_RotaryEncoder.h"
39
+ },
40
+ "dependencies": [],
41
+ "liverun": false,
42
+ "example": "from Barmaja_PyArduino import *\nupload()\n\nknob = RotaryEncoder(2, 3)\nlast = 0\nwhile True:\n p = knob.position()\n if p != last:\n print(\"Position:\", p)\n last = p\n",
43
+ "notes": "Polling: slow loops (long delay()) will miss steps."
44
+ }
@@ -0,0 +1,9 @@
1
+ name=Barmaja_ServoDriverPCA9685
2
+ version=1.1.0
3
+ author=BARMAJA
4
+ maintainer=BARMAJA
5
+ sentence=BARMAJA PyArduino device-pack adapter: PCA9685 16-channel servo driver board (I2C)
6
+ paragraph=
7
+ category=Device Control
8
+ url=
9
+ architectures=avr
@@ -0,0 +1,15 @@
1
+ #pragma once
2
+ #include <Arduino.h>
3
+ #include <Wire.h>
4
+ #include <Adafruit_PWMServoDriver.h>
5
+ // 50 Hz servo signals; angle 0..180 -> 544..2400 us like the Arduino Servo library.
6
+ class ServoDriverPCA9685 {
7
+ public:
8
+ explicit ServoDriverPCA9685(uint8_t address = 0x40): pwm_(address) {}
9
+ void begin() { pwm_.begin(); pwm_.setOscillatorFrequency(27000000); pwm_.setPWMFreq(50); delay(10); }
10
+ void setAngle(int channel, int angle) { setPulse(channel, 544 + (long)angle * (2400 - 544) / 180); }
11
+ void setPulse(int channel, int us) { pwm_.writeMicroseconds((uint8_t)channel, (uint16_t)us); }
12
+ void off(int channel) { pwm_.setPWM((uint8_t)channel, 0, 4096); }
13
+ private:
14
+ Adafruit_PWMServoDriver pwm_;
15
+ };
@@ -0,0 +1,10 @@
1
+ from Barmaja_PyArduino import *
2
+ upload()
3
+
4
+ arm = ServoDriverPCA9685()
5
+ arm.begin()
6
+ while True:
7
+ arm.setAngle(0, 0)
8
+ delay(800)
9
+ arm.setAngle(0, 180)
10
+ delay(800)
@@ -0,0 +1,117 @@
1
+ {
2
+ "schema": 1,
3
+ "class": "ServoDriverPCA9685",
4
+ "title": "PCA9685 16-channel servo driver board (I2C)",
5
+ "status": "compile-verified",
6
+ "boards": [
7
+ "uno",
8
+ "nano"
9
+ ],
10
+ "constructor": [
11
+ {
12
+ "name": "address",
13
+ "type": "Int",
14
+ "range": [
15
+ 64,
16
+ 127
17
+ ],
18
+ "default": 64
19
+ }
20
+ ],
21
+ "methods": {
22
+ "begin": {
23
+ "params": [],
24
+ "returns": "Void",
25
+ "starts": true
26
+ },
27
+ "setAngle": {
28
+ "params": [
29
+ {
30
+ "name": "channel",
31
+ "type": "Int",
32
+ "range": [
33
+ 0,
34
+ 15
35
+ ]
36
+ },
37
+ {
38
+ "name": "angle",
39
+ "type": "Int",
40
+ "range": [
41
+ 0,
42
+ 180
43
+ ]
44
+ }
45
+ ],
46
+ "returns": "Void"
47
+ },
48
+ "setPulse": {
49
+ "params": [
50
+ {
51
+ "name": "channel",
52
+ "type": "Int",
53
+ "range": [
54
+ 0,
55
+ 15
56
+ ]
57
+ },
58
+ {
59
+ "name": "microseconds",
60
+ "type": "Int",
61
+ "range": [
62
+ 400,
63
+ 2600
64
+ ]
65
+ }
66
+ ],
67
+ "returns": "Void"
68
+ },
69
+ "off": {
70
+ "params": [
71
+ {
72
+ "name": "channel",
73
+ "type": "Int",
74
+ "range": [
75
+ 0,
76
+ 15
77
+ ]
78
+ }
79
+ ],
80
+ "returns": "Void"
81
+ }
82
+ },
83
+ "resources": [
84
+ "i2c"
85
+ ],
86
+ "warnings": [
87
+ "Power the servos from the board's V+ terminal (external 5-6 V supply), never from the Uno 5V pin."
88
+ ],
89
+ "adapter": {
90
+ "library": "Barmaja_ServoDriverPCA9685",
91
+ "header": "Barmaja_ServoDriverPCA9685.h"
92
+ },
93
+ "dependencies": [
94
+ {
95
+ "id": "adafruit-busio",
96
+ "name": "Adafruit BusIO",
97
+ "version": "1.17.4",
98
+ "header": "Adafruit_I2CDevice.h",
99
+ "license": "MIT",
100
+ "source": "https://github.com/adafruit/Adafruit_BusIO",
101
+ "tag": "1.17.4",
102
+ "library_folder": "Adafruit_BusIO"
103
+ },
104
+ {
105
+ "id": "adafruit-pwm-servo-driver",
106
+ "name": "Adafruit PWM Servo Driver Library",
107
+ "version": "3.0.3",
108
+ "header": "Adafruit_PWMServoDriver.h",
109
+ "license": "BSD-3-Clause",
110
+ "source": "https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library",
111
+ "tag": "3.0.3",
112
+ "library_folder": "Adafruit_PWM_Servo_Driver_Library"
113
+ }
114
+ ],
115
+ "liverun": false,
116
+ "example": "from Barmaja_PyArduino import *\nupload()\n\narm = ServoDriverPCA9685()\narm.begin()\nwhile True:\n arm.setAngle(0, 0)\n delay(800)\n arm.setAngle(0, 180)\n delay(800)\n"
117
+ }
@@ -0,0 +1,9 @@
1
+ name=Barmaja_ShiftRegister595
2
+ version=1.1.0
3
+ author=BARMAJA
4
+ maintainer=BARMAJA
5
+ sentence=BARMAJA PyArduino device-pack adapter: 74HC595 shift register (8 extra outputs from 3 pins)
6
+ paragraph=
7
+ category=Device Control
8
+ url=
9
+ architectures=avr
@@ -0,0 +1,14 @@
1
+ #pragma once
2
+ #include <Arduino.h>
3
+ // MSB first. setPin() remembers the other 7 outputs.
4
+ class ShiftRegister595 {
5
+ public:
6
+ ShiftRegister595(uint8_t data, uint8_t clock, uint8_t latch): data_(data), clock_(clock), latch_(latch) {}
7
+ void write(int value) { setup(); state_ = (uint8_t)value; send(); }
8
+ void setPin(int output, bool on) { setup(); if (on) state_ |= (1 << output); else state_ &= ~(1 << output); send(); }
9
+ void clear() { write(0); }
10
+ private:
11
+ void setup() { if (!ready_) { pinMode(data_, OUTPUT); pinMode(clock_, OUTPUT); pinMode(latch_, OUTPUT); ready_ = true; } }
12
+ void send() { digitalWrite(latch_, LOW); shiftOut(data_, clock_, MSBFIRST, state_); digitalWrite(latch_, HIGH); }
13
+ uint8_t data_, clock_, latch_, state_ = 0; bool ready_ = false;
14
+ };
@@ -0,0 +1,9 @@
1
+ from Barmaja_PyArduino import *
2
+ upload()
3
+
4
+ leds = ShiftRegister595(11, 12, 8)
5
+ while True:
6
+ for k in range(8):
7
+ leds.clear()
8
+ leds.setPin(k, True)
9
+ delay(150)