Skip to content
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

Merged
merged 1 commit into from
Jul 23, 2017
Merged

Conversation

stufisher
Copy link
Contributor

Initial support for Trotec ac remote. No decoding yet i'm afraid.

Copy link
Owner

@crankyoldgit crankyoldgit left a 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:

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 @@
/*
Copy link
Owner

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"
Copy link
Owner

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]


void IRTrotecESP::setPower(bool state) {
if (state) trotec[2] |= TROTEC_ON;
else trotec[2] &= ~(TROTEC_ON);
Copy link
Owner

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);


void IRTrotecESP::setSleep(bool sleep) {
if (sleep) trotec[3] |= TROTEC_SLEEP_ON;
else trotec[3] &= ~(TROTEC_SLEEP_ON);
Copy link
Owner

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.


bool IRrecv::decodeTrotec(decode_results *results, uint16_t nbits,
bool strict) {

Copy link
Owner

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);
Copy link
Owner

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;
Copy link
Owner

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;

trotec[0] = TROTEC_INTRO1;
trotec[1] = TROTEC_INTRO2;

setPower(0);
Copy link
Owner

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);

setPower(0);
setTemp(25);
setSpeed(2);
setMode(0);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TROTEC_AUTO


setPower(0);
setTemp(25);
setSpeed(2);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TROTEC_FAN_MED

@@ -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
Copy link
Owner

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.

@@ -0,0 +1,170 @@
#include "ir_Trotec.h"
#include <algorithm>
Copy link
Owner

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.



void IRTrotecESP::setTimer(uint8_t timer) {
if (timer < TROTEC_MIN_TIMER) timer = TROTEC_MIN_TIMER;
Copy link
Owner

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

@stufisher
Copy link
Contributor Author

No worries, happy to keep to whatever style guide you are using, all useful points!

Copy link
Owner

@crankyoldgit crankyoldgit left a 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
Copy link
Owner

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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\o/

@crankyoldgit crankyoldgit merged commit 4f5f05a into crankyoldgit:master Jul 23, 2017
@NiKiZe
Copy link
Collaborator

NiKiZe commented Jun 2, 2020

I know this is old but ...
Any chance we can get information about which model of A/C and remote this works with, and maybe also a confirmation if decode routines work or not.

@stufisher
Copy link
Contributor Author

Hi @NiKiZe this was for a Trotec PAC 3200. Dont think i got round to testing the decode routines, sorry!

@NiKiZe
Copy link
Collaborator

NiKiZe commented Jun 3, 2020

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

@stufisher
Copy link
Contributor Author

I dont have this ac unit any more but ill see if i can get any more information about the remote

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants