Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
07ce624
commit acbb42a
Showing
7 changed files
with
282 additions
and
87 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-GB"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Raspberry Pi Timelapse Camera - Images</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" href="{{ .SiteInfo.SiteRoot }}/static/speed-test.css"> | ||
<link rel="stylesheet" href="{{ .SiteInfo.SharedAssetsSite }}/main.css"> | ||
</head> | ||
<body> | ||
<main class="content"> | ||
<a href="{{ .SiteInfo.SiteRoot }}/">Back</a> | ||
<h1>Images</h1> | ||
|
||
<a href="{{ .SiteInfo.SiteRoot }}/images/latest/">Latest</a> | ||
<ul> | ||
{{range .Images}} | ||
<li><a href="{{$.SiteInfo.SiteRoot}}/images/{{.Timestamp}}/">{{.Timestamp}}</a> | ||
{{end}} | ||
</ul> | ||
|
||
</main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-GB"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Raspberry Pi Timelapse Camera</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" href="{{ .SiteInfo.SiteRoot }}/static/speed-test.css"> | ||
<link rel="stylesheet" href="{{ .SiteInfo.SharedAssetsSite }}/main.css"> | ||
</head> | ||
<body> | ||
<main class="content"> | ||
<h1>Raspberry Pi Timelapse Camera</h1> | ||
<h2>New timelapse</h2> | ||
<form action="." method="post"> | ||
<label for="timelapse-name">Name</label> | ||
<input type="text" name="timelapse-name" id="timelapse-name"></input> | ||
<label for="timelapse-interval">Interval (seconds)</label> | ||
<input type="number" step="1" min="0" id="timelapse-interval" name="timelapse-interval"></input> | ||
<button type="submit">Create</button> | ||
</form> | ||
|
||
<h2>Current timelapse</h2> | ||
<p><a href="{{ .SiteInfo.SiteRoot }}/images/">Current timelapse images</a> | ||
|
||
<h2>Now</h2> | ||
<img src="{{ .SiteInfo.SiteRoot }}/images/now/"> | ||
</main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,65 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"log" | ||
"os" | ||
"sync" | ||
"time" | ||
|
||
"github.com/dhowden/raspicam" | ||
) | ||
|
||
type TimelapseCamera struct { | ||
Store *TimelapseStore | ||
ImageCapturer *ImageCapturer | ||
CurrentTicker *time.Ticker | ||
Mutex sync.Mutex | ||
} | ||
|
||
func (tt *TimelapseCamera) StartTimelapse(t *TimelapseSettings) { | ||
|
||
if tt.CurrentTicker != nil { | ||
tt.CurrentTicker.Stop() | ||
tt.CurrentTicker = nil | ||
} | ||
|
||
log.Printf("Starting timelapse ticker with interval %v", t.Interval) | ||
tt.CurrentTicker = time.NewTicker(t.Interval) | ||
go func() { | ||
for range tt.CurrentTicker.C { | ||
log.Printf("Taking image at triggered interval") | ||
err := tt.Store.StoreImage(tt.ImageCapturer.CaptureImage) | ||
err := tt.Store.StoreImage(tt.CaptureImage) | ||
if err != nil { | ||
log.Printf("Error storing image") | ||
log.Printf("Error storing image: %s", err.Error()) | ||
} | ||
} | ||
}() | ||
|
||
tt.Store.StoreImage(tt.ImageCapturer.CaptureImage) | ||
err := tt.Store.StoreImage(tt.CaptureImage) | ||
if err != nil { | ||
log.Printf("Error storing image: %s", err.Error()) | ||
} | ||
|
||
} | ||
|
||
func (c *TimelapseCamera) CaptureImage(cameraSettings *CameraSettings, w io.Writer) { | ||
log.Printf("Camera settings for capture: %+v", cameraSettings) | ||
s := raspicam.NewStill() | ||
s.Camera.VFlip = cameraSettings.VFlip | ||
s.Camera.HFlip = cameraSettings.HFlip | ||
s.Camera.Rotation = cameraSettings.Rotation | ||
s.Width = cameraSettings.Width | ||
s.Height = cameraSettings.Height | ||
s.Encoding = raspicam.EncodingPNG | ||
|
||
errCh := make(chan error) | ||
go func() { | ||
for x := range errCh { | ||
fmt.Fprintf(os.Stderr, "%v\n", x) | ||
} | ||
}() | ||
c.Mutex.Lock() | ||
raspicam.Capture(s, w, errCh) | ||
c.Mutex.Unlock() | ||
} |
Oops, something went wrong.