Accueil > > > SOURCE_ POUR AFFICHEUR LCD ET CLAVIER MATRICE
SOURCE_ POUR AFFICHEUR LCD ET CLAVIER MATRICE
Information sur la source
Description
cette source vous permet de communiqué avec un afficheur lcd 7segments en plus je vous ai rajouter un clavier matriciel au cas ou vous en avais besoin .. J'ai cree ces fonction a la base pour un monnayeur electronique
Source
- // [--]________________________________[--]
- // |**************************************|
- // |*******/\/\/\/\/\/\/\/\/\/\/\/\*******|
- // |*******\** GesClavier **/*******|
- // |*******/** 19/12/2001 **\*******|
- // |*******\** v1.0 **/*******|
- // |*******/** NiChaN EaTo© **\*******|
- // |*******\/\/\/\/\/\/\/\/\/\/\/\/*******|
- // |**************************************|
- // ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- #include <iostream.h>
- #include <conio.h>
- #include <windows.h>
-
- #define PORTLPTR 0x378 // Ad Base du Port //PORT
- #define REGIN 1
- #define REGOUT 0
-
- char GesClavier(); // a mettre eventuellement dans un ".h"
-
- bool toucheOK=false;
-
- char tabinit[5][4]={
- {'1','2','E','3'}, // TABLEAU D'INITIALISATION
- {'4','5','E','6'},
- {'7','8','E','9'},
- {'E','E','E','E'},
- {'*','0','E','#'}};
-
- int tabEnvoi[3]={0x6,0x5,0x3};
-
- int adress=0, a,b,c;
- int valeur=0,rebond=0;
- char GesClavier()
- {
-
- for(a=0;a<3;a++)
- {
- _outp(PORTLPTR+REGOUT,tabEnvoi[a]);
- rebond=_inp(PORTLPTR+REGIN); // lecture
- rebond=((rebond>>3)&0x0F); // modification pour le cablage
- if(rebond!=0x0F)
- {
- Sleep(100); // tempo pour le rebond
- adress=_inp(PORTLPTR+REGIN); // relecture en cas de rebond !
- adress=((adress>>3)&0x0F);
- }
-
- if((rebond==adress)&& (rebond!=0x0F))
- {
- b=((~adress)&0x0F)>>1; //modification pour l'indicer
- c=((~(tabEnvoi[a]))-1)&0x07; //modification pour l'indicer
- toucheOK=true;
- cout<<" "<<tabinit[b][c]<<endl; // Affichage
- Sleep(50); // Tempo repos !
- }
- }
- if (toucheOK==true)
- {toucheOK=false;
- return (tabinit[b][c]);
- }
- else return ('_');
- }
- ///////////////////////////////////////////////////////////////////////////////////////
- //TIMAFFICH.H
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-
- // Fonction : fonction qui permet afficher des donnes sur un ecran LCD
- // Date : 15/01/2002
- // Version : v1.0
- // Variable : RS= 1/0 #1 Donnee ->0 Instruction
- // : RW= 1/0 #1 lecture ->0 Ecriture
- // : Data= 'X' 1 caracteres a afficher
-
-
- void Timaffich(unsigned char RS,unsigned char RW, unsigned char DATA);
- void initAffiche();
- void AfficheMess(char *Ecrit);
- void ClearAffich();
- ////////////////////////////////////////////////////////////////////////////////////
- //TIMEAFFICH.cpp
- //
- // fonction afficheur timing
-
- #include "TIMAFFICH.h"
- #include <windows.h>
- #include <conio.h>
-
- #define PORTLPTRSORT 0x378 // PORTSORTIE
- #define SET 0x38 // ACTIVATION
- #define DISPLAYCONTROL 0x0E
- #define MODESET 0x06
- #define CLEAR 0x01 // EFFACER ECRAN LCD
- #define HOME 0x02 // RETOUR CURSEUR
- #define INIT 0x30 // INITIALISATION
- #define ALALIGN 0xC0 // RETOUR A LA LIGNE
-
- void Timaffich(unsigned char RS,unsigned char RW, unsigned char DATA)
- { //E=0
- _outp(PORTLPTRSORT+2,RS|RW|0);
- Sleep(1);
- _outp(PORTLPTRSORT+2,RS|RW|0x04);
- Sleep(1);
- _outp(PORTLPTRSORT,DATA); // ECRITURE
- Sleep(1);
- //E=0;
- _outp(PORTLPTRSORT+2,(RS|RW)&0xFB);
- Sleep(1);
- }
-
- ////////////////////////////INITAFFICHE//////////////////////////////////////////
- void initAffiche()
- {
- int b;
- unsigned char tabInitLCD[9]={INIT,INIT,INIT,SET,DISPLAYCONTROL,CLEAR,HOME,MODESET};
- //INITIALISATION
- Sleep(16);
- for(b=0;b<8;b++)
- {
- Timaffich(0x01,0x02,tabInitLCD[b]); // Initialisation LCD
- Sleep(1);
- }
-
-
- }
- ////////////////////////////////////////////////////////////////////////////////////////////
- void ClearAffich()
- {
-
- Timaffich(0x01,0x02,CLEAR); // Initialisation LCD
- Sleep(1);
-
- }
- ////////////////////////////////AFFICHEMESS//////////////////////////////////////////////////
- int alalign=0;
- void AfficheMess(char *pEcrit)
- {
- if(alalign==16) Timaffich(0x01,0x02,ALALIGN); // ECRITURE DE DONNES--*
- // RETOUR A LA LIGNE--*
- Timaffich(0x00,0x02,(unsigned char)*pEcrit); // 'H'
- alalign++;
- Sleep(1);
-
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- //Afficheur.cpp
- ////////////////////////////////////////////////////////////////////////////////////////
- // [--]________________________________[--]
- // |**************************************|
- // |*******/\/\/\/\/\/\/\/\/\/\/\/\*******|
- // |*******\** Afficheur **/*******|
- // |*******/** 19/12/2001 **\*******|
- // |*******\** v1.0 **/*******|
- // |*******/** NiChaN EaTo© **\*******|
- // |*******\/\/\/\/\/\/\/\/\/\/\/\/*******|
- // |**************************************|
- // ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // Port : serie
- // Afficheur LCD avec clavier
-
-
- #include <stdio.h>
- #include <iostream.h>
- #include <conio.h>
- #include <windows.h>
- #include "TIMAFFICH.H"
- #include "GesClavier.h"
-
-
-
- void main()
- {
-
- char Ecrit[80]=" ";
- char * pEcriture=Ecrit;
- int j=0;
- initAffiche();
- ClearAffich();
- j=0;
- for(;;)
- {
- *pEcriture=GesClavier(); // saisie du clavier sur l'afficheur
- if('_'!=(*pEcriture))
- {
- AfficheMess(pEcriture);
- j++;
- pEcriture++;
- // ClearAffich();
- }
-
- }
-
-
- }
- //////////////////////////////////////////////////////////////////////////////////////
-
// [--]________________________________[--]
// |**************************************|
// |*******/\/\/\/\/\/\/\/\/\/\/\/\*******|
// |*******\** GesClavier **/*******|
// |*******/** 19/12/2001 **\*******|
// |*******\** v1.0 **/*******|
// |*******/** NiChaN EaTo© **\*******|
// |*******\/\/\/\/\/\/\/\/\/\/\/\/*******|
// |**************************************|
// ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <iostream.h>
#include <conio.h>
#include <windows.h>
#define PORTLPTR 0x378 // Ad Base du Port //PORT
#define REGIN 1
#define REGOUT 0
char GesClavier(); // a mettre eventuellement dans un ".h"
bool toucheOK=false;
char tabinit[5][4]={
{'1','2','E','3'}, // TABLEAU D'INITIALISATION
{'4','5','E','6'},
{'7','8','E','9'},
{'E','E','E','E'},
{'*','0','E','#'}};
int tabEnvoi[3]={0x6,0x5,0x3};
int adress=0, a,b,c;
int valeur=0,rebond=0;
char GesClavier()
{
for(a=0;a<3;a++)
{
_outp(PORTLPTR+REGOUT,tabEnvoi[a]);
rebond=_inp(PORTLPTR+REGIN); // lecture
rebond=((rebond>>3)&0x0F); // modification pour le cablage
if(rebond!=0x0F)
{
Sleep(100); // tempo pour le rebond
adress=_inp(PORTLPTR+REGIN); // relecture en cas de rebond !
adress=((adress>>3)&0x0F);
}
if((rebond==adress)&& (rebond!=0x0F))
{
b=((~adress)&0x0F)>>1; //modification pour l'indicer
c=((~(tabEnvoi[a]))-1)&0x07; //modification pour l'indicer
toucheOK=true;
cout<<" "<<tabinit[b][c]<<endl; // Affichage
Sleep(50); // Tempo repos !
}
}
if (toucheOK==true)
{toucheOK=false;
return (tabinit[b][c]);
}
else return ('_');
}
///////////////////////////////////////////////////////////////////////////////////////
//TIMAFFICH.H
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Fonction : fonction qui permet afficher des donnes sur un ecran LCD
// Date : 15/01/2002
// Version : v1.0
// Variable : RS= 1/0 #1 Donnee ->0 Instruction
// : RW= 1/0 #1 lecture ->0 Ecriture
// : Data= 'X' 1 caracteres a afficher
void Timaffich(unsigned char RS,unsigned char RW, unsigned char DATA);
void initAffiche();
void AfficheMess(char *Ecrit);
void ClearAffich();
////////////////////////////////////////////////////////////////////////////////////
//TIMEAFFICH.cpp
//
// fonction afficheur timing
#include "TIMAFFICH.h"
#include <windows.h>
#include <conio.h>
#define PORTLPTRSORT 0x378 // PORTSORTIE
#define SET 0x38 // ACTIVATION
#define DISPLAYCONTROL 0x0E
#define MODESET 0x06
#define CLEAR 0x01 // EFFACER ECRAN LCD
#define HOME 0x02 // RETOUR CURSEUR
#define INIT 0x30 // INITIALISATION
#define ALALIGN 0xC0 // RETOUR A LA LIGNE
void Timaffich(unsigned char RS,unsigned char RW, unsigned char DATA)
{ //E=0
_outp(PORTLPTRSORT+2,RS|RW|0);
Sleep(1);
_outp(PORTLPTRSORT+2,RS|RW|0x04);
Sleep(1);
_outp(PORTLPTRSORT,DATA); // ECRITURE
Sleep(1);
//E=0;
_outp(PORTLPTRSORT+2,(RS|RW)&0xFB);
Sleep(1);
}
////////////////////////////INITAFFICHE//////////////////////////////////////////
void initAffiche()
{
int b;
unsigned char tabInitLCD[9]={INIT,INIT,INIT,SET,DISPLAYCONTROL,CLEAR,HOME,MODESET};
//INITIALISATION
Sleep(16);
for(b=0;b<8;b++)
{
Timaffich(0x01,0x02,tabInitLCD[b]); // Initialisation LCD
Sleep(1);
}
}
////////////////////////////////////////////////////////////////////////////////////////////
void ClearAffich()
{
Timaffich(0x01,0x02,CLEAR); // Initialisation LCD
Sleep(1);
}
////////////////////////////////AFFICHEMESS//////////////////////////////////////////////////
int alalign=0;
void AfficheMess(char *pEcrit)
{
if(alalign==16) Timaffich(0x01,0x02,ALALIGN); // ECRITURE DE DONNES--*
// RETOUR A LA LIGNE--*
Timaffich(0x00,0x02,(unsigned char)*pEcrit); // 'H'
alalign++;
Sleep(1);
}
/////////////////////////////////////////////////////////////////////////////////////////
//Afficheur.cpp
////////////////////////////////////////////////////////////////////////////////////////
// [--]________________________________[--]
// |**************************************|
// |*******/\/\/\/\/\/\/\/\/\/\/\/\*******|
// |*******\** Afficheur **/*******|
// |*******/** 19/12/2001 **\*******|
// |*******\** v1.0 **/*******|
// |*******/** NiChaN EaTo© **\*******|
// |*******\/\/\/\/\/\/\/\/\/\/\/\/*******|
// |**************************************|
// ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Port : serie
// Afficheur LCD avec clavier
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
#include <windows.h>
#include "TIMAFFICH.H"
#include "GesClavier.h"
void main()
{
char Ecrit[80]=" ";
char * pEcriture=Ecrit;
int j=0;
initAffiche();
ClearAffich();
j=0;
for(;;)
{
*pEcriture=GesClavier(); // saisie du clavier sur l'afficheur
if('_'!=(*pEcriture))
{
AfficheMess(pEcriture);
j++;
pEcriture++;
// ClearAffich();
}
}
}
//////////////////////////////////////////////////////////////////////////////////////
Conclusion
Aucun bug connu -- ecrie par NiChaN **The EaTo© Compagny**
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
TECHDAYS PARIS 2012 : NOUVELLES TENDANCES DU POSTE DE TRAVAIL - BRING YOUR OWN PCTECHDAYS PARIS 2012 : NOUVELLES TENDANCES DU POSTE DE TRAVAIL - BRING YOUR OWN PC par ROMELARD Fabrice
Speakers: Thierry Rapatout, Antoine Petit et Xavier Trebbia Cette session entre dans le cadre des RDV Décideurs des TechDays 2012, elle est liée à la consumérisation de l'IT et la mise en place du "DeskTop as a Service" dans de plus en ...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : SYSTEM CENTER SERVICE MANAGER 2012 VUE D'ENSEMBLETECHDAYS PARIS 2012 : SYSTEM CENTER SERVICE MANAGER 2012 VUE D'ENSEMBLE par ROMELARD Fabrice
Speakers: Julien Marechal, Gautier Confiant, Sébastien MEYER La session débute par le positionnement de la solution System Center par rapport aux concepts d'organisation ITIL. Le portail du catalogue de se...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : PLEINIèRE SECOND JOURTECHDAYS PARIS 2012 : PLEINIèRE SECOND JOUR par ROMELARD Fabrice
Après une première journée dédiée aux développeurs, cette seconde journée est dédiée au monde des entreprises et de ses applications. Ainsi, cette pleinière est dédiée à faire un 360 de l'évolution des applications Business aux demandes ac...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : RETOUR D'EXPéRIENCE SUR LA MISE EN PLACE D'UN CLOUD PRIVéTECHDAYS PARIS 2012 : RETOUR D'EXPéRIENCE SUR LA MISE EN PLACE D'UN CLOUD PRIVé par ROMELARD Fabrice
Speaker : Guillaume Rochette Cette session est dédiée à fournir le retour sur la mise en place d'un cloud privé (IaaS) par Osiatis pour son compte ou celui de ses clients. Ce projet s'est déroulé sur 4 mois et a permis de faire évoluer...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : COMMENT SHAREPOINT A SAUVé MES TECHDAYSTECHDAYS PARIS 2012 : COMMENT SHAREPOINT A SAUVé MES TECHDAYS par ROMELARD Fabrice
Speakers : Lionel Limozin et Alain Marty La session commence par une découverte de SharePoint à travers la mise en place d'un environnement SharePoint pour la gestion des Sessions animées par BeWise. Le besoin est très ba...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Forum
AUMLAUML par sassion
Cliquez pour lire la suite par sassion
Logiciels
Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|