Contrôle du port parrallèle et jeux de lumière

Soyez le premier à donner votre avis sur cette source.

Vue 15 950 fois - Téléchargée 1 095 fois

Description

Ce logiciel sert à contrôler les huit broches de données du port parallèle pour en faire ce que l'on veut...
Une première application est le jeu de lumière, mais on peut imaginer contrôler toutes sortes de choses comme des outils ménager via un circuit électronique trés simple et peu couteux à réaliser.

Source / Exemple :


// Ceci n'est qu'une partie du source à compiler avec visual c++6
// Télécharger le zip
// Je décline toute responsabilité dans le cas d'utilisations non conventionnelles du
// logiciel.
// Attention à votre imprimante et votre carte mère! ( pas de court circuit
// sur le port parallèle évidement) 

// Voilà, tout est là, bonne visite !

#include "stdafx.h"
#include "Para_Control.h"
#include "Para_ControlDlg.h"
#include "conio.h"
#include "math.h"
//#include "stdlib.h"

int p1 = 0x378; // Adresse Port Parallèle
CString temp;
int pos = 0;
int c = 0;
int Temps = 101; // ( Milli-secondes )

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

int last = 0;
//srand(0);

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPara_ControlDlg dialog

CPara_ControlDlg::CPara_ControlDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CPara_ControlDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPara_ControlDlg)
// Initialisation des 'Edit Box'
	m_cpt1 = 10;
	m_cpt2 = 10;
	m_cpt3 = 10;
	m_cpt4 = 10;
	m_cpt5 = 10;
	m_cpt6 = 10;
	m_cpt7 = 10;
	m_cpt8 = 10;
	m_cpt9 = 10;
	m_cpt12 = 50;
	m_cpt10 = 10;
	m_cpt11 = 0;
	m_cpt24 = 10;
	m_cpt13 = 3;
	m_cpt14 = 5;
	m_cpt15 = 7;
	m_cpt16 = 2;
	m_cpt17 = 1;
	m_cpt18 = 4;
	m_cpt19 = 6;
	m_cpt20 = 8;
	m_cpt21 = 1;
	m_cpt22 = 8;
	m_cpt23 = 1;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CPara_ControlDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPara_ControlDlg)
	DDX_Text(pDX, IDC_EDIT1, m_cpt1);
	DDX_Text(pDX, IDC_EDIT2, m_cpt2);
	DDX_Text(pDX, IDC_EDIT3, m_cpt3);
	DDX_Text(pDX, IDC_EDIT4, m_cpt4);
	DDX_Text(pDX, IDC_EDIT5, m_cpt5);
	DDX_Text(pDX, IDC_EDIT6, m_cpt6);
	DDX_Text(pDX, IDC_EDIT7, m_cpt7);
	DDX_Text(pDX, IDC_EDIT8, m_cpt8);
	DDX_Text(pDX, IDC_EDIT9, m_cpt9);
	DDX_Text(pDX, IDC_EDIT12, m_cpt12);
	DDX_Text(pDX, IDC_EDIT10, m_cpt10);
	DDX_Text(pDX, IDC_EDIT24, m_cpt24);
	DDX_Text(pDX, IDC_EDIT13, m_cpt13);
	DDX_Text(pDX, IDC_EDIT14, m_cpt14);
	DDX_Text(pDX, IDC_EDIT15, m_cpt15);
	DDX_Text(pDX, IDC_EDIT16, m_cpt16);
	DDX_Text(pDX, IDC_EDIT17, m_cpt17);
	DDX_Text(pDX, IDC_EDIT18, m_cpt18);
	DDX_Text(pDX, IDC_EDIT19, m_cpt19);
	DDX_Text(pDX, IDC_EDIT20, m_cpt20);
	DDX_Text(pDX, IDC_EDIT21, m_cpt21);
	DDX_Text(pDX, IDC_EDIT22, m_cpt22);
	DDX_Text(pDX, IDC_EDIT23, m_cpt23);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CPara_ControlDlg, CDialog)
	//{{AFX_MSG_MAP(CPara_ControlDlg)
// Initialisation des boutons
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON7, On_Allume_tout)
	ON_BN_CLICKED(IDC_BUTTON8, On_Eteindre_tout)
	ON_BN_CLICKED(IDC_BUTTON1, On_Allum1)
	ON_BN_CLICKED(IDC_BUTTON3, On_Cligno1)
	ON_BN_CLICKED(IDC_BUTTON2, On_Etein1)
	ON_BN_CLICKED(IDC_BUTTON24, On_Allum8)
	ON_BN_CLICKED(IDC_BUTTON25, On_Etein8)
	ON_BN_CLICKED(IDC_BUTTON26, On_Cligno8)
	ON_BN_CLICKED(IDC_BUTTON4, On_Allum2)
	ON_BN_CLICKED(IDC_BUTTON5, On_Etein2)
	ON_BN_CLICKED(IDC_BUTTON6, On_Cligno2)
	ON_BN_CLICKED(IDC_BUTTON9, On_Allum3)
	ON_BN_CLICKED(IDC_BUTTON10, On_Etein3)
	ON_BN_CLICKED(IDC_BUTTON11, On_Cligno3)
	ON_BN_CLICKED(IDC_BUTTON12, On_Allum4)
	ON_BN_CLICKED(IDC_BUTTON13, On_Etein4)
	ON_BN_CLICKED(IDC_BUTTON14, On_Cligno4)
	ON_BN_CLICKED(IDC_BUTTON15, On_Allum5)
	ON_BN_CLICKED(IDC_BUTTON16, On_Etein5)
	ON_BN_CLICKED(IDC_BUTTON17, On_Cligno5)
	ON_BN_CLICKED(IDC_BUTTON18, On_Allum6)
	ON_BN_CLICKED(IDC_BUTTON19, On_Etein6)
	ON_BN_CLICKED(IDC_BUTTON20, On_Cligno6)
	ON_BN_CLICKED(IDC_BUTTON21, On_Allum7)
	ON_BN_CLICKED(IDC_BUTTON22, On_Etein7)
	ON_BN_CLICKED(IDC_BUTTON23, On_Cligno7)
	ON_BN_CLICKED(IDC_BUTTON27, On_Cligno_tout)
	ON_BN_CLICKED(IDC_BUTTON28, On_Cheni_DG)
	ON_BN_CLICKED(IDC_BUTTON29, On_Cheni_GD)
	ON_BN_CLICKED(IDC_BUTTON30, On_Cheni_AR)
	ON_BN_CLICKED(IDC_BUTTON31, On_Rencontre)
	ON_BN_CLICKED(IDC_BUTTON32, On_Separe)
	ON_BN_CLICKED(IDC_BUTTON34, On_Croise)
	ON_BN_CLICKED(IDC_BUTTON33, On_Collision)
	ON_BN_CLICKED(IDC_BUTTON35, On_Seq)
	ON_BN_CLICKED(IDC_BUTTON36, On_Aleatoire1)
	ON_BN_CLICKED(IDC_BUTTON37, On_Alleatoire2)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPara_ControlDlg message handlers

BOOL CPara_ControlDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
// Mise à zéro de toutes les sorties:
_outp(p1,0);

// Initialisation et positionnement des sliders

CSliderCtrl* pSlide1 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER1) );	
pSlide1->SetRange(1,100,true);
pSlide1->SetPos(50);

CSliderCtrl* pSlide2 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER2) );	
pSlide2->SetRange(1,100,true);
pSlide2->SetPos(50);
	
CSliderCtrl* pSlide3 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER3) );	
pSlide3->SetRange(1,100,true);
pSlide3->SetPos(50);

CSliderCtrl* pSlide4 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER4) );	
pSlide4->SetRange(1,100,true);
pSlide4->SetPos(50);

CSliderCtrl* pSlide5 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER5) );	
pSlide5->SetRange(1,100,true);
pSlide5->SetPos(50);

CSliderCtrl* pSlide6 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER6) );	
pSlide6->SetRange(1,100,true);
pSlide6->SetPos(50);

CSliderCtrl* pSlide7 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER7) );	
pSlide7->SetRange(1,100,true);
pSlide7->SetPos(50);

CSliderCtrl* pSlide8 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER8) );	
pSlide8->SetRange(1,100,true);
pSlide8->SetPos(50);

CSliderCtrl* pSlide9 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER9) );	
pSlide9->SetRange(1,100,true);
pSlide9->SetPos(50);

CSliderCtrl* pSlide16 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER16) );	
pSlide16->SetRange(1,100,true);
pSlide16->SetPos(100);

CSliderCtrl* pSlide14 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER14) );	
pSlide14->SetRange(1,100,true);
pSlide14->SetPos(50);

CSliderCtrl* pSlide13 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER13) );	
pSlide13->SetRange(1,100,true);
pSlide13->SetPos(50);

CSliderCtrl* pSlide11 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER11) );	
pSlide11->SetRange(1,100,true);
pSlide11->SetPos(50);

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CPara_ControlDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CPara_ControlDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CPara_ControlDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CPara_ControlDlg::On_Allume_tout() 
{
	// TODO: Add your control notification handler code here
// On envoi 255, ce qui correspond à 11111111 en binaire:
// Donc toutes les sorties sont activées
// C'est aussi simple que ça...

	last = 255;
	_outp(p1,last);
	
}

void CPara_ControlDlg::On_Eteindre_tout() 
{
	// TODO: Add your control notification handler code here
	last = 0;
	_outp(p1,last);
}

void CPara_ControlDlg::On_Allum1() 
{
	// TODO: Add your control notification handler code here
// Ou bit à bit de ce qui était écrit sur le port para avec 0000 0001
// On est sûr que la sortie n°1 est active et que les autres sorties
// n'ont pas étés modifiées
// Si vous ne me croyez pas, révisez la logique...
	
	last = 1 | last;
	_outp(p1,last);
	
}

void CPara_ControlDlg::On_Cligno1() 
{
	// TODO: Add your control notification handler code here
	GetDlgItemText(IDC_EDIT1,temp); // Récup valeur dans edit box1
	int cpt1 = atoi(temp);// Conversion en entier
	CSliderCtrl* pSlide = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER1) );
	CSliderCtrl* pSlide2 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER16) );
	pos = 501 - 4*pSlide2->GetPos() - pSlide->GetPos();// lecture de
	// la position des sliders et opération pour déterminer la longueur
	// de la pause
	c = 0;
	int save_last = last;// sauvegarde ancienne config des sorties
	last = last & 254; 
	while(c<cpt1)
	{
		c++;
		last = 1 | last;
		_outp(p1,last);
		Sleep(pos);
		last = 254 & last;
		_outp(p1,last);
		Sleep(pos);
	}
	last = save_last;
	_outp(p1,last);
}

void CPara_ControlDlg::On_Etein1() 
{
	// TODO: Add your control notification handler code here
	last = 254 & last;// 254 = 11111110
	_outp(p1,last);   // donc sortie 1 désactivée seule grace à un ET
					  // bit à bit
}

// Bon aprés c'est quasi tout pareil, bonne lecture...

void CPara_ControlDlg::On_Allum8() 
{
	// TODO: Add your control notification handler code here
	last = 128 | last;
	_outp(p1,last);
}

void CPara_ControlDlg::On_Etein8() 
{
	// TODO: Add your control notification handler code here
	last = (255 - 128) & last;
	_outp(p1,last);
}

void CPara_ControlDlg::On_Cligno8() 
{
	// TODO: Add your control notification handler code here
	GetDlgItemText(IDC_EDIT8,temp);
	int cpt8 = atoi(temp);
	CSliderCtrl* pSlide = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER8) );
	CSliderCtrl* pSlide2 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER16) );
	pos = 501 - 4*pSlide2->GetPos() - pSlide->GetPos();
	c = 0;
	int save_last = last;
	last = last & (255 - 128);
	while(c<cpt8)
	{
		c++;
		last = 128 | last;
		_outp(p1,last);
		Sleep(pos);
		last = (255 - 128) & last;
		_outp(p1,last);
		Sleep(pos);
	}
	last = save_last;
	_outp(p1,last);	
}

void CPara_ControlDlg::On_Allum2() 
{
	// TODO: Add your control notification handler code here
	last = last | 2;
	_outp(p1,last);
}

void CPara_ControlDlg::On_Etein2() 
{
	// TODO: Add your control notification handler code here
	last &= (255 - 2);
	_outp(p1,last);
}

void CPara_ControlDlg::On_Cligno2() 
{
	// TODO: Add your control notification handler code here
	GetDlgItemText(IDC_EDIT2,temp);
	int cpt = atoi(temp);
	CSliderCtrl* pSlide = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER2) );
	CSliderCtrl* pSlide2 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER16) );
	pos = 501 - 4*pSlide2->GetPos() - pSlide->GetPos();
	c = 0;
	int save_last = last;
	last = last & (255 - 2);
	while(c<cpt)
	{
		c++;
		last = 2 | last;
		_outp(p1,last);
		Sleep(pos);
		last = (255 - 2) & last;
		_outp(p1,last);
		Sleep(pos);
	}
	last = save_last;
	_outp(p1,last);	
}

void CPara_ControlDlg::On_Allum3() 
{
	// TODO: Add your control notification handler code here
	last |= 4;
	_outp(p1,last);
}

void CPara_ControlDlg::On_Etein3() 
{
	// TODO: Add your control notification handler code here
	last &= (255 - 4);
	_outp(p1,last);
}

void CPara_ControlDlg::On_Cligno3() 
{
	// TODO: Add your control notification handler code here
	GetDlgItemText(IDC_EDIT3,temp);
	int cpt = atoi(temp);
	CSliderCtrl* pSlide = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER3) );
	CSliderCtrl* pSlide2 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER16) );
	pos = 501 - 4*pSlide2->GetPos() - pSlide->GetPos();
	c = 0;
	int save_last = last;
	last = last & (255 - 4);
	while(c<cpt)
	{
		c++;
		last = 4 | last;
		_outp(p1,last);
		Sleep(pos);
		last = (255 - 4) & last;
		_outp(p1,last);
		Sleep(pos);
	}
	last = save_last;
	_outp(p1,last);	
}

void CPara_ControlDlg::On_Allum4() 
{
	// TODO: Add your control notification handler code here
	last |= 8;
	_outp(p1,last);
}

void CPara_ControlDlg::On_Etein4() 
{
	// TODO: Add your control notification handler code here
	last &= (255 - 8);
	_outp(p1,last);
}

void CPara_ControlDlg::On_Cligno4() 
{
	// TODO: Add your control notification handler code here
	GetDlgItemText(IDC_EDIT4,temp);
	int cpt = atoi(temp);
	CSliderCtrl* pSlide = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER4) );
	CSliderCtrl* pSlide2 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER16) );
	pos = 501 - 4*pSlide2->GetPos() - pSlide->GetPos();
	c = 0;
	int save_last = last;
	last = last & (255 - 8);
	while(c<cpt)
	{
		c++;
		last = 8 | last;
		_outp(p1,last);
		Sleep(pos);
		last = (255 - 8) & last;
		_outp(p1,last);
		Sleep(pos);
	}
	last = save_last;
	_outp(p1,last);	
}

void CPara_ControlDlg::On_Allum5() 
{
	// TODO: Add your control notification handler code here
	last |= 16;
	_outp(p1,last);
}

void CPara_ControlDlg::On_Etein5() 
{
	// TODO: Add your control notification handler code here
	last &= (255 - 16);
	_outp(p1,last);
}

void CPara_ControlDlg::On_Cligno5() 
{
	// TODO: Add your control notification handler code here
	GetDlgItemText(IDC_EDIT5,temp);
	int cpt = atoi(temp);
	CSliderCtrl* pSlide = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER5) );
	CSliderCtrl* pSlide2 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER16) );
	pos = 501 - 4*pSlide2->GetPos() - pSlide->GetPos();
	c = 0;
	int save_last = last;
	last = last & (255 - 16);
	while(c<cpt)
	{
		c++;
		last = 16 | last;
		_outp(p1,last);
		Sleep(pos);
		last = (255 - 16) & last;
		_outp(p1,last);
		Sleep(pos);
	}
	last = save_last;
	_outp(p1,last);	
}

void CPara_ControlDlg::On_Allum6() 
{
	// TODO: Add your control notification handler code here
	last |= 32;
	_outp(p1,last);
}

void CPara_ControlDlg::On_Etein6() 
{
	// TODO: Add your control notification handler code here
	last &= (255-32);
	_outp(p1,last);
}

void CPara_ControlDlg::On_Cligno6() 
{
	// TODO: Add your control notification handler code here
	GetDlgItemText(IDC_EDIT6,temp);
	int cpt = atoi(temp);
	CSliderCtrl* pSlide = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER6) );
	CSliderCtrl* pSlide2 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER16) );
	pos = 501 - 4*pSlide2->GetPos() - pSlide->GetPos();
	c = 0;
	int save_last = last;
	last = last & (255 - 32);
	while(c<cpt)
	{
		c++;
		last = 32 | last;
		_outp(p1,last);
		Sleep(pos);
		last = (255 - 32) & last;
		_outp(p1,last);
		Sleep(pos);
	}
	last = save_last;
	_outp(p1,last);	
}

void CPara_ControlDlg::On_Allum7() 
{
	// TODO: Add your control notification handler code here
	last |= 64;
	_outp(p1,last);
}

void CPara_ControlDlg::On_Etein7() 
{
	// TODO: Add your control notification handler code here
	last &= (255 - 64);
	_outp(p1,last);
}

void CPara_ControlDlg::On_Cligno7() 
{
	// TODO: Add your control notification handler code here
	GetDlgItemText(IDC_EDIT7,temp);
	int cpt = atoi(temp);
	CSliderCtrl* pSlide = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER7) );
	CSliderCtrl* pSlide2 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER16) );
	pos = 501 - 4*pSlide2->GetPos() - pSlide->GetPos();
	c = 0;
	int save_last = last;
	last = last & (255 - 64);
	while(c<cpt)
	{
		c++;
		last = 64 | last;
		_outp(p1,last);
		Sleep(pos);
		last = (255 - 64) & last;
		_outp(p1,last);
		Sleep(pos);
	}
	last = save_last;
	_outp(p1,last);	
}

void CPara_ControlDlg::On_Cligno_tout() 
{
	// TODO: Add your control notification handler code here
	GetDlgItemText(IDC_EDIT9,temp);
	int cpt = atoi(temp);
	CSliderCtrl* pSlide = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER9) );
	CSliderCtrl* pSlide2 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER16) );
	pos = 501 - 4*pSlide2->GetPos() - pSlide->GetPos();
	c = 0;
	int save_last = last;

	while(c<cpt)
	{
		c++;
		last = 255;
		_outp(p1,last);
		Sleep(pos);
		last = 0;
		_outp(p1,last);
		Sleep(pos);
	}
	last = save_last;
	_outp(p1,last);	
}

void CPara_ControlDlg::On_Cheni_DG() 
{
	// TODO: Add your control notification handler code here
	GetDlgItemText(IDC_EDIT10,temp);
	int cpt = atoi(temp);
	CSliderCtrl* pSlide = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER13) );
	CSliderCtrl* pSlide2 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER16) );
	pos = 401 - 4*pSlide2->GetPos() + pSlide->GetPos();
	c = 0;
	int save_last = last;
	int i = 0;

	while(c<cpt)
	{
		c++;
		_outp(p1,128);
		Sleep(pos);
		_outp(p1,64);
		Sleep(pos);
		_outp(p1,32);
		Sleep(pos);
		_outp(p1,16);
		Sleep(pos);
		_outp(p1,8);
		Sleep(pos);
		_outp(p1,4);
		Sleep(pos);
		_outp(p1,2);
		Sleep(pos);
		_outp(p1,1);
		Sleep(pos);
	}

	last = save_last;
	_outp(p1,last);	
}

void CPara_ControlDlg::On_Cheni_GD() 
{
	// TODO: Add your control notification handler code here
	GetDlgItemText(IDC_EDIT10,temp);
	int cpt = atoi(temp);
	CSliderCtrl* pSlide = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER13) );
	CSliderCtrl* pSlide2 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER16) );
	pos = 401 - 4*pSlide2->GetPos() + pSlide->GetPos();
	c = 0;
	int save_last = last;
	int i = 0;

	while(c<cpt)
	{
		c++;
		_outp(p1,1);
		Sleep(pos);
		_outp(p1,2);
		Sleep(pos);
		_outp(p1,4);
		Sleep(pos);
		_outp(p1,8);
		Sleep(pos);
		_outp(p1,16);
		Sleep(pos);
		_outp(p1,32);
		Sleep(pos);
		_outp(p1,64);
		Sleep(pos);
		_outp(p1,128);
		Sleep(pos);
	}

	last = save_last;
	_outp(p1,last);	
}

void CPara_ControlDlg::On_Cheni_AR() 
{
	// TODO: Add your control notification handler code here
	GetDlgItemText(IDC_EDIT10,temp);
	int cpt = atoi(temp);
	CSliderCtrl* pSlide = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER13) );
	CSliderCtrl* pSlide2 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER16) );
	pos = 401 - 4*pSlide2->GetPos() + pSlide->GetPos();
	c = 0;
	int save_last = last;
	int i = 0;

	while(c<cpt)
	{
		c++;
		_outp(p1,128);
		Sleep(pos);
		_outp(p1,64);
		Sleep(pos);
		_outp(p1,32);
		Sleep(pos);
		_outp(p1,16);
		Sleep(pos);
		_outp(p1,8);
		Sleep(pos);
		_outp(p1,4);
		Sleep(pos);
		_outp(p1,2);
		Sleep(pos);
		_outp(p1,1);
//		Sleep(pos);
//		_outp(p1,1);
		Sleep(pos);
		_outp(p1,2);
		Sleep(pos);
		_outp(p1,4);
		Sleep(pos);
		_outp(p1,8);
		Sleep(pos);
		_outp(p1,16);
		Sleep(pos);
		_outp(p1,32);
		Sleep(pos);
		_outp(p1,64);
		Sleep(pos);
//		_outp(p1,128);
//		Sleep(pos);
	}

	last = save_last;
	_outp(p1,last);	
}

void CPara_ControlDlg::On_Rencontre() 
{
	// TODO: Add your control notification handler code here
	GetDlgItemText(IDC_EDIT10,temp);
	int cpt = atoi(temp);
	CSliderCtrl* pSlide = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER13) );
	CSliderCtrl* pSlide2 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER16) );
	pos = 401 - 4*pSlide2->GetPos() + pSlide->GetPos();
	c = 0;
	int save_last = last;
	int i = 0;

	while(c<cpt)
	{
		c++;
		_outp(p1,129);
		Sleep(pos);
		_outp(p1,66);
		Sleep(pos);
		_outp(p1,36);
		Sleep(pos);
		_outp(p1,24);
		Sleep(pos);
	}

	last = save_last;
	_outp(p1,last);	
}

void CPara_ControlDlg::On_Separe() 
{
	// TODO: Add your control notification handler code here
	GetDlgItemText(IDC_EDIT10,temp);
	int cpt = atoi(temp);
	CSliderCtrl* pSlide = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER13) );
	CSliderCtrl* pSlide2 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER16) );
	pos = 401 - 4*pSlide2->GetPos() + pSlide->GetPos();
	c = 0;
	int save_last = last;
	int i = 0;

	while(c<cpt)
	{
		c++;
		_outp(p1,24);
		Sleep(pos);
		_outp(p1,36);
		Sleep(pos);
		_outp(p1,66);
		Sleep(pos);
		_outp(p1,129);
		Sleep(pos);
	}

	last = save_last;
	_outp(p1,last);	
}

void CPara_ControlDlg::On_Croise() 
{
	// TODO: Add your control notification handler code here
	GetDlgItemText(IDC_EDIT10,temp);
	int cpt = atoi(temp);
	CSliderCtrl* pSlide = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER13) );
	CSliderCtrl* pSlide2 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER16) );
	pos = 401 - 4*pSlide2->GetPos() + pSlide->GetPos();
	c = 0;
	int save_last = last;
	int i = 0;

	while(c<cpt)
	{
		c++;
		_outp(p1,129);
		Sleep(pos);
		_outp(p1,66);
		Sleep(pos);
		_outp(p1,36);
		Sleep(pos);
		_outp(p1,24);
		Sleep(pos);
		_outp(p1,36);
		Sleep(pos);
		_outp(p1,66);
		Sleep(pos);
		_outp(p1,129);
		Sleep(pos);
	}

	last = save_last;
	_outp(p1,last);	
}

void CPara_ControlDlg::On_Collision() 
{
	// TODO: Add your control notification handler code here
	GetDlgItemText(IDC_EDIT10,temp);
	int cpt = atoi(temp);
	CSliderCtrl* pSlide = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER13) );
	CSliderCtrl* pSlide2 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER16) );
	pos = 401 - 4*pSlide2->GetPos() + pSlide->GetPos();
	c = 0;
	int save_last = last;
	int i = 0;

	while(c<cpt)
	{
		c++;
		_outp(p1,129);
		Sleep(pos);
		_outp(p1,66);
		Sleep(pos);
		_outp(p1,36);
		Sleep(pos);
		_outp(p1,24);
		Sleep(pos);
		_outp(p1,255);
		Sleep(pos);
		_outp(p1,0);
		Sleep(pos);
	}

	last = save_last;
	_outp(p1,last);		
}

void CPara_ControlDlg::On_Seq() 
{
	// TODO: Add your control notification handler code here
	GetDlgItemText(IDC_EDIT24,temp);
	int cpt = atoi(temp);
	int n_led;
	CSliderCtrl* pSlide = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER11) );
	CSliderCtrl* pSlide2 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER16) );
	pos = 501 - 4*pSlide2->GetPos() - pSlide->GetPos();
	c = 0;
	int save_last = last;
	int i = 0;

	while( c<cpt )
	{
		c++;
		
		GetDlgItemText(IDC_EDIT17,temp);
		n_led = atoi(temp);
		
		if( (n_led < 9) )
		{
			switch(n_led)
			{

			case 1:
				_outp(p1,1);
				Sleep(pos);
				break;
			case 2:
				_outp(p1,2);
				Sleep(pos);
				break;
			case 3:
				_outp(p1,4);
				Sleep(pos);
				break;
			case 4:
				_outp(p1,8);
				Sleep(pos);
				break;
			case 5:
				_outp(p1,16);
				Sleep(pos);
				break;
			case 6:
				_outp(p1,32);
				Sleep(pos);
				break;
			case 7:
				_outp(p1,64);
				Sleep(pos);
				break;
			case 8:
				_outp(p1,128);
				Sleep(pos);
				break;
			}
		}
		else
		{
			MessageBox("Malin !",MB_OK,MB_ICONASTERISK);
		}

		GetDlgItemText(IDC_EDIT13,temp);
		n_led = atoi(temp);
		
		if( (n_led < 9) )
		{
			switch(n_led)
			{

			case 1:
				_outp(p1,1);
				Sleep(pos);
				break;
			case 2:
				_outp(p1,2);
				Sleep(pos);
				break;
			case 3:
				_outp(p1,4);
				Sleep(pos);
				break;
			case 4:
				_outp(p1,8);
				Sleep(pos);
				break;
			case 5:
				_outp(p1,16);
				Sleep(pos);
				break;
			case 6:
				_outp(p1,32);
				Sleep(pos);
				break;
			case 7:
				_outp(p1,64);
				Sleep(pos);
				break;
			case 8:
				_outp(p1,128);
				Sleep(pos);
				break;
			}
		}
		else
		{
			MessageBox("Malin !",MB_OK,MB_ICONASTERISK);
		}

		GetDlgItemText(IDC_EDIT14,temp);
		n_led = atoi(temp);
		
		if( (n_led < 9) )
		{
			switch(n_led)
			{

			case 1:
				_outp(p1,1);
				Sleep(pos);
				break;
			case 2:
				_outp(p1,2);
				Sleep(pos);
				break;
			case 3:
				_outp(p1,4);
				Sleep(pos);
				break;
			case 4:
				_outp(p1,8);
				Sleep(pos);
				break;
			case 5:
				_outp(p1,16);
				Sleep(pos);
				break;
			case 6:
				_outp(p1,32);
				Sleep(pos);
				break;
			case 7:
				_outp(p1,64);
				Sleep(pos);
				break;
			case 8:
				_outp(p1,128);
				Sleep(pos);
				break;
			}
		}
		else
		{
			MessageBox("Malin !",MB_OK,MB_ICONASTERISK);
		}

		GetDlgItemText(IDC_EDIT15,temp);
		n_led = atoi(temp);
		
		if( (n_led < 9) )
		{
			switch(n_led)
			{

			case 1:
				_outp(p1,1);
				Sleep(pos);
				break;
			case 2:
				_outp(p1,2);
				Sleep(pos);
				break;
			case 3:
				_outp(p1,4);
				Sleep(pos);
				break;
			case 4:
				_outp(p1,8);
				Sleep(pos);
				break;
			case 5:
				_outp(p1,16);
				Sleep(pos);
				break;
			case 6:
				_outp(p1,32);
				Sleep(pos);
				break;
			case 7:
				_outp(p1,64);
				Sleep(pos);
				break;
			case 8:
				_outp(p1,128);
				Sleep(pos);
				break;
			}
		}
		else
		{
			MessageBox("Malin !",MB_OK,MB_ICONASTERISK);
		}

		GetDlgItemText(IDC_EDIT16,temp);
		n_led = atoi(temp);
		
		if( (n_led < 9) )
		{
			switch(n_led)
			{

			case 1:
				_outp(p1,1);
				Sleep(pos);
				break;
			case 2:
				_outp(p1,2);
				Sleep(pos);
				break;
			case 3:
				_outp(p1,4);
				Sleep(pos);
				break;
			case 4:
				_outp(p1,8);
				Sleep(pos);
				break;
			case 5:
				_outp(p1,16);
				Sleep(pos);
				break;
			case 6:
				_outp(p1,32);
				Sleep(pos);
				break;
			case 7:
				_outp(p1,64);
				Sleep(pos);
				break;
			case 8:
				_outp(p1,128);
				Sleep(pos);
				break;
			}
		}
		else
		{
			MessageBox("Malin !",MB_OK,MB_ICONASTERISK);
		}

		GetDlgItemText(IDC_EDIT18,temp);
		n_led = atoi(temp);
		
		if( (n_led < 9) )
		{
			switch(n_led)
			{

			case 1:
				_outp(p1,1);
				Sleep(pos);
				break;
			case 2:
				_outp(p1,2);
				Sleep(pos);
				break;
			case 3:
				_outp(p1,4);
				Sleep(pos);
				break;
			case 4:
				_outp(p1,8);
				Sleep(pos);
				break;
			case 5:
				_outp(p1,16);
				Sleep(pos);
				break;
			case 6:
				_outp(p1,32);
				Sleep(pos);
				break;
			case 7:
				_outp(p1,64);
				Sleep(pos);
				break;
			case 8:
				_outp(p1,128);
				Sleep(pos);
				break;
			}
		}
		else
		{
			MessageBox("Malin !",MB_OK,MB_ICONASTERISK);
		}

		GetDlgItemText(IDC_EDIT19,temp);
		n_led = atoi(temp);
		
		if( (n_led < 9) )
		{
			switch(n_led)
			{

			case 1:
				_outp(p1,1);
				Sleep(pos);
				break;
			case 2:
				_outp(p1,2);
				Sleep(pos);
				break;
			case 3:
				_outp(p1,4);
				Sleep(pos);
				break;
			case 4:
				_outp(p1,8);
				Sleep(pos);
				break;
			case 5:
				_outp(p1,16);
				Sleep(pos);
				break;
			case 6:
				_outp(p1,32);
				Sleep(pos);
				break;
			case 7:
				_outp(p1,64);
				Sleep(pos);
				break;
			case 8:
				_outp(p1,128);
				Sleep(pos);
				break;
			}
		}
		else
		{
			MessageBox("Malin !",MB_OK,MB_ICONASTERISK);
		}

		GetDlgItemText(IDC_EDIT20,temp);
		n_led = atoi(temp);
		
		if( (n_led < 9) )
		{
			switch(n_led)
			{

			case 1:
				_outp(p1,1);
				Sleep(pos);
				break;
			case 2:
				_outp(p1,2);
				Sleep(pos);
				break;
			case 3:
				_outp(p1,4);
				Sleep(pos);
				break;
			case 4:
				_outp(p1,8);
				Sleep(pos);
				break;
			case 5:
				_outp(p1,16);
				Sleep(pos);
				break;
			case 6:
				_outp(p1,32);
				Sleep(pos);
				break;
			case 7:
				_outp(p1,64);
				Sleep(pos);
				break;
			case 8:
				_outp(p1,128);
				Sleep(pos);
				break;
			}
		}
		else
		{
			MessageBox("Malin !",MB_OK,MB_ICONASTERISK);
		}

		GetDlgItemText(IDC_EDIT21,temp);
		n_led = atoi(temp);
		
		if( (n_led < 9) )
		{
			switch(n_led)
			{

			case 1:
				_outp(p1,1);
				Sleep(pos);
				break;
			case 2:
				_outp(p1,2);
				Sleep(pos);
				break;
			case 3:
				_outp(p1,4);
				Sleep(pos);
				break;
			case 4:
				_outp(p1,8);
				Sleep(pos);
				break;
			case 5:
				_outp(p1,16);
				Sleep(pos);
				break;
			case 6:
				_outp(p1,32);
				Sleep(pos);
				break;
			case 7:
				_outp(p1,64);
				Sleep(pos);
				break;
			case 8:
				_outp(p1,128);
				Sleep(pos);
				break;
			}
		}
		else
		{
			MessageBox("Malin !",MB_OK,MB_ICONASTERISK);
		}

		GetDlgItemText(IDC_EDIT22,temp);
		n_led = atoi(temp);
		
		if( (n_led < 9) )
		{
			switch(n_led)
			{

			case 1:
				_outp(p1,1);
				Sleep(pos);
				break;
			case 2:
				_outp(p1,2);
				Sleep(pos);
				break;
			case 3:
				_outp(p1,4);
				Sleep(pos);
				break;
			case 4:
				_outp(p1,8);
				Sleep(pos);
				break;
			case 5:
				_outp(p1,16);
				Sleep(pos);
				break;
			case 6:
				_outp(p1,32);
				Sleep(pos);
				break;
			case 7:
				_outp(p1,64);
				Sleep(pos);
				break;
			case 8:
				_outp(p1,128);
				Sleep(pos);
				break;
			}
		}
		else
		{
			MessageBox("Malin !",MB_OK,MB_ICONASTERISK);
		}

		GetDlgItemText(IDC_EDIT23,temp);
		n_led = atoi(temp);
		
		if( (n_led < 9) )
		{
			switch(n_led)
			{

			case 1:
				_outp(p1,1);
				Sleep(pos);
				break;
			case 2:
				_outp(p1,2);
				Sleep(pos);
				break;
			case 3:
				_outp(p1,4);
				Sleep(pos);
				break;
			case 4:
				_outp(p1,8);
				Sleep(pos);
				break;
			case 5:
				_outp(p1,16);
				Sleep(pos);
				break;
			case 6:
				_outp(p1,32);
				Sleep(pos);
				break;
			case 7:
				_outp(p1,64);
				Sleep(pos);
				break;
			case 8:
				_outp(p1,128);
				Sleep(pos);
				break;
			}
		}
		else
		{
			MessageBox("Malin !",MB_OK,MB_ICONASTERISK);
		}

	}

	last = save_last;
	_outp(p1,last);	
}

void CPara_ControlDlg::On_Aleatoire1() 
{
	// TODO: Add your control notification handler code here
	GetDlgItemText(IDC_EDIT12,temp);
	int cpt = atoi(temp);
	CSliderCtrl* pSlide = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER14) );
	CSliderCtrl* pSlide2 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER16) );
	pos = 501 - 4*pSlide2->GetPos() - pSlide->GetPos();
	c = 0;
	int save_last = last;
	int i = 0;
	int x;

	while(c<cpt)
	{
		c++;
		x = rand()%256;
		_outp(p1,x);
		Sleep(pos);
	}

	last = save_last;
	_outp(p1,last);	
}

void CPara_ControlDlg::On_Alleatoire2() 
{
	// TODO: Add your control notification handler code here
	GetDlgItemText(IDC_EDIT12,temp);
	int cpt = atoi(temp);
	CSliderCtrl* pSlide = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER14) );
	CSliderCtrl* pSlide2 = static_cast<CSliderCtrl*>( GetDlgItem(IDC_SLIDER16) );
	pos = 501 - 4*pSlide2->GetPos() - pSlide->GetPos();
	c = 0;
	int save_last = last;
	int i = 0;
	int x;

	while(c<cpt)
	{
		c++;
		x = rand()%9;
		switch(x)
		{
			case 1:
				_outp(p1,1);
				Sleep(pos);
				break;
			case 2:
				_outp(p1,2);
				Sleep(pos);
				break;
			case 3:
				_outp(p1,4);
				Sleep(pos);
				break;
			case 4:
				_outp(p1,8);
				Sleep(pos);
				break;
			case 5:
				_outp(p1,16);
				Sleep(pos);
				break;
			case 6:
				_outp(p1,32);
				Sleep(pos);
				break;
			case 7:
				_outp(p1,64);
				Sleep(pos);
				break;
			case 8:
				_outp(p1,128);
				Sleep(pos);
				break;
			default:
				_outp(p1,x);
				Sleep(pos);
				break;
		}
	}

	last = save_last;
	_outp(p1,last);	
}

Conclusion :


Pas de bug dans ce programme; a moins que vous en trouviez...
Mise à jour si vous en souhaitez une...
J'attend vos suggestions...

Codes Sources

A voir également

Ajouter un commentaire

Commentaires

crottepourit
Messages postés
1
Date d'inscription
samedi 2 octobre 2004
Statut
Membre
Dernière intervention
16 août 2005
-
j'aimerai savoir quel serai le montage du circuit électronic à brancher
sur le port // .

Merci
jimmy186
Messages postés
1
Date d'inscription
lundi 8 mars 2004
Statut
Membre
Dernière intervention
12 mars 2004
-
pour rendre les ports visibles sous Nt/2000/XP, il faut utiliser un petit logiciel qui s'appelle USERPORT : il est téléchargeable sur le net à l'adresse suivante ...
http://www.embeddedtronics.com/public/Electronics/minidaq/userport/UserPort.zip
maitrecesar
Messages postés
11
Date d'inscription
samedi 25 janvier 2003
Statut
Membre
Dernière intervention
3 août 2005
-
Salut

lors de la compilation ; il n'arrive pas a trouve une biblioth. nafxcwd.lib
est ce que vous pouvez m'aider, ou me l'envoier.
merci d'avance
cesar
cesarone@caramail.com
zeratul67
Messages postés
97
Date d'inscription
mardi 9 avril 2002
Statut
Membre
Dernière intervention
11 mai 2008
-
Et voila une super explication:
http://www.programmationworld.com/site/cours.asp?Action=cours&numero=23

(je travaille sur un jeu de lumières sous forme de DLL plug-in pour Winamp, la source sera bientôt dispo ...)
zeratul67
Messages postés
97
Date d'inscription
mardi 9 avril 2002
Statut
Membre
Dernière intervention
11 mai 2008
-
Et voila une super explication:
http://www.programmationworld.com/site/cours.asp?Action=cours&numero=23

(je travaille sur un jeu de lumières sous forme de DLL plug-in pour Winamp, la source sera bientôt dispo ...)

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.