Get data from program to feed gauges

i am really new to programming, i can just about remember the blink sketch, mechanical things are more my cup of tea.

I play on a bus simulator called OMSI, it's been written to be sort of semi open source, you can modify the buses, make new ones, maps and so on, and also you can write plugins to do almost anything,

The test plugin that comes with the sim makes a new window whick shows the speed in figures and on a sort of simple analoge speedo, as well as a button and lever to play with.

below is the code given for the test plug in, written in delphi i believe.

library Test;

uses
  SysUtils,
  Dialogs,
  Classes,
  TestU in 'TestU.pas' {Form1};

{$R *.res}

procedure Start( AOwner: TComponent ); stdcall;
begin
        form1 := TForm1.Create( AOwner );
        form1.Show;
end;

procedure Finalize; stdcall;
begin
        form1.Free;
end;

procedure AccessVariable( varindex: word; var value: single; var write: boolean ); stdcall;
begin
        case varindex of
                0:
                begin
                        form1.Label2.Caption := floattostrF( value, ffFixed, 5, 1 ) + ' km/h';
                        form1.Gauge1.Progress := round( value );
                        write := false;                        
                end;
                1:
                begin
                        value := form1.TrackBar1.Position / 30;
                        write := true;
                end;
        end;
end;

procedure AccessTrigger( triggerindex: word; var active: boolean ); stdcall;
begin
        case triggerindex of
                0:
                begin
                        active := form1.button1_pressed;
                end;
        end;
end;

exports
        AccessVariable,
        AccessTrigger,        
        Start,
        Finalize;


begin
end.

unfortunately i can't figure much of that out, but i am trying,

Basicaly, i want to take that code, and instead of have it display the speed in a window on the screen, send the speed data to the arduino, which can then display the speed on a gauge, the gauge needs to be fed with a 50 to 350Hz 50% duty cycle signal, 50Hz is zero, 383Hz is the end of the numbers, 433Hz is against the end stop, and 218Hz is needle pointing straight up.

How do i do what i want?? i.e. change the plugin code to send the speedo data to the arduino, then have the arduino modify it to output from 50 to 433Hz signals depending on the speed data,

i have got processing and have played with the firmata sketch slightly, i believe that may be a better way to have the computer talk to the arduino for this situation???

Compiling that code produces a DLL named “Test” with four entry points: Start, Finalize, AccessVariable, and AccessTrigger. The parameter to Start implies that the “bus” has to be built using Delphi.

i have got processing and have played with the firmata sketch slightly, i believe that may be a better way to have the computer talk to the arduino for this situation???

Given your skill-level that is very likely true. However, I believe Processing is not capable of producing a DLL.

I suggest you start by developing the data exchange between the PC and the Arduino. This forum is rife with examples and helpful information.

oh yes, the whole simulator is written in delphi, but to me it may as well be written in chinese for how much i an unerstand :)

The page i got that code from is : http://www.omnibussimulator.de/omsiwiki/index.php?title=Plug-In_Interface

i'll have a look through the forum to see if i can find what i need, tho i dont even know what kind of data needs to be exchanged,

Whoa. When you wrote "bus" you really meant "bus". I thought you were referring to "data bus" or something more abstract. So you're building a speedometer for a bus simulator.

How is speed data presented to the plugin?

sorry mate, yup i ment a bus driving simulator... ding ding tickets please kinda thing :)

This is where i am stuck, i dont know how the speed data is presented, or any data that comes out of this simulator is presented really,

All i know at the moment is that once i enable the test .dll by renaming one of the files to an .opl file, when i start omsi, a window pops up and it displays the vehicle speed, a slider that moves the heating temp lever in the bus and a button clicked with the mouse operates one of the door buttons.

i was hoping it could be something simple like modifying the .dll so that instead of it opening a window to display the data in, it sends the data somewhere that i can pick up with the arduino and send to the gauge,

i imagine the speed output is just numbers, i do know most sims output meters per second, so i need to apply a little maths to convert it to kph.. or mph, or anything, right now i'd be over the moon if i could find a way to get the needle of my real gauge to move with the simulated needle in the game, even if it's not calibrated at all... figure that later.

gazz:
This is where i am stuck, i dont know how the speed data is presented, or any data that comes out of this simulator is presented really,

Looks like speed is passed to the DLL through AccessVariable…

procedure AccessVariable( varindex: word; var value: single; var write: boolean ); stdcall;
begin
case varindex of
0:
begin
form1.Label2.Caption := floattostrF( value, ffFixed, 5, 1 ) + ’ km/h’;
form1.Gauge1.Progress := round( value );
{ Replace the two lines of code above with code that sends speed data to the Arduino }
write := false;
end;

i was hoping it could be something simple like modifying the .dll so that instead of it opening a window to display the data in, it sends the data somewhere that i can pick up with the arduino and send to the gauge,

Looks like it. See the highlighted bits above.

i imagine the speed output is just numbers, i do know most sims output meters per second, so i need to apply a little maths to convert it to kph… or mph, or anything,

I strongly suggest converting in the Arduino. That way you can easily replace the gauge with something completely different and the DLL codes stays the same.