espzero 0.0.1__tar.gz → 0.0.3__tar.gz

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.
@@ -1,9 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: espzero
3
- Version: 0.0.1
3
+ Version: 0.0.3
4
4
  Summary: Educational tool for physical computing and ESP32/ESP8266 development.
5
5
  Author-email: Neo Neopia-uz <neopia.uz@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/roboticsware/espzero
7
+ Project-URL: Documentation, https://espzero.readthedocs.io
7
8
  Project-URL: Bug Tracker, https://github.com/roboticsware/espzero/issues
8
9
  Classifier: Programming Language :: Python :: 3
9
10
  Classifier: License :: OSI Approved :: MIT License
@@ -13,6 +14,10 @@ Description-Content-Type: text/markdown
13
14
 
14
15
  # espzero
15
16
 
17
+ [![PyPI version](https://badge.fury.io/py/espzero.svg)](https://badge.fury.io/py/espzero)
18
+ [![Documentation Status](https://readthedocs.org/projects/espzero/badge/?version=latest)](https://espzero.readthedocs.io/)
19
+ [![License](https://img.shields.io/github/license/roboticsware/espzero)](https://github.com/roboticsware/espzero/blob/main/LICENSE)
20
+
16
21
  > A single MicroPython library that ports [picozero](https://github.com/raspberrypilearning/picozero) to the ESP32 family (WROOM, S3, C3, and more).
17
22
  > **"One codebase, many boards"** — hardware differences are absorbed by the Board Profile system.
18
23
 
@@ -20,10 +25,20 @@ Description-Content-Type: text/markdown
20
25
 
21
26
  ## Installation
22
27
 
23
- Copy the `espzero/` directory to the root of your ESP32 filesystem using Mu Editor, Thonny, or `mpremote`:
28
+ ### For your ESP32 board (Recommended)
29
+ Use `mpremote` to install directly from PyPI to your board:
24
30
 
31
+ ```bash
32
+ mpremote mip install espzero
25
33
  ```
26
- mpremote cp -r espzero/ :espzero/
34
+
35
+ Or manually copy the `espzero/` directory to your board's root.
36
+
37
+ ### For your PC (Development)
38
+ To get autocomplete and linting in your IDE:
39
+
40
+ ```bash
41
+ pip install espzero
27
42
  ```
28
43
 
29
44
  ---
@@ -1,5 +1,9 @@
1
1
  # espzero
2
2
 
3
+ [![PyPI version](https://badge.fury.io/py/espzero.svg)](https://badge.fury.io/py/espzero)
4
+ [![Documentation Status](https://readthedocs.org/projects/espzero/badge/?version=latest)](https://espzero.readthedocs.io/)
5
+ [![License](https://img.shields.io/github/license/roboticsware/espzero)](https://github.com/roboticsware/espzero/blob/main/LICENSE)
6
+
3
7
  > A single MicroPython library that ports [picozero](https://github.com/raspberrypilearning/picozero) to the ESP32 family (WROOM, S3, C3, and more).
4
8
  > **"One codebase, many boards"** — hardware differences are absorbed by the Board Profile system.
5
9
 
@@ -7,10 +11,20 @@
7
11
 
8
12
  ## Installation
9
13
 
10
- Copy the `espzero/` directory to the root of your ESP32 filesystem using Mu Editor, Thonny, or `mpremote`:
14
+ ### For your ESP32 board (Recommended)
15
+ Use `mpremote` to install directly from PyPI to your board:
11
16
 
17
+ ```bash
18
+ mpremote mip install espzero
12
19
  ```
13
- mpremote cp -r espzero/ :espzero/
20
+
21
+ Or manually copy the `espzero/` directory to your board's root.
22
+
23
+ ### For your PC (Development)
24
+ To get autocomplete and linting in your IDE:
25
+
26
+ ```bash
27
+ pip install espzero
14
28
  ```
15
29
 
16
30
  ---
@@ -0,0 +1,153 @@
1
+ # This file is part of espzero, automatically synced from
2
+ # https://github.com/roboticsware/espzero at revision 24cae2bc1c028458052675181e95f2a08fdf7481.
3
+ # Do not edit this file directly — run update_user_libs.py espzero instead.
4
+
5
+ """
6
+ espzero/__init__.py
7
+ Public entry point for the espzero library — an ESP32 port of picozero.
8
+
9
+ Quick start::
10
+
11
+ import espzero
12
+ espzero.begin() # initialise board (auto-detect)
13
+
14
+ from espzero import esp_led # built-in LED, ready after begin()
15
+ from time import sleep
16
+
17
+ while True:
18
+ esp_led.on()
19
+ sleep(1)
20
+ esp_led.off()
21
+ sleep(1)
22
+
23
+ Specify a board explicitly::
24
+
25
+ espzero.begin("esp32_devkit_v1") # override auto-detection
26
+
27
+ Import other components after begin()::
28
+
29
+ from espzero import LED, Button, Servo, WiFi
30
+
31
+ The board profile system abstracts hardware differences (pin aliases,
32
+ ADC attenuation, strapping pins, NeoPixel vs GPIO LEDs, etc.) so that
33
+ user code remains identical across supported boards.
34
+ """
35
+
36
+ from . import _hal
37
+
38
+ # ── Board → profile class mapping ─────────────────────────────
39
+ # Key : user-facing board name (passed to begin())
40
+ # Value : (module_name, class_name) for lazy import
41
+ _PROFILE_MAP = {
42
+ "esp32_devkit_v1": ("profiles.esp32_boards", "ESP32DevKitV1"),
43
+ "esp32_s3_devkit": ("profiles.esp32_boards", "ESP32S3DevKit"),
44
+ "esp32_c3_mini": ("profiles.esp32_boards", "ESP32C3Mini"),
45
+ "m5stack_atom": ("profiles.esp32_boards", "M5StackAtom"),
46
+ "wemos_d1_mini32": ("profiles.esp32_boards", "WemosD1Mini32"),
47
+ "esp8266_lolin_v3": ("profiles.esp32_boards", "ESP8266LolinV3"),
48
+ "esp32_38pin_nodemcu":("profiles.esp32_boards", "ESP32_38Pin_NodeMCU"),
49
+ }
50
+
51
+ # ── Internal state for convenience objects ─────────────────────
52
+ _esp_led = None # Built-in LED (DigitalLED or NeoPixelLED)
53
+ _esp_temp_sensor = None # Built-in temperature sensor
54
+
55
+ # Module-level __getattr__ (MicroPython 1.18+) for lazy loading.
56
+ # This prevents NoneType errors if user imports before calling begin().
57
+ def __getattr__(name):
58
+ if name == "esp_led":
59
+ if _esp_led is None:
60
+ raise RuntimeError(
61
+ "[espzero] ERROR: 'esp_led' is not initialized. "
62
+ "You must call espzero.begin() first."
63
+ )
64
+ return _esp_led
65
+ if name == "esp_temp_sensor":
66
+ if _esp_temp_sensor is None:
67
+ raise RuntimeError(
68
+ "[espzero] ERROR: 'esp_temp_sensor' is not initialized. "
69
+ "You must call espzero.begin() first."
70
+ )
71
+ return _esp_temp_sensor
72
+ raise AttributeError("module 'espzero' has no attribute '{}'".format(name))
73
+
74
+
75
+ def begin(board="auto"):
76
+ """
77
+ Initialise the board profile. Must be called before any espzero class.
78
+
79
+ :param board:
80
+ - ``"auto"`` – detect from ``sys.implementation._machine``
81
+ - A board name string – e.g. ``"esp32_devkit_v1"``
82
+ - A ``BoardProfile`` instance – for custom boards
83
+
84
+ Raises ``ValueError`` for unknown board name strings.
85
+ """
86
+ global _esp_led, _esp_temp_sensor
87
+
88
+ from .profiles._base import BoardProfile
89
+
90
+ if isinstance(board, BoardProfile):
91
+ _hal._profile = board
92
+
93
+ elif board == "auto":
94
+ from .profiles.auto import detect
95
+ begin(detect())
96
+ return
97
+
98
+ else:
99
+ if board not in _PROFILE_MAP:
100
+ raise ValueError(
101
+ "[espzero] Unknown board: '{}'. "
102
+ "Available boards: {}".format(board, list(_PROFILE_MAP.keys()))
103
+ )
104
+ mod_name, cls_name = _PROFILE_MAP[board]
105
+ # Dynamically import the profile module within the package
106
+ full_mod_name = __name__ + "." + mod_name
107
+ mod = __import__(full_mod_name, None, None, [cls_name])
108
+ _hal._profile = getattr(mod, cls_name)()
109
+
110
+ print("[espzero] Board: {} ({})".format(
111
+ _hal._profile.NAME, _hal._profile.CHIP))
112
+
113
+ # Initialise built-in LED — branch on LED type declared in the profile
114
+ from ._core import NeoPixelLED, LED as _LED
115
+ try:
116
+ p = _hal._profile
117
+ if p.INTERNAL_LED_TYPE == "neopixel":
118
+ _esp_led = NeoPixelLED(p.resolve_pin("internal"))
119
+ else:
120
+ _esp_led = _LED("internal",
121
+ pwm=False,
122
+ active_high=p.INTERNAL_LED_ACTIVE_HIGH)
123
+ except Exception as e:
124
+ print("[espzero] LED Init Error:", e)
125
+ _esp_led = None
126
+
127
+ # Initialise built-in temperature sensor
128
+ try:
129
+ from ._core import ESPTemperatureSensor
130
+ _esp_temp_sensor = ESPTemperatureSensor()
131
+ except Exception as e:
132
+ print("[espzero] TempSensor Init Error:", e)
133
+ _esp_temp_sensor = None
134
+
135
+
136
+ # ── Re-export public API ───────────────────────────────────────
137
+ from ._core import (
138
+ LED, DigitalLED, PWMLED, NeoPixelLED,
139
+ Buzzer, PWMBuzzer, Speaker,
140
+ RGBLED,
141
+ Servo,
142
+ Motor, Robot, Rover, Stepper,
143
+ Button, Switch, MotionSensor, TouchSensor,
144
+ Potentiometer, Pot,
145
+ TemperatureSensor, TempSensor, Thermistor,
146
+ DistanceSensor,
147
+ ESPTemperatureSensor,
148
+ DigitalOutputDevice, PWMOutputDevice,
149
+ DigitalInputDevice, AnalogInputDevice,
150
+ I2cLcd, GpioLcd,
151
+ )
152
+ from ._wifi import WiFi
153
+ from ._touch import CapTouch