main/u8g2_esp32_hal.h

Tue, 03 Oct 2023 17:24:06 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 03 Oct 2023 17:24:06 +0200
changeset 77
15dc572a7fcb
parent 57
232f318a6b51
permissions
-rw-r--r--

Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.

30
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 0
diff changeset
1 /**
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 0
diff changeset
2 * @file u8g2_esp32_hal.h
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 0
diff changeset
3 * @date Feb 12, 2017
8b630bf52092 Shorter lock times.
Michiel Broek <mbroek@mbse.eu>
parents: 0
diff changeset
4 * @author kolban
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 */
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 #ifndef U8G2_ESP32_HAL_H_
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 #define U8G2_ESP32_HAL_H_
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 #include "u8g2.h"
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 #include "driver/gpio.h"
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 #include "driver/spi_master.h"
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 #include "driver/i2c.h"
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14
57
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
15 #define U8G2_ESP32_HAL_UNDEFINED (-1) ///< Undefined value for this HAL
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16
57
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
17 #define I2C_MASTER_NUM (CONFIG_I2C_MASTER_PORT_NUM) ///< I2C port number for master dev (original 1)
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
18 #define I2C_MASTER_TX_BUF_DISABLE 0 ///< I2C master do not need buffer
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
19 #define I2C_MASTER_RX_BUF_DISABLE 0 ///< I2C master do not need buffer
37
358bbd5b608e menuconfig settings now work for I2C display setup. Lot's of code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 35
diff changeset
20 #define I2C_MASTER_FREQ_HZ (CONFIG_I2C_MASTER_FREQUENCY) ///< I2C master clock frequency (original 50000)
57
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
21 #define ACK_CHECK_EN 0x1 ///< I2C master will check ack from slave
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
22 #define ACK_CHECK_DIS 0x0 ///< I2C master will not check ack from slave
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 typedef struct {
57
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
25 gpio_num_t clk; ///< SPI clock
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
26 gpio_num_t mosi; ///< SPI mosi
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
27 gpio_num_t sda; ///< data for I²C
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
28 gpio_num_t scl; ///< clock for I²C
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
29 gpio_num_t cs; ///< SPI cs
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
30 gpio_num_t reset; ///< SPI reset
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 gpio_num_t dc;
57
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
32 } u8g2_esp32_hal_t; ///< HAL structure
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 #define U8G2_ESP32_HAL_DEFAULT {U8G2_ESP32_HAL_UNDEFINED, U8G2_ESP32_HAL_UNDEFINED, U8G2_ESP32_HAL_UNDEFINED, U8G2_ESP32_HAL_UNDEFINED, U8G2_ESP32_HAL_UNDEFINED, U8G2_ESP32_HAL_UNDEFINED, U8G2_ESP32_HAL_UNDEFINED }
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35
57
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
36 /**
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
37 * @brief Initialze the ESP32 HAL.
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
38 */
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 void u8g2_esp32_hal_init(u8g2_esp32_hal_t u8g2_esp32_hal_param);
57
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
40
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
41 /**
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
42 * @brief HAL callback function as prescribed by the U8G2 library.
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
43 * This callback is invoked to handle SPI communications.
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
44 */
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 uint8_t u8g2_esp32_spi_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
57
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
46
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
47 /**
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
48 * @brief HAL callback function as prescribed by the U8G2 library.
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
49 * This callback is invoked to handle I2C communications.
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
50 */
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 uint8_t u8g2_esp32_i2c_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
57
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
52
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
53 /**
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
54 * @brief HAL callback function as prescribed by the U8G2 library.
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
55 * This callback is invoked to handle callbacks for GPIO and delay functions.
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
56 */
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 uint8_t u8g2_esp32_gpio_and_delay_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 #endif /* U8G2_ESP32_HAL_H_ */

mercurial