/*****************************************************************/ /* */ /* CASIO fx-9860G SDK Library */ /* */ /* File name : [ProjectName].c */ /* */ /* Copyright (c) 2006 CASIO COMPUTER CO., LTD. */ /* */ /*****************************************************************/ #include "periodiq.h" #include "display.h" #include "stdlib.h" #include "stdio.h" #include "ctype.h" #include "keyboard.h" #include "tales.h" //#include //#include int atoi(const char *str) { // Variables declaration. int n=0, sign=1; // Parsing string until the first glyph. while(isspace(*str)) str++; // Checking sign. if(*str=='-') sign=-1, str++; else if(*str=='+') sign=+1, str++; // Reading digits. while(isdigit(*str)) { n += *str - '0'; if(*++str) n *= 10; } // Returning the final value. return n*sign; } //**************************************************************************** // AddIn_main (Sample program main function) // // param : isAppli : 1 = This application is launched by MAIN MENU. // : 0 = This application is launched by a strip in eACT application. // // OptionNum : Strip number (0~3) // (This parameter is only used when isAppli parameter is 0.) // // retval : 1 = No error / 0 = Error // //**************************************************************************** struct Element elements[] = { { /*1 */"Hydrogene", "H", 1, 1008, 1, 1, 220, 0, 1, {1} }, { /*2 */"Helium", "He", 0, 4003, 18, 1, -1, 2, 1, {2} }, { /*3 */"Lithium", "Li", 1, 6940, 1, 2, 98, 4, 0, {2, 1} }, { /*4 */"Beryllium", "Be", 2, 9012, 2, 2, 157, 5, 0, {2, 2} }, { /*5 */"Bore", "B", 3, 10810, 13, 2, 204, 3, 0, {2, 3} }, { /*6 */"Carbone", "C", 4, 12011, 14, 2, 255, 0, 0, {2, 4} }, { /*7 */"Azote", "N", 5, 14007, 15, 2, 304, 0, 1, {2, 5} }, { /*8 */"Oxygene", "O", 2, 15999, 16, 2, 344, 0, 1, {2, 6} }, { /*9 */"Fluor", "F", 1, 18998, 17, 2, 398, 1, 1, {2, 7} }, {/*10 */"Neon", "Ne", 0, 20178, 18, 2, -1, 2, 1, {2, 8} }, {/*11 */"Sodium", "Na", 1, 22990, 1, 3, 93, 4, 0, {2, 8, 1} }, {/*12 */"Magnesium", "Mg", 2, 24305, 2, 3, 131, 5, 0, {2, 8, 2} }, {/*13 */"Aluminium", "Al", 3, 26982, 13, 3, 161, 9, 0, {2, 8, 3} }, {/*14 */"Silicium", "Si", 4, 28085, 14, 3, 190, 3, 0, {2, 8, 4} }, {/*15 */"Phosphore", "P", 5, 30974, 15, 3, 219, 0, 0, {2, 8, 5} }, {/*16 */"Soufre", "S", 6, 32060, 16, 3, 258, 0, 0, {2, 8, 6} }, {/*17 */"Chlore", "Cl", 7, 35450, 17, 3, 316, 1, 1, {2, 8, 7} }, {/*18 */"Argon", "Ar", 2, 39948, 18, 3, -1, 2, 1, {2, 8, 8} }, {/*19 */"Potassium", "K", 1, 39098, 1, 4, 82, 4, 0, {2, 8, 8, 1} }, {/*20 */"Calcium", "Ca", 2, 40078, 2, 4, 100, 5, 0, {2, 8, 8, 2} }, {/*21 */"Scandium", "Sc", 3, 44956, 3, 4, 136, 8, 0, {2, 8, 9, 2} }, {/*22 */"Titane", "Ti", 4, 47867, 4, 4, 154, 8, 0, {2, 8, 10, 2} }, {/*23 */"Vanadium", "Va", 5, 50941, 5, 4, 163, 8, 0, {2, 8, 11, 2} }, {/*24 */"Chrome", "Cr", 6, 51996, 6, 4, 166, 8, 0, {2, 8, 13, 1} }, {/*25 */"Manganese", "Mn", 7, 54380, 7, 4, 155, 8, 0, {2, 8, 13, 2} }, {/*26 */"Fer", "Fe", 6, 55845, 8, 4, 183, 8, 0, {2, 8, 14, 2} }, {/*27 */"Cobalt", "Co", 5, 58933, 9, 4, 188, 8, 0, {2, 8, 15, 2} }, {/*28 */"Nickel", "Ni", 4, 58693, 10, 4, 191, 8, 0, {2, 8, 16, 2} }, {/*29 */"Cuivre", "Cu", 4, 63546,11, 4, 190, 8, 0, {2, 8, 18, 1} }, {/*30 */"Zinc", "Zn", 2, 65380, 12, 4, 165, 8, 0, {2, 8, 18, 2} }, {/*31 */"Gallium", "Ga", 3, 69723, 13, 4, 181, 9, 0, {2, 8, 18, 3} }, {/*32 */"Germanium", "Ge", 4, 72630, 14, 4, 201, 3, 0, {2, 8, 18, 4} }, {/*33 */"Arsenic", "As", 4, 74921, 15, 4, 218, 3, 0, {2, 8, 18, 5} }, {/*34 */"Selenium", "Se", 6, 78971, 16, 4, 255, 0, 0, {2, 8, 18, 6} }, {/*35 */"Brome", "Br", 7, 79904, 17, 4, 296, 1, 2, {2, 8, 18, 7} }, {/*36 */"Krypton", "Kr", 2, 83798, 18, 4, 300 , 2, 1, {2, 8, 18, 8} }, {/*37 */"Rubidium", "Rb", 1, 85468, 1, 5, 82, 4, 0, {2, 8, 18, 8, 1} }, {/*38 */"Strontium", "Sr", 2, 87620, 2, 5, 95, 5, 0, {2, 8, 18, 8, 2} }, {/*39 */"Yttrium", "Y", 3, 88906, 3, 5, 122, 8, 0, {2, 8, 18, 9, 2} }, {/*40 */"Zirconium", "Zr", 4, 91224, 4, 5, 133, 8, 0, {2, 8, 18, 10, 2} }, {/*41 */"Niobium", "Nb", 5, 92906, 5, 5, 160, 8, 0, {2, 8, 18, 12, 1} }, {/*42 */"Molybdene", "Mo", 6, 95950, 6, 5, 216, 8, 0, {2, 8, 18, 13, 1} }, {/*43 */"Technetium", "Tc", 7, 98000, 7, 5, 190, 8, 0, {2, 8, 18, 13, 2} }, {/*44 */"Ruthenium", "Ru", 8, 101070, 8, 5, 220, 8, 0, {2, 8, 18, 15, 1} }, {/*45 */"Rhodium", "Rh", 6, 102906, 9, 5, 228, 8, 0, {2, 8, 18, 16, 1} }, {/*46 */"Palladium", "Pd", 4, 106420, 10, 5, 8, 0, 220, {2, 8, 18, 18} }, {/*47 */"Argent", "Ag", 4, 107869, 11, 5, 8, 0, 193, {2, 8, 18, 18, 1} }, {/*48 */"Cadmium", "Cd", 2, 112414, 12, 5, 8, 0, 169, {2, 8, 18, 18, 2} }, {/*49 */"Indium", "In", 2, 114818, 13, 5, 9, 0, 178, {2, 8, 18, 18, 3} }, {/*50 */"Etain", "Sn", 3, 118710, 14, 5, 9, 0, 196, {2, 8, 18, 18, 4} }, {/*51 */"Antimoine", "Sb", 5, 121760, 15, 5, 205, 3, 0, {2, 8, 18, 18, 5} }, {/*52 */"Tellure", "Te", 6, 127600, 16, 5, 210, 3, 0, {2, 8, 18, 18, 6} }, {/*53 */"Iode", "I", 7, 126904, 17, 5, 266, 1, 0, {2, 8, 18, 18, 7} }, {/*54 */"Xenon", "Xe", 8, 130293, 18, 5, 260, 2, 1, {2, 8, 18, 18, 8} }, {/*55 */"Cesium", "Cs", 1, 132905, 1, 6, 79, 4, 0, {2, 8, 18, 18, 8, 1} }, {/*56 */"Baryum", "Ba", 2, 137327, 2, 6, 89, 5, 0 ,{2, 8, 18, 18, 8, 2} }, {/*57 */"Lanthane", "La", 3, 138910, 4, 6, 110, 6, 0, {2, 8, 18, 19, 8, 2} }, // lanthanides {/*58 */"Cerium", "Ce", 4, 140116, 5, 6, 112, 6, 0, {2, 8, 18, 19, 8, 2} }, {/*59 */"Praseodyme", "Pr", 4, 140907, 6, 6, 113, 6, 0, {2, 8, 18, 21, 8, 2} }, {/*60 */"Neodyme", "Nd", 3, 144242, 7, 6, 114, 6, 0, {2, 8, 18, 22, 8, 2} }, {/*61 */"Promethium", "Pm", 3, 145000, 8, 6, -1, 6, 0, {2, 8, 18, 23, 8, 2} }, {/*62 */"Samarium", "Sm", 2, 150360, 9, 6, 117, 6, 0, {2, 8, 18, 24, 8, 2} }, {/*63 */"Europium", "Eu", 3, 151964, 10, 6, -1, 6, 0, {2, 8, 18, 25, 8, 2} }, {/*64 */"Gadolinium", "Gd", 3, 157250, 11, 6, 120, 6, 0, {2, 8, 18, 25, 9, 2} }, {/*65 */"Terbium", "Tb", 4, 158925, 12, 6, -1, 6, 0,{2, 8, 18, 27, 8, 2} }, {/*66 */"Dysprosium", "Dy", 3, 162500, 13, 6, 112, 6, 0, {2, 8, 18, 28, 8, 2} }, {/*67 */"Holmium", "Ho", 3, 164930, 14, 6, 123, 6, 0, {2, 8, 18, 29, 8, 2} }, {/*68 */"Erbium", "Er", 3, 167259, 15, 6, 124, 6, 0, {2, 8, 18, 30, 8, 2} }, {/*69 */"Thulium", "Tm", 3, 168934, 16, 6, 125, 6, 0, {2, 8, 18, 31, 8, 2} }, {/*70 */"Yttrebium", "Yb", 3, 173054, 17,6, -1, 6, 0, {2, 8, 18, 32, 8, 2} }, {/*71 */"Lutecium", "Lu", 3, 174967, 18, 6, 127, 6, 0, {2, 8, 18, 32, 9, 2} }, //fin des lanthanides {/*72 */"Hafnium", "Hf", 4, 178490, 4, 6, 130, 8, 0, {2, 8, 18, 32, 10, 2} }, {/*73 */"Tantale", "Ta", 5, 180948, 5, 6, 150, 8, 0, {2, 8, 18, 32, 11, 2} }, {/*74 */"Tungstene", "W", 6, 183840, 6, 6, 236, 8, 0, {2, 8, 18, 32, 12, 2} }, {/*75 */"Rhenium", "Re", 7, 186207, 7, 6, 190, 8, 0, {2, 8, 18, 32, 13, 2} }, {/*76 */"Osmium", "Os", 8, 190230, 8, 6, 220, 8, 0, {2, 8, 18, 32, 14, 2} }, {/*77 */"Iridium", "Ir", 8, 192217, 9, 6, 220, 8, 0, {2, 8, 18, 32, 15, 2} }, {/*78 */"Platine", "Pt", 6, 195084, 10, 6, 228, 8, 0, {2, 8, 18, 32, 1, 1} }, {/*79 */"Or", "Au", 5, 196967, 11, 6, 254, 8, 0, {2, 8, 18, 32, 18, 1} }, {/*80 */"Mercure", "Hg", 4, 200590, 12, 6, 200, 8, 2, {2, 8, 18, 32, 18, 2} }, {/*81 */"Thallium", "Tl", 3, 204380, 13, 6, 162, 9, 0, {2, 8, 18, 32, 18, 3} }, {/*82 */"Plomb", "Pb", 4, 207200, 14, 6, 233, 9, 0, {2, 8, 18, 32, 18, 4} }, {/*83 */"Bismuth", "Bi", 5, 208980, 15, 6, 202, 9, 0, {2, 8, 18, 32, 18, 5} }, {/*84 */"Polonium", "Po", 6, 209000, 16, 6, 200, 3, 0, {2, 8, 18, 32, 18, 6} }, {/*85 */"Astate", "At", 7, 210000, 17, 6, 220, 1, 0, {2, 8, 18, 32, 18, 7} }, {/*86 */"Radon", "Rn", 6, 212000, 18, 6, -1, 2, 1, {2, 8, 18, 32, 18, 8} }, {/*87 */"Francium", "Fr", 1, 223000, 1, 7, 70, 4, 0, {2, 8, 18, 32, 18, 8, 1} }, {/*88 */"Radium", "Ra", 2, 226000, 2, 7, 90, 5, 0, {2, 8, 18, 32, 18, 8, 2} }, {/*89 */"Actinium", "Ac", 3, 227000, 4, 7, 110, 7, 0, {2, 8, 18, 32, 18, 9, 2} }, // actinide {/*90 */"Thorium", "Th", 4, 232038, 5, 7, 130, 7, 0, {2, 8, 18, 32, 18, 10, 2} }, {/*91 */"Protactinium", "Pa", 5, 231036, 6, 7, 150, 7, 0, {2, 8, 18, 32, 20, 9, 2} }, {/*92 */"Uranium", "U", 6, 238029, 7, 7, 138, 7, 0, {2, 8, 18, 32, 21, 9, 2} }, {/*93 */"Neptunium", "Np", 7, 237000, 8, 7, 136, 7, 0, {2, 8, 18, 32, 22, 9, 2} }, {/*94 */"Plutonium", "Pu", 8, 244000, 9, 7, 128, 7, 0, {2, 8, 18, 32, 24, 8, 2} }, {/*95 */"Americum", "Am", 6, 243000, 10, 7, 130, 7, 0, {2, 8, 18, 32, 25, 8, 2} }, {/*96 */"Curium", "Cm", 4, 247000, 11, 7, 130, 7, 0, {2, 8, 18, 32, 25, 9, 2} }, {/*97 */"Berkelium", "Bk", 4, 247000, 12, 7, 130, 7, 0, {2, 8, 18, 32, 28, 8, 2} }, {/*98 */"Californium", "Cf", 4, 251000, 13, 7, 130, 7, 0, {2, 8, 18, 32, 28, 8, 2} }, {/*99 */"Einsteinium", "Es", 3, 252000, 14, 7, 130, 7, 0, {2, 8, 18, 32, 29, 8, 2} }, {/*100 */"Fermium", "Fm", 3, 257000, 15, 7, 130, 7, 0, {2, 8, 18, 32, 30, 8, 2} }, {/*101 */"Mendelevium", "Md", 3, 258000, 16, 7, 130, 7, 0, {2, 8, 18, 32, 31, 8, 2} }, {/*102 */"Nobelium", "No", 3, 259000, 17, 7, 130, 7, 0, {2, 8, 18, 32, 32, 8, 2} }, {/*103 */"Lawrencium", "Lr", 3, 262000, 18, 7, -1, 7, 0, {2, 8, 18, 32, 32, 8, 3} }, // fin des actinides {/*104 */"Rutherfordium", "Rf", 4, 267000, 4, 7, -1, 8, 3, {2, 8, 18, 32, 32, 10, 2} }, {/*105 */"Dubnium", "Db", 5, 268000, 5, 7, -1, 8, 3, {2, 8, 18, 32, 32, 11, 2} }, {/*106 */"Seaborg", "Sg", 6, 271000, 6, 7, -1, 8, 3, {2, 8, 18, 32, 32, 12, 2} }, {/*107 */"Bohrium", "Bh", 7, 272000, 7, 7, -1, 8, 3, {2, 8, 18, 32, 32, 13, 2} }, {/*108 */"Hassium", "Hs", 8, 270000, 8, 7, -1, 8, 3, {2, 8, 18, 32, 32, 14, 2} }, {/*109 */"Meitnerium", "Mt", -1, 276000, 9, 7, -1, 8, 3, {2, 8, 18, 32, 32, 15, 2} }, {/*110 */"Darmstadium", "Ds", -1, 281000, 10, 7, -1, 8, 3, {2, 8, 18, 32, 32, 17, 1} }, {/*111 */"Roengenium", "Rg", -1,280000, 11, 7, -1, 8, 3, {2, 8, 18, 32, 32, 18, 1} }, {/*112 */"Copernicium", "Cn", -1, 285000, 12, 7, -1, 8, 3, {2, 8, 18, 32, 32, 18, 2} }, {/*113 */"Ununtrium", "Uut", -1, 284000, 13, 7, -1, 9, 3, {2, 8, 18, 32, 32, 18, 3} }, {/*114 */"Flerovium", "Fl", -1, 289000, 14, 7, -1, 9, 3, {2, 8, 18, 32, 32, 18, 4} }, {/*115 */"Ununpentium", "Uup", -1, 288000, 15, 7, -1, 9, 3, {2, 8, 18, 32, 32, 18, 5} }, {/*116 */"Livermorium", "Lv", -1, 288000, 16, 7, -1, 9, 3, {2, 8, 18, 32, 32, 18, 6} }, {/*117 */"Ununseptium", "Uus", -1, 294000, 17, 7, -1, 1, 3, {2, 8, 18, 32, 32, 18, 7} }, {/*118 */"Ununoctium", "Uun", -1, 294000, 18, 7, -1, 2, 3, {2, 8, 18, 32, 32, 18, 8} }, }; char *family[25] ={ {"non metaux"}, //0 {"halogene"}, //1 {"gaz rare"}, //2 {"metalloide"}, //3 {"metal alcalin"}, //4 {"metal alcalino terreux"}, //5 {"lanthanide"}, //6 {"actinide"}, //7 {"metal de transition"}, //8 {"post transition metal"}//9 }; char *etat[9]={ {"solide"}, //0 {"gaz"}, //1 {"liquide"}, //2 {"inconnu"}, //3 }; extern Font modern; #define floor(x) ((int)(x)) static const int counts[] = { 2, 8, 8, 18, 18, 32, 32 }; static const int firsts[] = { 1, 2, 2, 3, 3, 18, 18 }; /* returns element number (1-118) or 0 if there is nothing at the given cell */ /* x and y can hold any value, even if it's outside the table */ int element_at(int x, int y) { if(x < 0 || x >= 18 || y < 0 || y >= 9) return 0; if(y >= 7) { if(x < 3 || x > 17) return 0; return ((y == 7) ? (57) : (89)) + (x - 4); } int result = 0; if(x >= firsts[y]) { if(x + (counts[y] - firsts[y]) < 18) return 0; else x -= (18 - counts[y]); } while(--y >= 0) result += counts[y]; return result + x + 1 ; } /* updates x and y if there is an element if the requested direction */ /* in this case, returns the element's number; otherwise returns 0 */ int move(int *x, int *y, enum { up = 0, right, down, left } dir) { int dx[] = { 0, 1, 0, -1 }; int dy[] = { -1, 0, 1, 0 }; int elt = element_at(*x + dx[dir], *y + dy[dir]); if(elt) *x += dx[dir], *y += dy[dir]; return elt; } int main() { tableauElement(0); return 1; } void Mini(char* chaine, int n ) // fonc defini le numero de la fonction { short j; dtext(n*21+strlen(chaine), 58, chaine); drect(n*21+2, 56, n*21+20, 63, color_invert); //ML_display_vram(); } int tableauElement(int chang) { short decalx = 0, decaly = 0; unsigned char x = 1, y = 1; unsigned char i; text_configure(&modern, color_black); while(1) { dclear(); for(i = 0; i < 118; i++) { //dtext(13*(elements[i].groupe-1)+decalx+1, 8*( elements[i].famille == 6 || elements[i].famille == 7 ? elements[i].periode + 3 : elements[i].periode) +decaly-6, elements[i].symbol); } // x = elements[chang].groupe; // y = ( elements[chang].famille == 6 || elements[chang].famille == 7 ? elements[chang].periode + 3 : elements[chang].periode); dprint(1,1, "(%d,%d) => %d", x,y,element_at(x, y)); //drect(13*x,8*y,13*x+12,8*y+8, color_black); dupdate(); //drect() key=getkey(); switch(key) { case KEY_UP : y--; break; case KEY_DOWN : y++; break; case KEY_LEFT : x--; break; case KEY_RIGHT : x++; break; // case KEY_F4 : chang=tableauEleMini(chang); break; case KEY_F2 : chang=find(chang); break; // case KEY_F3 : calcul_mole(); break; case KEY_F6 : case KEY_EXE : chang=detailsElement(3); break; case KEY_EXIT : return 1; } } } int tableauEleMini(int chang) { /*char buffer[50]; char y; char menu=0; char choix=-1; while(1) { dclear(); // ML_bmp_or(TABLEAU_MINI, 0, 0, 91, 48); choix_famille(choix); // on met en place le choix sur les familles chang=(chang>=118 ? 0 : chang<=-1 ? 117 : chang); y=(chang>55 && chang<71 ? 9 : chang>87 && chang<103 ? 10 : elements[chang].periode); if (chang>55 && chang<71 || chang>87 && chang<103) { drect(5*elements[chang].groupe-4, 5*y-7, 5*elements[chang].groupe-1, 5*y-4, color_black); } else { drect(5*elements[chang].groupe-4, 5*y-4, 5*elements[chang].groupe-1, 5*y-1, color_black); } dtext(110-3*strlen(elements[chang].symbol), 13, elements[chang].symbol); sprintf(buffer, "%d", chang+1); // détail des éléments sur la droite dtext(110-2*strlen(buffer), 5, buffer); sprintf(buffer, "%.3f", elements[chang].masse_mol); dtext(110-2*strlen(buffer), 23, buffer); if(menu==0) { Mini("maxi", 0); Mini("find", 1); Mini("mol", 2); Mini("fami", 4); Mini("det", 5); key=getkey(); switch(key) { case KEY_F1 : case KEY_EXIT : return chang; case KEY_F2 : chang=find(chang); break; case KEY_F3 : calcul_mole(); break; case KEY_F5 : menu=1; break; case KEY_F6 : chang=detailsElement(chang); break; } } else if (menu==1) { Mini("n-me", 0); Mini("halo", 1); Mini("g-ra", 2); Mini("m-ti", 3); Mini("m-al", 4); Mini(" -->", 5); key=getkey(); switch(key) { case KEY_EXIT : menu=0; choix=-1; break; case KEY_F1 : choix=0; break; case KEY_F2 : choix=1; break; case KEY_F3 : choix=2; break; case KEY_F4 : choix=3; break; case KEY_F5 : choix=4; break; case KEY_F6 : menu=2; break; // on change dans les 2 menus } } else if (menu==2) { Mini("m-at", 0); Mini("lant", 1); Mini("acta", 2); Mini("m-tr", 3); Mini("p-tr", 4); Mini(" -->", 5); key=getkey(); switch(key) { case KEY_EXIT : menu=0; choix=-1;break; case KEY_F1 : choix=5; break; case KEY_F2 : choix=6; break; case KEY_F3 : choix=7; break; case KEY_F4 : choix=8; break; case KEY_F5 : choix=9; break; case KEY_F6 : menu=1; break; // on change dans les 2 menus } } switch(key) // pour les touches principales à chaque fois { case KEY_LEFT : chang+=1; break; case KEY_RIGHT : chang-=1; break; case KEY_DOWN : chang=elements[chang].dessous; break; case KEY_UP : chang=elements[chang].dessus; break; case KEY_EXE : chang=detailsElement(chang); break; } }*/ } void choix_famille(int choix) { /* char i=0, y; for(i;i<118;++i) { if (choix==ajout[i].famille) { y=(i>55 && i<71 ? 9 : i>87 && i<103 ? 10 : elements[i].periode); (i>55 && i<71 || i>87 && i<103 ? ML_bmp_or(select, 5*elements[i].groupe-4, 5*y-7, 4, 4) : ML_bmp_or(select, 5*elements[i].groupe-4, 5*y-4, 4, 4)); ML_bmp_or(select, 20, 50, 4, 4); dtext(30, 50, family[choix]); } }*/ } int detailsElement(int a) { unsigned char buffer[50]; unsigned char page = 0; unsigned char i, j = 0; text_configure(&modern, color_black); while (1) { dclear(); dprint(20, 2, "%s", elements[a].symbol); dprint(40, 2, "%s", elements[a].nom); dprint((10-a/25), 4, "%d", a+1); dline(0, 10, 128, 10, color_black); dline(127, 22*page + 12, 127, 22*page + 42, color_black); switch(page) { case 0 : { dprint(1, 12, "masse molaire %d.%03d g/mol", elements[a].masse_mol/1000, elements[a].masse_mol % 1000); dprint(20, 22, "propriete de base"); sprintf(buffer, "groupe : %d ", elements[a].groupe); if(elements[a].famille==6 || elements[a].famille==7) { sprintf(buffer, "groupe inconnu"); } dtext(1, 32, buffer); sprintf(buffer, "periode : %d ", elements[a].periode); dtext(1, 42, buffer); j=0; for(i = 0; i < strlen(elements[a].config_electro); i++) { if(elements[a].config_electro[i]>=10) { buffer[j++] = (int)elements[a].config_electro[i]/10 + '0'; buffer[j++] = elements[a].config_electro[i]%10 + '0'; } else { buffer[j++] = elements[a].config_electro[i] + '0'; } buffer[j++] = '-'; } j--; buffer[j]=0; sprintf(buffer, "couch electro %s", buffer); dtext(1, 52, buffer); break; } case 1 : { dprint(1, 12, "famille %s", family[elements[a].famille]); dprint(1, 22, "etat a 293.15 K : %s", etat[elements[a].etat]); dtext(20, 32, "reactivite :"); if (elements[a].electro_neg == -1) { sprintf(buffer, "electro neg inconnue"); } else { sprintf(buffer, "electro neg : %d.%02d ", elements[a].electro_neg/100, elements[a].electro_neg%100); } dtext(1, 42, buffer); if (elements[a].valence == -1) { sprintf(buffer, "valence inconnue "); } else { sprintf(buffer, "valence : %d", elements[a].valence); } dtext(1, 52, buffer); break; } } Mini("ret", 5); dupdate(); key=getkey(); switch (key) { case KEY_LEFT : a-=1; break; case KEY_RIGHT : a+=1; break; case KEY_DOWN : page = (page <= 1 ? 1 : page + 1); break; case KEY_UP : page = (page >=0 ? 0 : page - 1); break; case KEY_F6 : case KEY_EXE : case KEY_EXIT : return a; } a=(a<0 ? 117 : a>117 ? 0 : a); } } unsigned char* input(unsigned char* ask, unsigned char size, unsigned char* char_allowed) { unsigned char buffer[50]; unsigned char j,i; j=0; while(1) { dclear(); dtext(1, 1, ask); dtext(1, 20, buffer); dupdate(); key=getkey(); for(i = 0; i < strlen(char_allowed); i++) { if(char_allowed[i]==key_char(key) && j < size) { buffer[j++] = key_char(key); buffer[j]=0; } } if(key == KEY_DEL) { j--; buffer[j]=0; } if(key == KEY_EXE || key == KEY_EXIT) { return buffer; } } } int find(chang) { char *numero=NULL; char i=0, j=0; unsigned char buffer[50]; dclear(); dtext(10, 1, "Vous cherchez :"); dtext(10, 15, "1. numero de l'element"); dtext(10, 25, "2. masse molaire"); dtext(10, 35, "3. Symbole de l'element"); dtext(10, 45, "4. Nom de l'element"); dupdate(); while (1) { key=getkey(); switch(key) { case KEY_1 : { numero=input("Element num :", 3, "0123456789"); if (atoi(numero)>0 && atoi(numero)<119) { return atoi(numero)-1; } break; } case KEY_2 : { while(1) { numero=input("Masse molaire de :", 3, "0123456789"); for (i=0;i<118;i++) { if (atoi(numero)==floor(elements[i].masse_mol/1000+0.5)) { return i; } } } break; } /* case KEY_3 : { while(1) { Bdisp_AllClr_DDVRAM(); dtext(1, 1, "Vous cherchez le symbole ?", 0); EI_manage_config(EI_SET_START_MODE, EI_ALPHA_LOCKED); numero=EI_input_string(3, (const char*)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); numero[0]=toupper (numero[0]); // on met le 1er caractère en majuscule for (i=0;i<118;i++) { for (j = 1 ; numero[j] != '\0' ; j++) { numero[j] = tolower(numero[j]); // on met certains caractères en minuscule pour la recherche } if (!strcmp(numero, elements[i].symbol)) { return i; } } } } case KEY_4 : { while(1) { Bdisp_AllClr_DDVRAM(); dtext(1, 1, "Vous cherchez le nom ?", 0); EI_manage_config(EI_SET_START_MODE, EI_ALPHA_LOCKED); numero=EI_input_string(13, (const char*)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); numero[0]=toupper(numero[0]); // on met le 1er caractère en majuscule for (i=0;i<118;i++) { for (j = 1 ; numero[j] != '\0' ; j++) { numero[j] = tolower(numero[j]);// on met certains caractères en minuscule pour la recherche } if (!strcmp(numero, elements[i].nom)) { return i; } } } }*/ case KEY_EXIT : return chang; } } } void calcul_mole() {/* char *str = NULL, *p=str; char characts[20]={'\0'}; char i=0; float result=0, masse; const char buffer[50]={0}; char cap; while(1) { Bdisp_AllClr_DDVRAM(); dtext(1, 1, "Entrez votre formule : "); Mini("A a", 0); EI_init(); EI_manage_config(EI_SET_COLUMN, 1); EI_manage_config(EI_SET_ROW, 2); EI_manage_config(EI_SET_START_MODE, EI_NORMAL); str=EI_input_string(25, (const char*)"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); Bdisp_AllClr_DDVRAM(); sprintf(buffer, "%s", str); PrintXY(64-3*strlen(str), 10, buffer, 36); while(*str) // on va jusqu'a la fin de la chaine { i=0; while(isalpha(*str)) // on prends seulement les lettres { characts[i]=tolower(*str); // on copie la lettre en minuscule directement dans characts ++i; ++str; } characts[0]=toupper(characts[0]); // on met le 1er caractère en majuscule for(i=0;i<118;i++) // on se déplace dans les éléments de la structure { if(!strcmp(characts, elements[i].symbol)) { masse=elements[i].masse_mol; // on a la masse molaire break; } } for(i=0;i<20;++i) // on remet tout à zéro : évite les erreurs characts[i]='\0'; i=0; while(isdigit(*str)) // on prends seulement les chiffres { characts[i]=*str; // on copie la lettre dans characts ++i; ++str; } result += atoi(characts)*masse; for(i=0;i<4;++i) // on remet tout à zéro : évite les erreurs characts[i]='\0'; } free(p); dtext(1, 30, "la masse molaire est de"); sprintf(buffer, "%.3f g/mol", result); dtext(1, 40, buffer); Mini("calc", 0); Mini("ret", 5); result=0; GetKey(&key); switch(key) { case 29 : return; } }*/ }