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:
maximilienlv
Date:
Sat Mar 07 17:36:26 2020 +0000
Revision:
12:227c15c7ebe6
Parent:
10:1964bb91b925
communication entre strategie et robot fonctionnelle;

Who changed what in which revision?

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