unit uiMicrobit; {$mode objfpc}{$H+} interface uses Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, Spin, ComCtrls, uMicrobit; type { TfMicrobit } TfMicrobit = class(TForm) accx: TSpinEdit; snd: TSpinEdit; accy: TSpinEdit; light: TSpinEdit; cbGesture: TComboBox; GBInput: TGroupBox; GroupBox1: TGroupBox; Label1: TLabel; Label16: TLabel; Label17: TLabel; Label18: TLabel; Label2: TLabel; accz: TSpinEdit; compass: TSpinEdit; Label3: TLabel; Label4: TLabel; Shape1: TShape; Shape10: TShape; Shape11: TShape; Shape12: TShape; Shape13: TShape; Shape14: TShape; Shape15: TShape; Shape16: TShape; Shape17: TShape; Shape18: TShape; Shape19: TShape; Shape2: TShape; Shape20: TShape; Shape21: TShape; Shape22: TShape; Shape23: TShape; Shape24: TShape; Shape25: TShape; Shape3: TShape; Shape4: TShape; Shape5: TShape; Shape6: TShape; Shape7: TShape; Shape8: TShape; Shape9: TShape; tbLogo: TToggleBox; procedure FormActivate(Sender: TObject); private public procedure setImage(Display: TMBImage); procedure setPixel(x, y: integer; Value: boolean); end; var fMicrobit: TfMicrobit; implementation {$R *.lfm} { TfMicrobit } procedure TfMicrobit.FormActivate(Sender: TObject); var x, y: integer; begin for x := 0 to 4 do for y := 0 to 4 do setPixel(x, y, False); end; procedure TfMicrobit.setImage(Display: TMBImage); var x, y, pos: integer; Value: boolean; begin for x := 0 to 4 do for y := 0 to 4 do begin Value := Display[x, y] > 0; setPixel(x, y, Value); end; end; procedure TfMicrobit.setPixel(x, y: integer; Value: boolean); var pos: integer; begin pos := (x * 5) + y; case pos of 0: Shape1.Visible := Value; 1: Shape2.Visible := Value; 2: Shape3.Visible := Value; 3: Shape4.Visible := Value; 4: Shape5.Visible := Value; 5: Shape6.Visible := Value; 6: Shape7.Visible := Value; 7: Shape8.Visible := Value; 8: Shape9.Visible := Value; 9: Shape10.Visible := Value; 10: Shape11.Visible := Value; 11: Shape12.Visible := Value; 12: Shape13.Visible := Value; 13: Shape14.Visible := Value; 14: Shape15.Visible := Value; 15: Shape16.Visible := Value; 16: Shape17.Visible := Value; 17: Shape18.Visible := Value; 18: Shape19.Visible := Value; 19: Shape20.Visible := Value; 20: Shape21.Visible := Value; 21: Shape22.Visible := Value; 22: Shape23.Visible := Value; 23: Shape24.Visible := Value; 24: Shape25.Visible := Value; end; end; end.