Clean up some comments.
This commit is contained in:
parent
25b4564a8b
commit
63899a606a
esp/cpp/07_lcd-panel-i2c/main
@ -83,7 +83,8 @@ public:
|
||||
/**
|
||||
* Obtains LVGL API mutex lock for the duration of local scope.
|
||||
*
|
||||
* LVGL library is not thread-safe, this example calls LVGL APIs from tasks.
|
||||
* LVGL library is not thread-safe, this lock should be held when making calls
|
||||
* to the LVGL API, and released as soon as possible when finished.
|
||||
*/
|
||||
struct ScopedLock {
|
||||
explicit ScopedLock() { _lock_acquire(&lv_lock_); }
|
||||
@ -101,9 +102,16 @@ public:
|
||||
static TimeKeeper timers_;
|
||||
|
||||
private:
|
||||
|
||||
//
|
||||
// PRIVATE METHODS
|
||||
|
||||
/// Registers LVGL draw buffers for this display.
|
||||
void register_draw_buffer();
|
||||
|
||||
//
|
||||
// PRIVATE STATIC METHODS
|
||||
|
||||
/// Registers LVGL ticker timer callback for rendering this display.
|
||||
static void register_lvgl_tick_timer();
|
||||
|
||||
|
@ -49,6 +49,9 @@ struct I2C {
|
||||
|
||||
~I2C() = default;
|
||||
|
||||
//
|
||||
// GETTERS
|
||||
|
||||
/**
|
||||
* ESP I2C master bus handle getter.
|
||||
* This will fail if an I2C instance was never constructed.
|
||||
@ -60,6 +63,9 @@ struct I2C {
|
||||
return i2c;
|
||||
}
|
||||
|
||||
//
|
||||
// PUBLIC MEMBERS
|
||||
|
||||
/// ESP I2C master bus configuration used during initialization.
|
||||
i2c_master_bus_config_t esp_bus_config_;
|
||||
|
||||
@ -67,6 +73,10 @@ struct I2C {
|
||||
int rst_num_;
|
||||
|
||||
private:
|
||||
|
||||
//
|
||||
// PRIVATE MEMBERS
|
||||
|
||||
/// Tag used for ESP logging.
|
||||
const char * TAG = "I2C";
|
||||
};
|
||||
|
@ -42,6 +42,9 @@ struct Panel {
|
||||
|
||||
~Panel() = default;
|
||||
|
||||
//
|
||||
// PUBLIC MEMBERS
|
||||
|
||||
/// Pointer to object using known interface for IPanelDevice.
|
||||
IPanelDevice *device_;
|
||||
|
||||
@ -55,6 +58,10 @@ struct Panel {
|
||||
esp_lcd_panel_dev_config_t esp_panel_config_;
|
||||
|
||||
private:
|
||||
|
||||
//
|
||||
// PRIVATE MEMBERS
|
||||
|
||||
/// Tag used for ESP logging.
|
||||
const char * TAG = "Panel";
|
||||
};
|
||||
|
@ -15,9 +15,9 @@
|
||||
#define LVGL_PALETTE_SIZE 8
|
||||
|
||||
/**
|
||||
* Encapsulates vendor specific ESP LCD pabel initialization logic.
|
||||
* Encapsulates vendor specific ESP LCD panel initialization logic.
|
||||
* This pure virtual interface can be inherited from for using new LCD devices.
|
||||
* See the SSD1306 example for implementing a PanelDevice for NT35510 or ST7789.
|
||||
* See SSD1306 as an example to implement IPanelDevice for NT35510 or ST7789.
|
||||
*
|
||||
* At this time only I2C is supported.
|
||||
* Classes that inherit from this interface should likely be marked final.
|
||||
@ -61,6 +61,9 @@ public:
|
||||
|
||||
virtual ~IPanelDevice() = default;
|
||||
|
||||
//
|
||||
// PUBLIC METHODS
|
||||
|
||||
/**
|
||||
* Create an LVGL display using the width and height of this device.
|
||||
*
|
||||
@ -108,7 +111,6 @@ public:
|
||||
ESP_LOGI(TAG, "Install SSD1306 panel driver");
|
||||
// Call pure virtual method responsible for initializing the panel handle.
|
||||
init_panel(config, io, panel);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,6 +121,9 @@ public:
|
||||
*/
|
||||
virtual void *vendor_config() = 0;
|
||||
|
||||
//
|
||||
// PUBLIC MEMBERS
|
||||
|
||||
/// Width of the device screen in pixels.
|
||||
int32_t width_;
|
||||
|
||||
@ -135,6 +140,10 @@ public:
|
||||
esp_lcd_panel_io_i2c_config_t esp_io_config_;
|
||||
|
||||
private:
|
||||
|
||||
//
|
||||
// PRIVATE METHODS
|
||||
|
||||
/**
|
||||
* Initializes the ESP panel using vendor specific APIs and configurations.
|
||||
* This method should implement any setup logic specific to the device.
|
||||
@ -147,6 +156,9 @@ private:
|
||||
esp_lcd_panel_io_handle_t io,
|
||||
esp_lcd_panel_handle_t &panel) = 0;
|
||||
|
||||
//
|
||||
// PRIVATE MEMBERS
|
||||
|
||||
/// Tag used for ESP logging.
|
||||
const char * TAG = "IPanelDevice";
|
||||
};
|
||||
|
@ -75,6 +75,10 @@ public:
|
||||
|
||||
~SSD1306() final = default;
|
||||
|
||||
//
|
||||
// PUBLIC METHODS
|
||||
|
||||
/// SSD1306 configuration structure.
|
||||
/**
|
||||
* Provides the SSD1306 vendor configuration to IPanelDevice consumers.
|
||||
*
|
||||
@ -85,6 +89,9 @@ public:
|
||||
return &ssd1306_config_;
|
||||
}
|
||||
|
||||
//
|
||||
// PUBLIC MEMBERS
|
||||
|
||||
/// SSD1306 configuration structure.
|
||||
esp_lcd_panel_ssd1306_config_t ssd1306_config_;
|
||||
|
||||
@ -95,6 +102,10 @@ public:
|
||||
static uint8_t oled_buffer_[LCD_H_RES * LCD_V_RES / 8];
|
||||
|
||||
private:
|
||||
|
||||
//
|
||||
// PRIVATE METHODS
|
||||
|
||||
/// Initializes the ESP LCD panel handle for the SSD1306 device.
|
||||
void init_panel(esp_lcd_panel_dev_config_t &config,
|
||||
esp_lcd_panel_io_handle_t io,
|
||||
@ -103,6 +114,9 @@ private:
|
||||
ESP_ERROR_CHECK(esp_lcd_new_panel_ssd1306(io, &config, &panel));
|
||||
}
|
||||
|
||||
//
|
||||
// PRIVATE MEMBERS
|
||||
|
||||
/// Tag used for ESP logging.
|
||||
const char * TAG = "SSD1306";
|
||||
};
|
||||
|
@ -36,6 +36,9 @@ struct Timer {
|
||||
|
||||
Timer &operator=(Timer &) = delete;
|
||||
|
||||
//
|
||||
// PUBLIC MEMBERS
|
||||
|
||||
/// Arguments passed to ESP API during timer creation.
|
||||
esp_timer_create_args_t args_;
|
||||
|
||||
@ -43,6 +46,10 @@ struct Timer {
|
||||
esp_timer_handle_t esp_timer_;
|
||||
|
||||
private:
|
||||
|
||||
//
|
||||
// PRIVATE MEMBERS
|
||||
|
||||
/// Tag used for ESP logging.
|
||||
const char * TAG = "Timer";
|
||||
};
|
||||
@ -57,6 +64,9 @@ struct TimeKeeper {
|
||||
/// Timer handle type used for referring to Timers.
|
||||
using TimerHandle = Timer *;
|
||||
|
||||
//
|
||||
// GETTERS
|
||||
|
||||
TimerHandle get_handle(const char *name)
|
||||
{
|
||||
return &managed_timers_.at(name);
|
||||
@ -64,6 +74,9 @@ struct TimeKeeper {
|
||||
|
||||
TimerHandle operator[](const char *name) { return get_handle(name); }
|
||||
|
||||
//
|
||||
// PUBLIC METHODS
|
||||
|
||||
/**
|
||||
* Create a new managed Timer with the provided ESP arguments.
|
||||
* The timer can be retrieved later using the args.name field value.
|
||||
@ -128,6 +141,10 @@ struct TimeKeeper {
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//
|
||||
// PRIVATE MEMBERS
|
||||
|
||||
/// Existing ESP timers created for this TimeKeeper instance.
|
||||
std::unordered_map<const char *, Timer> managed_timers_;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user