mirror of
https://github.com/kevinveenbirkenbach/physical-interface.git
synced 2024-12-04 07:09:07 +01:00
Optimized general things
This commit is contained in:
parent
0577c51cd4
commit
cc4c4694c9
@ -7,13 +7,14 @@ const char* hostname = "physical-interface";
|
||||
|
||||
/**
|
||||
* Pin layout
|
||||
* I recommend to don't use D10, D9 and D0
|
||||
*/
|
||||
const uint16_t PIN_RADIO_TRANSMITTER = D7;
|
||||
const uint16_t PIN_RADIO_RECIEVER = D8;
|
||||
const uint16_t PIN_PIR = D1;
|
||||
const uint16_t PIN_DHT = D6;
|
||||
const uint16_t PIN_IR_RECIEVER = D4;
|
||||
const uint16_t PIN_IR_SEND = D2;
|
||||
const uint16_t PIN_RADIO_TRANSMITTER = D5;
|
||||
const uint16_t PIN_RADIO_RECIEVER = D4;
|
||||
const uint16_t PIN_PIR = D8;
|
||||
const uint16_t PIN_DHT = D7;
|
||||
const uint16_t PIN_IR_RECIEVER = D1;
|
||||
const uint16_t PIN_IR_SEND = D6;
|
||||
const uint16_t PIN_LDR = A0;
|
||||
const uint16_t PIN_ACTIVE_BUZZER = D5;
|
||||
const uint16_t PINS_SOIL_MOISTURE[] = {D3,D9,D10};
|
||||
const uint16_t PIN_SIGNAL = D2;
|
||||
const uint16_t PINS_SOIL_MOISTURE[] = {};
|
||||
|
@ -27,8 +27,8 @@ const char* PARAMETER_IR_TYPE="ir_type";
|
||||
const char* PARAMETER_IR_CODE="ir_code";
|
||||
const char* PARAMETER_IR_BITS="ir_bits";
|
||||
const char* PARAMETER_PRE_DELAY_TIME_IN_MS="pre_delay_time_in_ms";
|
||||
const char* PARAMETER_SOUND="sound_enabled";
|
||||
const char* PARAMETER_LIST[]={PARAMETER_PLUG_ADDRESS,PARAMETER_PLUG_ID,PARAMETER_PLUG_STATUS,PARAMETER_IR_TYPE,PARAMETER_IR_CODE,PARAMETER_IR_BITS,PARAMETER_PRE_DELAY_TIME_IN_MS,PARAMETER_SOUND};
|
||||
const char* PARAMETER_SIGNAL="signal";
|
||||
const char* PARAMETER_LIST[]={PARAMETER_PLUG_ADDRESS,PARAMETER_PLUG_ID,PARAMETER_PLUG_STATUS,PARAMETER_IR_TYPE,PARAMETER_IR_CODE,PARAMETER_IR_BITS,PARAMETER_PRE_DELAY_TIME_IN_MS,PARAMETER_SIGNAL};
|
||||
|
||||
/**
|
||||
* Define variables
|
||||
@ -95,14 +95,14 @@ void sendIrCode(decode_type_t type,uint32_t code, uint16_t bits) {
|
||||
/**
|
||||
* Actors
|
||||
*/
|
||||
void switchSound(boolean status){
|
||||
Serial.println("Switching sound \"" + String((status)?("on"):("off")) + ".");
|
||||
void switchSignal(boolean status){
|
||||
Serial.println("Switching signal\"" + String((status)?("on"):("off")) + ".");
|
||||
if(status){
|
||||
pinMode(PIN_ACTIVE_BUZZER,OUTPUT);
|
||||
digitalWrite(PIN_ACTIVE_BUZZER,LOW);
|
||||
pinMode(PIN_SIGNAL,OUTPUT);
|
||||
digitalWrite(PIN_SIGNAL,LOW);
|
||||
}else{
|
||||
digitalWrite(PIN_ACTIVE_BUZZER,HIGH);
|
||||
pinMode(PIN_ACTIVE_BUZZER,INPUT);
|
||||
digitalWrite(PIN_SIGNAL,HIGH);
|
||||
pinMode(PIN_SIGNAL,INPUT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ String getParameterType(const char* parameter){
|
||||
}
|
||||
|
||||
if(
|
||||
parameter==PARAMETER_SOUND ||
|
||||
parameter==PARAMETER_SIGNAL ||
|
||||
parameter==PARAMETER_PLUG_STATUS
|
||||
){
|
||||
return "boolean";
|
||||
@ -144,8 +144,8 @@ String getParameterType(const char* parameter){
|
||||
}
|
||||
|
||||
void controller(void){
|
||||
if(isParameterDefined(PARAMETER_SOUND)){
|
||||
switchSound(server.arg(PARAMETER_SOUND).equals("on"));
|
||||
if(isParameterDefined(PARAMETER_SIGNAL)){
|
||||
switchSignal(server.arg(PARAMETER_SIGNAL).equals("on"));
|
||||
}
|
||||
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());
|
||||
@ -279,10 +279,10 @@ void setup(void)
|
||||
server.onNotFound(handleRequest);
|
||||
server.begin();
|
||||
Serial.println("HTTP server started.");
|
||||
Serial.println("Generate test sound.");
|
||||
switchSound(true);
|
||||
Serial.println("Generate test signal.");
|
||||
switchSignal(true);
|
||||
delay(200);
|
||||
switchSound(false);
|
||||
switchSignal(false);
|
||||
}
|
||||
|
||||
void loop()
|
||||
|
Loading…
Reference in New Issue
Block a user