![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Programme carte strategie (disco)
Dependencies: mbed SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac
Diff: Instruction/Instruction.cpp
- Revision:
- 29:41e02746041d
- Parent:
- 11:ed13a480ddca
- Child:
- 34:6aa4b46b102e
diff -r acd18776ed2d -r 41e02746041d Instruction/Instruction.cpp --- a/Instruction/Instruction.cpp Sat May 27 05:40:26 2017 +0000 +++ b/Instruction/Instruction.cpp Fri Apr 06 13:47:19 2018 +0000 @@ -1,12 +1,11 @@ -#include "Instruction.h" +#include "global.h" + -char cheminFileStart[SIZE+8]="/local/"; -struct S_Instruction strat_instructions[SIZE_BUFFER_FILE];//Liste des instructions -unsigned char nb_instructions = 0;//Le nombre d'instruction dans le fichier de strategie -unsigned char actual_instruction = 0;//La ligne de l'instruction en cours d'execution + -LocalFileSystem local("local"); + +SDFileSystem sd(PB_15, PB_14,PD_3,PH_6,"sd"); enum E_InstructionType charToInstructionType(char type) { @@ -122,20 +121,25 @@ /* Il faut utiliser strcpy(cheminFileStart,"/local/strat.txt"); */ /* pour indiquer le fichier à utiliser */ /****************************************************************************************/ -void loadAllInstruction(void) { +void loadAllInstruction( signed char Strategie) { struct S_Instruction instruction; char LineBuffer[SIZE]; printf("Reading file : "); - printf(cheminFileStart); + printf(strat_sd[Strategie]); printf("\n"); - FILE *testFile = fopen(cheminFileStart, "rt"); //Ouverture du fichier en mode lecture seul au format string + strcpy(PATH[Strategie],"/sd/"); + strcat(PATH[Strategie],strat_sd[Strategie]); + strcat(PATH[Strategie],".txt"); + FILE *testFile = fopen(PATH[Strategie], "rt"); //Ouverture du fichier en mode lecture seul au format string nb_instructions = 0; while (fgets(LineBuffer, SIZE, testFile) != NULL) { instruction = stringToInstruction(LineBuffer); strat_instructions[nb_instructions] = instruction; if(strat_instructions[nb_instructions].order == UNKNOWN) { + Button STRAT_1 (0, 30, 190, 110, PATH[Strategie]); + STRAT_1.Draw(0xFFF0F0F0, 0); errorInstructionLoop();//L'instruction est pas bonne !! } //printf(LineBuffer); @@ -154,7 +158,7 @@ int FileExists(const char *fname) { FILE *file; - if (file = fopen(fname, "r")) + if (file == fopen(fname, "r")) { fclose(file); return 1;