Example #1
0
func blink(led, d int) {
	for {
		LED.SetBit(led)
		delay.Millisec(d)
		LED.ClearBit(led)
		delay.Millisec(d)
	}
}
Example #2
0
func blink(led, d int, max, inc float32) {
	for inc < max {
		LED.SetBit(led)
		delay.Millisec(d)
		LED.ClearBit(led)
		delay.Millisec(d)
		// Use floating point calculations to test STMF4 FPU context switching.
		inc *= inc
	}
}
Example #3
0
func main() {
	for {
		LED.ClearBit(Blue)
		LED.SetBit(Green)
		delay.Millisec(1000)

		LED.ClearBit(Green)
		LED.SetBit(Blue)
		delay.Millisec(1000)
	}
}
Example #4
0
func main() {
	for {
		LED.ClearBit(Green)
		LED.SetBit(Orange)
		delay.Millisec(500)

		LED.ClearBit(Orange)
		LED.SetBit(Red)
		delay.Millisec(500)

		LED.ClearBit(Red)
		LED.SetBit(Blue)
		delay.Millisec(500)

		LED.ClearBit(Blue)
		LED.SetBit(Green)
		delay.Millisec(500)
	}
}
Example #5
0
func toggle(m1, m2 *sync.Mutex) {
	leds := []int{Red, Orange, Blue}
	i := 0
	for {
		m1.Lock()
		m2.Unlock()
		LED.ClearBit(leds[i])
		i = (i + 1) % len(leds)
		LED.SetBit(leds[i])
		delay.Millisec(100)
	}
}
Example #6
0
func main() {
	for {
		go blink(Green, 100, 110, 1.0001)
		go blink(Orange, 230, 120, 1.0001)
		go blink(Red, 350, 130, 1.0001)
		blink(Blue, 500, 100, 1.0001)
		delay.Millisec(250)
		// BUG: In real application you schould ensure that all gorutines
		// finished before next loop. In this case Blue LED blinks longest
		// so this example works.
	}
}
Example #7
0
func toggle(led int) {
	LED.SetBit(led)
	delay.Millisec(500)
	LED.ClearBit(led)
	delay.Millisec(500)
}
Example #8
0
func toggle(led, d int) {
	LED.SetBit(led)
	delay.Millisec(d)
	LED.ClearBit(led)
	delay.Millisec(d)
}