Skip to content

Commit e5f10d1

Browse files
authored
Merge branch 'master' into esp32_adc2gpio
2 parents 858b0ab + 9b88092 commit e5f10d1

File tree

6 files changed

+110
-56
lines changed

6 files changed

+110
-56
lines changed

cores/esp32/USB.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ bool ESPUSB::begin(){
165165
StreamString s;
166166
uint8_t m[6];
167167
esp_efuse_mac_get_default(m);
168-
s.printf("%02X:%02X:%02X:%02X:%02X:%02X", m[0], m[1], m[2], m[3], m[4], m[5]);
168+
s.printf("%02X%02X%02X%02X%02X%02X", m[0], m[1], m[2], m[3], m[4], m[5]);
169169
serial_number = s;
170170
}
171171
#endif

cores/esp32/esp32-hal-ledc.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,12 @@ void analogWrite(uint8_t pin, int value) {
222222
log_e("No more analogWrite channels available! You can have maximum %u", LEDC_CHANNELS);
223223
return;
224224
}
225+
if(ledcSetup(cnt_channel - 1, analog_frequency, analog_resolution) == 0){
226+
log_e("analogWrite setup failed (freq = %u, resolution = %u). Try setting different resolution or frequency");
227+
return;
228+
}
229+
ledcAttachPin(pin, cnt_channel - 1);
225230
pin_to_channel[pin] = cnt_channel--;
226-
ledcSetup(cnt_channel, analog_frequency, analog_resolution);
227-
ledcAttachPin(pin, cnt_channel);
228231
}
229232
ledcWrite(pin_to_channel[pin] - 1, value);
230233
}
@@ -237,7 +240,10 @@ int8_t analogGetChannel(uint8_t pin) {
237240
void analogWriteFrequency(uint32_t freq) {
238241
if (cnt_channel != LEDC_CHANNELS) {
239242
for (int channel = LEDC_CHANNELS - 1; channel >= cnt_channel; channel--) {
240-
ledcChangeFrequency(channel, freq, analog_resolution);
243+
if (ledcChangeFrequency(channel, freq, analog_resolution) == 0){
244+
log_e("analogWrite frequency cant be set due to selected resolution! Try to adjust resolution first");
245+
return;
246+
}
241247
}
242248
}
243249
analog_frequency = freq;
@@ -250,7 +256,10 @@ void analogWriteResolution(uint8_t bits) {
250256
}
251257
if (cnt_channel != LEDC_CHANNELS) {
252258
for (int channel = LEDC_CHANNELS - 1; channel >= cnt_channel; channel--) {
253-
ledcChangeFrequency(channel, analog_frequency, bits);
259+
if (ledcChangeFrequency(channel, analog_frequency, bits) == 0){
260+
log_e("analogWrite resolution cant be set due to selected frequency! Try to adjust frequency first");
261+
return;
262+
}
254263
}
255264
}
256265
analog_resolution = bits;

docs/source/api/ledc.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,28 @@ It is compatible with Arduinos analogWrite function.
169169
* ``value`` select the duty cycle of pwm.
170170
* range is from 0 (always off) to 255 (always on).
171171

172+
analogWriteResolution
173+
*********************
174+
175+
This function is used to set resolution for all analogWrite channels.
176+
177+
.. code-block:: arduino
178+
179+
void analogWriteResolution(uint8_t bits);
180+
181+
* ``bits`` select resolution for analog channels.
182+
183+
analogWriteFrequency
184+
********************
185+
186+
This function is used to set frequency for all analogWrite channels.
187+
188+
.. code-block:: arduino
189+
190+
void analogWriteFrequency(uint32_t freq);
191+
192+
* ``freq`` select frequency of pwm.
193+
172194
Example Applications
173195
********************
174196

libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
// Select camera model
1515
// ===================
1616
//#define CAMERA_MODEL_WROVER_KIT // Has PSRAM
17-
//#define CAMERA_MODEL_ESP_EYE // Has PSRAM
17+
#define CAMERA_MODEL_ESP_EYE // Has PSRAM
1818
//#define CAMERA_MODEL_ESP32S3_EYE // Has PSRAM
1919
//#define CAMERA_MODEL_M5STACK_PSRAM // Has PSRAM
2020
//#define CAMERA_MODEL_M5STACK_V2_PSRAM // M5Camera version B Has PSRAM
2121
//#define CAMERA_MODEL_M5STACK_WIDE // Has PSRAM
2222
//#define CAMERA_MODEL_M5STACK_ESP32CAM // No PSRAM
2323
//#define CAMERA_MODEL_M5STACK_UNITCAM // No PSRAM
24-
#define CAMERA_MODEL_AI_THINKER // Has PSRAM
24+
//#define CAMERA_MODEL_AI_THINKER // Has PSRAM
2525
//#define CAMERA_MODEL_TTGO_T_JOURNAL // No PSRAM
2626
// ** Espressif Internal Boards **
2727
//#define CAMERA_MODEL_ESP32_CAM_BOARD
@@ -37,6 +37,7 @@ const char* ssid = "**********";
3737
const char* password = "**********";
3838

3939
void startCameraServer();
40+
void setupLedFlash(int pin);
4041

4142
void setup() {
4243
Serial.begin(115200);
@@ -124,6 +125,11 @@ void setup() {
124125
s->set_vflip(s, 1);
125126
#endif
126127

128+
// Setup LED FLash if LED pin is defined in camera_pins.h
129+
#if defined(LED_GPIO_NUM)
130+
setupLedFlash(LED_GPIO_NUM);
131+
#endif
132+
127133
WiFi.begin(ssid, password);
128134
WiFi.setSleep(false);
129135

0 commit comments

Comments
 (0)