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

Update camera and telemetry board sketches to those in use on PAN006 #291

Merged
merged 2 commits into from
Jan 4, 2018

Conversation

jamessynge
Copy link
Contributor

These have the benefit that they produce their reports faster because they first gather the data needed before they start writing. This reduces the risk that POCS will timeout while reading a single report.

In addition, the parsing of relay changes in the telemetry sketch is improved so that it can't accidentally shutdown everything.

This includes PR #290, and should be reviewed after that is submitted.

@codecov
Copy link

codecov bot commented Jan 3, 2018

Codecov Report

Merging #291 into develop will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #291   +/-   ##
========================================
  Coverage    83.81%   83.81%           
========================================
  Files           51       51           
  Lines         3367     3367           
  Branches       422      422           
========================================
  Hits          2822     2822           
  Misses         404      404           
  Partials       141      141

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ab8e95f...b2cfdc8. Read the comment docs.

Copy link
Member

@wtgee wtgee left a comment

Choose a reason for hiding this comment

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

LGTM. I wasn't as careful about checking the telemetry board code as the camera board as it seems like some of that will change with #289.

Also seems like you have the DHT changes from #290 i here as well, which is fine, but you might get a conflict.

const int RESET_PIN = 12;

// Utitlity Methods
Copy link
Member

Choose a reason for hiding this comment

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

spelling

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

if (!ready_) {
Serial.println("Accelerometer not ready, or not present.");
} else {
// Check Accelerometer range
Copy link
Member

Choose a reason for hiding this comment

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

I think this was commented out in old code but we should assess if we want it or not. I would be in favor of just removing. But since it only runs the first time (i.e. when not ready) then it might be useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's leave it in for the moment so that it is in the history, and so that we can figure out "what next".

if (ready()) {
accelerometer_.getEvent(&event_);
orientation_ = accelerometer_.getOrientation(); // Orientation
has_reading_ = true;
Copy link
Member

Choose a reason for hiding this comment

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

Can this get stale in any way? Perhaps an error on getEvent()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

getEvent() doesn't provide a status output, so we can't tell if something went wrong.

Do you mean can has_reading_ be wrong?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, wondering if getEvent() could somehow fail and then has_reading would be outdated. Since report() just checks for has_reading it would just keep reporting the same values and we wouldn't be the wiser. Would be nice to reset has_reading to false each time somehow. Might not be necessary though.

temperature_ = dht_.readTemperature();
}

void report() {
Copy link
Member

Choose a reason for hiding this comment

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

Accelerometer returns a bool so we should make consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about the other way: remove the bool return from AccelerometerHandler::report() as the value returned isn't currently used.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, sounds good. Just going for consistency so if not used let's definitely remove.

void collect() {
// Force readHumidity to actually talk to the device;
// otherwise will read at most every 2 seconds, which
// is sometimes just a too far apart.
Copy link
Member

Choose a reason for hiding this comment

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

Extra a in comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

led_handler.update();
Serial.print(report_num);
led_handler.update();
Serial.print(", \"inputs\":");
Copy link
Member

Choose a reason for hiding this comment

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

inputs was not at all clear to me until reading below. Maybe name the key inputs_recvd or something similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

turn_pin_off(pin_num);
}
break;
case LED_BUILTIN:
Copy link
Member

Choose a reason for hiding this comment

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

We might be able to remove this since the led_handler will just clobber it anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

out the values of the sensors and the settings of the relays.

This program has a class for each type of sensor, with a common API:
1) An Init() method that is called from setup.
Copy link
Member

Choose a reason for hiding this comment

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

Camera board has these methods as lower case names. We can make it conform in a PR that moves things to a shared library if you want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I'll clearly be forced to resolve that when extracting the shared classes.


int led_value = LOW;
// Utitlity Methods
Copy link
Member

Choose a reason for hiding this comment

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

Copy and paste spelling error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

} else if (pin_status == 9) {
toggle_pin(pin_num);
}
// Sort the devices so we get a consistent order from run to run...
Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised we need to do this. Is it due to DallasTemperature or the underlying OneWire?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't now recall if there is an inconsistency in the order from run-to-run, but I assume so since I went to the trouble. Fortunately, I did buy some more of those sensors and can test sometime Real Soon Now ®️. The main point is that it doesn't make a lot of sense to have 3 temps listed, but not have any idea which is which.

These have the benefit that they produce their reports faster because
they first gather the data needed before they start writing. This
reduces the risk that POCS will timeout while reading a single report.
@jamessynge jamessynge force-pushed the fast-output-sketches branch from 1352e38 to b2cfdc8 Compare January 4, 2018 02:02
@jamessynge jamessynge merged commit c45d032 into panoptes:develop Jan 4, 2018
@jamessynge jamessynge deleted the fast-output-sketches branch January 4, 2018 02:36
@wtgee wtgee mentioned this pull request Jan 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants