2022-10-24 15:57:52 +02:00
|
|
|
#include <DMXSerial.h>
|
|
|
|
|
|
|
|
|
|
String chaine = "";
|
|
|
|
|
|
|
|
|
|
//Traite la commande entrante
|
|
|
|
|
void traiterCommande(){
|
|
|
|
|
//Récupération version
|
|
|
|
|
if(chaine == "VERSION") Serial.println("DMXBOX V1.0.0");
|
|
|
|
|
//Affectation canal
|
|
|
|
|
else if(chaine.length() == 6) setCanal(chaine.substring(0,3).toInt(), chaine.substring(3,6).toInt());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Modifie un canal DMX512
|
|
|
|
|
void setCanal(int number, int value){
|
|
|
|
|
DMXSerial.write(number, value);
|
|
|
|
|
Serial.println("OK");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Initialisation
|
|
|
|
|
void setup() {
|
|
|
|
|
Serial.begin(9600);
|
|
|
|
|
DMXSerial.init(DMXController);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Interception des commandes de canaux
|
|
|
|
|
void loop() {
|
|
|
|
|
if(Serial.available())
|
|
|
|
|
{
|
|
|
|
|
char c = Serial.read();
|
2022-10-24 16:06:43 +02:00
|
|
|
if(c == '\n' || c == '\r'){
|
2022-10-24 15:57:52 +02:00
|
|
|
traiterCommande();
|
|
|
|
|
chaine = "";
|
|
|
|
|
}
|
|
|
|
|
else chaine += c;
|
|
|
|
|
}
|
|
|
|
|
}
|