Merge pull request #11258 from jbubik/XDRV53-KW9

XDRV53 PROJECTOR_CTRL: minor updates
This commit is contained in:
Theo Arends 2021-03-08 09:02:08 +01:00 committed by GitHub
commit b101657fba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 5 deletions

View File

@ -7,7 +7,10 @@
#endif //PROJECTOR_CTRL_PWR_BY_RELAY
#define PROJECTOR_CTRL_SERIAL_TIMEOUT 10 //up to 254 seconds
#ifndef PROJECTOR_CTRL_SERIAL_BAUDRATE
#define PROJECTOR_CTRL_SERIAL_BAUDRATE 9600
#endif //PROJECTOR_CTRL_SERIAL_BAUDRATE
#ifdef USE_PROJECTOR_CTRL_NEC
/* see the serial codes in
@ -32,6 +35,8 @@ static const struct projector_ctrl_command_info_s projector_ctrl_commands[] = {
};
#define PROJECTOR_CTRL_QRYPWR_ON 0x04
#define PROJECTOR_CTRL_QRYPWR_COOLING 0x05
#define PROJECTOR_CTRL_QRYPWR_STARTING 0x01 //undocumented state, seen on V300W
#define PROJECTOR_CTRL_QRYPWR_WARMING 0x02 //undocumented state, seen on V300W
#elif defined(USE_PROJECTOR_CTRL_OPTOMA)
@ -56,6 +61,8 @@ static const struct projector_ctrl_command_info_s projector_ctrl_commands[] = {
};
#define PROJECTOR_CTRL_QRYPWR_ON 0x31
#define PROJECTOR_CTRL_QRYPWR_COOLING 0x31 //placebo
#define PROJECTOR_CTRL_QRYPWR_STARTING 0x31 //placebo
#define PROJECTOR_CTRL_QRYPWR_WARMING 0x31 //placebo
#else

View File

@ -27,7 +27,7 @@
#define XDRV_53 53
#ifndef USE_PROJECTOR_CTRL_NEC
#if !defined(USE_PROJECTOR_CTRL_NEC) && !defined(USE_PROJECTOR_CTRL_OPTOMA)
#define USE_PROJECTOR_CTRL_NEC // Use at least one projector
#endif
@ -324,15 +324,29 @@ projector_ctrl_loop(struct projector_ctrl_softc_s *sc)
oldstate = sc->sc_ser_state;
switch (sc->sc_ser_state = (projector_ctrl_serial_state_e)projector_ctrl_parse(sc, serial->read())) {
case PROJECTOR_CTRL_S_UNCONNECTED:
sc->sc_dev_state=PROJECTOR_CTRL_DEV_UNKNOWN;
if (sc->sc_dev_state!=PROJECTOR_CTRL_DEV_UNKNOWN){
sc->sc_dev_state=PROJECTOR_CTRL_DEV_UNKNOWN;
AddLog_P(LOG_LEVEL_INFO,PSTR(PROJECTOR_CTRL_LOGNAME ": DISCONNECTED(unexpected input)"));
}
break;
case PROJECTOR_CTRL_S_IDLE:
if ((oldstate==PROJECTOR_CTRL_S_QRY_PWR)&&(sc->sc_ser_result==PROJECTOR_CTRL_R_PASS)){
if(((sc->sc_ser_value==PROJECTOR_CTRL_QRYPWR_ON)||(sc->sc_ser_value==PROJECTOR_CTRL_QRYPWR_COOLING))&&(sc->sc_dev_state!=PROJECTOR_CTRL_DEV_PWR_ON)){
if(sc->sc_dev_state==PROJECTOR_CTRL_DEV_UNKNOWN){
AddLog_P(LOG_LEVEL_INFO,PSTR(PROJECTOR_CTRL_LOGNAME ": CONNECTED"));
};
if(( (sc->sc_ser_value==PROJECTOR_CTRL_QRYPWR_ON)
||(sc->sc_ser_value==PROJECTOR_CTRL_QRYPWR_COOLING)
||(sc->sc_ser_value==PROJECTOR_CTRL_QRYPWR_STARTING)
||(sc->sc_ser_value==PROJECTOR_CTRL_QRYPWR_WARMING)
)&&(sc->sc_dev_state!=PROJECTOR_CTRL_DEV_PWR_ON)){
sc->sc_dev_state=PROJECTOR_CTRL_DEV_PWR_ON;
ExecuteCommandPower(sc->sc_device, POWER_ON, SRC_IGNORE);
};
if(((sc->sc_ser_value!=PROJECTOR_CTRL_QRYPWR_ON)&&(sc->sc_ser_value!=PROJECTOR_CTRL_QRYPWR_COOLING))&&(sc->sc_dev_state!=PROJECTOR_CTRL_DEV_PWR_OFF)){
if(( (sc->sc_ser_value!=PROJECTOR_CTRL_QRYPWR_ON)
&&(sc->sc_ser_value!=PROJECTOR_CTRL_QRYPWR_COOLING)
&&(sc->sc_ser_value!=PROJECTOR_CTRL_QRYPWR_STARTING)
&&(sc->sc_ser_value!=PROJECTOR_CTRL_QRYPWR_WARMING)
)&&(sc->sc_dev_state!=PROJECTOR_CTRL_DEV_PWR_OFF)){
sc->sc_dev_state=PROJECTOR_CTRL_DEV_PWR_OFF;
ExecuteCommandPower(sc->sc_device, POWER_OFF, SRC_IGNORE);
};
@ -375,7 +389,7 @@ projector_ctrl_tick(struct projector_ctrl_softc_s *sc)
};
}else if(sc->sc_ticks > sc->sc_cmd_info->timeout_ticks){
//current CMD has ran out of time, drop connection
AddLog_P(LOG_LEVEL_INFO,PSTR(PROJECTOR_CTRL_LOGNAME ": DISCONNECTED"));
AddLog_P(LOG_LEVEL_INFO,PSTR(PROJECTOR_CTRL_LOGNAME ": DISCONNECTED(timeout)"));
sc->sc_dev_state=PROJECTOR_CTRL_DEV_UNKNOWN;
sc->sc_ser_state=PROJECTOR_CTRL_S_UNCONNECTED;
};