next up previous contents
suivant: Corps du code monter: Approche multitâche précédent: Approche multitâche   Table des matières

Header

Vu que le code commence à présenter une certaine longueur, et qu'on utilise désormais un grand nombre de variables globales, on a recours à un fichier d'en-tête. Ce code est encore en version de développement, qu'il faudrait nettoyer et améliorer.

//dumb0.4.h


#ifndef _DUMB04_
#define _DUMB04_

#include <semaphore.h>
#include <conio.h>
#include <dbutton.h>
#include <dsensor.h>
#include <dmotor.h>
#include <dsound.h>
#include <time.h>
#include <sys/tm.h>
#include <rom/system.h>
#include <tm.h>

//les limites lumineuses obtenues apres de fastidieux tests....
#define BLANC_BRILLANT 100
#define ULTRA_BRIGHT(light) ((light)>(BLANC_BRILLANT))
//si on utilise que blanc et noir (et brillant of course) mettre NOIR_GRIS proche de GRIS_BLANC  
#define NOIR_GRIS 60
#define GRIS_BLANC 60
#define ULTRA_BLANC(light) (((light)>(NOIR_GRIS))&((light)<(BLANC_BRILLANT)))
#define ULTRA_NOIR(light) ((light)<(NOIR_GRIS)) 

//quelques variables globales
int speed=0,dir=0;
int current1,current3;

//relation de linearite sur les capteurs
// utilisation en vain de
// Unexpectedly Static Variables O'reilly p212
// qui ne semble plus etre d'actualite...dans legOS 0.2.4
int lambda=4, muhhhh=135;

int sleeptime;
sem_t semlight1;
sem_t semlight3;
sem_t semspeed;
sem_t semdir;
sem_t semtime;

pid_t pid1,pid2,pid3,pid4,pid5,pid6,pid7,pid8,pid9 ;
//--------------------------------------------------------------------------
//quelques bips significatifs pour le debugging

static const note_t melody[] = {
	//tu parles d'une melodie !
 {PITCH_A4,1},{ PITCH_END, 0 }
};
static const note_t lowbeep[] = {
	 {PITCH_E3,1},{ PITCH_END, 0 }
};
static const note_t hibeep[] = {
	 {PITCH_E6,1},{ PITCH_END, 0 }
};

static const note_t lost[] = {
 {PITCH_A4,1},{PITCH_G3,1},{PITCH_E3,1},{PITCH_D3,1},{ PITCH_END, 0 }
};


static const note_t dead[] = {
	//game over !
 {PITCH_A4,2}, {PITCH_A4,2},{PITCH_A4,1},{PITCH_A4,2},  // ok...
 //{PITCH_C4,2}, {PITCH_H4,1},{PITCH_A4,2},//{PITCH_H4,1},{PITCH_H4,1},
  
  {PITCH_A4,1},{PITCH_G3,1},{PITCH_E3,1},{PITCH_D3,1},
 
 //{PITCH_H4,1},{PITCH_H4,3}, 
 { PITCH_END, 0 }
};


//--------------------------------------------------------------------------

int tuning();
int vitesseGrad();
wakeup_t emitNoir(wakeup_t data);
int calibrate();
int standup();
int watchDir();
int bigBrother();
int task_manager();

#endif



2001-01-11