/* * morse.c * * Created: 18/05/2021 15:47:14 * Author: yboujon1 */ #include "main.h" #include "morse.h" unsigned char morse_library[LETTRES][7]= { {'a',POINT,TRAIT,'\0'}, {'b',TRAIT,POINT,POINT,POINT,'\0'}, {'c',TRAIT,POINT,TRAIT,POINT,'\0'}, {'d',TRAIT,POINT,POINT,'\0'}, {'e',POINT,'\0'}, {'f',POINT,POINT,TRAIT,POINT,'\0'}, {'g',TRAIT,TRAIT,POINT,'\0'}, {'h',POINT,POINT,POINT,POINT,'\0'}, {'i',POINT,POINT,'\0'}, {'j',POINT,TRAIT,TRAIT,TRAIT,'\0'}, {'k',TRAIT,POINT,TRAIT,'\0'}, {'l',POINT,TRAIT,POINT,POINT,'\0'}, {'m',TRAIT,TRAIT,'\0'}, {'n',TRAIT,POINT,'\0'}, {'o',TRAIT,TRAIT,TRAIT,'\0'}, {'p',POINT,TRAIT,TRAIT,POINT,'\0'}, {'q',TRAIT,TRAIT,POINT,TRAIT,'\0'}, {'r',POINT,TRAIT,POINT,'\0'}, {'s',POINT,POINT,POINT,'\0'}, {'t',TRAIT,'\0'}, {'u',POINT,POINT,TRAIT,'\0'}, {'v',POINT,POINT,POINT,TRAIT,'\0'}, {'w',POINT,TRAIT,TRAIT,'\0'}, {'x',TRAIT,POINT,POINT,TRAIT,'\0'}, {'y',TRAIT,POINT,TRAIT,TRAIT,'\0'}, {'z',TRAIT,TRAIT,POINT,POINT,'\0'}, {'0',TRAIT,TRAIT,TRAIT,TRAIT,TRAIT,'\0'}, {'1',POINT,TRAIT,TRAIT,TRAIT,TRAIT,'\0'}, {'2',POINT,POINT,TRAIT,TRAIT,TRAIT,'\0'}, {'3',POINT,POINT,POINT,TRAIT,TRAIT,'\0'}, {'4',POINT,POINT,POINT,POINT,TRAIT,'\0'}, {'5',POINT,POINT,POINT,POINT,POINT,'\0'}, {'6',TRAIT,POINT,POINT,POINT,POINT,'\0'}, {'7',TRAIT,TRAIT,POINT,POINT,POINT,'\0'}, {'8',TRAIT,TRAIT,TRAIT,POINT,POINT,'\0'}, {'9',TRAIT,TRAIT,TRAIT,TRAIT,POINT,'\0'} }; void envoyer_signe_morse(unsigned char signe_morse) { switch(signe_morse){ case POINT: start_timer0(); //démarre la fréquence 440 Hz start_timer1(ONEMS*speed); // 100ms*vitesse wait_ocf1a_timer1(); // d'attente stop_timer0(); //arrêt de 440 Hz start_timer1(ONEMS*speed); // 100ms*vitesse wait_ocf1a_timer1(); // d'attente break; case TRAIT: start_timer0(); //démarre la fréquence 440 Hz start_timer1(3*ONEMS*speed); // 300ms*vitesse wait_ocf1a_timer1(); // d'attente stop_timer0(); //arrêt de 440 Hz start_timer1(ONEMS*speed); // 100ms*vitesse wait_ocf1a_timer1(); // d'attente break; case INTERLETTRE: start_timer1(2*ONEMS*speed); // 200ms*vitesse wait_ocf1a_timer1(); // d'attente break; case INTERMOT: start_timer1(10*ONEMS*speed); // 1s*vitesse wait_ocf1a_timer1(); // d'attente break; case FIN: resume_timer1(); //on relance l'attente stop_timer1(); //on arrête les attentes break; default: break; }; } void maj2min_convert(char *tab, int n) { int i; //on initialise i for(i=0; i<=n; i++) //on incrémente tant qu'il n'est pas plus grand que la taille n { if(tab[i]>=65 && tab[i]<=90) //si c'est une majuscule { tab[i]=tab[i]+32; //la met en minuscule } else { tab[i]=tab[i]; //sinon rien }; }; } void printandtranslate(char *tab, int n) { int i=0; //varie la chaine de caractere int j=0; //varie la librarie int multiple=0; //tous les 16 caractères, s'incrémente do { firstlinetext(tab,i,&multiple,n); //16 caractères de la chaîne sur la première ligne switch(j) { case 0: //UNIQUEMENT quand j=0 secondlinetext(tab,&i,multiple);//seconde ligne de la chaîne pour un caractère maj2min_convert(tab,i); //converti les majuscules en minuscule default: //SINON dans tous les autres cas latin2morse(tab,&i,&j); //traduction morse break; }; }while(i