rename mqtt topic mute to enable
This commit is contained in:
parent
d53044a4e1
commit
4994ed9ac3
|
@ -182,7 +182,7 @@ void setup() {
|
||||||
|
|
||||||
if (useethernet)
|
if (useethernet)
|
||||||
{
|
{
|
||||||
Serial.println("trying DHCP");
|
Serial.println("DHCP..");
|
||||||
if (Ethernet.begin(mac) == 0) { // setup ethernet communication using DHCP
|
if (Ethernet.begin(mac) == 0) { // setup ethernet communication using DHCP
|
||||||
useethernet=false;
|
useethernet=false;
|
||||||
//Unable to configure Ethernet using DHCP
|
//Unable to configure Ethernet using DHCP
|
||||||
|
@ -193,7 +193,7 @@ void setup() {
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
useethernet=true;
|
useethernet=true;
|
||||||
Serial.print("IP address: ");
|
Serial.print("IP: ");
|
||||||
Serial.println(Ethernet.localIP());
|
Serial.println(Ethernet.localIP());
|
||||||
Serial.println();
|
Serial.println();
|
||||||
|
|
||||||
|
@ -238,9 +238,9 @@ void reconnect() {
|
||||||
publishCurrentSetVolume();
|
publishCurrentSetVolume();
|
||||||
mqttClient.publish("audiomixer/ip", ip.c_str()); //Publish own ip
|
mqttClient.publish("audiomixer/ip", ip.c_str()); //Publish own ip
|
||||||
mqttClient.subscribe("audiomixer/volume/set"); //subscribe to /set, republish without /set
|
mqttClient.subscribe("audiomixer/volume/set"); //subscribe to /set, republish without /set
|
||||||
mqttClient.subscribe("audiomixer/mute/set"); //without range
|
mqttClient.subscribe("audiomixer/enable/set"); //without range
|
||||||
for (uint8_t i=0;i<NUMMUTECHANNELS;i++) { //with range
|
for (uint8_t i=0;i<NUMMUTECHANNELS;i++) { //with range
|
||||||
String sub_topic="audiomixer/mute_"+String(i)+"/set";
|
String sub_topic="audiomixer/enable_"+String(i)+"/set";
|
||||||
mqttClient.subscribe((char*) sub_topic.c_str());
|
mqttClient.subscribe((char*) sub_topic.c_str());
|
||||||
}
|
}
|
||||||
mqttClient.subscribe("audiomixer/select/set"); //without range
|
mqttClient.subscribe("audiomixer/select/set"); //without range
|
||||||
|
@ -305,7 +305,7 @@ void loop() {
|
||||||
case 1: //mute
|
case 1: //mute
|
||||||
if (menu_selectedChannel<=MENU_MAXCHANNEL) { //inside valid range
|
if (menu_selectedChannel<=MENU_MAXCHANNEL) { //inside valid range
|
||||||
//setMuteChannel(menu_selectedChannel,!getMute(menu_selectedChannel)); // mute/unmute menu_selectedChannel
|
//setMuteChannel(menu_selectedChannel,!getMute(menu_selectedChannel)); // mute/unmute menu_selectedChannel
|
||||||
setRelaisByNumber(NUMMUTECHANNELS,"audiomixer/mute_", menu_selectedChannel, !getMute(menu_selectedChannel), &setMuteChannel); //toggle
|
setRelaisByNumber(NUMMUTECHANNELS,"audiomixer/enable_", menu_selectedChannel, !getMute(menu_selectedChannel), &setMuteChannel); //toggle
|
||||||
}else{ //nothing selected
|
}else{ //nothing selected
|
||||||
menu_mode = 0; //return to volume mode
|
menu_mode = 0; //return to volume mode
|
||||||
}
|
}
|
||||||
|
@ -589,18 +589,18 @@ void callback(char* topic, byte* payload, unsigned int length) {
|
||||||
|
|
||||||
publishCurrentSetVolume();
|
publishCurrentSetVolume();
|
||||||
|
|
||||||
}else if (String(topic).equals("audiomixer/mute/set")) { //withouth range
|
}else if (String(topic).equals("audiomixer/enable/set")) { //withouth range
|
||||||
//Serial.print("Mute string="); Serial.println(spayload);
|
//Serial.print("Mute string="); Serial.println(spayload);
|
||||||
uint16_t ipayload=spayload.toInt();
|
uint16_t ipayload=spayload.toInt();
|
||||||
if (spayload.equalsIgnoreCase("false")) {
|
if (spayload.equalsIgnoreCase("false")) {
|
||||||
setMuteInt(0); //all unmuted
|
setMuteInt(0); //all muted
|
||||||
}else if (spayload.equalsIgnoreCase("true")) {
|
}else if (spayload.equalsIgnoreCase("true")) {
|
||||||
setMuteInt(pow(2,NUMMUTECHANNELS)-1); //all muted
|
setMuteInt(pow(2,NUMMUTECHANNELS)-1); //all muted
|
||||||
}else if (ipayload>=0 && ipayload<((uint16_t)1<<NUMMUTECHANNELS)){ //in range
|
}else if (ipayload>=0 && ipayload<((uint16_t)1<<NUMMUTECHANNELS)){ //in range
|
||||||
setMuteInt(ipayload); //set bits directly
|
setMuteInt(ipayload); //set bits directly
|
||||||
}
|
}
|
||||||
|
|
||||||
publishAllStates(NUMMUTECHANNELS,"mute_", &getMute);
|
publishAllStates(NUMMUTECHANNELS,"enable_", &getMute);
|
||||||
|
|
||||||
}else if (String(topic).equals("audiomixer/select/set")) { //withouth range
|
}else if (String(topic).equals("audiomixer/select/set")) { //withouth range
|
||||||
//Serial.print("Select string="); Serial.println(spayload);
|
//Serial.print("Select string="); Serial.println(spayload);
|
||||||
|
@ -615,8 +615,8 @@ void callback(char* topic, byte* payload, unsigned int length) {
|
||||||
|
|
||||||
publishAllStates(NUMSELECTCHANNELS,"select_", &getSelection);
|
publishAllStates(NUMSELECTCHANNELS,"select_", &getSelection);
|
||||||
|
|
||||||
}else if (String(topic).startsWith("audiomixer/mute_")) { //with range
|
}else if (String(topic).startsWith("audiomixer/enable_")) { //with range
|
||||||
changeRelaisByNumberTopic(NUMMUTECHANNELS,"audiomixer/mute_", topic, spayload, &setMuteChannel);
|
changeRelaisByNumberTopic(NUMMUTECHANNELS,"audiomixer/enable_", topic, spayload, &setMuteChannel);
|
||||||
|
|
||||||
}else if (String(topic).startsWith("audiomixer/select_")) {
|
}else if (String(topic).startsWith("audiomixer/select_")) {
|
||||||
changeRelaisByNumberTopic(NUMSELECTCHANNELS,"audiomixer/select_", topic, spayload, &setSelectionChannel);
|
changeRelaisByNumberTopic(NUMSELECTCHANNELS,"audiomixer/select_", topic, spayload, &setSelectionChannel);
|
||||||
|
@ -660,7 +660,7 @@ uint32_t Wheel(byte WheelPos) {
|
||||||
return leds.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
|
return leds.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMuteInt(uint8_t i) {
|
void setMuteInt(uint8_t i) { //low is muted
|
||||||
uint16_t mask=(( (uint16_t)1<<(NUMMUTECHANNELS))-1 )<<NUMSELECTCHANNELS;
|
uint16_t mask=(( (uint16_t)1<<(NUMMUTECHANNELS))-1 )<<NUMSELECTCHANNELS;
|
||||||
srbits = ((i<<NUMSELECTCHANNELS) & mask) | (srbits & ~mask);
|
srbits = ((i<<NUMSELECTCHANNELS) & mask) | (srbits & ~mask);
|
||||||
srShiftOut();
|
srShiftOut();
|
||||||
|
|
Loading…
Reference in New Issue