This is a simple demonstration how to use the flags class in your code. Parts removed for demo purposes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "Flags.hpp" | |
#include <cstdint> | |
namespace lr { | |
class TCA9548A | |
{ | |
public: | |
enum Channel : uint8_t { | |
Channel0 = (1<<0), | |
Channel1 = (1<<1), | |
Channel2 = (1<<2), | |
Channel3 = (1<<3), | |
Channel4 = (1<<4), | |
Channel5 = (1<<5), | |
Channel6 = (1<<6), | |
Channel7 = (1<<7), | |
}; | |
LR_DECLARE_FLAGS(Channel, Channels); | |
enum class Status : uint8_t { | |
Success, | |
Error, | |
}; | |
public: | |
TCA9548A(/*...*/); | |
public: | |
void initialize(); | |
Status test(); | |
void reset(); | |
Status setChannel(Channel channel); | |
Status setChannels(Channels channels); | |
Status clearAllChannels(); | |
private: | |
// ... | |
Channels _enabledChannels; | |
}; | |
LR_DECLARE_OPERATORS_FOR_FLAGS(TCA9548A::Channels); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment