code de la carte IHM avant les bugs et avant le travail effectué avec Melchior

Dependencies:   mbed SerialHalfDuplex SDFileSystem liaison_Bluetooth ident_crac DISCO-F469NI_portrait

Committer:
gabrieltetar
Date:
Mon Feb 10 08:04:36 2020 +0000
Revision:
8:50afdde4f5bc
Child:
10:1964bb91b925
missing Debug folder

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gabrieltetar 8:50afdde4f5bc 1 #include "global.h"
gabrieltetar 8:50afdde4f5bc 2
gabrieltetar 8:50afdde4f5bc 3
gabrieltetar 8:50afdde4f5bc 4 //azezaea
gabrieltetar 8:50afdde4f5bc 5
gabrieltetar 8:50afdde4f5bc 6 void debug_Instruction(struct S_Instruction instruction)
gabrieltetar 8:50afdde4f5bc 7 {
gabrieltetar 8:50afdde4f5bc 8 printf("\n********* Debug instruction *********\n");
gabrieltetar 8:50afdde4f5bc 9
gabrieltetar 8:50afdde4f5bc 10 printf("* Line => %d\n", instruction.lineNumber);
gabrieltetar 8:50afdde4f5bc 11 printf("* Type => %s\n", InstructionTypeToString(instruction.order));
gabrieltetar 8:50afdde4f5bc 12 printf("* Direction => %s\n", InstructionDirectionToString(instruction.direction));
gabrieltetar 8:50afdde4f5bc 13
gabrieltetar 8:50afdde4f5bc 14 printf("* Arg1 => %d\n", instruction.arg1);
gabrieltetar 8:50afdde4f5bc 15 printf("* Arg2 => %d\n", instruction.arg2);
gabrieltetar 8:50afdde4f5bc 16 printf("* Arg3 => %d\n", instruction.arg3);
gabrieltetar 8:50afdde4f5bc 17
gabrieltetar 8:50afdde4f5bc 18 printf("* Recalage => %s\n", InstructionPrecisionOuRecalageToString(instruction.precision));
gabrieltetar 8:50afdde4f5bc 19 printf("* NextAction=> %s\n", InstructionNextActionTypeToString(instruction.nextActionType));
gabrieltetar 8:50afdde4f5bc 20 printf("* JumpAction=> %s\n", InstructionNextActionJumpTypeToString(instruction.jumpAction));
gabrieltetar 8:50afdde4f5bc 21
gabrieltetar 8:50afdde4f5bc 22 printf("* JumpTimeOrX => %d\n", instruction.JumpTimeOrX);
gabrieltetar 8:50afdde4f5bc 23 printf("* JumpY => %d\n", instruction.JumpY);
gabrieltetar 8:50afdde4f5bc 24 printf("* nextLineOK => %d\n", instruction.nextLineOK);
gabrieltetar 8:50afdde4f5bc 25 printf("* nextLineError => %d\n", instruction.nextLineError);
gabrieltetar 8:50afdde4f5bc 26
gabrieltetar 8:50afdde4f5bc 27 printf("*************************************\n");
gabrieltetar 8:50afdde4f5bc 28 }
gabrieltetar 8:50afdde4f5bc 29
gabrieltetar 8:50afdde4f5bc 30 char* InstructionTypeToString(enum E_InstructionType type)
gabrieltetar 8:50afdde4f5bc 31 {
gabrieltetar 8:50afdde4f5bc 32 switch(type)
gabrieltetar 8:50afdde4f5bc 33 {
gabrieltetar 8:50afdde4f5bc 34 case MV_COURBURE: return "Courbure";
gabrieltetar 8:50afdde4f5bc 35 case MV_LINE: return "Ligne";
gabrieltetar 8:50afdde4f5bc 36 case MV_TURN: return "Rotation";
gabrieltetar 8:50afdde4f5bc 37 case MV_XYT: return "Position XYT";
gabrieltetar 8:50afdde4f5bc 38 case MV_RECALAGE: return "Recalage";
gabrieltetar 8:50afdde4f5bc 39 case ACTION: return "Action";
gabrieltetar 8:50afdde4f5bc 40 default: return "Inconnue";
gabrieltetar 8:50afdde4f5bc 41 }
gabrieltetar 8:50afdde4f5bc 42 }
gabrieltetar 8:50afdde4f5bc 43 char* InstructionDirectionToString(enum E_InstructionDirection type)
gabrieltetar 8:50afdde4f5bc 44 {
gabrieltetar 8:50afdde4f5bc 45 switch(type)
gabrieltetar 8:50afdde4f5bc 46 {
gabrieltetar 8:50afdde4f5bc 47 case BACKWARD: return "en arriere";
gabrieltetar 8:50afdde4f5bc 48 case FORWARD: return "en avant";
gabrieltetar 8:50afdde4f5bc 49 case RELATIVE: return "relatif";
gabrieltetar 8:50afdde4f5bc 50 case ABSOLUTE: return "absolu";
gabrieltetar 8:50afdde4f5bc 51 default: return "absent";
gabrieltetar 8:50afdde4f5bc 52 }
gabrieltetar 8:50afdde4f5bc 53 }
gabrieltetar 8:50afdde4f5bc 54 char* InstructionPrecisionOuRecalageToString(enum E_InstructionPrecisionOuRecalage type)
gabrieltetar 8:50afdde4f5bc 55 {
gabrieltetar 8:50afdde4f5bc 56 switch(type)
gabrieltetar 8:50afdde4f5bc 57 {
gabrieltetar 8:50afdde4f5bc 58 case PRECISION: return "correction position en fin de mouvement";
gabrieltetar 8:50afdde4f5bc 59 case RECALAGE_X: return "recalage en X";
gabrieltetar 8:50afdde4f5bc 60 case RECALAGE_Y: return "recalage en Y";
gabrieltetar 8:50afdde4f5bc 61 default: return "absent";
gabrieltetar 8:50afdde4f5bc 62 }
gabrieltetar 8:50afdde4f5bc 63 }
gabrieltetar 8:50afdde4f5bc 64 char* InstructionNextActionTypeToString(enum E_InstructionNextActionType type)
gabrieltetar 8:50afdde4f5bc 65 {
gabrieltetar 8:50afdde4f5bc 66 switch(type)
gabrieltetar 8:50afdde4f5bc 67 {
gabrieltetar 8:50afdde4f5bc 68 case JUMP: return "jump";
gabrieltetar 8:50afdde4f5bc 69 case WAIT: return "attente fin instruction";
gabrieltetar 8:50afdde4f5bc 70 case ENCHAINEMENT: return "enchainement";
gabrieltetar 8:50afdde4f5bc 71 default: return "absent";
gabrieltetar 8:50afdde4f5bc 72 }
gabrieltetar 8:50afdde4f5bc 73 }
gabrieltetar 8:50afdde4f5bc 74 char* InstructionNextActionJumpTypeToString(enum E_InstructionNextActionJumpType type)
gabrieltetar 8:50afdde4f5bc 75 {
gabrieltetar 8:50afdde4f5bc 76 switch(type)
gabrieltetar 8:50afdde4f5bc 77 {
gabrieltetar 8:50afdde4f5bc 78 case JUMP_TIME: return "attente temps";
gabrieltetar 8:50afdde4f5bc 79 case JUMP_POSITION: return "attente position";
gabrieltetar 8:50afdde4f5bc 80 default: return "absent";
gabrieltetar 8:50afdde4f5bc 81 }
gabrieltetar 8:50afdde4f5bc 82 }
gabrieltetar 8:50afdde4f5bc 83
gabrieltetar 8:50afdde4f5bc 84 void errorLoop(void) {
gabrieltetar 8:50afdde4f5bc 85 while(true) {
gabrieltetar 8:50afdde4f5bc 86 led1 = 1;
gabrieltetar 8:50afdde4f5bc 87 wait(0.2);
gabrieltetar 8:50afdde4f5bc 88 led1 = 0;
gabrieltetar 8:50afdde4f5bc 89 wait(0.2);
gabrieltetar 8:50afdde4f5bc 90
gabrieltetar 8:50afdde4f5bc 91 }
gabrieltetar 8:50afdde4f5bc 92 }
gabrieltetar 8:50afdde4f5bc 93
gabrieltetar 8:50afdde4f5bc 94 void errorInstructionLoop(void) {
gabrieltetar 8:50afdde4f5bc 95 while(true) {
gabrieltetar 8:50afdde4f5bc 96 led2 = 1;
gabrieltetar 8:50afdde4f5bc 97 wait(0.2);
gabrieltetar 8:50afdde4f5bc 98 led2 = 0;
gabrieltetar 8:50afdde4f5bc 99 wait(0.2);
gabrieltetar 8:50afdde4f5bc 100 }
gabrieltetar 8:50afdde4f5bc 101 }
gabrieltetar 8:50afdde4f5bc 102
gabrieltetar 8:50afdde4f5bc 103 /****************************************************************************************/
gabrieltetar 8:50afdde4f5bc 104 /* FUNCTION NAME: sendStratEtat */
gabrieltetar 8:50afdde4f5bc 105 /* DESCRIPTION : permet le debug de l'etat de l'automate de stratégie */
gabrieltetar 8:50afdde4f5bc 106 /****************************************************************************************/
gabrieltetar 8:50afdde4f5bc 107 void sendStratEtat(unsigned char etat, unsigned char currentInstruction) {
gabrieltetar 8:50afdde4f5bc 108
gabrieltetar 8:50afdde4f5bc 109 CANMessage msgTx=CANMessage();
gabrieltetar 8:50afdde4f5bc 110 msgTx.id=DEBUG_STRATEGIE_AUTOMATE; // tx nouvelle position en (x,y,theta)
gabrieltetar 8:50afdde4f5bc 111 msgTx.len=1;
gabrieltetar 8:50afdde4f5bc 112 msgTx.format=CANStandard;
gabrieltetar 8:50afdde4f5bc 113 msgTx.type=CANData;
gabrieltetar 8:50afdde4f5bc 114 // x sur 2 octets
gabrieltetar 8:50afdde4f5bc 115 msgTx.data[0]=(unsigned char)etat;
gabrieltetar 8:50afdde4f5bc 116 msgTx.data[1]=(unsigned char)currentInstruction;
gabrieltetar 8:50afdde4f5bc 117
gabrieltetar 8:50afdde4f5bc 118 can1.write(msgTx);
gabrieltetar 8:50afdde4f5bc 119 }
gabrieltetar 8:50afdde4f5bc 120
gabrieltetar 8:50afdde4f5bc 121 void debugXYTTarget(signed short target_x_robot, signed short target_y_robot, signed short target_theta_robot) {
gabrieltetar 8:50afdde4f5bc 122 printf("going to new position x: %d, y: %d, t: %d\n",target_x_robot,target_y_robot,target_theta_robot);
gabrieltetar 8:50afdde4f5bc 123 }