Skip to content

Instantly share code, notes, and snippets.

Last active April 13, 2016 21:14
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
A SpectralWorkbench macro to periodically submit spectral data on a timer
setup: function() {
// code to run on startup
$W.timer = {}
$W.timer.title = prompt('Please provide a title for the spectra you will be capturing. They will also be numbered sequentially.')
$W.timer.number = 0
$W.timer.interval = 60*60 // seconds until next capture: 60 * 60 is one hour
// run this every hour:
$W.timer.capture = function() {
$W.timer.number += 1
if ($W.calibration_id) {
// submit the data:
url: "/spectrums",
type: "POST",
data: {
spectrum: {
title: $W.timer.title+" #"+$W.timer.number,
notes: "Part of a series of spectrum captures using the API.",
calibration_id: $W.calibration_id
dataurl: $W.excerptCanvas(0,0,$W.width,1,$W.ctx).canvas.toDataURL(),
tags: "periodic,macro",
setInterval($W.timer.capture,$W.timer.interval * 1000)
draw: function() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment