Skip to content

Commit 6cc41fc

Browse files
authored
Merge branch 'espressif:master' into main
2 parents c16f376 + 7ecde87 commit 6cc41fc

27 files changed

+578
-10
lines changed

.github/workflows/boards.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ jobs:
4545
- name: Checkout repository
4646
uses: actions/checkout@v3
4747

48+
- name: Check if build.board is uppercase
49+
run: |
50+
board_name=$(echo ${{ matrix.fqbn }} | awk -F':' '{print $NF}')
51+
if grep -q "^$board_name.build.board=[A-Z0-9_]*$" boards.txt; then
52+
echo "$board_name.build.board is valid.";
53+
else
54+
echo "Error: $board_name.build.board is not uppercase!";
55+
exit 1;
56+
fi
57+
4858
- name: Compile sketch
4959
uses: P-R-O-C-H-Y/compile-sketches@main
5060
with:

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ set(LIBRARY_SRCS
9797
libraries/Update/src/Updater.cpp
9898
libraries/Update/src/HttpsOTAUpdate.cpp
9999
libraries/USB/src/USBHID.cpp
100+
libraries/USB/src/USBMIDI.cpp
100101
libraries/USB/src/USBHIDMouse.cpp
101102
libraries/USB/src/USBHIDKeyboard.cpp
102103
libraries/USB/src/USBHIDGamepad.cpp

boards.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,8 @@ esp32c6.menu.PartitionScheme.custom.upload.maximum_size=16777216
430430

431431
esp32c6.menu.CPUFreq.160=160MHz (WiFi)
432432
esp32c6.menu.CPUFreq.160.build.f_cpu=160000000L
433+
esp32c6.menu.CPUFreq.120=120MHz (WiFi)
434+
esp32c6.menu.CPUFreq.120.build.f_cpu=120000000L
433435
esp32c6.menu.CPUFreq.80=80MHz (WiFi)
434436
esp32c6.menu.CPUFreq.80.build.f_cpu=80000000L
435437
esp32c6.menu.CPUFreq.40=40MHz
@@ -17110,7 +17112,7 @@ heltec_wifi_kit_32.build.target=esp32
1711017112
heltec_wifi_kit_32.build.mcu=esp32
1711117113
heltec_wifi_kit_32.build.core=esp32
1711217114
heltec_wifi_kit_32.build.variant=heltec_wifi_kit_32
17113-
heltec_wifi_kit_32.build.board=heltec_wifi_kit_32
17115+
heltec_wifi_kit_32.build.board=HELTEC_WIFI_KIT_32
1711417116

1711517117
heltec_wifi_kit_32.build.f_cpu=240000000L
1711617118
heltec_wifi_kit_32.build.flash_size=4MB
@@ -17199,7 +17201,7 @@ heltec_wifi_kit_32_V3.build.target=esp32s3
1719917201
heltec_wifi_kit_32_V3.build.mcu=esp32s3
1720017202
heltec_wifi_kit_32_V3.build.core=esp32
1720117203
heltec_wifi_kit_32_V3.build.variant=heltec_wifi_kit_32_V3
17202-
heltec_wifi_kit_32_V3.build.board=heltec_wifi_kit_32_V3
17204+
heltec_wifi_kit_32_V3.build.board=HELTEC_WIFI_KIT_32_V3
1720317205

1720417206
heltec_wifi_kit_32_V3.build.usb_mode=1
1720517207
heltec_wifi_kit_32_V3.build.cdc_on_boot=0
@@ -17298,7 +17300,7 @@ heltec_wifi_lora_32.build.target=esp32
1729817300
heltec_wifi_lora_32.build.mcu=esp32
1729917301
heltec_wifi_lora_32.build.core=esp32
1730017302
heltec_wifi_lora_32.build.variant=heltec_wifi_lora_32
17301-
heltec_wifi_lora_32.build.board=heltec_wifi_lora_32
17303+
heltec_wifi_lora_32.build.board=HELTEC_WIFI_LORA_32
1730217304

1730317305
heltec_wifi_lora_32.build.f_cpu=240000000L
1730417306
heltec_wifi_lora_32.build.flash_size=4MB
@@ -17435,7 +17437,7 @@ heltec_wifi_lora_32_V2.build.target=esp32
1743517437
heltec_wifi_lora_32_V2.build.mcu=esp32
1743617438
heltec_wifi_lora_32_V2.build.core=esp32
1743717439
heltec_wifi_lora_32_V2.build.variant=heltec_wifi_lora_32_V2
17438-
heltec_wifi_lora_32_V2.build.board=heltec_wifi_lora_32_V2
17440+
heltec_wifi_lora_32_V2.build.board=HELTEC_WIFI_LORA_32_V2
1743917441

1744017442
heltec_wifi_lora_32_V2.build.f_cpu=240000000L
1744117443
heltec_wifi_lora_32_V2.build.flash_size=8MB
@@ -17551,7 +17553,7 @@ heltec_wifi_lora_32_V3.build.target=esp32s3
1755117553
heltec_wifi_lora_32_V3.build.mcu=esp32s3
1755217554
heltec_wifi_lora_32_V3.build.core=esp32
1755317555
heltec_wifi_lora_32_V3.build.variant=heltec_wifi_lora_32_V3
17554-
heltec_wifi_lora_32_V3.build.board=heltec_wifi_32_lora_V3
17556+
heltec_wifi_lora_32_V3.build.board=HELTEC_WIFI_LORA_32_V3
1755517557

1755617558
heltec_wifi_lora_32_V3.build.usb_mode=1
1755717559
heltec_wifi_lora_32_V3.build.cdc_on_boot=0
@@ -17693,7 +17695,7 @@ heltec_wireless_stick.build.target=esp32
1769317695
heltec_wireless_stick.build.mcu=esp32
1769417696
heltec_wireless_stick.build.core=esp32
1769517697
heltec_wireless_stick.build.variant=heltec_wireless_stick
17696-
heltec_wireless_stick.build.board=heltec_wireless_stick
17698+
heltec_wireless_stick.build.board=HELTEC_WIRELESS_STICK
1769717699

1769817700
heltec_wireless_stick.build.f_cpu=240000000L
1769917701
heltec_wireless_stick.build.flash_size=8MB
@@ -17806,7 +17808,7 @@ heltec_wireless_stick_lite.build.target=esp32
1780617808
heltec_wireless_stick_lite.build.mcu=esp32
1780717809
heltec_wireless_stick_lite.build.core=esp32
1780817810
heltec_wireless_stick_lite.build.variant=heltec_wireless_stick_lite
17809-
heltec_wireless_stick_lite.build.board=heltec_wireless_stick_LITE
17811+
heltec_wireless_stick_lite.build.board=HELTEC_WIRELESS_STICK_LITE
1781017812

1781117813
heltec_wireless_stick_lite.build.f_cpu=240000000L
1781217814
heltec_wireless_stick_lite.build.flash_size=4MB

cores/esp32/esp32-hal-cpu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,11 @@ bool setCpuFrequencyMhz(uint32_t cpu_freq_mhz){
188188
}
189189
#endif
190190
#ifndef CONFIG_IDF_TARGET_ESP32H2
191-
if(cpu_freq_mhz > xtal && cpu_freq_mhz != 240 && cpu_freq_mhz != 160 && cpu_freq_mhz != 80){
191+
if(cpu_freq_mhz > xtal && cpu_freq_mhz != 240 && cpu_freq_mhz != 160 && cpu_freq_mhz != 120 && cpu_freq_mhz != 80){
192192
if(xtal >= RTC_XTAL_FREQ_40M){
193-
log_e("Bad frequency: %u MHz! Options are: 240, 160, 80, %u, %u and %u MHz", cpu_freq_mhz, xtal, xtal/2, xtal/4);
193+
log_e("Bad frequency: %u MHz! Options are: 240, 160, 120, 80, %u, %u and %u MHz", cpu_freq_mhz, xtal, xtal/2, xtal/4);
194194
} else {
195-
log_e("Bad frequency: %u MHz! Options are: 240, 160, 80, %u and %u MHz", cpu_freq_mhz, xtal, xtal/2);
195+
log_e("Bad frequency: %u MHz! Options are: 240, 160, 120, 80, %u and %u MHz", cpu_freq_mhz, xtal, xtal/2);
196196
}
197197
return false;
198198
}

libraries/USB/examples/MIDI/MidiController/.skip.esp32

Whitespace-only changes.

libraries/USB/examples/MIDI/MidiController/.skip.esp32c3

Whitespace-only changes.

libraries/USB/examples/MIDI/MidiController/.skip.esp32c6

Whitespace-only changes.

libraries/USB/examples/MIDI/MidiController/.skip.esp32h2

Whitespace-only changes.
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
This is an example of a Simple MIDI Controller using an ESP32 with a native USB support stack (S2, S3,
3+
etc.).
4+
5+
For a hookup guide and more information on reading the ADC, please see:
6+
https://randomnerdtutorials.com/esp32-adc-analog-read-arduino-ide/ (Note: This sketch uses GPIO05)
7+
8+
For best results, it is recommended to add an extra offset resistor between VCC and the potentiometer.
9+
(For a standard 10kOhm potentiometer, 3kOhm - 4kOhm will do.)
10+
11+
View this sketch in action on YouTube: https://youtu.be/Y9TLXs_3w1M
12+
*/
13+
#if ARDUINO_USB_MODE
14+
#warning This sketch should be used when USB is in OTG mode
15+
void setup() {}
16+
void loop() {}
17+
#else
18+
19+
#include <math.h>
20+
21+
#include "USB.h"
22+
#include "USBMIDI.h"
23+
USBMIDI MIDI;
24+
25+
#define MIDI_NOTE_C4 64
26+
27+
#define MIDI_CC_CUTOFF 74
28+
29+
///// ADC & Controller Input Handling /////
30+
31+
#define CONTROLLER_PIN 5
32+
33+
// ESP32 ADC needs a ton of smoothing
34+
#define SMOOTHING_VALUE 1000
35+
static double controllerInputValue = 0;
36+
37+
void updateControllerInputValue() {
38+
controllerInputValue =
39+
(controllerInputValue * (SMOOTHING_VALUE - 1) + analogRead(CONTROLLER_PIN)) / SMOOTHING_VALUE;
40+
}
41+
42+
void primeControllerInputValue() {
43+
for (int i = 0; i < SMOOTHING_VALUE; i++) {
44+
updateControllerInputValue();
45+
}
46+
}
47+
48+
uint16_t readControllerValue() {
49+
// Lower ADC input amplitude to get a stable value
50+
return round(controllerInputValue / 12);
51+
}
52+
53+
///// Button Handling /////
54+
55+
#define BUTTON_PIN 0
56+
57+
// Simple button state transition function with debounce
58+
// (See also: https://tinyurl.com/simple-debounce)
59+
#define PRESSED 0xff00
60+
#define RELEASED 0xfe1f
61+
uint16_t getButtonEvent() {
62+
static uint16_t state = 0;
63+
state = (state << 1) | digitalRead(BUTTON_PIN) | 0xfe00;
64+
return state;
65+
}
66+
67+
///// Arduino Hooks /////
68+
69+
void setup() {
70+
Serial.begin(115200);
71+
MIDI.begin();
72+
USB.begin();
73+
74+
primeControllerInputValue();
75+
}
76+
77+
void loop() {
78+
uint16_t newControllerValue = readControllerValue();
79+
static uint16_t lastControllerValue = 0;
80+
81+
// Auto-calibrate the controller range
82+
static uint16_t maxControllerValue = 0;
83+
static uint16_t minControllerValue = 0xFFFF;
84+
85+
if (newControllerValue < minControllerValue) {
86+
minControllerValue = newControllerValue;
87+
}
88+
if (newControllerValue > maxControllerValue) {
89+
maxControllerValue = newControllerValue;
90+
}
91+
92+
// Send update if the controller value has changed
93+
if (lastControllerValue != newControllerValue) {
94+
lastControllerValue = newControllerValue;
95+
96+
// Can't map if the range is zero
97+
if (minControllerValue != maxControllerValue) {
98+
MIDI.controlChange(MIDI_CC_CUTOFF,
99+
map(newControllerValue, minControllerValue, maxControllerValue, 0, 127));
100+
}
101+
}
102+
103+
updateControllerInputValue();
104+
105+
// Hook Button0 to a MIDI note so that we can observe
106+
// the CC effect without the need for a MIDI keyboard.
107+
switch (getButtonEvent()) {
108+
case PRESSED:
109+
MIDI.noteOn(MIDI_NOTE_C4, 64);
110+
break;
111+
case RELEASED:
112+
MIDI.noteOff(MIDI_NOTE_C4, 0);
113+
break;
114+
default:
115+
break;
116+
}
117+
}
118+
#endif /* ARDUINO_USB_MODE */

libraries/USB/examples/MIDI/MidiInterface/.skip.esp32

Whitespace-only changes.

0 commit comments

Comments
 (0)