Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.76 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Threading;
  4. using Microsoft.SPOT;
  5. using Microsoft.SPOT.Presentation;
  6. using Microsoft.SPOT.Presentation.Controls;
  7. using Microsoft.SPOT.Presentation.Media;
  8. using Microsoft.SPOT.Presentation.Shapes;
  9. using Microsoft.SPOT.Touch;
  10.  
  11. using Gadgeteer.Networking;
  12. using GT = Gadgeteer;
  13. using GTM = Gadgeteer.Modules;
  14. using Gadgeteer.Modules.GHIElectronics;
  15.  
  16. namespace GadgeteerApp4
  17. {
  18. public partial class Program
  19. {
  20. #region Programos sablonas
  21. #region kintamuju aprasymas
  22. private Boolean timerPaleistas = false;
  23. private GT.Timer timer = new GT.Timer(1000);
  24. private int minutes = 0;
  25. private int sekundes = 0;
  26. private Font font = Resources.GetFont(Resources.FontResources.consolas_72);
  27. private Font font2 = Resources.GetFont(Resources.FontResources.consolas_24);
  28. private Font font3 = Resources.GetFont(Resources.FontResources.Arial_18);
  29. private Window window;
  30. private Canvas canvas;
  31. private Text antraste;
  32. private Text laikas;
  33. private Image paleistiStabdyti;
  34. private Image atkurti;
  35. private int row = 1;
  36. private int nr = 1;
  37. #endregion
  38. void ProgramStarted()
  39. {
  40. /*******************************************************************************************
  41. Modules added in the Program.gadgeteer designer view are used by typing
  42. their name followed by a period, e.g. button. or camera.
  43.  
  44. Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.:
  45. button.ButtonPressed +=<tab><tab>
  46.  
  47. If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.:
  48. GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
  49. timer.Tick +=<tab><tab>
  50. timer.Start();
  51. *******************************************************************************************/
  52.  
  53.  
  54. // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
  55. Debug.Print("Program Started");
  56. timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);
  57. displayT43.SimpleGraphics.DisplayTextInRectangle("Akselerometras", 20, 1, 300, 17, GT.Color.Magenta, Resources.GetFont(Resources.FontResources.small));
  58. timer.Start();
  59. }
  60. void timer_Tick(GT.Timer timer)
  61. {
  62. var data = accelG248.GetAcceleration();
  63. string tekstas = nr.ToString() + ": x = " + data.X.ToString() + ", y = " + data.Y.ToString() + ", z = " + data.Z.ToString();
  64. if (row <= 10)
  65. displayT43.SimpleGraphics.DisplayRectangle(GT.Color.Blue, 2, GT.Color.Black, 20, 20 * row, 300, 20);
  66. displayT43.SimpleGraphics.DisplayTextInRectangle(tekstas, 25, 20 * row + 5, 300, 50, GT.Color.Orange, Resources.GetFont(Resources.FontResources.small));
  67. if (row == 10)
  68. row = 1;
  69. else row++;
  70. nr++;
  71. }
  72. void SetupWindow()
  73. {
  74. #region Lango elementu konfiguravimas
  75.  
  76.  
  77.  
  78.  
  79. #endregion
  80. #endregion
  81. //Veiksmas 1
  82. button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);
  83. //Veiksmas 2
  84. //Veiksmas 3
  85. //led7C.SetColor(LED7C.Color.Red);
  86.  
  87. }
  88.  
  89. void button_ButtonPressed(Button sender, Button.ButtonState state)
  90. {
  91. timer.Start();
  92. }
  93.  
  94. void paleistiStabdyti_TouchDown(object sender, Microsoft.SPOT.Input.TouchEventArgs e)
  95. {
  96. if (timerPaleistas)
  97. {
  98. this.timerPaleistas = false;
  99. timer.Stop();
  100. led7C.SetColor(LED7C.Color.Red);
  101. led7R.TurnAllLedsOff();
  102. }
  103. else
  104. {
  105. this.timerPaleistas = true;
  106. timer.Start();
  107. led7C.SetColor(LED7C.Color.Green);
  108. led7R.Animate(250, true, true, false);
  109. }
  110. }
  111.  
  112. void atkurti_TouchDown(object sender, Microsoft.SPOT.Input.TouchEventArgs e)
  113. {
  114. sekundes = 0;
  115. minutes = 0;
  116. laikas.TextContent = "00:00";
  117. if (timerPaleistas)
  118. {
  119. led7C.SetColor(LED7C.Color.Green);
  120. led7R.Animate(250, true, true, false);
  121. }
  122. else
  123. {
  124. led7C.SetColor(LED7C.Color.Red);
  125. led7R.Animate(250, true, false, false);
  126. }
  127.  
  128. }
  129. }
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement