Skip to content

Commit

Permalink
Change .clang-format to the latest M5 one
Browse files Browse the repository at this point in the history
  • Loading branch information
GOB52 committed Sep 25, 2024
1 parent 5b40ab1 commit c3d6a23
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
Language: Cpp
BasedOnStyle: Google
AccessModifierOffset: -1
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: true
AlignConsecutiveAssignments: true
Expand Down Expand Up @@ -29,7 +29,7 @@ BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
Expand All @@ -42,7 +42,7 @@ BraceWrapping:
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
Expand Down
12 changes: 8 additions & 4 deletions src/unit/unit_PCA9548AP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,22 @@ const char UnitPCA9548AP::name[] = "UnitPCA9548AP";
const types::uid_t UnitPCA9548AP::uid{"UnitPCA9548AP"_mmh3};
const types::uid_t UnitPCA9548AP::attr{0};

UnitPCA9548AP::UnitPCA9548AP(const uint8_t addr) : Component(addr) {
UnitPCA9548AP::UnitPCA9548AP(const uint8_t addr) : Component(addr)
{
auto ccfg = component_config();
ccfg.max_children = MAX_CHANNEL;
ccfg.clock = 400 * 1000U;
component_config(ccfg);
}

bool UnitPCA9548AP::readChannel(uint8_t& bits) {
bool UnitPCA9548AP::readChannel(uint8_t& bits)
{
bits = 0;
return readWithTransaction(&bits, 1) == m5::hal::error::error_t::OK;
}

Adapter* UnitPCA9548AP::duplicate_adapter(const uint8_t ch) {
Adapter* UnitPCA9548AP::duplicate_adapter(const uint8_t ch)
{
if (ch >= _adapters.size()) {
M5_LIB_LOGE("Invalid channel %u", ch);
return nullptr;
Expand All @@ -56,7 +59,8 @@ Adapter* UnitPCA9548AP::duplicate_adapter(const uint8_t ch) {
return myadapter ? myadapter->duplicate(unit->address()) : nullptr;
}

m5::hal::error::error_t UnitPCA9548AP::select_channel(const uint8_t ch) {
m5::hal::error::error_t UnitPCA9548AP::select_channel(const uint8_t ch)
{
// M5_LIB_LOGV("Try current to %u => %u", _current, ch);
if (ch != _current && ch < MAX_CHANNEL) {
_current = 0;
Expand Down
9 changes: 5 additions & 4 deletions src/unit/unit_PCA9548AP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace unit {
class UnitPCA9548AP : public Component {
M5_UNIT_COMPONENT_HPP_BUILDER(UnitPCA9548AP, 0x70);

public:
public:
constexpr static uint8_t MAX_CHANNEL = 6;

explicit UnitPCA9548AP(const uint8_t addr = DEFAULT_ADDRESS);
Expand All @@ -33,7 +33,8 @@ class UnitPCA9548AP : public Component {
Get current channel
@return Channel no(0...)
*/
uint8_t currentChannel() const {
uint8_t currentChannel() const
{
return _current;
}

Expand All @@ -44,11 +45,11 @@ class UnitPCA9548AP : public Component {
*/
bool readChannel(uint8_t& bits);

protected:
protected:
virtual Adapter* duplicate_adapter(const uint8_t ch) override;
virtual m5::hal::error::error_t select_channel(const uint8_t ch = 8) override;

protected:
protected:
std::array<std::unique_ptr<Adapter>, +MAX_CHANNEL> _adapters{}; // For children
uint8_t _current{0xFF}; // current channel 0 ~ MAX_CHANNEL
};
Expand Down
3 changes: 2 additions & 1 deletion test/common_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
If the Arduino framework is used, the framework library main is used.
*/
#if !defined(ARDUINO)
int main(int argc, char **argv) {
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);

#ifdef GTEST_FILTER
Expand Down
9 changes: 6 additions & 3 deletions test/embedded/embedded_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ namespace {
auto& lcd = M5.Display;
} // namespace

void test() {
void test()
{
lcd.fillRect(0, 0, lcd.width() >> 1, lcd.height(), RUN_ALL_TESTS() ? TFT_RED : TFT_GREEN);
}

void setup() {
void setup()
{
delay(1500);

M5.begin();
Expand All @@ -46,7 +48,8 @@ void setup() {
#endif
}

void loop() {
void loop()
{
test();
#if 0
delay(1000);
Expand Down
11 changes: 7 additions & 4 deletions test/embedded/test_pca9548ap/pca9548ap_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ using namespace m5::unit;
const ::testing::Environment* global_fixture = ::testing::AddGlobalTestEnvironment(new GlobalFixture<400000U>());

class TestPCA9548AP : public ComponentTestBase<UnitPCA9548AP, bool> {
protected:
virtual UnitPCA9548AP* get_instance() override {
protected:
virtual UnitPCA9548AP* get_instance() override
{
auto ptr = new m5::unit::UnitPCA9548AP();
return ptr;
}
virtual bool is_using_hal() const override {
virtual bool is_using_hal() const override
{
return GetParam();
};
};
Expand All @@ -37,7 +39,8 @@ class TestPCA9548AP : public ComponentTestBase<UnitPCA9548AP, bool> {
// INSTANTIATE_TEST_SUITE_P(ParamValues, TestPCA9548AP,::testing::Values(true));
INSTANTIATE_TEST_SUITE_P(ParamValues, TestPCA9548AP, ::testing::Values(false));

TEST_P(TestPCA9548AP, Basic) {
TEST_P(TestPCA9548AP, Basic)
{
SCOPED_TRACE(ustr);

for (uint8_t ch = 0; ch < 6U; ++ch) {
Expand Down

0 comments on commit c3d6a23

Please sign in to comment.