PROGRAM Arduino_Archimedes_Spiral; ////////////////////////////////////////////////////////////////////// // #sign:max: APSN21: 10.11.2013 21:39:44 // Purpose: Grabs outlook contacts out of, more items see below // // #path>ples\E:\maxbox\maxbox3\examples\ // // Lines of Code #locs:135 ////////////////////////////////////////////////////////////////////// Const TEXTOUT = 'hi world of code coverage with cover age'; //############################################################################ // Archimedes Spiral App mX4 Script Studio //############################################################################ //TODO: Button with stop event, change color and save bitmap as png //TODO: transfer the Algo to a LED Matrix on Arduino ex. I^2C Adafruit Shield!! {TYPE } var aform: TForm; FWait, switch: Boolean; FValueA: Float; FValueB: Float; ComPorts: TStrings; // // procedure stopClick(sender: TObject); begin writeln('archimedes demo stopped'); FWait:= true; end; procedure CreateAForm; //diaform:= CreateMessageDialog('my fast form perform',mtconfirmation, []); begin FValueA:= 3.0; FValueB:= 1.4; FWait:= false; aform:= CreateMessageDialog('Archimedes Spiral - Click to Stop or KeyPress',mtwarning, [mball, mbyes, mbhelp, mbok]); with aform do begin caption:= 'Archimedes Spiral Architect Demo'; setBounds(50,50,800,850) Formstyle:= fsStayontop; Color:= clRed; //1266; Canvas.Brush.Color:= clBlack; //clBlue; Canvas.Brush.Style:= bsSolid; Canvas.Pen.Color:= clWhite; onclick:= @stopclick; end; with TLabel.Create(self) do begin parent:= aform; SetBounds(305,30,400,70) font.size:= 34; font.style:= [fsItalic] font.color:= clyellow; caption:= 'Archimedes LED Spiral '; end; aform.show; end; procedure TApplication_PaintView(Canvas: TCanvas); var cx, cy, i: Integer; angle,x,y: Float; begin if FWait then Exit; FValueB:= FValueB + 0.001; //Canvas.FillStyle := 'rgba(0,0,99,0.08)'; if switch then // Clear background Canvas.FillRect(rect(0,90, aForm.Width, aForm.Height)); //Draw our framerate on the screen cx:= aForm.width div 2; cy:= aForm.Height div 2; // Canvas.BeginPath; for i:= 42 downto 0 do begin angle:= FValueB * i; x:= cx + (FValueA + FValueB * angle) * Cos(angle); y:= cy + (FValueA + FValueB * angle) * Sin(angle); if i = 42 then Canvas.MoveTo(round(x), round(y)) else Canvas.LineTo(round(x),round(y)); end; //Canvas.StrokeStyle := '#FFF'; end; function SplitToken(const Text: string; SplitChar: Char; var First, Last: string): Boolean; var SplitPos: Integer; begin Result:= False; SplitPos:= Pos(SplitChar, Text); if SplitPos = 0 then Exit; First:= Trim(Copy(Text, 1, SplitPos -1)); Last:= Trim(Copy(Text, SplitPos +1, Length(Text) -SplitPos)); Result:= (First <>'') and (Last <>''); end; Begin //Main // //TOutlookExport_Spy; Writeln(''); ComPorts:= TStringlist.Create; EnumComPorts(ComPorts); Writeln('Start COM Port Command of Arduino COM: '+ComPorts[0]); ComPorts.Free; // //ares:= TResolver.create; { with TResolver.create do begin //writeln(inttostr(GetHostByName(gethostname))); Free; end; } with TledForm.create(self) do begin caption:= 'Archimed Arduino LED Matrix Project'; label1.caption:= 'Archimed'; showmodal; Free; end; CreateAForm; repeat TApplication_PaintView(aform.canvas); switch:= NOT switch; //repaint each second Sleep(20); until isKeyPressed or FWait; END. unit uPSI_delphi_arduino_Unit1; { arduino tester } interface uses SysUtils ,Classes ,uPSComponent ,uPSRuntime ,uPSCompiler ; type (*----------------------------------------------------------------------------*) TPSImport_delphi_arduino_Unit1 = class(TPSPlugin) protected procedure CompileImport1(CompExec: TPSScript); override; procedure ExecImport1(CompExec: TPSScript; const ri: TPSRuntimeClassImporter); override; end; { compile-time registration functions } procedure SIRegister_TForm1(CL: TPSPascalCompiler); procedure SIRegister_delphi_arduino_Unit1(CL: TPSPascalCompiler); { run-time registration functions } procedure RIRegister_TForm1(CL: TPSRuntimeClassImporter); procedure RIRegister_delphi_arduino_Unit1(CL: TPSRuntimeClassImporter); procedure Register; implementation uses Windows ,Messages ,Variants ,Graphics ,Controls ,Forms ,Dialogs ,StdCtrls ,ComCtrls ,CPort ,CPortCtl ,Menus ,delphi_arduino_Unit1 ; procedure Register; begin RegisterComponents('Pascal Script', [TPSImport_delphi_arduino_Unit1]); end; (* === compile-time registration functions === *) (*----------------------------------------------------------------------------*) procedure SIRegister_TForm1(CL: TPSPascalCompiler); begin //with RegClassS(CL,'TForm', 'TForm1') do with CL.AddClassN(CL.FindClass('TForm'),'TledForm') do begin RegisterProperty('btn_connect', 'TButton', iptrw); RegisterProperty('ComPort1', 'TComPort', iptrw); RegisterProperty('StatusBar1', 'TStatusBar', iptrw); RegisterProperty('btn_Setup', 'TButton', iptrw); RegisterProperty('chk_led1', 'TCheckBox', iptrw); RegisterProperty('chk_led2', 'TCheckBox', iptrw); RegisterProperty('chk_led3', 'TCheckBox', iptrw); RegisterProperty('chk_led4', 'TCheckBox', iptrw); RegisterProperty('chk_led5', 'TCheckBox', iptrw); RegisterProperty('btn_loop', 'TButton', iptrw); RegisterProperty('Label1', 'TLabel', iptrw); RegisterProperty('Label2', 'TLabel', iptrw); RegisterProperty('Label3', 'TLabel', iptrw); RegisterProperty('Label4', 'TLabel', iptrw); RegisterProperty('Label5', 'TLabel', iptrw); RegisterProperty('Label6', 'TLabel', iptrw); RegisterProperty('Label7', 'TLabel', iptrw); RegisterProperty('Label8', 'TLabel', iptrw); RegisterProperty('Label9', 'TLabel', iptrw); RegisterProperty('Label10', 'TLabel', iptrw); RegisterProperty('Label11', 'TLabel', iptrw); RegisterProperty('Label12', 'TLabel', iptrw); RegisterMethod('Procedure btn_connectClick( Sender : TObject)'); RegisterMethod('Procedure btn_SetupClick( Sender : TObject)'); RegisterMethod('Procedure FormCreate( Sender : TObject)'); RegisterMethod('Procedure chk_led1Click( Sender : TObject)'); RegisterMethod('Procedure chk_led2Click( Sender : TObject)'); RegisterMethod('Procedure chk_led3Click( Sender : TObject)'); RegisterMethod('Procedure chk_led4Click( Sender : TObject)'); RegisterMethod('Procedure chk_led5Click( Sender : TObject)'); RegisterMethod('Procedure FormClose( Sender : TObject; var Action : TCloseAction)'); RegisterMethod('Procedure btn_loopClick( Sender : TObject)'); end; end; //############################################################################ // Archimedes Spiral App //############################################################################ unit ArchSpiralMain; interface uses w3system, w3components, w3ctrls, w3application, w3game, w3gameapp, w3polygons, w3inet, w3graphics; type TApplication = class(TW3CustomGameApplication) private FValueA: Float; FValueB: Float; FWait: Boolean; procedure HandleClick(Sender:TObject); protected procedure ApplicationStarting; override; procedure ApplicationClosing; override; procedure PaintView(Canvas: TW3Canvas); override; end; implementation //############################################################################ // TApplication //############################################################################ procedure TApplication.ApplicationStarting; begin inherited; FValueA := 3.0; FValueB := 1.4; GameView.OnClick := Self.HandleClick; // Initialize refresh interval, set this to 1 for optimal speed GameView.Delay := 10; // Start the redraw-cycle with framecounter active // Note: the framecounter impacts rendering speed. Disable // the framerate for maximum speed (false) GameView.StartSession(true); end; procedure TApplication.ApplicationClosing; begin GameView.EndSession; inherited; end; procedure TApplication.HandleClick(Sender: TObject); begin FWait := not FWait; end; // Note: In a real live game you would try to cache as much // info as you can. Typical tricks are: // 1: Only get the width/height when resized // 2: Pre-calculate strings, especially RGB/RGBA values // 3: Only redraw what has changed, avoid a full repaint // The code below is just to get you started procedure TApplication.PaintView(Canvas: TW3Canvas); var cx, cy: Integer; i: Integer; angle: Float; x, y: Float; begin if FWait then exit; FValueB := FValueB + 0.001; // Clear background Canvas.FillStyle := 'rgba(0,0,99,0.08)'; Canvas.FillRectF(0, 0, GameView.Width, GameView.Height); // Draw our framerate on the screen // Canvas.font := '10pt verdana'; // Canvas.FillStyle := 'rgb(255,255,255)'; // Canvas.FillTextF('FPS:' + IntToStr(GameView.FrameRate) + ' / ' + floatToStr(FbValue) ,10,20,MAX_INT); cx := GameView.width div 2; cy := GameView.Height div 2; Canvas.BeginPath; for i := 42 downto 0 do begin angle := FValueB * i; x := cx + (FValueA + FValueB * angle) * cos(angle); y := cy + (FValueA + FValueB * angle) * sin(angle); if i = 42 then Canvas.MoveToF(x, y) else Canvas.LineToF(x,y); end; Canvas.StrokeStyle := '#FFF'; Canvas.Stroke; end; end. More Items: aContactItem.Categories:='Kunde'; // neu aContactItem.FirstName:=KundeName1.AsString; aContactItem.LastName:=KundeName2.AsString; aContactItem.FileAs:=KundeSuchbegriff.AsString; aContactItem.CompanyName:=KundeSuchbegriff.AsString; aContactItem.CustomerID:=KundeKundenNr.AsString; aContactItem.Account:=KundeFibuNr.AsString; // neu aContactItem.Body:=KundeAnsprechpartner.AsString; aContactItem.BusinessAddressStreet:=KundeStrasse.AsString; aContactItem.BusinessAddressPostalCode:=KundePLZ.AsString; aContactItem.BusinessAddressPostOfficeBox:=KundePostfach.AsString; aContactItem.BusinessAddressCity:=KundeOrt.AsString; // aContactItem.BusinessAddressCountry:=KundeLand.AsString; // neu aContactItem.OrganizationalIDNumber:=KundeUStIdNr.AsString; // neu // aContactItem.GovernmentIDNumber:='' aContactItem.BusinessTelephoneNumber:=KundeTelefon1.AsString; aContactItem.BusinessFaxNumber:=KundeFax.AsString; aContactItem.MobileTelephoneNumber:=KundeTelefon2.AsString; aContactItem.Email1Address:=KundeEMail.AsString; aContactItem.WebPage:=KundeHomepage.AsString; aContactItem.Save; http://i1-win.softpedia-static.com/screenshots/maXbox_5.png?1381322021 RegisterMethod('Constructor Create(AOwner: TComponent)'); RegisterConstructor(@TJvMail.Create, 'Create'); RegisterMethod('Procedure Free'); RegisterMethod(@TJvMail.Destroy, 'Free'); ----app_template_loaded_code----