Jup, gut daß ich dir Helfen konnte!
Ja klar kann man den inp32/outp32 befehl auch in einer konsolen anwendung verwenden. So wird es auch in dem beispiel programm erklärt.
Ich habe mir dann daraus ein kleines Tool erstellt mit dem ich die 8 Datenleitungen über eine grafische oberfläche ansteuern kann erstellt. Dazu kommen ein paar Lauflichteffekte in verschiedenen unter modis!
Bild im anhang!
Da aber die Konsolenprogrammierung ein wenig von der der grafischen Oberfläche abweicht kann man das Programm nicht einfach übernehmen.
Aber hier als beispiel:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Project1.h"
#include <stdio.h>
#include <conio.h>
#include <windows.h>
#include <math.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
#define port 0x378
int y;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Timer1->Enabled = true;
Timer1->Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1(TObject *Sender)
{
if (y == 0) { y = y + 0x01; goto end;}
if (y == 1) { y = y + 0x02; goto end;}
if (y == 3) { y = y + 0x04; goto end;}
if (y == 7) { y = y + 0x08; goto end;}
if (y == 15) { y = y + 0x10; goto end;}
if (y == 31) { y = y + 0x20; goto end;}
if (y == 63) { y = y + 0x40; goto end;}
if (y == 127) { y = y + 0x80; goto end;}
if (y == 255) { y = y - 0x01; goto end;}
if (y == 254) { y = y - 0x02; goto end;}
if (y == 252) { y = y - 0x04; goto end;}
if (y == 24{ y = y - 0x08; goto end;}
if (y == 240) { y = y - 0x10; goto end;}
if (y == 224) { y = y - 0x20; goto end;}
if (y == 192) { y = y - 0x40; goto end;}
if (y == 12{ y = y - 0x80; goto end;}
end:
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer2(TObject *Sender)
{
(oup32)(port, y);
Label1->Caption = "0x" + IntToHex( y, 2);
Label2->Caption = y;
}
//---------------------------------------------------------------------------
Für dieses Beispiel benötigst du einen Button, zwei Timer und zwei Labels. Der Quelltext ist eine vereinfachte form von dem was ich in dem LED Programm verwendet habe.
Lesezeichen