mirror of
https://github.com/yoboujon/dumber.git
synced 2025-06-08 13:50:49 +02:00
Rationalisation des messages batterie, la tension n'est plus envoyé que pour test
This commit is contained in:
parent
7d9e38f3ef
commit
c5250eb3f4
7 changed files with 203 additions and 126 deletions
|
@ -327,17 +327,6 @@
|
||||||
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.1151842665.1610208999" name="Resource Custom Build Step Output Type"/>
|
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.1151842665.1610208999" name="Resource Custom Build Step Output Type"/>
|
||||||
</tool>
|
</tool>
|
||||||
</fileInfo>
|
</fileInfo>
|
||||||
<fileInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1504381080.727722516.584766423" name="moteurs.c" rcbsApplicability="disable" resourcePath="Application/moteurs.c" toolsToInvoke="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1017015985.1839636316">
|
|
||||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1017015985.1839636316" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1017015985">
|
|
||||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.422540263" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
|
|
||||||
</tool>
|
|
||||||
<tool customBuildStep="true" id="org.eclipse.cdt.managedbuilder.ui.rcbs.1811836732" name="Resource Custom Build Step">
|
|
||||||
<inputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype.1316072342" name="Resource Custom Build Step Input Type">
|
|
||||||
<additionalInput kind="additionalinputdependency"/>
|
|
||||||
</inputType>
|
|
||||||
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.861774528" name="Resource Custom Build Step Output Type"/>
|
|
||||||
</tool>
|
|
||||||
</fileInfo>
|
|
||||||
<fileInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1504381080.727722516.Application/application.c" name="application.c" rcbsApplicability="disable" resourcePath="Application/application.c" toolsToInvoke="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.983087978">
|
<fileInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1504381080.727722516.Application/application.c" name="application.c" rcbsApplicability="disable" resourcePath="Application/application.c" toolsToInvoke="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.983087978">
|
||||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.983087978" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1017015985">
|
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.983087978" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1017015985">
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.606614377" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.o0" valueType="enumerated"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.606614377" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.o0" valueType="enumerated"/>
|
||||||
|
@ -350,6 +339,18 @@
|
||||||
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.1700687045.61103792" name="Resource Custom Build Step Output Type"/>
|
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.1700687045.61103792" name="Resource Custom Build Step Output Type"/>
|
||||||
</tool>
|
</tool>
|
||||||
</fileInfo>
|
</fileInfo>
|
||||||
|
<fileInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1504381080.727722516.200947957" name="leds.c" rcbsApplicability="disable" resourcePath="Application/leds.c" toolsToInvoke="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1017015985.155574165">
|
||||||
|
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1017015985.155574165" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1017015985">
|
||||||
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.301013410" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.o0" valueType="enumerated"/>
|
||||||
|
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1898228332" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
|
||||||
|
</tool>
|
||||||
|
<tool customBuildStep="true" id="org.eclipse.cdt.managedbuilder.ui.rcbs.2113983486" name="Resource Custom Build Step">
|
||||||
|
<inputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype.1308025369" name="Resource Custom Build Step Input Type">
|
||||||
|
<additionalInput kind="additionalinputdependency" paths=""/>
|
||||||
|
</inputType>
|
||||||
|
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.555839812" name="Resource Custom Build Step Output Type"/>
|
||||||
|
</tool>
|
||||||
|
</fileInfo>
|
||||||
<fileInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1504381080.727722516.53808517" name="batterie.c" rcbsApplicability="disable" resourcePath="Application/batterie.c" toolsToInvoke="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1017015985.1171631638">
|
<fileInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1504381080.727722516.53808517" name="batterie.c" rcbsApplicability="disable" resourcePath="Application/batterie.c" toolsToInvoke="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1017015985.1171631638">
|
||||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1017015985.1171631638" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1017015985">
|
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1017015985.1171631638" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1017015985">
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.2016549754" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.o0" valueType="enumerated"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.2016549754" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.o0" valueType="enumerated"/>
|
||||||
|
|
|
@ -177,20 +177,23 @@ void APPLICATION_MainThread(void* params) {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_ID_BAT_CHARGE_OFF:
|
/* TODO
|
||||||
case MSG_ID_BAT_CHARGE_COMPLETE:
|
* Revoir la gestion de la batterie ici
|
||||||
systemInfos.batteryVoltage = *((uint16_t*)msg.data);
|
*/
|
||||||
systemInfos.batteryUpdate = 1;
|
// case MSG_ID_BAT_CHARGE_OFF:
|
||||||
|
// case MSG_ID_BAT_CHARGE_COMPLETE:
|
||||||
if (msg.id == MSG_ID_BAT_CHARGE_COMPLETE)
|
// systemInfos.batteryVoltage = *((uint16_t*)msg.data);
|
||||||
systemInfos.inCharge =1;
|
// systemInfos.batteryUpdate = 1;
|
||||||
else
|
//
|
||||||
systemInfos.inCharge =0;
|
// if (msg.id == MSG_ID_BAT_CHARGE_COMPLETE)
|
||||||
break;
|
// systemInfos.inCharge =1;
|
||||||
|
// else
|
||||||
case MSG_ID_BAT_CHARGE_ON:
|
// systemInfos.inCharge =0;
|
||||||
systemInfos.inCharge =1;
|
// break;
|
||||||
break;
|
//
|
||||||
|
// case MSG_ID_BAT_CHARGE_ON:
|
||||||
|
// systemInfos.inCharge =1;
|
||||||
|
// break;
|
||||||
|
|
||||||
case MSG_ID_MOTEURS_STOP:
|
case MSG_ID_MOTEURS_STOP:
|
||||||
systemInfos.endOfMouvement= 1;
|
systemInfos.endOfMouvement= 1;
|
||||||
|
@ -215,15 +218,18 @@ void APPLICATION_StateMachine() {
|
||||||
APPLICATION_TransitionToNewState(stateInCharge);
|
APPLICATION_TransitionToNewState(stateInCharge);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (systemInfos.batteryUpdate) {
|
/* TODO
|
||||||
ledState = APPLICATION_BatteryLevel(systemInfos.batteryVoltage, systemInfos.state);
|
* Revoir la gestion de la batterie ici
|
||||||
|
*/
|
||||||
if (ledState == leds_niveau_bat_0)
|
// if (systemInfos.batteryUpdate) {
|
||||||
APPLICATION_TransitionToNewState(stateLowBatDisable);
|
// ledState = APPLICATION_BatteryLevel(systemInfos.batteryVoltage, systemInfos.state);
|
||||||
else if (systemInfos.state==stateStartup) {
|
//
|
||||||
MESSAGE_SendMailbox(LEDS_Mailbox, MSG_ID_LED_ETAT, APPLICATION_Mailbox, (void*)&ledState);
|
// if (ledState == leds_niveau_bat_0)
|
||||||
}
|
// APPLICATION_TransitionToNewState(stateLowBatDisable);
|
||||||
}
|
// else if (systemInfos.state==stateStartup) {
|
||||||
|
// MESSAGE_SendMailbox(LEDS_Mailbox, MSG_ID_LED_ETAT, APPLICATION_Mailbox, (void*)&ledState);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
if (systemInfos.cmd != CMD_NONE) {
|
if (systemInfos.cmd != CMD_NONE) {
|
||||||
/* a newer command just arrived, process it
|
/* a newer command just arrived, process it
|
||||||
|
@ -353,8 +359,9 @@ void APPLICATION_TransitionToNewState(APPLICATION_State new_state) {
|
||||||
systemTimeout.watchdogEnabled=0;
|
systemTimeout.watchdogEnabled=0;
|
||||||
break;
|
break;
|
||||||
case stateLowBatDisable:
|
case stateLowBatDisable:
|
||||||
ledState = leds_charge_bat_0;
|
ledState = leds_bat_critical_low;
|
||||||
MESSAGE_SendMailbox(LEDS_Mailbox, MSG_ID_LED_ETAT, APPLICATION_Mailbox, (void*)&ledState);
|
LEDS_Set(ledState);
|
||||||
|
//MESSAGE_SendMailbox(LEDS_Mailbox, MSG_ID_LED_ETAT, APPLICATION_Mailbox, (void*)&ledState);
|
||||||
systemTimeout.watchdogEnabled=0;
|
systemTimeout.watchdogEnabled=0;
|
||||||
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(4000)); // wait 4s
|
vTaskDelay(pdMS_TO_TICKS(4000)); // wait 4s
|
||||||
|
@ -369,24 +376,6 @@ void APPLICATION_TransitionToNewState(APPLICATION_State new_state) {
|
||||||
systemInfos.state = new_state;
|
systemInfos.state = new_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t APPLICATION_NiveauBatteryNormal[5] = {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
const uint8_t APPLICATION_NiveauBatteryCharge[5] = {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
LEDS_State APPLICATION_BatteryLevel(uint8_t voltage, APPLICATION_State state) {
|
|
||||||
LEDS_State ledState=leds_niveau_bat_0;
|
|
||||||
|
|
||||||
/* TODO: A faire
|
|
||||||
* Pour l'instant, testons les niveaux de batterie
|
|
||||||
*/
|
|
||||||
ledState = leds_niveau_bat_5;
|
|
||||||
return ledState;
|
|
||||||
}
|
|
||||||
|
|
||||||
void APPLICATION_PowerOff() {
|
void APPLICATION_PowerOff() {
|
||||||
/*
|
/*
|
||||||
* TODO: a decommenter quand le code sera debuggé
|
* TODO: a decommenter quand le code sera debuggé
|
||||||
|
|
|
@ -117,9 +117,28 @@ int BATTERIE_LireTension(uint16_t *val) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const uint8_t BATTERIE_NiveauBatteryNormal[5] = {
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t BATTERIE_NiveauBatteryCharge[5] = {
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
uint16_t BATTERIE_BatteryLevel(uint8_t voltage, BATTERIE_StatusChargerTypedef chargerStatus) {
|
||||||
|
uint16_t msgId=0;
|
||||||
|
|
||||||
|
/* TODO: A faire
|
||||||
|
* Pour l'instant, testons les niveaux de batterie
|
||||||
|
*/
|
||||||
|
|
||||||
|
return msgId;
|
||||||
|
}
|
||||||
|
|
||||||
void BATTERIE_VoltageThread(void* params) {
|
void BATTERIE_VoltageThread(void* params) {
|
||||||
static uint16_t tension;
|
static uint16_t tension;
|
||||||
BATTERIE_StatusChargerTypedef currentStatus;
|
BATTERIE_StatusChargerTypedef currentStatus;
|
||||||
|
uint16_t messageID;
|
||||||
|
|
||||||
TickType_t xLastWakeTime;
|
TickType_t xLastWakeTime;
|
||||||
|
|
||||||
|
@ -128,16 +147,21 @@ void BATTERIE_VoltageThread(void* params) {
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (BATTERIE_LireTension(&tension) ==0) {
|
if (BATTERIE_LireTension(&tension) ==0) {
|
||||||
|
|
||||||
currentStatus = BATTERIE_LireStatusChargeur();
|
currentStatus = BATTERIE_LireStatusChargeur();
|
||||||
if (currentStatus == CHARGEUR_ERROR)
|
if (currentStatus == CHARGEUR_ERROR)
|
||||||
MESSAGE_SendMailbox(APPLICATION_Mailbox, MSG_ID_BAT_CHARGE_ERR, (QueueHandle_t)0x0, (void*)NULL);
|
MESSAGE_SendMailbox(APPLICATION_Mailbox, MSG_ID_BAT_CHARGE_ERR, (QueueHandle_t)0x0, (void*)NULL);
|
||||||
else if (currentStatus == CHARGEUR_IN_CHARGE)
|
/*else if (currentStatus == CHARGEUR_IN_CHARGE)
|
||||||
MESSAGE_SendMailbox(APPLICATION_Mailbox, MSG_ID_BAT_CHARGE_ON, (QueueHandle_t)0x0, (void*)&tension);
|
MESSAGE_SendMailbox(APPLICATION_Mailbox, MSG_ID_BAT_CHARGE_ON, (QueueHandle_t)0x0, (void*)&tension);
|
||||||
else if (currentStatus == CHARGEUR_CHARGE_COMPLETE)
|
else if (currentStatus == CHARGEUR_CHARGE_COMPLETE)
|
||||||
MESSAGE_SendMailbox(APPLICATION_Mailbox, MSG_ID_BAT_CHARGE_COMPLETE, (QueueHandle_t)0x0, (void*)&tension);
|
MESSAGE_SendMailbox(APPLICATION_Mailbox, MSG_ID_BAT_CHARGE_COMPLETE, (QueueHandle_t)0x0, (void*)&tension);
|
||||||
else
|
else
|
||||||
MESSAGE_SendMailbox(APPLICATION_Mailbox, MSG_ID_BAT_CHARGE_OFF, (QueueHandle_t)0x0, (void*)&tension);
|
MESSAGE_SendMailbox(APPLICATION_Mailbox, MSG_ID_BAT_CHARGE_OFF, (QueueHandle_t)0x0, (void*)&tension);*/
|
||||||
|
messageID = BATTERIE_BatteryLevel(tension, currentStatus);
|
||||||
|
MESSAGE_SendMailbox(APPLICATION_Mailbox, messageID, (QueueHandle_t)0x0, (void*)NULL);
|
||||||
|
|
||||||
|
#ifdef TESTS
|
||||||
|
MESSAGE_SendMailbox(APPLICATION_Mailbox, MSG_ID_BAT_LEVEL, (QueueHandle_t)0x0, (void*)&tension);
|
||||||
|
#endif /* TESTS*/
|
||||||
} else {
|
} else {
|
||||||
MESSAGE_SendMailbox(APPLICATION_Mailbox, MSG_ID_BAT_ADC_ERR, (QueueHandle_t)0x0, (void*)0x0);
|
MESSAGE_SendMailbox(APPLICATION_Mailbox, MSG_ID_BAT_ADC_ERR, (QueueHandle_t)0x0, (void*)0x0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,9 +65,35 @@
|
||||||
#define LED_PATTERN_DIGIT_7 28
|
#define LED_PATTERN_DIGIT_7 28
|
||||||
#define LED_PATTERN_DIGIT_8 29
|
#define LED_PATTERN_DIGIT_8 29
|
||||||
#define LED_PATTERN_DIGIT_9 30
|
#define LED_PATTERN_DIGIT_9 30
|
||||||
#define LED_PATTERN_DIGIT_UNKNOWN 31
|
#define LED_PATTERN_DIGIT_C 31
|
||||||
|
#define LED_PATTERN_DIGIT_L 32
|
||||||
|
#define LED_PATTERN_DIGIT_B 33
|
||||||
|
#define LED_PATTERN_DIGIT_UNKNOWN 34
|
||||||
|
|
||||||
#define LED_MAX_PATTERNS 32
|
#define LED_MAX_PATTERNS 35
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Relation entre segment et nom
|
||||||
|
*
|
||||||
|
* Avant du robot
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* D
|
||||||
|
* -----
|
||||||
|
* | |
|
||||||
|
* C | | E
|
||||||
|
* | G |
|
||||||
|
* -----
|
||||||
|
* | |
|
||||||
|
* B | | F
|
||||||
|
* | |
|
||||||
|
* -----
|
||||||
|
* A
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Arriere du robot
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
uint16_t LEDS_Patterns [LED_MAX_PATTERNS][4]= {
|
uint16_t LEDS_Patterns [LED_MAX_PATTERNS][4]= {
|
||||||
// GPIOA ON / GPIOB ON / GPIOA OFF / GPIOB OFF
|
// GPIOA ON / GPIOB ON / GPIOA OFF / GPIOB OFF
|
||||||
|
@ -102,7 +128,10 @@ uint16_t LEDS_Patterns [LED_MAX_PATTERNS][4]= {
|
||||||
{ LED_SEG_D_Pin|LED_SEG_E_Pin|LED_SEG_F_Pin, 0, LED_SEG_G_Pin|LED_SEG_DP_Pin, LED_SEG_A_Pin|LED_SEG_B_Pin|LED_SEG_C_Pin}, // 7
|
{ LED_SEG_D_Pin|LED_SEG_E_Pin|LED_SEG_F_Pin, 0, LED_SEG_G_Pin|LED_SEG_DP_Pin, LED_SEG_A_Pin|LED_SEG_B_Pin|LED_SEG_C_Pin}, // 7
|
||||||
{ LED_SEG_D_Pin|LED_SEG_E_Pin|LED_SEG_F_Pin|LED_SEG_G_Pin, LED_SEG_A_Pin|LED_SEG_B_Pin|LED_SEG_C_Pin, LED_SEG_DP_Pin, 0}, // 8
|
{ LED_SEG_D_Pin|LED_SEG_E_Pin|LED_SEG_F_Pin|LED_SEG_G_Pin, LED_SEG_A_Pin|LED_SEG_B_Pin|LED_SEG_C_Pin, LED_SEG_DP_Pin, 0}, // 8
|
||||||
{ LED_SEG_D_Pin|LED_SEG_E_Pin|LED_SEG_F_Pin|LED_SEG_G_Pin, LED_SEG_A_Pin|LED_SEG_C_Pin, LED_SEG_DP_Pin, LED_SEG_B_Pin}, // 9
|
{ LED_SEG_D_Pin|LED_SEG_E_Pin|LED_SEG_F_Pin|LED_SEG_G_Pin, LED_SEG_A_Pin|LED_SEG_C_Pin, LED_SEG_DP_Pin, LED_SEG_B_Pin}, // 9
|
||||||
{ LED_SEG_D_Pin|LED_SEG_E_Pin|LED_SEG_G_Pin, LED_SEG_B_Pin, LED_SEG_G_Pin|LED_SEG_DP_Pin, LED_SEG_A_Pin|LED_SEG_C_Pin} // ?
|
{ LED_SEG_D_Pin, LED_SEG_A_Pin|LED_SEG_B_Pin|LED_SEG_C_Pin, LED_SEG_E_Pin|LED_SEG_F_Pin|LED_SEG_G_Pin|LED_SEG_DP_Pin, 0}, // C
|
||||||
|
{ 0, LED_SEG_A_Pin|LED_SEG_B_Pin|LED_SEG_C_Pin, LED_SEG_D_Pin|LED_SEG_E_Pin|LED_SEG_F_Pin|LED_SEG_G_Pin|LED_SEG_DP_Pin, 0},// L
|
||||||
|
{ LED_SEG_F_Pin|LED_SEG_G_Pin, LED_SEG_A_Pin|LED_SEG_B_Pin|LED_SEG_C_Pin, LED_SEG_D_Pin|LED_SEG_E_Pin|LED_SEG_DP_Pin, 0}, // b
|
||||||
|
{ LED_SEG_D_Pin|LED_SEG_E_Pin|LED_SEG_G_Pin, LED_SEG_B_Pin, LED_SEG_F_Pin|LED_SEG_DP_Pin, LED_SEG_A_Pin|LED_SEG_C_Pin} // ?
|
||||||
};
|
};
|
||||||
|
|
||||||
LEDS_State LEDS_Animation;
|
LEDS_State LEDS_Animation;
|
||||||
|
@ -150,6 +179,16 @@ void LEDS_Init(void) {
|
||||||
vTaskResume(xHandleLedsHandler);
|
vTaskResume(xHandleLedsHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LEDS_Set(LEDS_State state) {
|
||||||
|
static LEDS_State leds_state;
|
||||||
|
|
||||||
|
if ((state>=leds_off) && (state <=leds_state_unknown)) {
|
||||||
|
leds_state = state;
|
||||||
|
MESSAGE_SendMailbox(LEDS_Mailbox, MSG_ID_LED_ETAT,
|
||||||
|
(QueueHandle_t)0x0, (void*) &leds_state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LEDS_ShowPattern(uint8_t pattern) {
|
void LEDS_ShowPattern(uint8_t pattern) {
|
||||||
if (pattern < LED_MAX_PATTERNS) {
|
if (pattern < LED_MAX_PATTERNS) {
|
||||||
HAL_GPIO_WritePin(GPIOA, LEDS_Patterns[pattern][2], GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(GPIOA, LEDS_Patterns[pattern][2], GPIO_PIN_RESET);
|
||||||
|
@ -240,16 +279,25 @@ void LEDS_ActionThread(void* params) {
|
||||||
if (cnt>5) cnt=0;
|
if (cnt>5) cnt=0;
|
||||||
LEDS_ShowPattern(LED_PATTERN_RUN_WITH_WATCHDOG_0+cnt);
|
LEDS_ShowPattern(LED_PATTERN_RUN_WITH_WATCHDOG_0+cnt);
|
||||||
break;
|
break;
|
||||||
case leds_niveau_bat_0:
|
case leds_bat_critical_low:
|
||||||
|
if (cnt<3)
|
||||||
|
LEDS_ShowPattern(LED_PATTERN_DIGIT_C);
|
||||||
|
else if (cnt<6)
|
||||||
|
LEDS_ShowPattern(LED_PATTERN_DIGIT_L);
|
||||||
|
else if (cnt <9)
|
||||||
|
LEDS_ShowPattern(LED_PATTERN_DIGIT_B);
|
||||||
|
else if (cnt <12)
|
||||||
|
LEDS_ShowPattern(LED_PATTERN_ALL_OFF);
|
||||||
|
else
|
||||||
|
cnt=0;
|
||||||
|
break;
|
||||||
|
case leds_bat_low:
|
||||||
if (!(cnt%2))
|
if (!(cnt%2))
|
||||||
LEDS_ShowPattern(LED_PATTERN_BAT_SPRITE_1);
|
LEDS_ShowPattern(LED_PATTERN_BAT_SPRITE_1);
|
||||||
else
|
else
|
||||||
LEDS_ShowPattern(LED_PATTERN_ALL_OFF);
|
LEDS_ShowPattern(LED_PATTERN_ALL_OFF);
|
||||||
break;
|
break;
|
||||||
case leds_niveau_bat_1:
|
case leds_bat_med:
|
||||||
LEDS_ShowPattern(LED_PATTERN_BAT_SPRITE_1);
|
|
||||||
break;
|
|
||||||
case leds_niveau_bat_2:
|
|
||||||
if (cnt<3)
|
if (cnt<3)
|
||||||
LEDS_ShowPattern(LED_PATTERN_BAT_SPRITE_1);
|
LEDS_ShowPattern(LED_PATTERN_BAT_SPRITE_1);
|
||||||
else if (cnt<6)
|
else if (cnt<6)
|
||||||
|
@ -257,15 +305,7 @@ void LEDS_ActionThread(void* params) {
|
||||||
else
|
else
|
||||||
cnt=0;
|
cnt=0;
|
||||||
break;
|
break;
|
||||||
case leds_niveau_bat_3:
|
case leds_bat_high:
|
||||||
if (cnt<3)
|
|
||||||
LEDS_ShowPattern(LED_PATTERN_BAT_SPRITE_1);
|
|
||||||
else if (cnt<6)
|
|
||||||
LEDS_ShowPattern(LED_PATTERN_BAT_SPRITE_2);
|
|
||||||
else
|
|
||||||
cnt=7; // on maintient l'affichage de deux barres
|
|
||||||
break;
|
|
||||||
case leds_niveau_bat_4:
|
|
||||||
if (cnt<3)
|
if (cnt<3)
|
||||||
LEDS_ShowPattern(LED_PATTERN_BAT_SPRITE_1);
|
LEDS_ShowPattern(LED_PATTERN_BAT_SPRITE_1);
|
||||||
else if (cnt<6)
|
else if (cnt<6)
|
||||||
|
@ -275,18 +315,7 @@ void LEDS_ActionThread(void* params) {
|
||||||
else
|
else
|
||||||
cnt=3;
|
cnt=3;
|
||||||
break;
|
break;
|
||||||
case leds_niveau_bat_5:
|
case leds_bat_charge_low:
|
||||||
if (cnt<3)
|
|
||||||
LEDS_ShowPattern(LED_PATTERN_BAT_SPRITE_1);
|
|
||||||
else if (cnt<6)
|
|
||||||
LEDS_ShowPattern(LED_PATTERN_BAT_SPRITE_2);
|
|
||||||
else if (cnt <9)
|
|
||||||
LEDS_ShowPattern(LED_PATTERN_BAT_SPRITE_3);
|
|
||||||
else
|
|
||||||
cnt=10;
|
|
||||||
break;
|
|
||||||
case leds_charge_bat_0:
|
|
||||||
case leds_charge_bat_1:
|
|
||||||
if (cnt<3)
|
if (cnt<3)
|
||||||
LEDS_ShowPattern(LED_PATTERN_BAT_SPRITE_1);
|
LEDS_ShowPattern(LED_PATTERN_BAT_SPRITE_1);
|
||||||
else if (cnt<6)
|
else if (cnt<6)
|
||||||
|
@ -298,8 +327,7 @@ void LEDS_ActionThread(void* params) {
|
||||||
else
|
else
|
||||||
cnt=0;
|
cnt=0;
|
||||||
break;
|
break;
|
||||||
case leds_charge_bat_2:
|
case leds_bat_charge_med:
|
||||||
case leds_charge_bat_3:
|
|
||||||
if (cnt<3)
|
if (cnt<3)
|
||||||
LEDS_ShowPattern(LED_PATTERN_BAT_SPRITE_2);
|
LEDS_ShowPattern(LED_PATTERN_BAT_SPRITE_2);
|
||||||
else if (cnt<6)
|
else if (cnt<6)
|
||||||
|
@ -309,8 +337,7 @@ void LEDS_ActionThread(void* params) {
|
||||||
else
|
else
|
||||||
cnt=0;
|
cnt=0;
|
||||||
break;
|
break;
|
||||||
case leds_charge_bat_4:
|
case leds_bat_charge_high:
|
||||||
case leds_charge_bat_5:
|
|
||||||
if (cnt<3)
|
if (cnt<3)
|
||||||
LEDS_ShowPattern(LED_PATTERN_BAT_SPRITE_3);
|
LEDS_ShowPattern(LED_PATTERN_BAT_SPRITE_3);
|
||||||
else if (cnt<6)
|
else if (cnt<6)
|
||||||
|
@ -318,6 +345,11 @@ void LEDS_ActionThread(void* params) {
|
||||||
else
|
else
|
||||||
cnt=0;
|
cnt=0;
|
||||||
break;
|
break;
|
||||||
|
case leds_bat_charge_complete:
|
||||||
|
LEDS_ShowPattern(LED_PATTERN_BAT_SPRITE_3);
|
||||||
|
|
||||||
|
cnt=0;
|
||||||
|
break;
|
||||||
case leds_erreur_1:
|
case leds_erreur_1:
|
||||||
if (cnt<5)
|
if (cnt<5)
|
||||||
LEDS_ShowPattern(LED_PATTERN_ERROR);
|
LEDS_ShowPattern(LED_PATTERN_ERROR);
|
||||||
|
|
|
@ -15,18 +15,14 @@ typedef enum {
|
||||||
leds_idle,
|
leds_idle,
|
||||||
leds_run,
|
leds_run,
|
||||||
leds_run_with_watchdog,
|
leds_run_with_watchdog,
|
||||||
leds_niveau_bat_0,
|
leds_bat_critical_low,
|
||||||
leds_niveau_bat_1,
|
leds_bat_low,
|
||||||
leds_niveau_bat_2,
|
leds_bat_med,
|
||||||
leds_niveau_bat_3,
|
leds_bat_high,
|
||||||
leds_niveau_bat_4,
|
leds_bat_charge_low,
|
||||||
leds_niveau_bat_5,
|
leds_bat_charge_med,
|
||||||
leds_charge_bat_0,
|
leds_bat_charge_high,
|
||||||
leds_charge_bat_1,
|
leds_bat_charge_complete,
|
||||||
leds_charge_bat_2,
|
|
||||||
leds_charge_bat_3,
|
|
||||||
leds_charge_bat_4,
|
|
||||||
leds_charge_bat_5,
|
|
||||||
leds_erreur_1,
|
leds_erreur_1,
|
||||||
leds_erreur_2,
|
leds_erreur_2,
|
||||||
leds_erreur_3,
|
leds_erreur_3,
|
||||||
|
@ -36,4 +32,6 @@ typedef enum {
|
||||||
} LEDS_State;
|
} LEDS_State;
|
||||||
|
|
||||||
void LEDS_Init(void);
|
void LEDS_Init(void);
|
||||||
|
void LEDS_Set(LEDS_State state);
|
||||||
|
|
||||||
#endif /* INC_LEDS_H_ */
|
#endif /* INC_LEDS_H_ */
|
||||||
|
|
|
@ -26,11 +26,20 @@ extern QueueHandle_t XBEE_Mailbox;
|
||||||
|
|
||||||
#define MSG_ID_LED_ETAT 0x10
|
#define MSG_ID_LED_ETAT 0x10
|
||||||
|
|
||||||
#define MSG_ID_BAT_CHARGE_COMPLETE 0x20
|
#define MSG_ID_BAT_CHARGE_ERR 0x20
|
||||||
#define MSG_ID_BAT_CHARGE_ON 0x21
|
#define MSG_ID_BAT_ADC_ERR 0x21
|
||||||
#define MSG_ID_BAT_CHARGE_OFF 0x22
|
#define MSG_ID_BAT_LEVEL 0x22
|
||||||
#define MSG_ID_BAT_CHARGE_ERR 0x23
|
#define MSG_ID_BAT_CRITICAL_LOW 0x23
|
||||||
#define MSG_ID_BAT_ADC_ERR 0x24
|
#define MSG_ID_BAT_LOW 0x24
|
||||||
|
#define MSG_ID_BAT_MED 0x25
|
||||||
|
#define MSG_ID_BAT_HIGH 0x26
|
||||||
|
#define MSG_ID_BAT_CHARGE_LOW 0x27
|
||||||
|
#define MSG_ID_BAT_CHARGE_MED 0x28
|
||||||
|
#define MSG_ID_BAT_CHARGE_HIGH 0x29
|
||||||
|
#define MSG_ID_BAT_CHARGE_COMPLETE 0x2A
|
||||||
|
//#define MSG_ID_BAT_CHARGE_ON 0x23
|
||||||
|
//#define MSG_ID_BAT_CHARGE_OFF 0x24
|
||||||
|
|
||||||
|
|
||||||
#define MSG_ID_BUTTON_PRESSED 0x30
|
#define MSG_ID_BUTTON_PRESSED 0x30
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ StackType_t xStackBasicTests[ STACK_SIZE ];
|
||||||
TaskHandle_t xHandleBasicTests = NULL;
|
TaskHandle_t xHandleBasicTests = NULL;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
LED_Tests=1,
|
LEDS_Tests=1,
|
||||||
XBEE_Tests,
|
XBEE_Tests,
|
||||||
COMMANDS_Tests,
|
COMMANDS_Tests,
|
||||||
BATTERY_Tests,
|
BATTERY_Tests,
|
||||||
|
@ -35,7 +35,7 @@ typedef enum {
|
||||||
MISC_Tests
|
MISC_Tests
|
||||||
} TESTS_Type;
|
} TESTS_Type;
|
||||||
|
|
||||||
TESTS_Type TESTS_Nbr=MOTEURS_Tests; // Number indicating which test is being run
|
TESTS_Type TESTS_Nbr=LEDS_Tests; // Number indicating which test is being run
|
||||||
|
|
||||||
void TESTS_BasicTests(void* params);
|
void TESTS_BasicTests(void* params);
|
||||||
|
|
||||||
|
@ -67,24 +67,24 @@ void TESTS_Init(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TESTS_BasicTests(void* params) {
|
void TESTS_BasicTests(void* params) {
|
||||||
static LEDS_State ledsStates = leds_off;
|
static LEDS_State ledsState = leds_off;
|
||||||
MESSAGE_Typedef msg;
|
MESSAGE_Typedef msg;
|
||||||
CMD_Generic* cmd;
|
CMD_Generic* cmd;
|
||||||
|
|
||||||
char* ans;
|
char* ans;
|
||||||
char str[100];
|
char str[100];
|
||||||
|
|
||||||
ledsStates = leds_run;
|
ledsState = leds_run;
|
||||||
MESSAGE_SendMailbox(LEDS_Mailbox, MSG_ID_LED_ETAT, APPLICATION_Mailbox, (void*)&ledsStates); // show program is running
|
MESSAGE_SendMailbox(LEDS_Mailbox, MSG_ID_LED_ETAT, APPLICATION_Mailbox, (void*)&ledsState); // show program is running
|
||||||
|
|
||||||
switch (TESTS_Nbr) {
|
switch (TESTS_Nbr) {
|
||||||
case LED_Tests: //Leds tests
|
case LEDS_Tests: //Leds tests
|
||||||
|
|
||||||
while (ledsStates<=leds_state_unknown) {
|
while (ledsState<=leds_state_unknown) {
|
||||||
ledsStates++;
|
//MESSAGE_SendMailbox(LEDS_Mailbox, MSG_ID_LED_ETAT, APPLICATION_Mailbox, (void*)&ledsState);
|
||||||
|
LEDS_Set(ledsState);
|
||||||
MESSAGE_SendMailbox(LEDS_Mailbox, MSG_ID_LED_ETAT, APPLICATION_Mailbox, (void*)&ledsStates);
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(TESTS_PERIODE)); // wait 10s
|
vTaskDelay(pdMS_TO_TICKS(TESTS_PERIODE)); // wait 10s
|
||||||
|
ledsState++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XBEE_Tests: // Xbee tests
|
case XBEE_Tests: // Xbee tests
|
||||||
|
@ -220,32 +220,56 @@ void TESTS_BasicTests(void* params) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BATTERY_Tests:
|
case BATTERY_Tests:
|
||||||
|
LEDS_Set(leds_off);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
//char* str;
|
|
||||||
|
|
||||||
msg = MESSAGE_ReadMailbox(APPLICATION_Mailbox); // Wait for a message from Xbee
|
msg = MESSAGE_ReadMailbox(APPLICATION_Mailbox); // Wait for a message from Xbee
|
||||||
//str = (char*)malloc(100); /* allocate a buffer of 100 bytes */
|
|
||||||
str[0]=0;
|
str[0]=0;
|
||||||
|
|
||||||
switch (msg.id) {
|
switch (msg.id) {
|
||||||
|
case MSG_ID_BAT_LEVEL:
|
||||||
|
snprintf(str, 99, "Bat level %u\r", *((uint16_t*)msg.data));
|
||||||
|
break;
|
||||||
case MSG_ID_BAT_ADC_ERR:
|
case MSG_ID_BAT_ADC_ERR:
|
||||||
snprintf(str, 99, "ADC error received\r");
|
snprintf(str, 99, "ADC error received\r");
|
||||||
break;
|
break;
|
||||||
case MSG_ID_BAT_CHARGE_COMPLETE:
|
case MSG_ID_BAT_CHARGE_COMPLETE:
|
||||||
snprintf(str, 99, "Charge complete (plug in) [Level = %u]\r", *((uint16_t*)msg.data));
|
snprintf(str, 99, "Charge complete (plug in)\r");
|
||||||
|
LEDS_Set(leds_bat_charge_complete);
|
||||||
break;
|
break;
|
||||||
case MSG_ID_BAT_CHARGE_ON:
|
case MSG_ID_BAT_CHARGE_HIGH:
|
||||||
snprintf(str, 99, "Charging (plug in) [Level = %u]\r", *((uint16_t*)msg.data));
|
snprintf(str, 99, "Charge high (plug in)\r");
|
||||||
|
LEDS_Set(leds_bat_charge_high);
|
||||||
break;
|
break;
|
||||||
case MSG_ID_BAT_CHARGE_OFF:
|
case MSG_ID_BAT_CHARGE_MED:
|
||||||
snprintf(str, 99, "Not in charge (plug removed) [Level = %u]\r", *((uint16_t*)msg.data));
|
snprintf(str, 99, "Charge med (plug in)\r");
|
||||||
|
LEDS_Set(leds_bat_charge_med);
|
||||||
|
break;
|
||||||
|
case MSG_ID_BAT_CHARGE_LOW:
|
||||||
|
snprintf(str, 99, "Charge low (plug in)\r");
|
||||||
|
LEDS_Set(leds_bat_charge_low);
|
||||||
|
break;
|
||||||
|
case MSG_ID_BAT_HIGH:
|
||||||
|
snprintf(str, 99, "Battery high (unplugged)\r");
|
||||||
|
LEDS_Set(leds_bat_high);
|
||||||
|
break;
|
||||||
|
case MSG_ID_BAT_MED:
|
||||||
|
snprintf(str, 99, "Battery med (unplugged)\r");
|
||||||
|
LEDS_Set(leds_bat_med);
|
||||||
|
break;
|
||||||
|
case MSG_ID_BAT_LOW:
|
||||||
|
snprintf(str, 99, "Battery low (unplugged)\r");
|
||||||
|
LEDS_Set(leds_bat_low);
|
||||||
|
break;
|
||||||
|
case MSG_ID_BAT_CRITICAL_LOW:
|
||||||
|
snprintf(str, 99, "Battery critical low (unplugged)\r");
|
||||||
|
LEDS_Set(leds_bat_critical_low);
|
||||||
break;
|
break;
|
||||||
case MSG_ID_BAT_CHARGE_ERR:
|
case MSG_ID_BAT_CHARGE_ERR:
|
||||||
snprintf(str, 99, "Charge error (plug in)\r");
|
snprintf(str, 99, "Charge error (plug in)\r");
|
||||||
|
LEDS_Set(leds_erreur_2);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//free(str); // buffer alloué non utilisé
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue