112 lines
3.2 KiB
C++
112 lines
3.2 KiB
C++
/*
|
|
* Copyright (c) 2023 Fancy Code.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
#ifndef IHALCPP_H
|
|
#define IHALCPP_H
|
|
#include "StatusCode.h"
|
|
#include <iostream>
|
|
#include <memory>
|
|
#include <vector>
|
|
constexpr int INVALID_PERIOD = -1;
|
|
constexpr int PERIPHERAL_CHECK_PERIOD_MS = 100;
|
|
constexpr int IMEI_LEN = 15;
|
|
constexpr long int KEY_DO_NOT_HOLD_PRESSING = -1;
|
|
enum class KeyHalEvent
|
|
{
|
|
PRESSING = 0,
|
|
NOT_PRESSING,
|
|
END
|
|
};
|
|
class VKeyHalOwner
|
|
{
|
|
public:
|
|
VKeyHalOwner() = default;
|
|
virtual ~VKeyHalOwner() = default;
|
|
virtual void KeyEventTrigger(const KeyHalEvent &event) {}
|
|
virtual void TimerKeyEventTrigger(const KeyHalEvent &event) {}
|
|
virtual long int GetHoldPressingTimeMs(void) { return KEY_DO_NOT_HOLD_PRESSING; }
|
|
};
|
|
class VKeyHal
|
|
{
|
|
public:
|
|
VKeyHal() = default;
|
|
virtual ~VKeyHal() = default;
|
|
virtual void SetKeyHalOwner(std::shared_ptr<VKeyHalOwner> owner) {}
|
|
virtual const std::string GetKeyName(void) { return "undefine"; }
|
|
};
|
|
|
|
enum HalLedState
|
|
{
|
|
HAL_LED_STATE_OFF = 0,
|
|
HAL_LED_STATE_ON,
|
|
HAL_LED_STATE_GREEN,
|
|
HAL_LED_STATE_RED,
|
|
HAL_LED_STATE_YELLOW,
|
|
HAL_LED_STATE_LEVEL_0,
|
|
HAL_LED_STATE_LEVEL_1,
|
|
HAL_LED_STATE_LEVEL_2,
|
|
HAL_LED_STATE_LEVEL_3,
|
|
HAL_LED_STATE_LEVEL_4,
|
|
HAL_LED_STATE_LEVEL_END,
|
|
HAL_LED_STATE_END
|
|
};
|
|
|
|
class VLedHal
|
|
{
|
|
public:
|
|
VLedHal() = default;
|
|
~VLedHal() = default;
|
|
virtual StatusCode SetHalLedState(const HalLedState &state)
|
|
{
|
|
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
}
|
|
virtual std::string GetLedName(void) { return "undefine"; }
|
|
};
|
|
|
|
#if 0
|
|
class WifiLed : public VLedHalOwner, public VLedHal
|
|
{
|
|
public:
|
|
WifiLed() = default;
|
|
~WifiLed() = default;
|
|
|
|
// StatusCode SetLedHalOwner(std::shared_ptr<VLedHalOwner> owner) override;
|
|
StatusCode SetHalLedState(const HalLedState &state) override;
|
|
std::string GetLedName(void) override;
|
|
|
|
private:
|
|
// VLedHalOwner m_LedHalOwner;
|
|
std::string m_LedName;
|
|
SF_LED_GPIO_IDX_E mPinRed;
|
|
SF_LED_GPIO_IDX_E mPinGreen;
|
|
}
|
|
#endif
|
|
|
|
class IHalCpp
|
|
{
|
|
public:
|
|
IHalCpp() = default;
|
|
virtual ~IHalCpp() = default;
|
|
static std::shared_ptr<IHalCpp> &GetInstance(std::shared_ptr<IHalCpp> *impl = nullptr);
|
|
virtual StatusCode Init(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
|
virtual StatusCode UnInit(void) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); }
|
|
virtual StatusCode GetLedHals(std::vector<std::shared_ptr<VLedHal>> &ledHals)
|
|
{
|
|
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
|
}
|
|
};
|
|
void CreateHalCppModule(void);
|
|
|
|
#endif
|