I’ve modified the AQW (Air Quality FeatherWing) example, basic with display,
so that the inexpensive SSD1306 OLED 128x64
can be used. These are readily available from aliexpress.com
and other places.
Here’s the change in the particle_xenon.overlay
.
display: ssd1306@3c {
compatible = "solomon,ssd1306fb";
reg = <0x3c>;
width = <128>;
height = <64>;
segment-offset = <0>;
page-offset = <0>;
display-offset = <0>;
multiplex-ratio = <63>;
segment-remap;
com-invdir;
prechargep = <0x22>;
};
In addition, here’s the display_init()
code changes to get the right label/data format for the 128×64 layout.
static int display_init(void)
{
const struct device *display_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_display));
if (!device_is_ready(display_dev))
{
LOG_ERR("Display not ready!");
return -EIO;
}
// get display and set primary & secondary colors
lv_disp_t * lv_disp = lv_disp_get_default();
lv_theme_default_init(lv_disp, lv_color_black(), lv_color_white(), 1, &lv_font_montserrat_12);
temp_label = lv_label_create(lv_scr_act());
lv_label_set_text(temp_label, "T: (C)");
lv_obj_align(temp_label, LV_ALIGN_TOP_MID, 0, 0);
temp_value_label = lv_label_create(lv_scr_act());
lv_label_set_text(temp_value_label, "*");
lv_obj_align(temp_value_label, LV_ALIGN_TOP_LEFT, 0, 0);
hum_label = lv_label_create(lv_scr_act());
lv_label_set_text(hum_label, "H: (%)");
lv_obj_align(hum_label, LV_ALIGN_TOP_MID, 0,16);
hum_value_label = lv_label_create(lv_scr_act());
lv_label_set_text(hum_value_label, "*");
lv_obj_align(hum_value_label, LV_ALIGN_TOP_LEFT, 0, 16);
voc_label = lv_label_create(lv_scr_act());
lv_label_set_text(voc_label, "VOC:");
lv_obj_align(voc_label, LV_ALIGN_TOP_MID, 0, 32);
voc_value_label = lv_label_create(lv_scr_act());
lv_label_set_text(voc_value_label, "*");
lv_obj_align(voc_value_label, LV_ALIGN_TOP_LEFT, 0, 32);
pm25_label = lv_label_create(lv_scr_act());
lv_label_set_text(pm25_label, "PM25:");
lv_obj_align(pm25_label, LV_ALIGN_TOP_MID, 0, 48);
pm25_value_label = lv_label_create(lv_scr_act());
lv_label_set_text(pm25_value_label, "*");
lv_obj_align(pm25_value_label, LV_ALIGN_TOP_LEFT, 0, 48);
lv_task_handler();
return 0;
}