Commits

Anonymous committed f0effad

last modifs before fete de la science 2010 - grenoble

Comments (0)

Files changed (4)

 	maxNbImages int = 8
 	signaltoconf = map[int]int{
 		41: 1, 
+		25: 2,
 		37: 2, 
-		24: 3,
 		21: 4,
 		42: 5,
-		40: 6,
-		26: 7,
-		32: 8,
+		26: 6,
+		38: 7,
+		22: 8,
 	}
 )
 
 //configuration 6 is the most compact.  Thus, the mapping is (cf
 //signaltoconf map):
 //41: 1, (00101001)
-//37: 2, (00100101)
-//24: 3, (00011001)
+//25: 2, (00011001)
+//37: 3, (00100101)
 //21: 4, (00010101)
 //42: 5, (00101010)
-//40: 6, (00100110)
-//26: 7, (00011010)
-//32: 8, (00010110)
+//26: 6, (00011010)
+//38: 7, (00100110)
+//22: 8, (00010110)
 
 type lineReader struct {
 	*os.File
 	currentDir.Close()
 
 //TODO: don't hardcode that, or make it able to grow
-	dirs := make([]string, 10)
+	dirs := make([]string, 15)
 	counter := 0
 	sort.SortStrings(names)
 	for _, v := range names {
 	//--------------------------------------------------------
 	// GtkComboBox
 	//--------------------------------------------------------
+	lastsignal := 0
+	configuration := 0
 	controls := gtk.HBox(false, 1)
 	var combotext *gtk.GtkLabel
 	var combobox *gtk.GtkComboBox
-	togglebutton := gtk.ToggleButtonWithLabel("On/Off")
+	togglebutton := gtk.ToggleButtonWithLabel("Start capture")
 	togglebutton.Connect("toggled", func() {
 		if togglebutton.GetActive() {
 			combotext.Hide()
 			combobox.Hide()
-			togglebutton.SetLabel("On")
+			togglebutton.SetLabel("Stop capture")
 		} else {
 			combotext.Show()
 			combobox.Show()
-			togglebutton.SetLabel("Off")
+			togglebutton.SetLabel("Start capture")
 		}
 	},
 		nil)
 			for _, v := range imgs.bufs {
 				framebox2.Add(v)
 			}
-			imgs.visible = imgs.bufs[0]
+			configuration = signaltoconf[lastsignal]
+			imgs.visible = imgs.bufs[configuration - 1]
+//			imgs.visible = imgs.bufs[0]
 			imgs.visible.Show()
 		}
 	}, nil)
 	// listen for signal from the other (i.e labview) program
 	//--------------------------------------------------------
 	go func() {
-		lastsignal := 0
-		configuration := 0
+		counter := 0
 		for {
 			signal := <-c
 			if togglebutton.GetActive() {
 					imgs.visible = imgs.bufs[configuration-1]
 					imgs.visible.Show()
 					lastsignal = signal
+					counter++
+					log.Stdoutf("counter: %d \n", counter)
 				}
 			}
 		}
 	for ;; {
 		key = int(math.Ceil(rand.Float64() * 11.0))
 		print(conftosig[key], "\n")
-		syscall.Sleep(1000000000)
+		syscall.Sleep(2000000000)
 	}
 }
 
-#!/usr/local/plan9/bin/rc
+#!/bin/sh
 
 cd $1
 mv $1-1.jpg $1.jpg
-../prep $1.jpg 8
+../prep $1.jpg 8 &&
 rm $1.jpg
 	return m
 }
 
+//note: -resize is -scale + some smoothing, so maybe we'll want -resize
 func degrade(inputfile string, counter int, width int, height int) os.Error {
 	suffixes := []string{".jpg", ".jpeg", ".png"}
 	var suffix string
 	}
 	outputfile := strings.Replace(inputfile, suffix, "-" + fmt.Sprint(counter) + suffix, 1)
 	tmpfile := "/tmp/foo" + suffix
-	w := width / counter
-	h := height / counter
+	w := width / (3 * counter)
+	h := height / (3 * counter)
 	geometry := fmt.Sprint(w) + "x" + fmt.Sprint(h)
 
 	if counter == 1 {
 
 	geometry = fmt.Sprint(width) + "x" + fmt.Sprint(height)
 	args[1] = tmpfile
-	args[2] = "-resize"
+	args[2] = "-scale"
 	args[3] = geometry
 	args[4] = outputfile
 	pid, err = os.ForkExec(args[0], args, os.Environ(), "", fds)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.