Пример #1
0
func test_2() {
	const pauseSec time.Duration = 5
	ansiterm.ClearPage()
	ansiterm.MoveToRC(9, 20)
	fmt.Printf("In a few seconds program will print 1000 X chars")
	ansiterm.MoveToRC(10, 20)
	fmt.Printf("This is slowed by forcing a 10 ms sleep per loop")
	pause(pauseSec)
	ansiterm.ClearPage()
	for i := 0; i < 1000; i++ {
		row := int(rand.Int31n(25))
		col := int(rand.Int31n(80))
		ansiterm.MoveToRC(row, col)
		time.Sleep(time.Duration(0.01 * float64(time.Second)))
		fmt.Printf("X")
	}
	pause(pauseSec)
	ansiterm.ClearPage()
	ansiterm.MoveToRC(9, 20)
	fmt.Printf("In a few seconds program will print 1000 X chars")
	ansiterm.MoveToRC(10, 20)
	fmt.Printf("using the same program at FULL speed - don't blink...")
	pause(pauseSec)
	ansiterm.ClearPage()
	for i := 0; i < 1000; i++ {
		row := int(rand.Int31n(25))
		col := int(rand.Int31n(80))
		ansiterm.MoveToRC(row, col)
		fmt.Printf("X")
	}
	pause(pauseSec)
	ansiterm.ClearPage()
}
Пример #2
0
func main() {
	ansiterm.ResetTerm(0)
	ansiterm.ClearPage()
	initFields()
	startSensors()
	runfor = 1
	done := time.After(time.Duration(runfor) * time.Minute)
	fmt.Printf("This demo will stop after %d minutes\n", runfor)

L1:
	for {
		select {
		case t := <-temp.Ch:
			temp.Show(fmt.Sprintf("%d", t))
		case t := <-clock.Ch:
			clock.Show(fmt.Sprintf("%d", t))
		case t := <-seekerrs.Ch:
			seekerrs.Show(fmt.Sprintf("%d", t))

		// note: label is required else it 'breaks' the select, not the for
		case _ = <-done:
			break L1
		}
	}
	if false {
		os.Exit(0)
	}
	ansiterm.ClearPage()
}
Пример #3
0
func main() {

	//test color/additional functions here
	ansiterm.ResetTerm(ansiterm.NORMAL)
	ansiterm.ClearPage()

	ansiterm.MoveToXY(10, 10)
	sleepOne()

	ansiterm.HideCursor()
	sleepOne()

	ansiterm.SetFGColor(5)
	fmt.Printf("TEST MOVE HIDDEN CURSOR / OUT IN PURPLE")
	sleepOne()

	ansiterm.MoveToXY(10, 12)
	ansiterm.SetColorBright()
	fmt.Printf("BRIGHT COLORS")
	sleepOne()

	ansiterm.MoveToXY(10, 14)
	ansiterm.SetColorNormal()
	fmt.Printf("NORMAL COLORS AGAIN")
	sleepOne()

	ansiterm.ShowCursor()
	sleepOne()

	ansiterm.ResetTerm(ansiterm.NORMAL)
}
Пример #4
0
func test_1() {
	const pauseSec = 5
	fmt.Printf("Test_001\n")
	ansiterm.ResetTerm(ansiterm.NORMAL)
	defer ansiterm.ClearPage()

	ansiterm.ClearPage()
	Headline("this headline should be on row 1")
	StatusUpdate("one")
	pause(pauseSec)

	ansiterm.MoveToRC(3, 1)
	Headline("erase page and print Test on third line")
	StatusUpdate("two")
	fmt.Printf("Test\r")
	pause(pauseSec)

	Headline("erase first 3 chars on third line")
	StatusUpdate("three")
	ansiterm.Erase(3)
	pause(pauseSec)

	Headline("print Best on third line")
	StatusUpdate("four")
	fmt.Printf("Best\r")
	pause(pauseSec)

	Headline("erase entire third line")
	StatusUpdate("five")
	ansiterm.ClearLine()
	pause(pauseSec)

	Headline("print Rest on third line")
	StatusUpdate("six")
	fmt.Printf("Rest\r")
	pause(pauseSec)

	Headline("move to 10,10 and print a msg")
	StatusUpdate("seven")
	ansiterm.MoveToRC(10, 10)
	fmt.Printf("x at 10,10")
	pause(pauseSec)
}
Пример #5
0
func main() {
	flag.Parse()
	if flag.NArg() > 0 {
		for i := 0; i < flag.NArg(); i++ {
			fmt.Printf("args(%v)\n", flag.Arg(i))
		}
	}
	_ = rand.Int31n(10)
	ansiterm.ClearPage()
	test_1()
}
Пример #6
0
func main() {
	ansiterm.ResetTerm(0)
	ansiterm.ClearPage()
	//	ansiterm.MoveToRC(13,13)
	//	ansiterm.QueryPosn()  hangs
	//	os.Exit(0)
	ansiterm.HideCursor()
	defer ansiterm.ShowCursor()
	setupForm()
	startSensors()
	runfor = 1
	prog := make(chan int)
	// prompt, row,col,barWidth,listen chan, alldone
	go progressBar("Progress: ", 20, 20, 50, prog, 60*runfor)
	done := time.After(time.Duration(runfor) * time.Minute) // set up a timeout channel
	fmt.Printf("This demo will stop after %d minute(s)\n", runfor)
	time.Sleep(2 * time.Second)
L1:
	for {
		select {
		case t := <-sensors[0]:
			g_Form.UpdateMsg("temp", fmt.Sprintf("%5d", t))
		case t := <-sensors[1]:
			g_Form.UpdateMsg("seekerr", fmt.Sprintf("%5d", t))
		case t := <-sensors[2]:
			g_Form.UpdateMsg("time", fmt.Sprintf("%5d", t))
			g_Form.UpdateMsg("progress", fmt.Sprintf("%5d", t))
			prog <- t
			g_Form.Draw()
		// note: label is required else it 'breaks' the select, not the for
		case _ = <-done:
			break L1
		}
	}
	if true { // optional wrapup stats
		ansiterm.ClearPage()
		ansiterm.ResetTerm(ansiterm.NORMAL)
		fmt.Printf("<done>\n")
	}
}