mirror of
https://github.com/kevinveenbirkenbach/physical-interface.git
synced 2024-11-14 22:31:04 +01:00
Adapted remote plug and sound enabled
This commit is contained in:
parent
c0b5c2edd7
commit
6fc2358a9c
@ -67,13 +67,13 @@ void setRecievedIr(decode_results *results) {
|
|||||||
/**
|
/**
|
||||||
* Transmitter functions
|
* Transmitter functions
|
||||||
*/
|
*/
|
||||||
void sendRemoteGroupSignal(int state)
|
void sendRemoteGroupSignal(boolean state)
|
||||||
{
|
{
|
||||||
transmitter.sendGroup(state);
|
transmitter.sendGroup(state);
|
||||||
Serial.println("The state \"" + String(state,BIN) + "\" was send to the group \"" + String(RITTER_STANDART_GROUP_ADDRESS,DEC) + "\".");
|
Serial.println("The state \"" + String(state,BIN) + "\" was send to the group \"" + String(RITTER_STANDART_GROUP_ADDRESS,DEC) + "\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendRemoteUnitSignal(int unit, int state)
|
void sendRemoteUnitSignal(int unit, boolean state)
|
||||||
{
|
{
|
||||||
transmitter.sendUnit(unit, state);
|
transmitter.sendUnit(unit, state);
|
||||||
Serial.println("The state \"" + String(state,BIN) + "\" was send to the switch \"" + String(unit,DEC) + "\".");
|
Serial.println("The state \"" + String(state,BIN) + "\" was send to the switch \"" + String(unit,DEC) + "\".");
|
||||||
@ -87,13 +87,15 @@ void sendIrCode(decode_type_t type,uint32_t code, uint16_t bits) {
|
|||||||
/**
|
/**
|
||||||
* Actors
|
* Actors
|
||||||
*/
|
*/
|
||||||
void makeSound(int time_in_ms){
|
void switchSound(boolean status){
|
||||||
Serial.println("Making sound for \"" + String(time_in_ms) + "ms.");
|
Serial.println("Switching sound \"" + String((status)?("on"):("off")) + ".");
|
||||||
|
if(status){
|
||||||
pinMode(PIN_ACTIVE_BUZZER,OUTPUT);
|
pinMode(PIN_ACTIVE_BUZZER,OUTPUT);
|
||||||
digitalWrite(PIN_ACTIVE_BUZZER,LOW);
|
digitalWrite(PIN_ACTIVE_BUZZER,LOW);
|
||||||
delay(time_in_ms);
|
}else{
|
||||||
digitalWrite(PIN_ACTIVE_BUZZER,HIGH);
|
digitalWrite(PIN_ACTIVE_BUZZER,HIGH);
|
||||||
pinMode(PIN_ACTIVE_BUZZER,INPUT);
|
pinMode(PIN_ACTIVE_BUZZER,INPUT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -130,17 +132,15 @@ String getParameterType(const char* parameter){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void controller(void){
|
void controller(void){
|
||||||
if(isParameterDefined(PARAMETER_SOUND)){
|
switchSound(server.arg(PARAMETER_SOUND).equals("on"));
|
||||||
makeSound(server.arg(PARAMETER_SOUND).toInt());
|
|
||||||
}
|
|
||||||
if(isParameterDefined(PARAMETER_IR_TYPE) && isParameterDefined(PARAMETER_IR_CODE) && isParameterDefined(PARAMETER_IR_BITS)){
|
if(isParameterDefined(PARAMETER_IR_TYPE) && isParameterDefined(PARAMETER_IR_CODE) && isParameterDefined(PARAMETER_IR_BITS)){
|
||||||
sendIrCode(static_cast<decode_type_t>(server.arg(PARAMETER_IR_TYPE).toInt()),server.arg(PARAMETER_IR_CODE).toInt(),server.arg(PARAMETER_IR_BITS).toInt());
|
sendIrCode(static_cast<decode_type_t>(server.arg(PARAMETER_IR_TYPE).toInt()),server.arg(PARAMETER_IR_CODE).toInt(),server.arg(PARAMETER_IR_BITS).toInt());
|
||||||
}
|
}
|
||||||
if(isParameterDefined(PARAMETER_PLUG_ID) && isParameterDefined(PARAMETER_PLUG_STATUS)){
|
if(isParameterDefined(PARAMETER_PLUG_ID)){
|
||||||
if(server.arg(PARAMETER_PLUG_ID)=="group"){
|
if(server.arg(PARAMETER_PLUG_ID).equals("0")){
|
||||||
sendRemoteGroupSignal(server.arg(PARAMETER_PLUG_STATUS).toInt());
|
sendRemoteGroupSignal(server.arg(PARAMETER_PLUG_STATUS).equals("on"));
|
||||||
}else if(server.arg(PARAMETER_PLUG_ID).toInt()>0){
|
}else if(server.arg(PARAMETER_PLUG_ID).toInt()>0){
|
||||||
sendRemoteUnitSignal(server.arg(PARAMETER_PLUG_ID).toInt(),server.arg(PARAMETER_PLUG_STATUS).toInt());
|
sendRemoteUnitSignal(server.arg(PARAMETER_PLUG_ID).toInt(),server.arg(PARAMETER_PLUG_STATUS).equals("on"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -206,7 +206,7 @@ void setup(void)
|
|||||||
Serial.println("Enable IR-sender.");
|
Serial.println("Enable IR-sender.");
|
||||||
irsend.begin();
|
irsend.begin();
|
||||||
Serial.println("Activate active buzzer.");
|
Serial.println("Activate active buzzer.");
|
||||||
makeSound(1);
|
switchSound(true);
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
Serial.println("Started program.");
|
Serial.println("Started program.");
|
||||||
//WiFi.softAPdisconnect(true);
|
//WiFi.softAPdisconnect(true);
|
||||||
@ -225,6 +225,7 @@ void setup(void)
|
|||||||
server.begin();
|
server.begin();
|
||||||
Serial.println("HTTP server started.");
|
Serial.println("HTTP server started.");
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
switchSound(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
|
Loading…
Reference in New Issue
Block a user