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:
goldmas
Date:
Sat Jul 17 11:07:17 2021 +0000
Revision:
38:9d6a3ccc0582
Parent:
14:6aa8aa1699ad
Dernier code de la coupe de fracne 2021

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