Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Utils by
Utils.h@4:872676dd87a4, 2018-02-13 (annotated)
- Committer:
- POTLESS_2
- Date:
- Tue Feb 13 14:36:26 2018 +0000
- Revision:
- 4:872676dd87a4
- Parent:
- 3:01677db45b2a
- Child:
- 5:0f3b6e6677ef
reprise de la fonction file exist
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
POTLESS_2 | 0:794c15bd30b0 | 1 | #ifndef CHANGEME_H_ |
POTLESS_2 | 0:794c15bd30b0 | 2 | #define CHANGEME_H_ |
POTLESS_2 | 0:794c15bd30b0 | 3 | |
POTLESS_2 | 0:794c15bd30b0 | 4 | #include "mbed.h" |
POTLESS_2 | 0:794c15bd30b0 | 5 | #include <string> |
POTLESS_2 | 0:794c15bd30b0 | 6 | |
POTLESS_2 | 0:794c15bd30b0 | 7 | #include "FATFileSystem.h" |
POTLESS_2 | 0:794c15bd30b0 | 8 | #include "SDBlockDevice.h" |
POTLESS_2 | 0:794c15bd30b0 | 9 | #include <stdio.h> |
POTLESS_2 | 0:794c15bd30b0 | 10 | #include <errno.h> |
POTLESS_2 | 0:794c15bd30b0 | 11 | |
POTLESS_2 | 0:794c15bd30b0 | 12 | //PIN OUT carte SD |
POTLESS_2 | 0:794c15bd30b0 | 13 | #define SD_MOSI PA_7 |
POTLESS_2 | 0:794c15bd30b0 | 14 | #define SD_MISO PA_6 |
POTLESS_2 | 0:794c15bd30b0 | 15 | #define SD_SCK PA_5 |
POTLESS_2 | 0:794c15bd30b0 | 16 | #define SD_CS PB_6 |
POTLESS_2 | 0:794c15bd30b0 | 17 | |
POTLESS_2 | 0:794c15bd30b0 | 18 | /** Utils class. |
POTLESS_2 | 0:794c15bd30b0 | 19 | * Rassemblant des fonctions annexes pour le fonctionnement de l'ARNSRS. |
POTLESS_2 | 0:794c15bd30b0 | 20 | * |
POTLESS_2 | 0:794c15bd30b0 | 21 | * A besoin des libs suivantes : |
POTLESS_2 | 0:794c15bd30b0 | 22 | * |
POTLESS_2 | 0:794c15bd30b0 | 23 | * - FATFileSystem |
POTLESS_2 | 0:794c15bd30b0 | 24 | * |
POTLESS_2 | 0:794c15bd30b0 | 25 | * - SDBlockDevice |
POTLESS_2 | 0:794c15bd30b0 | 26 | * |
POTLESS_2 | 0:794c15bd30b0 | 27 | * |
POTLESS_2 | 0:794c15bd30b0 | 28 | * Constantes de l'application : |
POTLESS_2 | 0:794c15bd30b0 | 29 | * |
POTLESS_2 | 0:794c15bd30b0 | 30 | * Pin out carte SD : |
POTLESS_2 | 0:794c15bd30b0 | 31 | * |
POTLESS_2 | 0:794c15bd30b0 | 32 | * - SD_MOSI PA_7 |
POTLESS_2 | 0:794c15bd30b0 | 33 | * |
POTLESS_2 | 0:794c15bd30b0 | 34 | * - SD_MISO PA_6 |
POTLESS_2 | 0:794c15bd30b0 | 35 | * |
POTLESS_2 | 0:794c15bd30b0 | 36 | * - SD_SCK PA_5 |
POTLESS_2 | 0:794c15bd30b0 | 37 | * |
POTLESS_2 | 0:794c15bd30b0 | 38 | * - SD_CS PB_6 |
POTLESS_2 | 0:794c15bd30b0 | 39 | * |
POTLESS_2 | 0:794c15bd30b0 | 40 | */ |
POTLESS_2 | 0:794c15bd30b0 | 41 | |
POTLESS_2 | 0:794c15bd30b0 | 42 | class UTILS |
POTLESS_2 | 0:794c15bd30b0 | 43 | { |
POTLESS_2 | 0:794c15bd30b0 | 44 | |
POTLESS_2 | 0:794c15bd30b0 | 45 | public: |
POTLESS_2 | 0:794c15bd30b0 | 46 | |
POTLESS_2 | 0:794c15bd30b0 | 47 | /**Remapper une valeur dans une autre échelle. |
POTLESS_2 | 0:794c15bd30b0 | 48 | * @param float Valeur à remapper |
POTLESS_2 | 0:794c15bd30b0 | 49 | * @param float Minimum de l'échelle de la valeur |
POTLESS_2 | 0:794c15bd30b0 | 50 | * @param float Maximum de l'échelle de la valeur |
POTLESS_2 | 0:794c15bd30b0 | 51 | * @param float Minimum de la nouvelle échelle |
POTLESS_2 | 0:794c15bd30b0 | 52 | * @param float Maximum de de la nouvelle échelle |
POTLESS_2 | 0:794c15bd30b0 | 53 | */ |
POTLESS_2 | 0:794c15bd30b0 | 54 | static float Remap(float x, float in_min, float in_max, float out_min, float out_max); |
POTLESS_2 | 0:794c15bd30b0 | 55 | |
POTLESS_2 | 0:794c15bd30b0 | 56 | /**Contraint une valeur entre deux limites. |
POTLESS_2 | 0:794c15bd30b0 | 57 | * @param float Valeur à contraindre |
POTLESS_2 | 0:794c15bd30b0 | 58 | * @param float Minimum de la valeur |
POTLESS_2 | 0:794c15bd30b0 | 59 | * @param float Maximum de la valeur |
POTLESS_2 | 0:794c15bd30b0 | 60 | */ |
POTLESS_2 | 0:794c15bd30b0 | 61 | static float constrain(float x, float a, float b); |
POTLESS_2 | 0:794c15bd30b0 | 62 | |
POTLESS_2 | 0:794c15bd30b0 | 63 | /**Fonction de stockage valeur sur la carte SD. |
POTLESS_2 | 0:794c15bd30b0 | 64 | * @param float Val_To_Store, la valeur à stocker |
POTLESS_2 | 0:794c15bd30b0 | 65 | * @param char* Nom du fichier ou stocker cette valeur |
POTLESS_2 | 0:794c15bd30b0 | 66 | */ |
POTLESS_2 | 0:794c15bd30b0 | 67 | static void Store_A_Val(float Val_To_Store, char* File_Name); |
POTLESS_2 | 0:794c15bd30b0 | 68 | |
POTLESS_2 | 0:794c15bd30b0 | 69 | /**Fonction de récupération d'une valeur stockée sur la carte SD. |
POTLESS_2 | 0:794c15bd30b0 | 70 | * @param char* Nom du fichier ou stocker cette valeur |
POTLESS_2 | 0:794c15bd30b0 | 71 | * @returns |
POTLESS_2 | 0:794c15bd30b0 | 72 | * valeur de calibration des capteurs O2 |
POTLESS_2 | 0:794c15bd30b0 | 73 | */ |
POTLESS_2 | 0:794c15bd30b0 | 74 | static float Read_A_Val(char* File_Name); |
POTLESS_2 | 0:794c15bd30b0 | 75 | |
POTLESS_2 | 0:794c15bd30b0 | 76 | /**Fonction d'enregistrement d'une chaine de charatères sur la carte SD. |
POTLESS_2 | 0:794c15bd30b0 | 77 | * @param char* To_Store, chaine de charactères |
POTLESS_2 | 0:794c15bd30b0 | 78 | * @param char* Nom du fichier, s'il existe il est ouvert, sinon il est créé |
POTLESS_2 | 0:794c15bd30b0 | 79 | */ |
POTLESS_2 | 2:5af7a1fb1903 | 80 | static void Write_SD_File(char* To_Store, char* File_Name); |
POTLESS_2 | 0:794c15bd30b0 | 81 | |
POTLESS_2 | 0:794c15bd30b0 | 82 | /**Fonction de lecture d'un fichier sur la carte SD. |
POTLESS_2 | 0:794c15bd30b0 | 83 | * @param char* Nom du fichier |
POTLESS_2 | 0:794c15bd30b0 | 84 | */ |
POTLESS_2 | 2:5af7a1fb1903 | 85 | static void Read_SD_File(char* File_Name); |
POTLESS_2 | 0:794c15bd30b0 | 86 | |
POTLESS_2 | 0:794c15bd30b0 | 87 | /**Fonction d'éffaçage d'un fichier sur la carte SD. |
POTLESS_2 | 0:794c15bd30b0 | 88 | * @param char* Nom du fichier |
POTLESS_2 | 0:794c15bd30b0 | 89 | */ |
POTLESS_2 | 2:5af7a1fb1903 | 90 | static void Delete_SD_File(char* File_Name); |
POTLESS_2 | 0:794c15bd30b0 | 91 | |
POTLESS_2 | 0:794c15bd30b0 | 92 | /**Fonction d'éffaçage d'un fichier sur la carte SD. |
POTLESS_2 | 0:794c15bd30b0 | 93 | * @param char* Nom du fichier à effacer |
POTLESS_2 | 0:794c15bd30b0 | 94 | * @param char* Nouveau Nom du fichier |
POTLESS_2 | 0:794c15bd30b0 | 95 | */ |
POTLESS_2 | 4:872676dd87a4 | 96 | static void Rename_SD_File(char* Old_File_Name, char* New_File_Name); |
POTLESS_2 | 0:794c15bd30b0 | 97 | |
POTLESS_2 | 0:794c15bd30b0 | 98 | /**Fonction montage de la carte SD. |
POTLESS_2 | 0:794c15bd30b0 | 99 | */ |
POTLESS_2 | 0:794c15bd30b0 | 100 | static void Mount_SD(); |
POTLESS_2 | 0:794c15bd30b0 | 101 | |
POTLESS_2 | 0:794c15bd30b0 | 102 | /**Fonction demontage de la carte SD. |
POTLESS_2 | 0:794c15bd30b0 | 103 | */ |
POTLESS_2 | 0:794c15bd30b0 | 104 | static void UnMount_SD(); |
POTLESS_2 | 0:794c15bd30b0 | 105 | |
POTLESS_2 | 0:794c15bd30b0 | 106 | /**Fonction formatage de la carte SD. |
POTLESS_2 | 0:794c15bd30b0 | 107 | */ |
POTLESS_2 | 0:794c15bd30b0 | 108 | static void Format_SD(); |
POTLESS_2 | 2:5af7a1fb1903 | 109 | |
POTLESS_2 | 2:5af7a1fb1903 | 110 | /**Fonction DIR. |
POTLESS_2 | 2:5af7a1fb1903 | 111 | * @param char* Nom du répertoire |
POTLESS_2 | 2:5af7a1fb1903 | 112 | */ |
POTLESS_2 | 3:01677db45b2a | 113 | static void Dir_SD(char* Dir_Name = ""); |
POTLESS_2 | 3:01677db45b2a | 114 | |
POTLESS_2 | 3:01677db45b2a | 115 | /**Fonction de numérotage des fichiers log. |
POTLESS_2 | 3:01677db45b2a | 116 | * @returns |
POTLESS_2 | 3:01677db45b2a | 117 | * Index du nouveau fichier log |
POTLESS_2 | 3:01677db45b2a | 118 | */ |
POTLESS_2 | 3:01677db45b2a | 119 | static int File_Index(); |
POTLESS_2 | 3:01677db45b2a | 120 | |
POTLESS_2 | 3:01677db45b2a | 121 | /**Fonction de test si un fichier existe. |
POTLESS_2 | 3:01677db45b2a | 122 | * @param char* Nom du fichier |
POTLESS_2 | 3:01677db45b2a | 123 | * @returns |
POTLESS_2 | 3:01677db45b2a | 124 | * true si le fichier existe, false s'il n'existe pas |
POTLESS_2 | 3:01677db45b2a | 125 | */ |
POTLESS_2 | 3:01677db45b2a | 126 | static bool File_Exist(char* File_Name); |
POTLESS_2 | 3:01677db45b2a | 127 | |
POTLESS_2 | 0:794c15bd30b0 | 128 | |
POTLESS_2 | 0:794c15bd30b0 | 129 | private: |
POTLESS_2 | 0:794c15bd30b0 | 130 | //Rien... |
POTLESS_2 | 0:794c15bd30b0 | 131 | }; |
POTLESS_2 | 0:794c15bd30b0 | 132 | #endif |