From 745b5dfb81ff1dde9e24116f415592206fa07bd0 Mon Sep 17 00:00:00 2001 From: Ron Evans Date: Thu, 18 Apr 2019 19:03:13 +0200 Subject: [PATCH] examples: remove colorlamp example that is better suited for the TinyGo Zoo (and already in it) Signed-off-by: Ron Evans --- src/examples/colorlamp/colorlamp.go | 79 ----------------------------- 1 file changed, 79 deletions(-) delete mode 100644 src/examples/colorlamp/colorlamp.go diff --git a/src/examples/colorlamp/colorlamp.go b/src/examples/colorlamp/colorlamp.go deleted file mode 100644 index 442d352d..00000000 --- a/src/examples/colorlamp/colorlamp.go +++ /dev/null @@ -1,79 +0,0 @@ -// This program runs on an Arduino that has the following four devices connected: -// - Button connected to D2 -// - Rotary analog dial connected to A0 -// - RGB LED connected to D3, D5, and D6 used as PWM pins -// - BlinkM I2C RGB LED -// -// Pushing the button switches which color is selected. -// Rotating the dial changes the value for the currently selected color. -// Changing the color value updates the color displayed on both the -// PWM-controlled RGB LED and the I2C-controlled BlinkM. -package main - -import ( - "machine" - "time" -) - -const ( - buttonPin = 2 - redPin = 3 - greenPin = 5 - bluePin = 6 - - red = 0 - green = 1 - blue = 2 -) - -func main() { - machine.InitADC() - machine.InitPWM() - machine.I2C0.Configure(machine.I2CConfig{}) - - // Init BlinkM - machine.I2C0.WriteTo(0x09, []byte("o")) - - button := machine.GPIO{buttonPin} - button.Configure(machine.GPIOConfig{Mode: machine.GPIO_INPUT}) - - dial := machine.ADC{machine.ADC0} - dial.Configure() - - redLED := machine.PWM{redPin} - redLED.Configure() - - greenLED := machine.PWM{greenPin} - greenLED.Configure() - - blueLED := machine.PWM{bluePin} - blueLED.Configure() - - selectedColor := red - colors := []uint16{0, 0, 0} - - for { - // If we pushed the button, switch active color. - if !button.Get() { - if selectedColor == blue { - selectedColor = red - } else { - selectedColor++ - } - } - - // Change the intensity for the currently selected color based on the dial setting. - colors[selectedColor] = (dial.Get()) - - // Update the RGB LED. - redLED.Set(colors[red]) - greenLED.Set(colors[green]) - blueLED.Set(colors[blue]) - - // Update the BlinkM. - machine.I2C0.WriteTo(0x09, []byte("n")) - machine.I2C0.WriteTo(0x09, []byte{byte(colors[red] >> 8), byte(colors[green] >> 8), byte(colors[blue] >> 8)}) - - time.Sleep(time.Millisecond * 100) - } -}