Improve:sd card status led.
This commit is contained in:
parent
59f6b7ec8b
commit
4278452de1
|
@ -26,6 +26,16 @@ void LedsHandle::ControlDeviceStatusLed(const DeviceStatus &status, const long i
|
||||||
case DeviceStatus::FORMATTING:
|
case DeviceStatus::FORMATTING:
|
||||||
mDeviceStatus = SetLedState::ControlLed("device_status", LedState::RED, keepAliveTime, blinkPeriod);
|
mDeviceStatus = SetLedState::ControlLed("device_status", LedState::RED, keepAliveTime, blinkPeriod);
|
||||||
break;
|
break;
|
||||||
|
case DeviceStatus::SD_CARD_REMOVE:
|
||||||
|
mDeviceStatus = SetLedState::ControlLed("device_status", LedState::GREEN, keepAliveTime, blinkPeriod);
|
||||||
|
break;
|
||||||
|
case DeviceStatus::SD_CARD_INSERT:
|
||||||
|
/**
|
||||||
|
* @brief When the SD card is normal, there is no need to change the state of the status light, but the status
|
||||||
|
* light resources need to be released and the status light needs to be restored to its proper state.
|
||||||
|
*/
|
||||||
|
mDeviceStatus.reset();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
LogWarning("unknow device status.\n");
|
LogWarning("unknow device status.\n");
|
||||||
|
|
|
@ -20,6 +20,8 @@ enum class DeviceStatus
|
||||||
NORMAL = 0,
|
NORMAL = 0,
|
||||||
TAKING_PICTURE_OR_VIDEO,
|
TAKING_PICTURE_OR_VIDEO,
|
||||||
FORMATTING,
|
FORMATTING,
|
||||||
|
SD_CARD_REMOVE,
|
||||||
|
SD_CARD_INSERT,
|
||||||
END
|
END
|
||||||
};
|
};
|
||||||
class LedsHandle
|
class LedsHandle
|
||||||
|
|
|
@ -53,6 +53,7 @@ void SdCardHandleState::StateInit(void)
|
||||||
void SdCardHandleState::StateUnInit(void)
|
void SdCardHandleState::StateUnInit(void)
|
||||||
{
|
{
|
||||||
IFilesManager::GetInstance()->UnInit();
|
IFilesManager::GetInstance()->UnInit();
|
||||||
|
LedsHandle::DeleteAllLeds();
|
||||||
}
|
}
|
||||||
bool SdCardHandleState::MediaReportHandle(VStateMachineData *msg)
|
bool SdCardHandleState::MediaReportHandle(VStateMachineData *msg)
|
||||||
{
|
{
|
||||||
|
@ -102,6 +103,7 @@ bool SdCardHandleState::SdCardEventHandle(VStateMachineData *msg)
|
||||||
std::make_shared<VMissionData>(static_cast<MissionEvent>(InternalStateEvent::CHECK_UPGRADE_FILE));
|
std::make_shared<VMissionData>(static_cast<MissionEvent>(InternalStateEvent::CHECK_UPGRADE_FILE));
|
||||||
MissionStateMachine::GetInstance()->SendStateMessage(message);
|
MissionStateMachine::GetInstance()->SendStateMessage(message);
|
||||||
}
|
}
|
||||||
|
SetSdCardLedsStatus(mSdCardStatus);
|
||||||
return EXECUTED;
|
return EXECUTED;
|
||||||
}
|
}
|
||||||
bool SdCardHandleState::ResetKeyMediaTaskHandle(VStateMachineData *msg)
|
bool SdCardHandleState::ResetKeyMediaTaskHandle(VStateMachineData *msg)
|
||||||
|
@ -130,4 +132,18 @@ bool SdCardHandleState::FormatKeyFormattingSDCardHandle(VStateMachineData *msg)
|
||||||
}
|
}
|
||||||
LogWarning("Sd card is not inserted, ignore format key.\n");
|
LogWarning("Sd card is not inserted, ignore format key.\n");
|
||||||
return EXECUTED;
|
return EXECUTED;
|
||||||
|
}
|
||||||
|
void SdCardHandleState::SetSdCardLedsStatus(const StorageEvent &event)
|
||||||
|
{
|
||||||
|
switch (event) {
|
||||||
|
case StorageEvent::SD_CARD_REMOVE:
|
||||||
|
LedsHandle::ControlDeviceStatusLed(DeviceStatus::SD_CARD_REMOVE, KEEP_ALIVE_FOREVER, BLINKING_SLOW_MS);
|
||||||
|
break;
|
||||||
|
case StorageEvent::SD_CARD_INSERT:
|
||||||
|
LedsHandle::ControlDeviceStatusLed(DeviceStatus::SD_CARD_INSERT);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -19,9 +19,11 @@
|
||||||
#include "IMediaManager.h"
|
#include "IMediaManager.h"
|
||||||
#include "IStateMachine.h"
|
#include "IStateMachine.h"
|
||||||
#include "IStorageManager.h"
|
#include "IStorageManager.h"
|
||||||
|
#include "LedsHandle.h"
|
||||||
#include "VStateBase.h"
|
#include "VStateBase.h"
|
||||||
class SdCardHandleState : public State,
|
class SdCardHandleState : public State,
|
||||||
public DataProcessing,
|
public DataProcessing,
|
||||||
|
public LedsHandle,
|
||||||
public VStateBase,
|
public VStateBase,
|
||||||
public std::enable_shared_from_this<SdCardHandleState>
|
public std::enable_shared_from_this<SdCardHandleState>
|
||||||
{
|
{
|
||||||
|
@ -39,6 +41,7 @@ protected:
|
||||||
bool SdCardEventHandle(VStateMachineData *msg);
|
bool SdCardEventHandle(VStateMachineData *msg);
|
||||||
bool ResetKeyMediaTaskHandle(VStateMachineData *msg);
|
bool ResetKeyMediaTaskHandle(VStateMachineData *msg);
|
||||||
bool FormatKeyFormattingSDCardHandle(VStateMachineData *msg);
|
bool FormatKeyFormattingSDCardHandle(VStateMachineData *msg);
|
||||||
|
void SetSdCardLedsStatus(const StorageEvent &event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
StorageEvent mSdCardStatus;
|
StorageEvent mSdCardStatus;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user