diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2019-04-04 12:12:57 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2019-04-04 12:12:57 +0300 |
| commit | 3254beb8358745efc6988df3d52a24fcb858fcdd (patch) | |
| tree | 1fe93f36b57aa07bd14db08d5905993f1aabfbac /Software/Embedded_SW/Embedded/Modules | |
| parent | 2357e733b204ddd6efab45d9aa2dad1f4f4e07fe (diff) | |
| parent | fd1d4b77b1f34420b12ea45dabc2897c1d9ee918 (diff) | |
| download | Tango-3254beb8358745efc6988df3d52a24fcb858fcdd.tar.gz Tango-3254beb8358745efc6988df3d52a24fcb858fcdd.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules')
4 files changed, 164 insertions, 31 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/General/buttons.c b/Software/Embedded_SW/Embedded/Modules/General/buttons.c index ee6204060..21d425221 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/buttons.c +++ b/Software/Embedded_SW/Embedded/Modules/General/buttons.c @@ -13,6 +13,7 @@ #include "Modules/General/buttons.h" #include "StateMachines/Printing/PrintingSTM.h" #include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h" +//#include "StateMachines/Initialization/PowerOffSequence.h" #include <stdlib.h> #include <stdint.h> @@ -68,7 +69,7 @@ uint32_t ButtonJogCallBackFunction(uint32_t IfIndex, uint32_t ReadValue); uint32_t ButtonJogCBFunction(uint32_t IfIndex, uint32_t ReadValue); uint8_t thraedJogging(uint8_t off); uint32_t setJoggingEnableCondition( button *pBtn); -uint32_t joggingMachine(uint8_t OnOffPB, button *pBtn); +uint32_t joggingMachine( button *pBtn); //uint8_t OnOffPB, uint32_t ButtonLoadCallBackFunction(uint32_t IfIndex, uint32_t ReadValue); @@ -100,6 +101,51 @@ int PowerUp() } +bool SetPowerMachineState(PBmachineState state) +{ + bool ret = OK; + switch ( state ) + { + case sttOFF: + power.state = state; + break; + case sttON: + power.state = state; + break; + case sttDISABLE: + jog.state = state; + break; + case sttENABLE: + jog.state = state; + break; + case sttIDLE: + power.state = state; + break; + case sttJOGGING: + jog.state = state; + break; + case sttRDY: + load.state = state; + break; + case sttPRELOAD: + load.state = state; + break; + case sttLOADING: + load.state = state; + break; + case sttLOADSUCSESS: + load.state = state; + break; + case sttLOADFAIL: + load.state = state; + break; + default: + break; + } + + + return ret; +} /* * read GPIO status * port: GPIO_PORTN_BASE @@ -147,17 +193,17 @@ uint32_t Buttons_Init(void) // power.bttn_status = 0 ; // power.bttn_name = "power"; //option - power.bttn_status = 0; // 0=release 1=press + power.bttn_status = release; // 0=release 1=press power.Action = OFFPB ; //off,short,long,count,replong - power.color = colorOFF; //off, blue, blink, bithing - power.state = sttOFF; //sttOFF, sttON, sttDISABLE, sttENABLE, sttIDLE, sttJOGGING + power.color = BLUE; //off, blue, blink, bithing + power.state = sttON; //sttOFF, sttON, sttDISABLE, sttENABLE, sttIDLE, sttJOGGING power.count = 0; AddControlCallback( ButtonPowerCBFunction, BUTTOMS_SAMPLE_TIME, ButtonPowerCallBackFunction, 0,0,0 ); // eFiftyMillisecond // jog.bttn_status = 0 ; // jog.bttn_name = "jog"; //option - jog.bttn_status = 0; // 0=release 1=press + jog.bttn_status = release; // 0=release 1=press jog.Action = OFFPB ; //OFFPB,short,long,count,replong jog.color = colorOFF; //colorOFF, BLUE, BLINK, jog.state = sttOFF; // sttDISABLE, sttENABLE, sttJOGGING @@ -166,7 +212,7 @@ uint32_t Buttons_Init(void) // load.bttn_status = 0 ; // load.bttn_name = "load"; //option - load.bttn_status = 0; // 0=release 1=press + load.bttn_status = release; // 0=release 1=press load.Action = OFFPB ; //OFFPB,short,long,count,replong load.color = colorOFF; //colorOFF, BLUE, BLINK, load.state = sttOFF; // sttDISABLE, sttENABLE, sttJOGGING @@ -186,8 +232,15 @@ uint32_t ButtonPowerCBFunction(uint32_t IfIndex, uint32_t ReadValue) uint32_t ButtonJogCBFunction(uint32_t IfIndex, uint32_t ReadValue) { - setJoggingEnableCondition(&jog); - joggingMachine(ReadValue, &jog); + + jog.bttn_status = ReadValue; + //if (ReadValue == press) + { + setJoggingEnableCondition(&jog); + joggingMachine(&jog); + } + + return 0; } @@ -195,8 +248,16 @@ uint32_t ButtonJogCBFunction(uint32_t IfIndex, uint32_t ReadValue) uint32_t ButtonLoadCBFunction(uint32_t IfIndex, uint32_t ReadValue) { uint8_t parameter = 2; - REPORT_MSG(parameter," ------------ Start thread loading empty function ----------------- "); - LoadStatMachine(&load); + + if ((load.bttn_status == release) && (ReadValue == press)) + { + REPORT_MSG(parameter," ------------ Start thread loading empty function ----------------- "); + load.bttn_status = press; + LoadStatMachine(&load); + + } + else load.bttn_status = ReadValue; + return 0; } @@ -308,6 +369,7 @@ uint32_t ShortLongOffPB(uint8_t OnOffPB, button *pBtn) uint32_t StateMachine( button *pBtn) //short press(=0)/long press(=1) { uint8_t parameter = 1; + Report(" ------------ StateMachine state action ----------------- ",__FILE__,__LINE__,pBtn->state,RpWarning,pBtn->Action,0); switch (pBtn->state)// sttON/sttOFF/sttIDLE { @@ -316,6 +378,8 @@ uint32_t StateMachine( button *pBtn) //short press(=0)/long press(=1) { case LONGPB: //Power Down pBtn->state = sttOFF; + pBtn->color = colorOFF; + Pannel_Leds(POWER_ON_OFF,MODE_OFF);//AVI+ PowerDown();// todo REPORT_MSG(parameter," ------------ Power state is OFF ----------------- "); break; @@ -335,6 +399,8 @@ uint32_t StateMachine( button *pBtn) //short press(=0)/long press(=1) case SHORTPB: //powerup? // to do ? pBtn->state = sttON; + pBtn->color = BLUE ; + Pannel_Leds(POWER_ON_OFF,MODE_ON);//AVI+ PowerUp(); //todo REPORT_MSG(parameter," ------------ Power state is ON ----------------- "); break; @@ -347,6 +413,8 @@ uint32_t StateMachine( button *pBtn) //short press(=0)/long press(=1) { case LONGPB: //Power off from idle pBtn->state = sttOFF; + pBtn->color = colorOFF; + Pannel_Leds(POWER_ON_OFF,MODE_OFF);//AVI+ PowerDown(); // todo Pannel_Leds(POWER_ON_OFF,MODE_OFF); //AVI+ - TODO option MODE_ON to stop Breathing and the led will turn off in power down REPORT_MSG(parameter," ------------ Power state is OFF ----------------- "); @@ -397,14 +465,18 @@ uint32_t setJoggingEnableCondition( button *pBtn) ) { pBtn->state = sttDISABLE; - REPORT_MSG(parameter," ------------ Jogging : sttDISABLE ----------------- "); + REPORT_MSG(parameter," ------------ Jogging : setJoggingEnableCondition sttDISABLE ----------------- "); + pBtn->color = colorOFF; + Pannel_Leds(THREAD_JOGGING, MODE_OFF); //AVI+ // ThreadAbortJoggingFunc(); } else { pBtn->state = sttENABLE; - REPORT_MSG(parameter," ------------ Jogging : sttENABLE ----------------- "); +// REPORT_MSG(parameter," ------------ Jogging : setJoggingEnableCondition sttENABLE ----------------- "); + pBtn->color = BLUE; + Pannel_Leds(THREAD_JOGGING, MODE_ON); //AVI+ //ThreadJoggingFunc(40); } @@ -424,7 +496,7 @@ return 0; */ -uint32_t joggingMachine(uint8_t OnOffPB, button *pBtn) +uint32_t joggingMachine( button *pBtn) //uint8_t OnOffPB, { uint8_t parameter = 4; @@ -432,26 +504,66 @@ uint32_t joggingMachine(uint8_t OnOffPB, button *pBtn) if (sttDISABLE == pBtn->state) { // jogging is disable - REPORT_MSG(parameter," ------------ Jogging is Disable ----------------- "); + REPORT_MSG(parameter," ------------joggingMachine: Jogging is Disable ----------------- "); + pBtn->Action = OFFPB; pBtn->color = colorOFF; Pannel_Leds(THREAD_JOGGING,MODE_OFF);//AVI+ } else { - if (!OnOffPB) + if ( (pBtn->Action != OFFPB) && (pBtn->bttn_status == release)) { - REPORT_MSG(parameter," ------------ stop Jogging ----------------- "); + REPORT_MSG(parameter," ------------joggingMachine: Jogging OnOffPB == 00----------------- "); + REPORT_MSG(parameter," ------------joggingMachine: stop Jogging ----------------- "); + pBtn->Action = OFFPB; ThreadAbortJoggingFunc(); // to do!!!! pBtn->color = BLUE; - Pannel_Leds(THREAD_JOGGING,MODE_ON);//AVI+ + Pannel_Leds(THREAD_JOGGING, MODE_ON);//AVI+ } - else + else if ((pBtn->Action == OFFPB) && (pBtn->bttn_status == press)) { - REPORT_MSG(parameter," ------------ start Jogging ----------------- "); + pBtn->Action = LONGPB; + REPORT_MSG(parameter," ------------joggingMachine: Jogging OnOffPB == 1 ----------------- "); + REPORT_MSG(parameter," ------------joggingMachine: start Jogging ----------------- "); pBtn->color = BLINK; ThreadJoggingFunc(40); } +// if (pBtn->bttn_status == press)ThreadJoggingFunc(40); +// else +// { +// pBtn->Action = OFFPB; +// REPORT_MSG(parameter," ??????????????????? joggingMachine: start Jogging ???????????????????"); +// } } + + + +// if (OnOffPB == release) +// { +// REPORT_MSG(parameter," ------------joggingMachine: Jogging OnOffPB == 00----------------- "); +// REPORT_MSG(parameter," ------------joggingMachine: stop Jogging ----------------- "); +// pBtn->Action = OFFPB; +// ThreadAbortJoggingFunc(); // to do!!!! +// pBtn->color = BLUE; +// Pannel_Leds(THREAD_JOGGING, MODE_ON);//AVI+ +// } +// else +// { +// if (pBtn->Action == OFFPB) +// { +// pBtn->Action = LONGPB; +// REPORT_MSG(parameter," ------------joggingMachine: Jogging OnOffPB == 1 ----------------- "); +// REPORT_MSG(parameter," ------------joggingMachine: start Jogging ----------------- "); +// pBtn->color = BLINK; +// ThreadJoggingFunc(40); +// } +// else +// { +// REPORT_MSG(parameter," ??????????????????? joggingMachine: start Jogging ???????????????????"); +// } +// +// } +// } return 0; } @@ -463,9 +575,10 @@ return 0; uint32_t LoadStatMachine( button *pBtn) { - uint8_t parameter = 5; + //uint8_t parameter = 5; - REPORT_MSG(parameter," ------------ start loadong ----------------- "); + //REPORT_MSG(parameter," ------------ start loading ----------------- "); + Report(" ------------ start loading ----------------- ",__FILE__,__LINE__,pBtn->state,RpWarning,pBtn->color,0); switch (pBtn->state) { case sttRDY : @@ -476,12 +589,18 @@ uint32_t LoadStatMachine( button *pBtn) case (REPLONGPB): pBtn->state = sttPRELOAD; pBtn->color = BLINK; + Pannel_Leds(THREAD_LOAD, MODE_ON);//AVI+ if (ThreadLoadStateMachine( THREAD_LOAD_INIT)) - { - pBtn->state = sttPRELOAD ; // to do - pBtn->color = BLUE; - } - else pBtn->state = sttDISABLE ; + { + pBtn->state = sttPRELOAD ; // to do + pBtn->color = BLUE; + Pannel_Leds(THREAD_LOAD, MODE_ON);//AVI+ + } + else + { + pBtn->state = sttDISABLE ; + Pannel_Leds(THREAD_LOAD, MODE_OFF);//AVI+ + } break; default : break; @@ -493,15 +612,19 @@ uint32_t LoadStatMachine( button *pBtn) case (SHORTPB): case (LONGPB): case (REPLONGPB): - if (ThreadLoadStateMachine( THREAD_LOAD_INITIAL_TENSION)) + pBtn->color = BLUE; + Pannel_Leds(THREAD_LOAD, MODE_ON);//AVI+ + if (ThreadLoadStateMachine( THREAD_LOAD_INITIAL_TENSION)) { pBtn->state = sttLOADSUCSESS ; // to do pBtn->color = BLUE; + Pannel_Leds(THREAD_LOAD, MODE_ON);//AVI+ } else { pBtn->state = sttLOADFAIL ; pBtn->color = fastBILNK ; // to do + Pannel_Leds(THREAD_LOAD, MODE_ON);//AVI+ } break; default : @@ -517,6 +640,7 @@ uint32_t LoadStatMachine( button *pBtn) default: //sttDISABLE pBtn->color = colorOFF; + Pannel_Leds(THREAD_LOAD, MODE_OFF);//AVI+ break; } return OK; diff --git a/Software/Embedded_SW/Embedded/Modules/General/buttons.h b/Software/Embedded_SW/Embedded/Modules/General/buttons.h index adf975979..8b064bbcc 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/buttons.h +++ b/Software/Embedded_SW/Embedded/Modules/General/buttons.h @@ -3,6 +3,12 @@ typedef enum { + release = 0, + press +} PB_Status; + +typedef enum +{ colorOFF = 0, BLUE, BLINK, @@ -32,7 +38,7 @@ typedef enum sttLOADING, sttLOADSUCSESS, sttLOADFAIL -} PBmachinState; +} PBmachineState; typedef struct Button { @@ -40,7 +46,7 @@ typedef struct Button int bttn_status; // 0=release 1=press PBstat Action; // enum : offPB,shortPB,longPB,countPB,replongPB PBcolor color; // enum : off, blue, blink, bithing - PBmachinState state; // enum : sttOFF, sttON, sttDISABLE, sttENABLE, sttIDLE, sttJOGGING + PBmachineState state; // enum : sttOFF, sttON, sttDISABLE, sttENABLE, sttIDLE, sttJOGGING uint32_t count; }button; @@ -49,5 +55,9 @@ extern button power , jog, load; uint32_t Buttons_Init(void); uint32_t Button_load_Init(void); uint32_t Button_JOG_Init(void); +bool SetPowerMachineState(PBmachineState state); + + + #endif diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/Waste.h b/Software/Embedded_SW/Embedded/Modules/Waste/Waste.h index f6b7d760a..bda01564f 100644 --- a/Software/Embedded_SW/Embedded/Modules/Waste/Waste.h +++ b/Software/Embedded_SW/Embedded/Modules/Waste/Waste.h @@ -100,6 +100,5 @@ U8 WHS_HW_test(void); bool WHS_IsEmptying(); - #endif diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c index 447e954d4..9531b67d6 100644 --- a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c @@ -52,6 +52,7 @@ bool SetActiveWastCartridge(); + struct waste_cartridge_params { uint32_t serial_number; @@ -108,7 +109,6 @@ bool WHS_IsEmptying() return ret; } - /* -------- cartridge function ----*/ |
