Skip to content

Commit

Permalink
Merge pull request #3 from c-s-1/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
c-s-1 committed Jun 18, 2018
2 parents 165bfb7 + 8804ad8 commit 5ed7832
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
31 changes: 31 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,31 @@
# Changelog

This changelog lists all notable changes to the project.

## v0.3

### Added

- Changelog.
- "Troubleshooting / FAQ" section in README.md.
- Hints for LCDs with different I<sup>2</sup>C addresses.

### Fixed

- Use milliseconds instead of microseconds to avoid overflow problems.

## v0.2

### Added

- Serial output of CSV lines for re-using data.
- Average calculation.

### Changed

- Code restructuring.
- Reset button flapping prevention.

## v0.1

- Initial release.
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -47,6 +47,11 @@ and to use a mirror, however, it's hard to get satisfying results.*
To upload the code to your Arduino, open [src/shutter-tester/shutter-tester.ino](https://raw.githubusercontent.com/c-s-1/shutter-tester/master/src/shutter-tester/shutter-tester.ino) in the Arduino IDE and upload it to your Arduino Uno R3.
You only need to do this once or whenever you want to update the code.

## Troubleshooting / FAQ

* Q: My LCD doesn't show anything, the LED backlight only lights up.
* A: Some I<sup>2</sup>C modules use different addresses than others. In the LCD initialisation line `LiquidCrystal_I2C lcd();` try addresses `0x27` or `0x3F`. If both don't work, try using a I<sup>2</sup>C scanner sketch (there're many available) and use the address that it detects.

## User Manual

### Setting up the Shutter Tester
Expand Down
23 changes: 15 additions & 8 deletions src/shutter-tester/shutter-tester.ino
Expand Up @@ -24,11 +24,18 @@
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Initialise an LCD
/*
Initialise an LCD
Please note that some I2C chips use a different address. If your display
doesn't display anything, comment the active line and uncomment the other
line.
*/
LiquidCrystal_I2C lcd(0x27, 20, 4);
//LiquidCrystal_I2C lcd(0x3F, 20, 4);

// Version
const String version = "v0.2";
const String version = "v0.3";
// Pin for IR sensor
const byte interruptPin = 2;
// Pin for reset button
Expand Down Expand Up @@ -128,7 +135,7 @@ void loop() {
exposure++;
if (start_time > 0 && start_time < end_time)
{
// Calculate time difference between start and end of exposure in microseconds.
// Calculate time difference between start and end of exposure in milliseconds.
timed = end_time - start_time;
s = t_to_string(timed);
// Check if the last exposure is a new minimum.
Expand Down Expand Up @@ -180,20 +187,20 @@ void print_result(String s, String avg) {

String t_to_string(unsigned long timed) {
/*
Method for formating unsigned long timed (measured speed in microseconds)
Method for formating unsigned long timed (measured speed in milliseconds)
to a string "x.xs" for speeds over 1s and "1/xs" for speeds unter a
second. Returns string of converted time.
*/
String s = "";
if (timed >= 1000000)
if (timed >= 1000)
{
// Format shutter times >1s.
s = String((float)timed / 1000000.0);
s = String((float)timed / 1000.0);
}
else
{
// Format shutter times <1s.
s = String("1/" + String(int(1.0 / (timed / 1000000.0))));
s = String("1/" + String(int(1.0 / (float(timed) / 1000.0))));
}
return s;
}
Expand All @@ -202,7 +209,7 @@ void exp() {
/*
Method called by interrupt attached to IR sensor output.
*/
unsigned long temp_time = micros();
unsigned long temp_time = millis();
// Pin is LOW if IR sensor detects IR (i. e. shutter is open).
if (digitalRead(interruptPin) == LOW)
{
Expand Down

0 comments on commit 5ed7832

Please sign in to comment.