Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Threading;
- using Microsoft.SPOT;
- using Microsoft.SPOT.Presentation;
- using Microsoft.SPOT.Presentation.Controls;
- using Microsoft.SPOT.Presentation.Media;
- using Microsoft.SPOT.Presentation.Shapes;
- using Microsoft.SPOT.Touch;
- using Gadgeteer.Networking;
- using GT = Gadgeteer;
- using GTM = Gadgeteer.Modules;
- using Gadgeteer.Modules.GHIElectronics;
- namespace GadgeteerApp4
- {
- public partial class Program
- {
- #region Programos sablonas
- #region kintamuju aprasymas
- private Boolean timerPaleistas = false;
- private GT.Timer timer = new GT.Timer(1000);
- private int minutes = 0;
- private int sekundes = 0;
- private Font font = Resources.GetFont(Resources.FontResources.consolas_72);
- private Font font2 = Resources.GetFont(Resources.FontResources.consolas_24);
- private Font font3 = Resources.GetFont(Resources.FontResources.Arial_18);
- private Window window;
- private Canvas canvas;
- private Text antraste;
- private Text laikas;
- private Image paleistiStabdyti;
- private Image atkurti;
- private int row = 1;
- private int nr = 1;
- #endregion
- void ProgramStarted()
- {
- /*******************************************************************************************
- Modules added in the Program.gadgeteer designer view are used by typing
- their name followed by a period, e.g. button. or camera.
- Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.:
- button.ButtonPressed +=<tab><tab>
- If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.:
- GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
- timer.Tick +=<tab><tab>
- timer.Start();
- *******************************************************************************************/
- // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
- Debug.Print("Program Started");
- timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);
- displayT43.SimpleGraphics.DisplayTextInRectangle("Akselerometras", 20, 1, 300, 17, GT.Color.Magenta, Resources.GetFont(Resources.FontResources.small));
- timer.Start();
- }
- void timer_Tick(GT.Timer timer)
- {
- var data = accelG248.GetAcceleration();
- string tekstas = nr.ToString() + ": x = " + data.X.ToString() + ", y = " + data.Y.ToString() + ", z = " + data.Z.ToString();
- if (row <= 10)
- displayT43.SimpleGraphics.DisplayRectangle(GT.Color.Blue, 2, GT.Color.Black, 20, 20 * row, 300, 20);
- displayT43.SimpleGraphics.DisplayTextInRectangle(tekstas, 25, 20 * row + 5, 300, 50, GT.Color.Orange, Resources.GetFont(Resources.FontResources.small));
- if (row == 10)
- row = 1;
- else row++;
- nr++;
- }
- void SetupWindow()
- {
- #region Lango elementu konfiguravimas
- #endregion
- #endregion
- //Veiksmas 1
- button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);
- //Veiksmas 2
- //Veiksmas 3
- //led7C.SetColor(LED7C.Color.Red);
- }
- void button_ButtonPressed(Button sender, Button.ButtonState state)
- {
- timer.Start();
- }
- void paleistiStabdyti_TouchDown(object sender, Microsoft.SPOT.Input.TouchEventArgs e)
- {
- if (timerPaleistas)
- {
- this.timerPaleistas = false;
- timer.Stop();
- led7C.SetColor(LED7C.Color.Red);
- led7R.TurnAllLedsOff();
- }
- else
- {
- this.timerPaleistas = true;
- timer.Start();
- led7C.SetColor(LED7C.Color.Green);
- led7R.Animate(250, true, true, false);
- }
- }
- void atkurti_TouchDown(object sender, Microsoft.SPOT.Input.TouchEventArgs e)
- {
- sekundes = 0;
- minutes = 0;
- laikas.TextContent = "00:00";
- if (timerPaleistas)
- {
- led7C.SetColor(LED7C.Color.Green);
- led7R.Animate(250, true, true, false);
- }
- else
- {
- led7C.SetColor(LED7C.Color.Red);
- led7R.Animate(250, true, false, false);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement