163 lines
4.5 KiB
C++
163 lines
4.5 KiB
C++
/**
|
|
* @file test_cv_output.cpp
|
|
* @brief Exemple de test pour les sorties CV/GATE du STM32F3
|
|
* @part of Apple-ADB-Ressurector
|
|
*
|
|
* Ce fichier fournit des exemples d'utilisation des sorties CV/GATE.
|
|
* Copiez ces fonctions dans votre main.cpp pour tester.
|
|
*
|
|
* @date 2025
|
|
* @author Clément SAILLANT
|
|
* @license GNU GPL v3
|
|
*/
|
|
|
|
// Exemple d'utilisation des fonctions CV/GATE
|
|
// À inclure dans votre main.cpp pour tester
|
|
|
|
#ifdef ARDUINO_ARCH_STM32
|
|
|
|
/**
|
|
* @brief Test simple des sorties CV
|
|
* Génère un sweep sur CV1 et CV2
|
|
*/
|
|
void test_cv_sweep() {
|
|
Serial.println("Test CV Sweep - Démarrage");
|
|
|
|
// Reset au centre
|
|
hid_mouse_reset_cv_values();
|
|
delay(1000);
|
|
|
|
// Sweep CV1 de 0 à max
|
|
for (int i = 0; i < 20; i++) {
|
|
// Simule un mouvement vers la droite
|
|
hid_mouse_send_report(false, 10, 0);
|
|
delay(100);
|
|
}
|
|
|
|
delay(500);
|
|
|
|
// Sweep CV2 de 0 à max
|
|
for (int i = 0; i < 20; i++) {
|
|
// Simule un mouvement vers le haut
|
|
hid_mouse_send_report(false, 0, 10);
|
|
delay(100);
|
|
}
|
|
|
|
delay(500);
|
|
|
|
// Test du signal GATE
|
|
Serial.println("Test GATE - 5 impulsions");
|
|
for (int i = 0; i < 5; i++) {
|
|
hid_mouse_send_report(true, 0, 0); // GATE ON
|
|
delay(200);
|
|
hid_mouse_send_report(false, 0, 0); // GATE OFF
|
|
delay(200);
|
|
}
|
|
|
|
// Retour au centre
|
|
hid_mouse_reset_cv_values();
|
|
|
|
Serial.println("Test CV Sweep - Terminé");
|
|
}
|
|
|
|
/**
|
|
* @brief Test interactif via Serial
|
|
* Tapez des commandes pour contrôler les CV
|
|
*/
|
|
void test_cv_interactive() {
|
|
if (Serial.available()) {
|
|
String command = Serial.readStringUntil('\n');
|
|
command.trim();
|
|
|
|
if (command == "reset") {
|
|
hid_mouse_reset_cv_values();
|
|
Serial.println("CV Reset");
|
|
}
|
|
else if (command == "up") {
|
|
hid_mouse_send_report(false, 0, 5);
|
|
Serial.println("CV2 +");
|
|
}
|
|
else if (command == "down") {
|
|
hid_mouse_send_report(false, 0, -5);
|
|
Serial.println("CV2 -");
|
|
}
|
|
else if (command == "left") {
|
|
hid_mouse_send_report(false, -5, 0);
|
|
Serial.println("CV1 -");
|
|
}
|
|
else if (command == "right") {
|
|
hid_mouse_send_report(false, 5, 0);
|
|
Serial.println("CV1 +");
|
|
}
|
|
else if (command == "gate") {
|
|
hid_mouse_send_report(true, 0, 0);
|
|
delay(100);
|
|
hid_mouse_send_report(false, 0, 0);
|
|
Serial.println("GATE pulse");
|
|
}
|
|
else if (command == "status") {
|
|
uint16_t cv1 = hid_mouse_get_cv1_value();
|
|
uint16_t cv2 = hid_mouse_get_cv2_value();
|
|
float v1 = (float)(cv1 * 3.3 / 4095.0);
|
|
float v2 = (float)(cv2 * 3.3 / 4095.0);
|
|
|
|
Serial.print("CV1: ");
|
|
Serial.print(cv1);
|
|
Serial.print(" (");
|
|
Serial.print(v1, 2);
|
|
Serial.print("V), CV2: ");
|
|
Serial.print(cv2);
|
|
Serial.print(" (");
|
|
Serial.print(v2, 2);
|
|
Serial.println("V)");
|
|
}
|
|
else if (command == "help") {
|
|
Serial.println("Commandes disponibles:");
|
|
Serial.println(" reset - Remet CV au centre");
|
|
Serial.println(" up - CV2 +");
|
|
Serial.println(" down - CV2 -");
|
|
Serial.println(" left - CV1 -");
|
|
Serial.println(" right - CV1 +");
|
|
Serial.println(" gate - Impulsion GATE");
|
|
Serial.println(" status - Affiche valeurs CV");
|
|
Serial.println(" help - Cette aide");
|
|
}
|
|
else {
|
|
Serial.println("Commande inconnue. Tapez 'help' pour l'aide.");
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @brief Exemple d'intégration dans setup()
|
|
*/
|
|
void setup_cv_test() {
|
|
Serial.begin(115200);
|
|
|
|
// Initialisation de la souris HID (qui inclut le DAC CV)
|
|
hid_mouse_init();
|
|
|
|
Serial.println("=== Test CV/GATE pour STM32F3 ===");
|
|
Serial.println("Connexions:");
|
|
Serial.println(" CV1 (X) -> PA4");
|
|
Serial.println(" CV2 (Y) -> PA5");
|
|
Serial.println(" GATE -> PA0");
|
|
Serial.println("Tapez 'help' pour les commandes");
|
|
|
|
// Test automatique au démarrage (optionnel)
|
|
// test_cv_sweep();
|
|
}
|
|
|
|
/**
|
|
* @brief Exemple d'intégration dans loop()
|
|
*/
|
|
void loop_cv_test() {
|
|
// Test interactif
|
|
test_cv_interactive();
|
|
|
|
// Autres tâches de votre programme...
|
|
delay(10);
|
|
}
|
|
|
|
#endif // ARDUINO_ARCH_STM32
|