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"
},
"cmake.sourceDirectory": "${workspaceFolder}/.pio/libdeps/esp32/Adafruit BusIO",
"editor.formatOnSave": false,
"editor.formatOnSave": true,
"idf.portWin": "COM8"
}

File diff suppressed because it is too large Load diff

View file

@ -3,32 +3,31 @@
#pragma once
#include "lvgl.h"
class Images{
class Images {
public:
Images();
lv_obj_t* addAppleTVIcon(lv_obj_t* parent);
lv_obj_t* addAppleDisplayImage(lv_obj_t* parent);
lv_obj_t* addAppleBackIcon(lv_obj_t* parent);
lv_obj_t *addAppleTVIcon(lv_obj_t *parent);
lv_obj_t *addAppleDisplayImage(lv_obj_t *parent);
lv_obj_t *addAppleBackIcon(lv_obj_t *parent);
lv_obj_t* addLowBrightnessIcon(lv_obj_t* parent);
lv_obj_t* addHighBrightnessIcon(lv_obj_t* parent);
lv_obj_t* addLightBulbIcon(lv_obj_t* parent);
lv_obj_t *addLowBrightnessIcon(lv_obj_t *parent);
lv_obj_t *addHighBrightnessIcon(lv_obj_t *parent);
lv_obj_t *addLightBulbIcon(lv_obj_t *parent);
lv_obj_t* addLeftGradiant(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 *addLeftGradiant(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);
private:
// Make Image based on anImageDesc then
// 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();
lv_img_dsc_t appleTvIcon;
@ -46,5 +45,4 @@ private:
lv_img_dsc_t wifiLowSignal;
lv_img_dsc_t wifiMidSignal;
lv_img_dsc_t wifiHighSignal;
};

View file

@ -2,6 +2,5 @@
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 <memory>
namespace UI{
namespace UI {
class UIBase{
class UIBase {
public:
UIBase(std::shared_ptr<HardwareAbstract> aHardware);
protected:
std::shared_ptr<HardwareAbstract> mHardware;
};
}
} // namespace UI

View file

@ -1,16 +1,13 @@
#include "ScreenManager.hpp"
using namespace UI::Screen;
Manager Manager::mManager = Manager();
Manager& Manager::getInstance(){
return mManager;
}
Manager &Manager::getInstance() { 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));
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -2,12 +2,9 @@
using namespace UI::Screen;
Base::Base(uint16_t aId) : UIElement(mScreen, aId),
mScreen(lv_obj_create(NULL))
{
}
Base::Base(uint16_t aId)
: 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));
}

View file

@ -6,7 +6,7 @@
#include "WidgetBase.hpp"
#include <vector>
namespace UI::Screen{
namespace UI::Screen {
class Base : UIElement {
public:
@ -21,4 +21,4 @@ private:
std::vector<Widget::Base::Ptr> mWidgets;
};
}
} // namespace UI::Screen

View file

@ -1,8 +1,5 @@
#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 <memory>
namespace UI::Widget{
namespace UI::Widget {
class Base : public UIElement{
class Base : public UIElement {
public:
typedef std::unique_ptr<Base> Ptr;
Base(lv_obj_t* aLvglSelf);
Base(lv_obj_t *aLvglSelf);
private:
};
}
} // namespace UI::Widget