Skip to content

Instantly share code, notes, and snippets.

@LuckyResistor
Created May 6, 2018 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LuckyResistor/5f8285ee336b0d8eefb7d722e61f1cb8 to your computer and use it in GitHub Desktop.
Save LuckyResistor/5f8285ee336b0d8eefb7d722e61f1cb8 to your computer and use it in GitHub Desktop.
This is a simple demonstration how to use the flags class in your code. Parts removed for demo purposes.
#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