Quantcast
Channel: Themen - Paules-PC-Forum.de
Viewing all articles
Browse latest Browse all 42347

Timer verfeinern....

$
0
0
Hallo, guten Tag.

Ich habe in meinem Programm einen Timer eingebaut der regelmäßig eine Proc ausführt um Daten von einem Roboter abzufragen (Hindernissensor) und in einer Pic darstellt. Es funktioniert auch soweit. Nur wenn ich ein Button drücke , kommt der Buttondruck nicht beim ersten mal , sondern ich muss mehrmals drauf drücken damit eine Reaktion kommt. Es wirkt sich aus, wenn der Roboter sofort anhalten soll, es kommt mit verzögerung.

Wie kann man bitte den Timer verfeinern? Oder gibt es noch eine andere Weise um eine Proc Regelmäßig abzufragen?

Danke.
Gruss

Quellcode

  1. $MAKE CLE
  2. declare url$,urlpart$
  3. declare b_vor&,b_zur&
  4. declare b_links&,b_hlinks&,b_mitte&,b_hrechts&,b_rechts&
  5. declare b_v0&,b_v1&,b_v2&
  6. declare b_ser0&,b_ser1&,b_sharp&,b_ton&
  7. declare b_cls&
  8. declare ende&,test&,win&
  9. Window 20,20-400,400
  10. win&=create("window",%HWnd,"test",420,20,300,420)
  11. SetTimer 100
  12. b_vor& = Create("Button",win&,"vor", 10, 20, 80, 24)
  13. b_zur& = Create("Button",win&,"zurück", 10, 45, 80, 24)
  14. b_links& = Create("Button",win&,"links", 10, 70, 80, 24)
  15. b_hlinks& = Create("Button",win&,"hlinks", 10, 95, 80, 24)
  16. b_mitte& = Create("Button",win&,"mitte", 10, 120, 80, 24)
  17. b_hrechts& = Create("Button",win&,"hrechts", 10, 145, 80, 24)
  18. b_rechts& = Create("Button",win&,"rechts", 10, 170, 80, 24)
  19. b_v0& = Create("Button",win&,"v0", 10, 195, 80, 24)
  20. b_v1& = Create("Button",win&,"v1", 10, 220, 80, 24)
  21. b_v2& = Create("Button",win&,"v2", 10, 245, 80, 24)
  22. b_ser0& = Create("Button",win&,"ser0", 10, 270, 80, 24)
  23. b_ser1& = Create("Button",win&,"ser1", 10, 295, 80, 24)
  24. b_sharp& = Create("Button",win&,"sharp", 10, 320, 80, 24)
  25. b_ton& = Create("Button",win&,"ton", 10, 345, 80, 24)
  26. b_cls& = Create("Button",win&,"cls", 220, 20, 40, 24)
  27. ende&=1
  28. While ende&
  29. WaitInput
  30. Case %wmTimer : TimerProc
  31. If Clicked(b_vor&)
  32. urlpart$="vor"
  33. test&=1
  34. EndIf
  35. If Clicked(b_zur&)
  36. urlpart$="zur"
  37. test&=1
  38. EndIf
  39. If Clicked(b_links&)
  40. urlpart$="links"
  41. test&=1
  42. EndIf
  43. If Clicked(b_hlinks&)
  44. urlpart$="hlinks"
  45. test&=1
  46. EndIf
  47. If Clicked(b_mitte&)
  48. urlpart$="mitte"
  49. test&=1
  50. EndIf
  51. If Clicked(b_hrechts&)
  52. urlpart$="hrechts"
  53. test&=1
  54. EndIf
  55. If Clicked(b_rechts&)
  56. urlpart$="rechts"
  57. test&=1
  58. EndIf
  59. If Clicked(b_v0&)
  60. urlpart$="v0"
  61. test&=1
  62. EndIf
  63. If Clicked(b_v1&)
  64. urlpart$="v1"
  65. test&=1
  66. EndIf
  67. If Clicked(b_v2&)
  68. urlpart$="v2"
  69. test&=1
  70. EndIf
  71. If Clicked(b_ser0&)
  72. urlpart$="ser0"
  73. test&=1
  74. EndIf
  75. If Clicked(b_ser1&)
  76. urlpart$="ser1"
  77. test&=1
  78. EndIf
  79. If Clicked(b_sharp&)
  80. urlpart$="sharp"
  81. test&=1
  82. EndIf
  83. If Clicked(b_ton&)
  84. urlpart$="ton"
  85. test&=1
  86. EndIf
  87. If Clicked(b_cls&)
  88. leere
  89. EndIf
  90. endwhile
  91. killtimer
  92. end
  93. proc leere
  94. cls
  95. endproc
  96. proc TimerProc
  97. if test&=1
  98. downloadfile("http://192.168.2.101/?pin="+urlpart$)
  99. test&=0
  100. else
  101. downloadfile("http://192.168.2.101/?pin=leer")
  102. endif
  103. while %Loading
  104. waitinput 100
  105. endwhile
  106. print str$(ord($download))
  107. endproc
Alles anzeigen

Viewing all articles
Browse latest Browse all 42347