Skip to content

Commit

Permalink
Restyled by clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits committed Jun 12, 2022
1 parent 7889c07 commit e4da0a7
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
7 changes: 4 additions & 3 deletions examples/lighting-app/esp32/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,11 @@ void AppTask::LightingActionEventHandler(AppEvent * aEvent)
chip::DeviceLayer::PlatformMgr().UnlockChipStack();
}

void AppTask::ButtonPressCallback(){
void AppTask::ButtonPressCallback()
{
AppEvent button_event;
button_event.Type = AppEvent::kEventType_Button;
button_event.mHandler = AppTask::LightingActionEventHandler;
button_event.Type = AppEvent::kEventType_Button;
button_event.mHandler = AppTask::LightingActionEventHandler;
sAppTask.PostEvent(&button_event);
}

Expand Down
35 changes: 19 additions & 16 deletions examples/lighting-app/esp32/main/Button.cpp
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
#include "Button.h"

#define GPIO_INPUT_IO_0 9
#define GPIO_INPUT_PIN_SEL (1ULL<<GPIO_INPUT_IO_0)
#define GPIO_INPUT_IO_0 9
#define GPIO_INPUT_PIN_SEL (1ULL << GPIO_INPUT_IO_0)
#define ESP_INTR_FLAG_DEFAULT 0


static const char * TAG = "Button";

static Button::ButtonPressCallback button_press_handler = nullptr;

static void IRAM_ATTR gpio_isr_handler(void* arg)
static void IRAM_ATTR gpio_isr_handler(void * arg)
{
if(button_press_handler != nullptr){
if (button_press_handler != nullptr)
{
button_press_handler();
}
}

void Button::Init(){
void Button::Init()
{
/* Initialize button interrupt*/
//zero-initialize the config structure.
// zero-initialize the config structure.
gpio_config_t io_conf = {};
//interrupt of rising edge
// interrupt of rising edge
io_conf.intr_type = GPIO_INTR_NEGEDGE;
//bit mask of the pins, use GPIO4/5 here
// bit mask of the pins, use GPIO4/5 here
io_conf.pin_bit_mask = GPIO_INPUT_PIN_SEL;
//set as input mode
// set as input mode
io_conf.mode = GPIO_MODE_INPUT;
//enable pull-up mode
// enable pull-up mode
io_conf.pull_up_en = GPIO_PULLUP_ENABLE;
gpio_config(&io_conf);

//install gpio isr service
// install gpio isr service
gpio_install_isr_service(ESP_INTR_FLAG_DEFAULT);
//hook isr handler for specific gpio pin
gpio_isr_handler_add(static_cast<gpio_num_t>(GPIO_INPUT_IO_0), gpio_isr_handler, (void*) GPIO_INPUT_IO_0);
// hook isr handler for specific gpio pin
gpio_isr_handler_add(static_cast<gpio_num_t>(GPIO_INPUT_IO_0), gpio_isr_handler, (void *) GPIO_INPUT_IO_0);

ESP_LOGI(TAG, "Button initialized..");
}

void Button::SetButtonPressCallback(ButtonPressCallback button_callback){
if(button_callback != nullptr){
void Button::SetButtonPressCallback(ButtonPressCallback button_callback)
{
if (button_callback != nullptr)
{
button_press_handler = button_callback;
}
}
12 changes: 5 additions & 7 deletions examples/lighting-app/esp32/main/LEDWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void LEDWidget::Init(void)

void LEDWidget::Set(bool state)
{
ESP_LOGI(TAG, "Setting state to %d", state?1:0);
ESP_LOGI(TAG, "Setting state to %d", state ? 1 : 0);
if (state == mState)
return;

Expand All @@ -78,8 +78,6 @@ void LEDWidget::Toggle()
DoSet();
}



void LEDWidget::SetBrightness(uint8_t brightness)
{
ESP_LOGI(TAG, "Setting brightness to %d", brightness);
Expand All @@ -91,16 +89,16 @@ void LEDWidget::SetBrightness(uint8_t brightness)
DoSet();
}

uint8_t LEDWidget::GetLevel(){
uint8_t LEDWidget::GetLevel()
{
return this->mBrightness;
}


bool LEDWidget::IsTurnedOn(){
bool LEDWidget::IsTurnedOn()
{
return this->mState;
}


#if CONFIG_LED_TYPE_RMT
void LEDWidget::SetColor(uint8_t Hue, uint8_t Saturation)
{
Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/esp32/main/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
#include <stdbool.h>
#include <stdint.h>

#include "LEDWidget.h"
#include "Button.h"
#include "AppEvent.h"
#include "Button.h"
#include "LEDWidget.h"
#include "freertos/FreeRTOS.h"
#include <platform/CHIPDeviceLayer.h>

Expand Down
2 changes: 0 additions & 2 deletions examples/lighting-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ static void InitServer(intptr_t context)
Esp32AppServer::Init(); // Init ZCL Data Model and CHIP App Server AND Initialize device attestation config
}


extern "C" void app_main()
{
// Initialize the ESP NVS layer.
Expand Down Expand Up @@ -98,5 +97,4 @@ extern "C" void app_main()
{
ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed : %s", ErrorStr(error));
}

}

0 comments on commit e4da0a7

Please sign in to comment.