SPIBus, Sensor SHTC3, Driver ST7789, MicroUI with json-settings - #2238
Draft
TobiasIvanSergeevich wants to merge 20 commits into
Draft
TobiasIvanSergeevich wants to merge 20 commits into
TobiasIvanSergeevich wants to merge 20 commits into
Conversation
…/sensirion.com/products/catalog/SHTC3 ). Communication via the I2C bus. Pin support for sensor power management.
Add HWSPI driver, that support on ESP8266 platform only HSPI. To start driver add to command line "startDriver HWSPI". On start driver have registred on SPPIBUS interface. Any SPI-device can attach to spi-bus, gives bus name, eg. "hspi". Add ST7789 driver for TFT-display vis spi interface. Can attach to spi-bus by this name. Eg. for platform ESP8266 - "hspi". To start driver add to command line "startDriver ST7789 [SPI_NAME] [CS_PIN] [CS_LEVEL] [DC_PIN] [RESET_PIN] [DYSP_WIDTH] [DYSP_HEIGHT] [DYSP_W_OFS] [DYSP_H_OFS] [ROTATION]", where [SPI_NAME] - spi bus hame, eg. "hspi" [CS_PIN] - chip select line, eg. "IO12" or "NA" if not use [CS_LEVEL] - chip select line level, not implemented yet [DC_PIN] - data/command line, eg. "IO15" [RS_PIN] - reset line, eg. "IO2" or "NA" if not use [DYSP_WIDTH] - actual dislay width, eg.135 [DYSP_HEIGHT] - actual dislay height, eg.240 [DYSP_W_OFS] - width, offset, eg.52 [DYSP_H_OFS] - height offset, eg.40 [ROTATION] - display rotation: 0, 90, 270, 360, not implemented yet.
The main functions of the microui core are in the file drv_microui_core.c. The rendering functions for basic primitives are in the drv_microui_renderer.c file. The interface for interacting with the graphics driver is described in the drv_idisplay.h file. General interaction and functions of the obk driver are in the drv_microui.c file: Launch: startDriver MicroUI st7789 st7789 is the name of the graphics driver that has the obk_display_renderer_t interface. The reading of the GUI from the microui.json file has been implemented. Due to lack of memory on the ESP8266 platform, the jsmn_stream streaming reader module has been added.c In the cJSON module.c in the JSON_SetValuestring function(cJSON added the valuestring check for NULL The following gui objects are implemented: - window - label; you can specify the name of the channel, the value of which will be displayed in the text. Teskt should be a string with formatting. - button; you can specify the name of the command that is executed when the button is clicked. - header; - layout, including layoutset (arbitrary region), width, height, and row. - icon; you can specify the channel name and different icons for the ON and OFF states. To control button presses, the OnKeyPress command is available. The command can be linked to obk events such as OnClick, OnHold, OnDoubleClick, etc. The focus is transferred to the required element when the TAB key is pressed. Pressing the button is performed when the ENTER key is pressed. Example for a physical button at input IO0: addEventHandler OnClick 0 OnKeyPress TAB addEventHandler OnHold 0 OnKeyPress ENTER Modification of the SHTC3 driver: - initialization of the pulse time via the I2C bus has been added; - the error in calculating the CRC has been fixed; - an installation command has been added that allows specifying the channel for saving the measurement error (can be used for display indication) Modification of the new_pins.c module. Special channels have been added: SPECIAL_CHANNEL_WIFICONNECTED 139 SPECIAL_CHANNEL_MQTTCONNECTED 140 indicating a connection to Wi‑Fi and MQTT, respectively. Used for display.
TobiasIvanSergeevich
marked this pull request as ready for review
September 24, 2026 11:40
TobiasIvanSergeevich
marked this pull request as draft
September 25, 2026 09:50
A result of calling the doHomeAssistantDiscovery method, the heap size decreases by more than 10 kB. On the esp8266 platform this leads to a critical memory level, which causes the http and mqtt modules to stop working. An error related to memory allocation is visible in the logs. As a result, the information required for HA Discovery is not published. Now it runs in separate task and wait while actual sending every peace of information will complete.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SENSOR SHTC3
Added support for temperature and humidity sensor type SHTC3 (https://sensirion.com/products/catalog/SHTC3)
Communication via the I2C bus. Pin support for sensor power management. Lines SHTC3_SCK, SHTC3_SDA, SHTC3_PWR (or SHTC3_PWR_n) have assiged via WEB Config Module. Driver starts automaticaly. Additional error channel can be assigned for sensor state signaling thought command line: SHTC3_SetErrorOutput CH10
HARDWARE SPI-BUS DRIVER (HWSPI)
(HAL layer implemented only for ESP8266 platform) Оn ESP8266 platform supports only HSPI.
To start driver add to command line "startDriver HWSPI". On start driver have registred on SPPIBUS interface. Any SPI-device can attach to spi-bus, gives bus name, eg. "hspi".
To implement spi-device should add this code:
!Important: HAL method xfer for ESP8266 platform used function spi_trans from sdk. This function is not applicable, then you need write and read during the same transfer. It should be corrected in future.
ST7789 TFT-DISPLAY DRIVER
ST7789 driver for TFT-display via spi interface. Can attach to spi-bus by this name. Eg. for platform ESP8266 - "hspi".
To start driver add to command line "startDriver ST7789 [SPI_NAME] [CS_PIN] [CS_LEVEL] [DC_PIN] [RESET_PIN]
[DYSP_WIDTH] [DYSP_HEIGHT] [DYSP_W_OFS] [DYSP_H_OFS] [ROTATION]", where
[SPI_NAME] - spi bus hame, eg. "hspi"
[CS_PIN] - chip select line, eg. "IO12" or "NA" if not use
[CS_LEVEL] - chip select line level, not implemented yet
[DC_PIN] - data/command line, eg. "IO15"
[RS_PIN] - reset line, eg. "IO2" or "NA" if not use
[DYSP_WIDTH] - actual dislay width, eg.135
[DYSP_HEIGHT] - actual dislay height, eg.240
[DYSP_W_OFS] - width, offset, eg.52
[DYSP_H_OFS] - height offset, eg.40
[ROTATION] - display rotation: 0, 90, 270, 360
Source code for use st7789 driver:
MICROUI DRIVER
Launch: startDriver MicroUI st7789
st7789 is the name of the graphics driver that has the obk_display_renderer_t interface.
The reading of the GUI from the microui.json file has been implemented. Due to lack of memory on the ESP8266 platform, the jsmn_stream streaming reader module has been added.c
In the cJSON module.c in the JSON_SetValuestring function(cJSON added the valuestring check for NULL
The following gui objects are implemented:
be a string with formatting.
To control button presses, the OnKeyPress command is available.
The command can be linked to obk events such as OnClick, OnHold, OnDoubleClick, etc.
The focus is transferred to the required element when the TAB key is pressed.
Pressing the button is performed when the ENTER key is pressed.
Example for a physical button at input IO0:
addEventHandler OnClick 0 OnKeyPress TAB
addEventHandler OnHold 0 OnKeyPress ENTER
Modification of the new_pins.c module.
Special channels have been added:
SPECIAL_CHANNEL_WIFICONNECTED 139
SPECIAL_CHANNEL_MQTTCONNECTED 140
indicating a connection to Wi‑Fi and MQTT, respectively. Used for display.
Full autoexec,bat for complex project ESP8266+SHTC3+ST7789+MICROUI
Example microui.json
{"driver":"MicroUI","style":{"font":"","font_size":2,"size":[30,130],"padding":5,"spacing":4,"indent":24,"title_height":26,"scrollbar_size":12,"thumb_size":8,"color_text":{"a":255,"b":255,"g":255,"r":255},"color_border":{"a":255,"b":255,"g":100,"r":100},"color_windowbg":{"a":255,"b":50,"g":0,"r":0},"color_titlebg":{"a":255,"b":25,"g":0,"r":0},"color_titletext":{"a":255,"b":255,"g":255,"r":255},"color_panelbg":{"a":0,"b":0,"g":0,"r":0},"color_button":{"a":255,"b":115,"g":0,"r":0},"color_buttonhover":{"a":255,"b":95,"g":0,"r":0},"color_buttonfocus":{"a":255,"b":255,"g":0,"r":0},"color_base":{"a":255,"b":30,"g":0,"r":0},"color_basehover":{"a":255,"b":35,"g":0,"r":0},"color_basefocus":{"a":255,"b":40,"g":0,"r":0},"color_scrollbase":{"a":255,"b":43,"g":0,"r":0},"color_scrollthumb":{"a":255,"b":30,"g":0,"r":0}},"gui":[{"window":{"title":"","opt":["notitle"],"rect":{"h":237,"w":130,"x":2,"y":2},"items":[{"layout":{"row":[27,27,27],"height":27}},{"icon":{"on":{"icon":6},"off":{"icon":7},"state":"CH139"}},{"icon":{"on":{"icon":6},"off":{"icon":7},"state":"CH140"}},{"icon":{"on":{"icon":9},"off":{"icon":8},"state":"CH10"}},{"header":{"title":"T,oC:","opt":["expanded"],"items":[{"layout":{"height":50}},{"label":{"align":"center","size":4,"text":"%0.1f","arguments":["CH0"]}}]}},{"header":{"title":"H,%:","opt":["expanded"],"items":[{"layout":{"height":50}},{"label":{"align":"center","size":4,"text":"%0.1f","arguments":["CH1"]}}]}},{"layout":{"row":[27,27,27,27],"height":27}},{"button":{"title":"","icon":5,"command":"restart"}},{"button":{"title":"","icon":11,"command":"restart"}},{"button":{"title":"","icon":9,"command":"restart"}},{"button":{"title":"","icon":10,"command":"restart"}}]}}]}Some illustrations:
