-
Notifications
You must be signed in to change notification settings - Fork 839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for trotec ac #279
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the whole, excellent stuff. Tackling adding an A/C unit remote is a fair chunk of hard work. Congrats!
There is a lot of comments in this review, a lot of them are really nitpicky/style related. So, please don't take them personally.
FYI, a number of them are for the Google C++ cpplint.py program we use to try to keep a consistent style. Those HAVE to be fixed/completed before our Travis build will succeed etc.
In addition:
- Please add yourself to:
https://github.com/markszabo/IRremoteESP8266/blob/master/.github/Contributors.md
and
https://github.com/markszabo/IRremoteESP8266/blob/master/src/IRremoteESP8266.h
You deserve the credit. ;-)
- Also, please add a line to the .travis.yaml file to confirm we don't break your code and our users know everything compiles etc:
e.g.
- arduino --verify --board $BD $PWD/examples/TurnOnTrotecAC/TurnOnTrotecAC.ino
@@ -0,0 +1,53 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No copyright message found. You should have a line: "Copyright [year] " [legal/copyright] [5]
Give yourself some credit. ;-)
@@ -0,0 +1,170 @@ | |||
#include "ir_Trotec.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/ir_Trotec.cpp:0: No copyright message found. You should have a line: "Copyright [year] " [legal/copyright] [5]
src/ir_Trotec.cpp
Outdated
|
||
void IRTrotecESP::setPower(bool state) { | ||
if (state) trotec[2] |= TROTEC_ON; | ||
else trotec[2] &= ~(TROTEC_ON); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/ir_Trotec.cpp:88: Else clause should never be on same line as else (use 2 lines) [whitespace/newline] [4]
e.g.
if (state)
trotec[2] |= TROTEC_ON;
else
trotec[2] &= ~(TROTEC_ON);
src/ir_Trotec.cpp
Outdated
|
||
void IRTrotecESP::setSleep(bool sleep) { | ||
if (sleep) trotec[3] |= TROTEC_SLEEP_ON; | ||
else trotec[3] &= ~(TROTEC_SLEEP_ON); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/ir_Trotec.cpp:132: Else clause should never be on same line as else (use 2 lines) [whitespace/newline] [4]
Ditto the previous similar review comment.
src/ir_Trotec.cpp
Outdated
|
||
bool IRrecv::decodeTrotec(decode_results *results, uint16_t nbits, | ||
bool strict) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/ir_Trotec.cpp:167: Redundant blank line at the start of a code block should be deleted. [whitespace/blank_line] [2]
Serial.println("Sending..."); | ||
|
||
// Set up what we want to send. See ir_Trotec.cpp for all the options. | ||
trotecir.setState(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does state 1 mean?
|
||
for (i = 2; i < 8; i++) sum += trotec[i]; | ||
|
||
trotec[8] = sum & 0xFF; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, I think this sum & 0xFF
is redundant as it's a uint8_t
. But better safe than sorry I guess.
e.g.
You could just use:
trotec[8] = sum;
src/ir_Trotec.cpp
Outdated
trotec[0] = TROTEC_INTRO1; | ||
trotec[1] = TROTEC_INTRO2; | ||
|
||
setPower(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick:
It would be great if you used constants for these values below.
e.g.
What is 0 in this context? I think you should be using true
and false
given it's a Boolean.
What is speed 2 etc?
Maybe something like this would make things clearer:
#define TROTEC_DEF_TEMP 25
...
setTemp(TROTEC_DEF_TEMP);
src/ir_Trotec.cpp
Outdated
setPower(0); | ||
setTemp(25); | ||
setSpeed(2); | ||
setMode(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TROTEC_AUTO
src/ir_Trotec.cpp
Outdated
|
||
setPower(0); | ||
setTemp(25); | ||
setSpeed(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TROTEC_FAN_MED
src/IRremoteESP8266.h
Outdated
@@ -210,6 +214,8 @@ enum decode_type_t { | |||
#define SONY_20_BITS 20U | |||
#define SONY_MIN_BITS SONY_12_BITS | |||
#define SONY_MIN_REPEAT 2U | |||
#define TROTEC_BITS 72U |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm missing it, but this doesn't seem to be used anywhere.
src/ir_Trotec.cpp
Outdated
@@ -0,0 +1,170 @@ | |||
#include "ir_Trotec.h" | |||
#include <algorithm> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need this header. I don't see anything using it. e.g. max & min etc.
Try it without it.
src/ir_Trotec.cpp
Outdated
|
||
|
||
void IRTrotecESP::setTimer(uint8_t timer) { | ||
if (timer < TROTEC_MIN_TIMER) timer = TROTEC_MIN_TIMER; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant: timer can't be less than TROTEC_MIN_TIMER
(0) as it is unsigned
No worries, happy to keep to whatever style guide you are using, all useful points! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now.
One last thing. Please merge(rebase) this all into a single commit, so we can roll it back out if we need to. It makes for a cleaner commit history too. ;-)
e.g.
git rebase -i HEAD~11
should do the trick.
Once that's done. Let me know and I'll merge it in.
src/ir_Trotec.h
Outdated
@@ -17,7 +20,8 @@ | |||
#define TROTEC_DRY 2 | |||
#define TROTEC_FAN 3 | |||
|
|||
#define TROTEC_ON 1 << 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, I think your original approach was nicer.
No need to change it. Just saying.
e.g.
#define TROTEC_ON (1 << 3)
@@ -32,6 +32,7 @@ | |||
* Updated by sillyfrog for Daikin, adopted from | |||
* (https://github.com/mharizanov/Daikin-AC-remote-control-over-the-Internet/) | |||
* Fujitsu A/C code added by jonnygraham | |||
* Trotec AC code by stufisher |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\o/
I know this is old but ... |
Hi @NiKiZe this was for a Trotec PAC 3200. Dont think i got round to testing the decode routines, sorry! |
Awesome, thank you for the model number |
I dont have this ac unit any more but ill see if i can get any more information about the remote |
Initial support for Trotec ac remote. No decoding yet i'm afraid.