Skip to content

Commit

Permalink
Only enable timelapse feature when necessary config settings are made…
Browse files Browse the repository at this point in the history
…. Expanded on documentation.
  • Loading branch information
foosel committed Jan 4, 2013
1 parent ef0820a commit 7ffb8c3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 19 deletions.
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ Alternatively, the host and port on which to bind can be defined via the configu
Configuration
-------------

The config-file for Printer WebUI is expected at `~/.printerwebui/config.ini` for Linux, at `%APPDATA%/PrinterWebUI/config.ini`
for Windows and at `~/Library/Application Support/config.ini` for MacOS X.
The config-file `config.ini` for Printer WebUI is expected at `~/.printerwebui` for Linux, at `%APPDATA%/PrinterWebUI`
for Windows and at `~/Library/Application Support` for MacOS X.

The following example config should explain the available options:

[serial]
Expand All @@ -64,16 +65,23 @@ The following example config should explain the available options:
port = 5000

[webcam]
# use this option to enable display of a webcam stream in the UI, e.g. via MJPG-Streamer
stream = http://10.0.0.2:8080/?action=stream
# use this option to enable timelapse support via snapshot, e.g. via MJPG-Streamer
snapshot = http://10.0.0.1:8080/?action=snapshot
# use this option to enable display of a webcam stream in the UI, e.g. via MJPG-Streamer.
# Webcam support will be disabled if not set
stream = http://<stream host>:<stream port>/?action=stream
# use this option to enable timelapse support via snapshot, e.g. via MJPG-Streamer.
# Timelapse support will be disabled if not set
snapshot = http://<stream host>:<stream port>/?action=snapshot
# path to ffmpeg binary to use for creating timelapse recordings.
# Timelapse support will be disabled if not set
ffmpeg = /path/to/ffmpeg

[folder]
# absolute path where to store gcode uploads. Defaults to the uploads folder in the Printer WebUI settings dir
uploads = /path/to/upload/folder
# absolute path where to store gcode uploads. Defaults to the timelapse folder in the Printer WebUI settings dir
# absolute path where to store finished timelapse recordings. Defaults to the timelapse folder in the Printer WebUI settings dir
timelapse = /path/to/timelapse/folder
# absolute path where to store temporary timelapse files. Defaults to the timelapse/tmp folder in the Printer WebUI settings dir
timelapse_tmp = /path/timelapse/tmp/folder

Setup on a Raspberry Pi running Raspbian
----------------------------------------
Expand All @@ -95,7 +103,7 @@ You should then be able to start the WebUI server:
If you also want webcam support, you'll need to download and compile MJPG-Streamer:

cd ~
sudo apt-get install libjpeg8-dev imagemagick
sudo apt-get install libjpeg8-dev imagemagick ffmpeg
wget -Omjpg-streamer.tar.gz http://mjpg-streamer.svn.sourceforge.net/viewvc/mjpg-streamer/mjpg-streamer/?view=tar
tar xfz mjpg-streamer.tar.gz
cd mjpg-streamer
Expand All @@ -120,6 +128,8 @@ Open `~/.printerwebui/config.ini` and add the following lines to it:

[webcam]
stream = http://<your Raspi's IP>:8080/?action=stream
snapshot = http://127.0.0.1:8080/?action=snapshot
ffmpeg = /usr/bin/ffmpeg

Restart the WebUI server and reload its frontend. You should now see a Webcam tab with content.

Expand Down
10 changes: 7 additions & 3 deletions printer_webui/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import os
import fnmatch

BASEURL="/ajax/"
SUCCESS={}
BASEURL = "/ajax/"
SUCCESS = {}

UPLOAD_FOLDER = settings().getBaseFolder("uploads")

Expand All @@ -22,7 +22,11 @@

@app.route("/")
def index():
return render_template("index.html", webcamStream = settings().get("webcam", "stream"))
return render_template(
"index.html",
webcamStream=settings().get("webcam", "stream"),
enableTimelapse=(settings().get("webcam", "snapshot") is not None and settings().get("webcam", "ffmpeg") is not None)
)

#~~ Printer state

Expand Down
8 changes: 1 addition & 7 deletions printer_webui/static/css/ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ table th.gcode_files_action, table td.gcode_files_action {
overflow: hidden;
}

#temp_newTemp, #temp_newBedTemp, #speed_innerWall, #speed_outerWall, #speed_fill, #speed_support {
#temp_newTemp, #temp_newBedTemp, #speed_innerWall, #speed_outerWall, #speed_fill, #speed_support, #webcam_timelapse_interval {
text-align: right;
}

Expand Down Expand Up @@ -107,12 +107,6 @@ table th.gcode_files_action, table td.gcode_files_action {
margin: auto;
}

#webcam_container {
height: 440px;
background-color: #000000;
margin-bottom: 20px;
}

table th.timelapse_files_name, table td.timelapse_files_name {
text-overflow: ellipsis;
text-align: left;
Expand Down
7 changes: 6 additions & 1 deletion printer_webui/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ <h1>Bed Temperature</h1>
<img id="webcam_image" src="{{ webcamStream }}">
</div>

{% if enableTimelapse %}
<h1>Timelapse Configuration</h1>

<label for="webcam_timelapse_mode">Timelapse Mode</label>
Expand All @@ -229,7 +230,10 @@ <h1>Timelapse Configuration</h1>

<div id="webcam_timelapse_timedsettings" data-bind="visible: intervalInputEnabled()">
<label for="webcam_timelapse_interval">Interval</label>
<input type="text" id="webcam_timelapse_interval" data-bind="value: timelapseTimedInterval, enable: isOperational() && !isPrinting()">
<div class="input-append">
<input type="text" class="input-mini" id="webcam_timelapse_interval" data-bind="value: timelapseTimedInterval, enable: isOperational() && !isPrinting()">
<span class="add-on">sec</span>
</div>
</div>

<div>
Expand All @@ -254,6 +258,7 @@ <h1>Finished Timelapses</h1>
</tr>
</tbody>
</table>
{% endif %}
</div>
{% endif %}
</div>
Expand Down

0 comments on commit 7ffb8c3

Please sign in to comment.