uimicrobit.pas 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. unit uiMicrobit;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
  6. Spin, ComCtrls, uMicrobit;
  7. type
  8. { TfMicrobit }
  9. TfMicrobit = class(TForm)
  10. accx: TSpinEdit;
  11. snd: TSpinEdit;
  12. accy: TSpinEdit;
  13. light: TSpinEdit;
  14. cbGesture: TComboBox;
  15. GBInput: TGroupBox;
  16. GroupBox1: TGroupBox;
  17. Label1: TLabel;
  18. Label16: TLabel;
  19. Label17: TLabel;
  20. Label18: TLabel;
  21. Label2: TLabel;
  22. accz: TSpinEdit;
  23. compass: TSpinEdit;
  24. Label3: TLabel;
  25. Label4: TLabel;
  26. Shape1: TShape;
  27. Shape10: TShape;
  28. Shape11: TShape;
  29. Shape12: TShape;
  30. Shape13: TShape;
  31. Shape14: TShape;
  32. Shape15: TShape;
  33. Shape16: TShape;
  34. Shape17: TShape;
  35. Shape18: TShape;
  36. Shape19: TShape;
  37. Shape2: TShape;
  38. Shape20: TShape;
  39. Shape21: TShape;
  40. Shape22: TShape;
  41. Shape23: TShape;
  42. Shape24: TShape;
  43. Shape25: TShape;
  44. Shape3: TShape;
  45. Shape4: TShape;
  46. Shape5: TShape;
  47. Shape6: TShape;
  48. Shape7: TShape;
  49. Shape8: TShape;
  50. Shape9: TShape;
  51. tbLogo: TToggleBox;
  52. procedure FormActivate(Sender: TObject);
  53. private
  54. public
  55. procedure setImage(Display: TMBImage);
  56. procedure setPixel(x, y: integer; Value: boolean);
  57. end;
  58. var
  59. fMicrobit: TfMicrobit;
  60. implementation
  61. {$R *.lfm}
  62. { TfMicrobit }
  63. procedure TfMicrobit.FormActivate(Sender: TObject);
  64. var
  65. x, y: integer;
  66. begin
  67. for x := 0 to 4 do
  68. for y := 0 to 4 do
  69. setPixel(x, y, False);
  70. end;
  71. procedure TfMicrobit.setImage(Display: TMBImage);
  72. var
  73. x, y, pos: integer;
  74. Value: boolean;
  75. begin
  76. for x := 0 to 4 do
  77. for y := 0 to 4 do
  78. begin
  79. Value := Display[x, y] > 0;
  80. setPixel(x, y, Value);
  81. end;
  82. end;
  83. procedure TfMicrobit.setPixel(x, y: integer; Value: boolean);
  84. var
  85. pos: integer;
  86. begin
  87. pos := (x * 5) + y;
  88. case pos of
  89. 0: Shape1.Visible := Value;
  90. 1: Shape2.Visible := Value;
  91. 2: Shape3.Visible := Value;
  92. 3: Shape4.Visible := Value;
  93. 4: Shape5.Visible := Value;
  94. 5: Shape6.Visible := Value;
  95. 6: Shape7.Visible := Value;
  96. 7: Shape8.Visible := Value;
  97. 8: Shape9.Visible := Value;
  98. 9: Shape10.Visible := Value;
  99. 10: Shape11.Visible := Value;
  100. 11: Shape12.Visible := Value;
  101. 12: Shape13.Visible := Value;
  102. 13: Shape14.Visible := Value;
  103. 14: Shape15.Visible := Value;
  104. 15: Shape16.Visible := Value;
  105. 16: Shape17.Visible := Value;
  106. 17: Shape18.Visible := Value;
  107. 18: Shape19.Visible := Value;
  108. 19: Shape20.Visible := Value;
  109. 20: Shape21.Visible := Value;
  110. 21: Shape22.Visible := Value;
  111. 22: Shape23.Visible := Value;
  112. 23: Shape24.Visible := Value;
  113. 24: Shape25.Visible := Value;
  114. end;
  115. end;
  116. end.