ECode.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /***********************************/
  2. /** Easy Coding **/
  3. /**Category : Snippets Collection **/
  4. /**@author Eiyeron **/
  5. /**@contact eiyeron@gmail.com **/
  6. /**@file ECode.h **/
  7. /**Version : 1.11 **/
  8. /**Date of creation : 06/28/2011 **/
  9. /***********************************/
  10. #ifndef EASYCODE
  11. #define EASYCODE
  12. /****************************************************/
  13. /** uncomment #define EASY_of functions you want to use **/
  14. /****************************************************/
  15. // #define EASY_ALL //define all functions
  16. // #define EASY_MODEL
  17. // #define EASY_STRING
  18. // #define EASY_2STR
  19. // #define EASY_2NUM
  20. // #deinfe EASY_ALL_2HEX
  21. // #define EASY_OPS_BITS
  22. #define EASY_KEYS_DETECTION
  23. // #define EASY_OTHERS
  24. /**MODEL DETECTION**/
  25. // #define EASY_ISEMULATOR
  26. // #define EASY_ISG35P
  27. // #define EASY_ISG75
  28. // #define EASY_ISG85P
  29. // #define EASY_ISG95
  30. // #define EASY_MODELDETECTOR
  31. /**STRING MANIUPLATION**/
  32. // #define EASY_TOLOWER
  33. // #define EASY_TOUPPER
  34. // #define EASY_STRMIRROR
  35. // #define EASY_STRROTATE
  36. // #define EASY_PRINTF
  37. // #define EASY_PRINTN
  38. /**TO STRING**/
  39. // #define EASY_CHAR2STR
  40. // #define EASY_UCHAR2STR
  41. #define EASY_INT2STR
  42. #define EASY_UINT2STR
  43. // #define EASY_FLOAT2STR
  44. /**TO NUMBER**/
  45. // #define EASY_STR2CHAR
  46. // #define EASY_STR2UCHAR
  47. #define EASY_STR2INT
  48. // #define EASY_STR2UINT
  49. /**TO HEX**/
  50. // #define EASY_CHAR2HEX
  51. // #define EASY_INT2HEX
  52. /**BITS OPERATIONS**/
  53. // #define EASY_READ_BIT_CHAR
  54. // #define EASY_UP_BIT_CHAR
  55. // #define EASY_DOWN_BIT_CHAR
  56. // #define EASY_INVERSE_BIT_CHAR
  57. // #define EASY_READ_BIT_INT
  58. // #define EASY_UP_BIT_INT
  59. // #define EASY_DOWN_BIT_INT
  60. // #define EASY_INVERSE_BIT_INT
  61. /**FAST KEYS DETECTION**/
  62. #define EASY_KEY_DOWN
  63. #define EASY_KEY_UP
  64. // #define EASY_ANY_KEY
  65. /**OTHERS**/
  66. #define EASY_INPUT
  67. // #define EASY_NUMARRAY_CHAR
  68. // #define EASY_NUMARRAY_INT
  69. /**USEFUL VARIABLES**/
  70. // #define NULL 0
  71. // #define EXIT_SUCCESS 1
  72. /**************************/
  73. /** Functions prototypes **/
  74. /**************************/
  75. typedef enum {EMUlATOR, G35, G75, G85, G85SD, G95, UNDEFINED} Model;
  76. /**MODEL DETECTION**/
  77. char isEmulator();
  78. char isG35p75();
  79. char isG75(); // BESOIN DE LA VALEUR!!!
  80. char isG85();
  81. char isG85SD();
  82. char isG95();
  83. char hasSD();
  84. Model modelDetector();
  85. /**STRING MANIUPLATION**/
  86. char* toLower(unsigned char* str, unsigned int len);
  87. char* toUpper(unsigned char* str, unsigned int len);
  88. char* strMirror(unsigned char* str, unsigned int len);
  89. char* strRotate(unsigned char* str, unsigned int len, unsigned char mov);
  90. void printf(unsigned char x, unsigned char y, unsigned char str, int mode);
  91. void printn(unsigned char x, unsigned char y, int n, unsigned char mode);
  92. /**TO STRING OPERATIONS**/
  93. unsigned char* intToStr(unsigned char* c, int n);
  94. unsigned char* uintToStr(unsigned char* c, unsigned int n);
  95. unsigned char* charToStr(char* c, char n);
  96. unsigned char* ucharToStr(char* c, unsigned char n);
  97. unsigned char* floatToStr(char* c, float f, int pecision);
  98. /**TO NUMBER**/
  99. char strToChar(char* c);
  100. unsigned char strToUchar(char* c);
  101. int strToInt(unsigned char* c);
  102. unsigned int strToUint(char* c);
  103. /**TO HEX**/
  104. char* charToHex(char* result, unsigned char hex);
  105. char* intToHex(char* result, unsigned int hex);
  106. /**BITS OPERATIONS**/
  107. char readBit_char(char num, char index);
  108. char inverseBit_char(char num, char index);
  109. char upBit_char(char num, char index);
  110. char downBit_char(char num, char index);
  111. char readBit_int(int num, char index);
  112. int inverseBit_int(int num, char index);
  113. int upBit_int(int num, char index);
  114. int downBit_int(int num, char index);
  115. /**KEY DETECTION**/
  116. unsigned char KeyDown( unsigned char code);
  117. unsigned char KeyUp( unsigned char code);
  118. unsigned char AnyKey();
  119. /**OTHERS**/
  120. char* input(char* c, int x, int y, int longueur, char nb);
  121. int numArray_char(char* arr);
  122. int numArray_int(char* arr);
  123. /********************/
  124. /** Key Codes List **/
  125. /********************/
  126. #define K_F1 0x69
  127. #define K_F2 0x59
  128. #define K_F3 0x49
  129. #define K_F4 0x39
  130. #define K_F5 0x29
  131. #define K_F6 0x19
  132. #define K_SHIFT 0x68
  133. #define K_OPTN 0x58
  134. #define K_VARS 0x48
  135. #define K_MENU 0x38
  136. #define K_LEFT 0x28
  137. #define K_UP 0x18
  138. #define K_ALPHA 0x67
  139. #define K_SQR 0x57
  140. #define K_EXPO 0x47
  141. #define K_EXIT 0x37
  142. #define K_DOWN 0x27
  143. #define K_RIGHT 0x17
  144. #define K_THETA 0x66
  145. #define K_LOG 0x56
  146. #define K_LN 0x46
  147. #define K_SIN 0x36
  148. #define K_COS 0x26
  149. #define K_TAN 0x16
  150. #define K_FRAC 0x65
  151. #define K_FD 0x55
  152. #define K_LPAR 0x45
  153. #define K_RPAR 0x35
  154. #define K_COMMA 0x25
  155. #define K_STORE 0x15
  156. #define K_7 0x64
  157. #define K_8 0x54
  158. #define K_9 0x44
  159. #define K_DEL 0x34
  160. #define K_4 0x63
  161. #define K_5 0x53
  162. #define K_6 0x43
  163. #define K_MULT 0x33
  164. #define K_DIV 0x23
  165. #define K_1 0x62
  166. #define K_2 0x52
  167. #define K_3 0x42
  168. #define K_PLUS 0x32
  169. #define K_MINUS 0x22
  170. #define K_0 0x61
  171. #define K_DOT 0x51
  172. #define K_EXP 0x41
  173. #define K_NEG 0x31
  174. #define K_EXE 0x21
  175. #define K_AC 0x00
  176. #endif //EASYCODE