Add boot-time layout test (no serial input needed)
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
#include "app_task.h"
|
#include "app_task.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
|
||||||
AppTask::AppTask(LedStub* led, SwitchStub* sw, UsbMidiTransport* midi)
|
AppTask::AppTask(LedStub* led, SwitchStub* sw, UsbMidiTransport* midi)
|
||||||
: led_driver(led), switch_driver(sw), midi_transport(midi) {
|
: led_driver(led), switch_driver(sw), midi_transport(midi) {
|
||||||
@@ -23,9 +25,82 @@ void AppTask::begin() {
|
|||||||
process_midi_event(event);
|
process_midi_event(event);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Auto-run layout test on boot (no serial needed)
|
||||||
|
run_layout_test();
|
||||||
|
|
||||||
Serial.println("[APP] Controller ready");
|
Serial.println("[APP] Controller ready");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppTask::run_layout_test() {
|
||||||
|
Serial.println("[APP] Running layout identification test...");
|
||||||
|
|
||||||
|
// Test 1: Launchpad X (notes 36-45, ch1)
|
||||||
|
Serial.println("[APP] Layout 1: Launchpad X (notes 36-45, ch1)");
|
||||||
|
for (uint8_t i = 0; i < NUM_PADS; i++) {
|
||||||
|
MidiEvent event;
|
||||||
|
event.type = MidiEvent::NOTE_ON;
|
||||||
|
event.channel = 1;
|
||||||
|
event.data1 = 36 + i;
|
||||||
|
event.data2 = 64;
|
||||||
|
process_midi_event(event);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1500));
|
||||||
|
event.type = MidiEvent::NOTE_OFF;
|
||||||
|
event.data2 = 0;
|
||||||
|
process_midi_event(event);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(300));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test 2: Launchpad Mini (notes 0-9, ch1)
|
||||||
|
Serial.println("[APP] Layout 2: Launchpad Mini (notes 0-9, ch1)");
|
||||||
|
for (uint8_t i = 0; i < NUM_PADS; i++) {
|
||||||
|
MidiEvent event;
|
||||||
|
event.type = MidiEvent::NOTE_ON;
|
||||||
|
event.channel = 1;
|
||||||
|
event.data1 = i;
|
||||||
|
event.data2 = 64;
|
||||||
|
process_midi_event(event);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1500));
|
||||||
|
event.type = MidiEvent::NOTE_OFF;
|
||||||
|
event.data2 = 0;
|
||||||
|
process_midi_event(event);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(300));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test 3: Channel 2 (notes 36-45)
|
||||||
|
Serial.println("[APP] Layout 3: Channel 2 flashing (notes 36-45, ch2)");
|
||||||
|
for (uint8_t i = 0; i < NUM_PADS; i++) {
|
||||||
|
MidiEvent event;
|
||||||
|
event.type = MidiEvent::NOTE_ON;
|
||||||
|
event.channel = 2;
|
||||||
|
event.data1 = 36 + i;
|
||||||
|
event.data2 = 64;
|
||||||
|
process_midi_event(event);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1500));
|
||||||
|
event.type = MidiEvent::NOTE_OFF;
|
||||||
|
event.data2 = 0;
|
||||||
|
process_midi_event(event);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(300));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test 4: Channel 3 (notes 36-45)
|
||||||
|
Serial.println("[APP] Layout 4: Channel 3 pulsing (notes 36-45, ch3)");
|
||||||
|
for (uint8_t i = 0; i < NUM_PADS; i++) {
|
||||||
|
MidiEvent event;
|
||||||
|
event.type = MidiEvent::NOTE_ON;
|
||||||
|
event.channel = 3;
|
||||||
|
event.data1 = 36 + i;
|
||||||
|
event.data2 = 64;
|
||||||
|
process_midi_event(event);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1500));
|
||||||
|
event.type = MidiEvent::NOTE_OFF;
|
||||||
|
event.data2 = 0;
|
||||||
|
process_midi_event(event);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(300));
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.println("[APP] Layout test complete - observe which lit your pads");
|
||||||
|
}
|
||||||
|
|
||||||
void AppTask::update() {
|
void AppTask::update() {
|
||||||
for (uint8_t i = 0; i < NUM_PADS; i++) {
|
for (uint8_t i = 0; i < NUM_PADS; i++) {
|
||||||
bool is_pressed = switch_driver->is_pressed(i);
|
bool is_pressed = switch_driver->is_pressed(i);
|
||||||
|
|||||||
Reference in New Issue
Block a user