clang format code

This commit is contained in:
MatthewColvin 2023-09-16 15:34:16 -05:00
parent 91d7c9fffc
commit 1458aa7992
18 changed files with 1230 additions and 1212 deletions

View file

@ -81,6 +81,6 @@
"variant": "cpp" "variant": "cpp"
}, },
"cmake.sourceDirectory": "${workspaceFolder}/.pio/libdeps/esp32/Adafruit BusIO", "cmake.sourceDirectory": "${workspaceFolder}/.pio/libdeps/esp32/Adafruit BusIO",
"editor.formatOnSave": false, "editor.formatOnSave": true,
"idf.portWin": "COM8" "idf.portWin": "COM8"
} }

File diff suppressed because it is too large Load diff

View file

@ -3,48 +3,46 @@
#pragma once #pragma once
#include "lvgl.h" #include "lvgl.h"
class Images{ class Images {
public: public:
Images(); Images();
lv_obj_t* addAppleTVIcon(lv_obj_t* parent); lv_obj_t *addAppleTVIcon(lv_obj_t *parent);
lv_obj_t* addAppleDisplayImage(lv_obj_t* parent); lv_obj_t *addAppleDisplayImage(lv_obj_t *parent);
lv_obj_t* addAppleBackIcon(lv_obj_t* parent); lv_obj_t *addAppleBackIcon(lv_obj_t *parent);
lv_obj_t* addLowBrightnessIcon(lv_obj_t* parent); lv_obj_t *addLowBrightnessIcon(lv_obj_t *parent);
lv_obj_t* addHighBrightnessIcon(lv_obj_t* parent); lv_obj_t *addHighBrightnessIcon(lv_obj_t *parent);
lv_obj_t* addLightBulbIcon(lv_obj_t* parent); lv_obj_t *addLightBulbIcon(lv_obj_t *parent);
lv_obj_t* addLeftGradiant(lv_obj_t* parent); lv_obj_t *addLeftGradiant(lv_obj_t *parent);
lv_obj_t* addRightGradiant(lv_obj_t* parent); lv_obj_t *addRightGradiant(lv_obj_t *parent);
lv_obj_t* addWifiNoSignal(lv_obj_t* parent);
lv_obj_t* addWifiLowSignal(lv_obj_t* parent);
lv_obj_t* addWifiMidSignal(lv_obj_t* parent);
lv_obj_t* addWifiHighSignal(lv_obj_t* parent);
lv_obj_t *addWifiNoSignal(lv_obj_t *parent);
lv_obj_t *addWifiLowSignal(lv_obj_t *parent);
lv_obj_t *addWifiMidSignal(lv_obj_t *parent);
lv_obj_t *addWifiHighSignal(lv_obj_t *parent);
private: private:
// Make Image based on anImageDesc then // Make Image based on anImageDesc then
// add that image to parent. // add that image to parent.
lv_obj_t* addImg(lv_obj_t* parent, lv_img_dsc_t* anImgDesc); lv_obj_t *addImg(lv_obj_t *parent, lv_img_dsc_t *anImgDesc);
void setupImageDescriptions(); void setupImageDescriptions();
lv_img_dsc_t appleTvIcon; lv_img_dsc_t appleTvIcon;
lv_img_dsc_t appleDisplayIcon; lv_img_dsc_t appleDisplayIcon;
lv_img_dsc_t appleBackIcon; lv_img_dsc_t appleBackIcon;
lv_img_dsc_t low_brightness; lv_img_dsc_t low_brightness;
lv_img_dsc_t high_brightness; lv_img_dsc_t high_brightness;
lv_img_dsc_t lightbulb_icon; lv_img_dsc_t lightbulb_icon;
lv_img_dsc_t gradientLeft; lv_img_dsc_t gradientLeft;
lv_img_dsc_t gradientRight; lv_img_dsc_t gradientRight;
lv_img_dsc_t wifiNoSignal;
lv_img_dsc_t wifiLowSignal;
lv_img_dsc_t wifiMidSignal;
lv_img_dsc_t wifiHighSignal;
lv_img_dsc_t wifiNoSignal;
lv_img_dsc_t wifiLowSignal;
lv_img_dsc_t wifiMidSignal;
lv_img_dsc_t wifiHighSignal;
}; };

View file

@ -2,6 +2,5 @@
using namespace UI; using namespace UI;
UIBase::UIBase(std::shared_ptr<HardwareAbstract> aHardware):mHardware(aHardware){ UIBase::UIBase(std::shared_ptr<HardwareAbstract> aHardware)
: mHardware(aHardware) {}
}

View file

@ -5,15 +5,14 @@
#include "HardwareAbstract.hpp" #include "HardwareAbstract.hpp"
#include <memory> #include <memory>
namespace UI{ namespace UI {
class UIBase{ class UIBase {
public: public:
UIBase(std::shared_ptr<HardwareAbstract> aHardware); UIBase(std::shared_ptr<HardwareAbstract> aHardware);
protected: protected:
std::shared_ptr<HardwareAbstract> mHardware; std::shared_ptr<HardwareAbstract> mHardware;
}; };
} } // namespace UI

View file

@ -1,16 +1,13 @@
#include "ScreenManager.hpp" #include "ScreenManager.hpp"
using namespace UI::Screen; using namespace UI::Screen;
Manager Manager::mManager = Manager(); Manager Manager::mManager = Manager();
Manager& Manager::getInstance(){ Manager &Manager::getInstance() { return mManager; }
return mManager;
}
Manager::Manager(){} Manager::Manager() {}
void Manager::pushScreen(std::unique_ptr<UI::Screen::Base> aPage){ void Manager::pushScreen(std::unique_ptr<UI::Screen::Base> aPage) {
pages.push(std::move(aPage)); pages.push(std::move(aPage));
} }

View file

@ -1,20 +1,20 @@
#include "ScreenBase.hpp" #include "ScreenBase.hpp"
#include <stack>
#include <memory> #include <memory>
#include <stack>
namespace UI::Screen{ namespace UI::Screen {
class Manager{ class Manager {
public: public:
static Manager& getInstance(); static Manager &getInstance();
void pushScreen(std::unique_ptr<UI::Screen::Base> aPage); void pushScreen(std::unique_ptr<UI::Screen::Base> aPage);
private: private:
Manager(); Manager();
static Manager mManager; static Manager mManager;
std::stack<std::unique_ptr<UI::Screen::Base>> pages; std::stack<std::unique_ptr<UI::Screen::Base>> pages;
}; };
} } // namespace UI::Screen

View file

@ -1,12 +1,9 @@
#include "UIElement.hpp" #include "UIElement.hpp"
namespace UI namespace UI {
{ UIElement::UIElement(lv_obj_t *aLvglSelf, uint16_t aId)
UIElement::UIElement(lv_obj_t* aLvglSelf, uint16_t aId): : mLvglSelf(aLvglSelf), mId(aId) {
mLvglSelf(aLvglSelf), mLvglSelf->user_data = this;
mId(aId) }
{
mLvglSelf->user_data = this;
}
} // namespace UI } // namespace UI

View file

@ -2,15 +2,15 @@
#include "lvgl.h" #include "lvgl.h"
namespace UI{ namespace UI {
class UIElement{ class UIElement {
public: public:
UIElement(lv_obj_t* aLvglSelf, uint16_t aId = 0); UIElement(lv_obj_t *aLvglSelf, uint16_t aId = 0);
protected: protected:
lv_obj_t* mLvglSelf; lv_obj_t *mLvglSelf;
uint16_t mId; uint16_t mId;
}; };
} } // namespace UI

View file

@ -1,3 +1,4 @@
class IHandleButtons{ #pragma once
virtual void OnKeyTap() = 0; class IHandleButtons {
virtual void OnKeyTap() = 0;
}; };

View file

@ -4,23 +4,25 @@
#include <memory> #include <memory>
using namespace std::chrono; using namespace std::chrono;
using namespace UI;
poller::poller(std::function<void()> aOnPollCb, milliseconds aPollTime):mIntermittentCallback(std::move(aOnPollCb)){ poller::poller(std::function<void()> aOnPollCb, milliseconds aPollTime)
mTimer = lv_timer_create(poller::onPoll,aPollTime.count(),this); : mIntermittentCallback(std::move(aOnPollCb)) {
lv_timer_set_repeat_count(mTimer,-1); // Call forever mTimer = lv_timer_create(poller::onPoll, aPollTime.count(), this);
lv_timer_set_repeat_count(mTimer, -1); // Call forever
} }
poller::~poller(){ poller::~poller() {
if(mTimer){ if (mTimer) {
lv_timer_del(mTimer); lv_timer_del(mTimer);
mTimer = nullptr; mTimer = nullptr;
} }
} }
void poller::onPoll(_lv_timer_t* aTimer){ void poller::onPoll(_lv_timer_t *aTimer) {
poller* currentPoller = reinterpret_cast<poller*>(aTimer->user_data); poller *currentPoller = reinterpret_cast<poller *>(aTimer->user_data);
if(currentPoller->mIntermittentCallback){ if (currentPoller->mIntermittentCallback) {
currentPoller->mIntermittentCallback(); currentPoller->mIntermittentCallback();
} }
} }

View file

@ -1,23 +1,29 @@
#include <chrono>
#include <memory>
#include <functional>
#include "lvgl.h" #include "lvgl.h"
#include <chrono>
#include <functional>
#include <memory>
class poller{ namespace UI {
class poller {
public: public:
poller(std::function<void()> aOnPollCb, std::chrono::milliseconds pollTime = std::chrono::seconds(5)); poller(std::function<void()> aOnPollCb,
virtual ~poller(); std::chrono::milliseconds pollTime = std::chrono::seconds(5));
virtual ~poller();
void setPollPeriod(std::chrono::milliseconds aPollPeriod){ lv_timer_set_period(mTimer, aPollPeriod.count());} void setPollPeriod(std::chrono::milliseconds aPollPeriod) {
inline void pause() { lv_timer_pause(mTimer);} lv_timer_set_period(mTimer, aPollPeriod.count());
inline void resume() { lv_timer_resume(mTimer);} }
inline void reset() { lv_timer_reset(mTimer);} inline void pause() { lv_timer_pause(mTimer); }
inline void runNext() { lv_timer_ready(mTimer);} inline void resume() { lv_timer_resume(mTimer); }
inline void reset() { lv_timer_reset(mTimer); }
inline void runNext() { lv_timer_ready(mTimer); }
private: private:
lv_timer_t* mTimer = nullptr; lv_timer_t *mTimer = nullptr;
std::function<void()> mIntermittentCallback = nullptr; std::function<void()> mIntermittentCallback = nullptr;
// Static function registered to every timers callback to pass this object as context // Static function registered to every timers callback to pass this object as
static void onPoll(_lv_timer_t* aTimer); // context
static void onPoll(_lv_timer_t *aTimer);
}; };
} // namespace UI

View file

@ -2,12 +2,9 @@
using namespace UI::Screen; using namespace UI::Screen;
Base::Base(uint16_t aId) : UIElement(mScreen, aId), Base::Base(uint16_t aId)
mScreen(lv_obj_create(NULL)) : UIElement(mScreen, aId), mScreen(lv_obj_create(NULL)) {}
{
}
void Base::AddWidget(Widget::Base::Ptr aWidget) void Base::AddWidget(Widget::Base::Ptr aWidget) {
{ mWidgets.push_back(std::move(aWidget));
mWidgets.push_back(std::move(aWidget));
} }

View file

@ -6,19 +6,19 @@
#include "WidgetBase.hpp" #include "WidgetBase.hpp"
#include <vector> #include <vector>
namespace UI::Screen{ namespace UI::Screen {
class Base : UIElement { class Base : UIElement {
public: public:
typedef std::unique_ptr<Base> Ptr; typedef std::unique_ptr<Base> Ptr;
Base(uint16_t aId = 0); Base(uint16_t aId = 0);
void AddWidget(Widget::Base::Ptr aWidget); void AddWidget(Widget::Base::Ptr aWidget);
private: private:
lv_obj_t *mScreen; lv_obj_t *mScreen;
std::vector<Widget::Base::Ptr> mWidgets; std::vector<Widget::Base::Ptr> mWidgets;
}; };
} } // namespace UI::Screen

View file

@ -1,8 +1,5 @@
#include "WidgetBase.hpp" #include "WidgetBase.hpp"
namespace UI::Widget{ using namespace UI::Widget;
Base::Base(lv_obj_t* aLvglSelf) : UIElement(aLvglSelf){} Base::Base(lv_obj_t *aLvglSelf) : UIElement(aLvglSelf) {}
}

View file

@ -2,16 +2,15 @@
#include "UIElement.hpp" #include "UIElement.hpp"
#include <memory> #include <memory>
namespace UI::Widget{ namespace UI::Widget {
class Base : public UIElement{ class Base : public UIElement {
public: public:
typedef std::unique_ptr<Base> Ptr; typedef std::unique_ptr<Base> Ptr;
Base(lv_obj_t* aLvglSelf); Base(lv_obj_t *aLvglSelf);
private: private:
}; };
} } // namespace UI::Widget