updated display driver with custom constructor-NOK
This commit is contained in:
@@ -68,7 +68,7 @@
|
||||
Use 16 Bit mode for any display with more than 240 pixel in one
|
||||
direction.
|
||||
*/
|
||||
//#define U8G2_16BIT
|
||||
#define U8G2_16BIT
|
||||
|
||||
|
||||
/* always enable U8G2_16BIT on 32bit environments, see issue https://github.com/olikraus/u8g2/issues/1222 */
|
||||
|
||||
@@ -7,10 +7,10 @@ void scanI2C(void);
|
||||
#define HAS_SSD1322
|
||||
|
||||
#define OLED_CS gpio_num_t(26)
|
||||
#define OLED_DC gpio_num_t(27)
|
||||
#define OLED_DC gpio_num_t(14)
|
||||
#define OLED_RST gpio_num_t(25)
|
||||
#define OLED_MOSI gpio_num_t(14)
|
||||
#define OLED_SCK gpio_num_t(13)
|
||||
#define OLED_MOSI 27 // gpio_num_t(14)
|
||||
#define OLED_SCK 5 // gpio_num_t(13)
|
||||
|
||||
#define ADC_SDA 4
|
||||
#define ADC_SCL 15
|
||||
|
||||
@@ -1,65 +1,47 @@
|
||||
#include "display.h"
|
||||
#include "u8g2_esp32_hal.h"
|
||||
|
||||
|
||||
u8g2_t display;
|
||||
u8g2_esp32_hal_t u8g2_esp32_hal;
|
||||
U8G2_SSD1322 display(U8G2_R2, OLED_MOSI, OLED_SCK, OLED_CS, OLED_DC, OLED_RST); // Enable U8G2_16BIT in u8g2.h
|
||||
uint64_t lastDisplayTime = 0;
|
||||
|
||||
u8g2_t* getDisplay(void)
|
||||
U8G2_SSD1322 *getDisplay(void)
|
||||
{
|
||||
return &display;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void initDisplay()
|
||||
{
|
||||
log_i("init display");
|
||||
u8g2_esp32_hal = U8G2_ESP32_HAL_DEFAULT;
|
||||
|
||||
u8g2_esp32_hal.clk = OLED_SCK;
|
||||
u8g2_esp32_hal.mosi = OLED_MOSI;
|
||||
u8g2_esp32_hal.cs = OLED_CS;
|
||||
u8g2_esp32_hal.dc = OLED_DC;
|
||||
u8g2_esp32_hal.reset = OLED_RST;
|
||||
|
||||
u8g2_esp32_hal_init(u8g2_esp32_hal);
|
||||
//u8g2_Setup_ssd1322_nhd_256x64_f(&display, U8G2_R2, u8g2_esp32_spi_byte_cb, u8g2_esp32_gpio_and_delay_cb);
|
||||
|
||||
u8g2_Setup_ssd1322_nhd_256x64_1(&display, U8G2_R2, u8x8_byte_arduino_4wire_sw_spi, u8x8_gpio_and_delay_arduino);
|
||||
u8x8_SetPin_4Wire_SW_SPI(u8g2_GetU8x8(&display), OLED_SCK, OLED_MOSI, OLED_CS, OLED_DC, OLED_RST);
|
||||
|
||||
u8g2_SetFont(&display, FONT8);
|
||||
u8g2_InitDisplay(&display);
|
||||
clearDisplay();
|
||||
//display.setFont(FONT8);
|
||||
display.begin();
|
||||
//clearDisplay();
|
||||
lastDisplayTime = millis();
|
||||
log_i("init display: OK");
|
||||
|
||||
}
|
||||
|
||||
void handleDisplay()
|
||||
{
|
||||
uint64_t currentmillis = millis();
|
||||
if (currentmillis - lastDisplayTime > SCREENREFRESH)
|
||||
{
|
||||
u8g2_SendBuffer(&display);
|
||||
// uint64_t currentmillis = millis();
|
||||
// if (currentmillis - lastDisplayTime > SCREENREFRESH)
|
||||
// {
|
||||
display.clearBuffer(); // clear the internal memory
|
||||
display.drawStr(0, 10, "Hello World!"); // write something to the internal memory
|
||||
display.sendBuffer();
|
||||
lastDisplayTime = millis();
|
||||
}
|
||||
|
||||
// }
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void clearDisplay(void)
|
||||
{
|
||||
u8g2_ClearBuffer(&display);
|
||||
display.clearBuffer();
|
||||
}
|
||||
|
||||
uint16_t getDisplayWidth(void)
|
||||
{
|
||||
return u8g2_GetDisplayWidth(&display);
|
||||
return display.getDisplayHeight();
|
||||
}
|
||||
|
||||
uint16_t getDisplayHeight(void)
|
||||
{
|
||||
return u8g2_GetDisplayWidth(&display);
|
||||
return display.getDisplayWidth();
|
||||
}
|
||||
@@ -16,6 +16,22 @@
|
||||
#define FONT16 u8g2_font_7x14_tf
|
||||
#define FONT24 u8g2_font_freedoomr25_tn //u8g2_font_logisoso24_tf
|
||||
|
||||
class U8G2_SSD1322 : public U8G2 {
|
||||
public:
|
||||
U8G2_SSD1322(const u8g2_cb_t *rotation, uint8_t mosi, uint8_t clk, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
|
||||
u8g2_Setup_ssd1322_nhd_256x64_f(&u8g2, rotation, u8x8_byte_arduino_hw_spi, u8x8_gpio_and_delay_arduino);
|
||||
SetPin_4Wire_HW_SPI(getU8x8(), mosi, clk, cs, dc, reset);
|
||||
}
|
||||
|
||||
void SetPin_4Wire_HW_SPI(u8x8_t *u8x8, uint8_t mosi, uint8_t clk, uint8_t cs, uint8_t dc, uint8_t reset)
|
||||
{
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_CS, cs);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_DC, dc);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_I2C_DATA, mosi); //note the orignina u8x8 callbacks are using I2C_data and I2C_clk
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_I2C_CLOCK, clk);
|
||||
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void initDisplay(void);
|
||||
@@ -28,6 +44,6 @@ String showValue(String designator, float value, String unit);
|
||||
uint16_t getDisplayWidth(void);
|
||||
uint16_t getDisplayHeight(void);
|
||||
|
||||
u8g2_t* getDisplay(void);
|
||||
U8G2_SSD1322* getDisplay(void);
|
||||
void drawDashedVLine(uint16_t x, uint16_t y, uint16_t len);
|
||||
void drawDashedHLine(uint16_t x, uint16_t y, uint16_t len);
|
||||
@@ -12,16 +12,16 @@ void c_onScreenButton::begin(uint16_t xpos, uint16_t ypos, uint16_t width, uint1
|
||||
if (_location == LocBottom)
|
||||
{
|
||||
log_d(":Calc_yTpos");
|
||||
_yTpos = getDisplayHeight() - 1 - (CONTROLSLINE_H / 2) + ( u8g2_GetMaxCharHeight(getDisplay()) / 2);
|
||||
_yTpos = getDisplayHeight() - 1 - (CONTROLSLINE_H / 2) + ( getDisplay()->getMaxCharHeight() / 2);
|
||||
log_d(":Calc_xTpos");
|
||||
_xTpos = _xpos + (_width / 2) - (u8g2_GetStrWidth(getDisplay(), _name.c_str()) / 2);
|
||||
_xTpos = _xpos + (_width / 2) - (getDisplay()->getStrWidth(_name.c_str()) / 2);
|
||||
}
|
||||
if (_location == LocRight)
|
||||
{
|
||||
log_d(":Calc_yTpos");
|
||||
_yTpos = _ypos + getDisplayHeight() - 2;
|
||||
log_d(":Calc_xTpos");
|
||||
_xTpos = _xpos + (_width / 2) - (u8g2_GetStrWidth(getDisplay(), _name.c_str()) / 2);
|
||||
_xTpos = _xpos + (_width / 2) - (getDisplay()->getStrWidth( _name.c_str()) / 2);
|
||||
}
|
||||
|
||||
log_d(":OK | ");
|
||||
@@ -30,33 +30,33 @@ void c_onScreenButton::begin(uint16_t xpos, uint16_t ypos, uint16_t width, uint1
|
||||
|
||||
void c_onScreenButton::drawButton()
|
||||
{
|
||||
u8g2_SetFont(getDisplay(), FONT8);
|
||||
getDisplay()->setFont( FONT8);
|
||||
log_d("drawbutton:%s(x=%u, y=%u, w=%u, h=%u)\n", _name.c_str(), _xpos, _ypos, _width, _height);
|
||||
if (!_visible)
|
||||
{
|
||||
//hide button
|
||||
return;
|
||||
}
|
||||
u8g2_SetDrawColor(getDisplay(),0);
|
||||
getDisplay()->setDrawColor(0);
|
||||
|
||||
u8g2_DrawBox(getDisplay(), _xpos, _ypos, _width, _height);
|
||||
u8g2_SetDrawColor(getDisplay(),1);
|
||||
getDisplay()->drawBox(_xpos, _ypos, _width, _height);
|
||||
getDisplay()->setDrawColor(1);
|
||||
|
||||
|
||||
if (getState())
|
||||
{
|
||||
u8g2_DrawRBox(getDisplay(), _xpos, _ypos, _width, _height, _radius);
|
||||
u8g2_SetDrawColor(getDisplay(),0);
|
||||
u8g2_DrawStr(getDisplay(), _xTpos, _yTpos, _name.c_str());
|
||||
getDisplay()->drawRBox( _xpos, _ypos, _width, _height, _radius);
|
||||
getDisplay()->setDrawColor(0);
|
||||
getDisplay()->drawStr(_xTpos, _yTpos, _name.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
u8g2_SetDrawColor(getDisplay(),1);
|
||||
u8g2_DrawRFrame(getDisplay(), _xpos, _ypos, _width, _height, _radius);
|
||||
u8g2_DrawStr(getDisplay(), _xTpos, _yTpos, _name.c_str());
|
||||
getDisplay()->setDrawColor(1);
|
||||
getDisplay()->drawRFrame( _xpos, _ypos, _width, _height, _radius);
|
||||
getDisplay()->drawStr(_xTpos, _yTpos, _name.c_str());
|
||||
}
|
||||
|
||||
u8g2_SetDrawColor(getDisplay(),1);
|
||||
getDisplay()->setDrawColor(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,12 +78,12 @@ void drawProgressBar(uint16_t x, uint16_t y, uint16_t width, uint16_t height, ui
|
||||
uint16_t radius = height / 2;
|
||||
uint16_t doubleRadius = radius << 1;
|
||||
|
||||
u8g2_SetDrawColor(getDisplay(), 1);
|
||||
u8g2_DrawRFrame(getDisplay(), x, y, width, height, radius);
|
||||
getDisplay()->setDrawColor( 1);
|
||||
getDisplay()->drawRFrame(x, y, width, height, radius);
|
||||
|
||||
uint16_t maxProgressWidth = (width - doubleRadius + 1) * progress / 100;
|
||||
|
||||
u8g2_DrawRBox(getDisplay(), x + 1, y + 2, maxProgressWidth, height - 3, radius);
|
||||
getDisplay()->drawRBox(x + 1, y + 2, maxProgressWidth, height - 3, radius);
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ void drawDashedHLine(uint16_t x, uint16_t y, uint16_t len)
|
||||
{
|
||||
for(int i = 0; i < len; i+=2)
|
||||
{
|
||||
u8g2_DrawPixel(getDisplay(), x+i, y);
|
||||
getDisplay()->drawPixel( x+i, y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +99,6 @@ void drawDashedVLine(uint16_t x, uint16_t y, uint16_t len)
|
||||
{
|
||||
for(int i = 0; i < len; i+=2)
|
||||
{
|
||||
u8g2_DrawPixel(getDisplay(), x, y+i);
|
||||
getDisplay()->drawPixel( x, y+i);
|
||||
}
|
||||
}
|
||||
@@ -71,6 +71,7 @@ void drawMainSceenButtons()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void drawMainscreenValues()
|
||||
{
|
||||
if (getDisplay() == NULL)
|
||||
@@ -80,17 +81,17 @@ void drawMainscreenValues()
|
||||
|
||||
drawDashedHLine(0, 12, 220);
|
||||
drawDashedVLine(40, 12, 33);
|
||||
u8g2_SetFont(getDisplay(),FONT8);
|
||||
u8g2_DrawStr(getDisplay(), 5, 8, "Fs:100Hz LP");
|
||||
getDisplay()->setFont(FONT8);
|
||||
getDisplay()->drawStr(5, 8, "Fs:100Hz LP");
|
||||
|
||||
u8g2_SetFont(getDisplay(), FONT24);
|
||||
getDisplay()->setFont(FONT24);
|
||||
|
||||
u8g2_DrawStr(getDisplay(), 60, 45, String(getValue()).c_str());
|
||||
|
||||
//u8g2_DrawStr(getDisplay(), 60, 45);
|
||||
uint16_t stringwidth = u8g2_GetStrWidth(getDisplay(), showValue("", getValue(), "").c_str());
|
||||
u8g2_SetFont(getDisplay(), u8g2_font_8x13_t_symbols);
|
||||
u8g2_DrawUTF8(getDisplay(), 60 + stringwidth + 3, 43, "mΩ");
|
||||
//display.drawStr(60, 45, String(getValue()).c_str());
|
||||
getDisplay()->setCursor(60, 45);
|
||||
getDisplay()->printf("%4.2f", getValue());
|
||||
uint16_t stringwidth = getDisplay()->getStrWidth(showValue("", getValue(), "").c_str());
|
||||
getDisplay()->setFont(u8g2_font_8x13_t_symbols);
|
||||
getDisplay()->drawUTF8(60 + stringwidth + 3, 43, "mΩ");
|
||||
//drawProgressBar(0, 40, 127, 5, getBar());
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ void setup()
|
||||
{
|
||||
// put your setup code here, to run once:
|
||||
initBoard();
|
||||
initButtons();
|
||||
//initButtons();
|
||||
initDisplay();
|
||||
initMeasure();
|
||||
initGui();
|
||||
//initMeasure();
|
||||
//initGui();
|
||||
|
||||
looptime = millis();
|
||||
}
|
||||
@@ -23,10 +23,10 @@ void loop()
|
||||
{
|
||||
// put your main code here, to run repeatedly:
|
||||
looptime = micros();
|
||||
handleMeasure();
|
||||
handleButtons();
|
||||
handleGui();
|
||||
handleGUIButtons();
|
||||
//handleMeasure();
|
||||
//handleButtons();
|
||||
//handleGui();
|
||||
//handleGUIButtons();
|
||||
handleDisplay(); //make sure to update the display last (writes buffer to the screen)
|
||||
log_i("T=%4.2fms\n", (double)(micros() - looptime)/1000);
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_log.h"
|
||||
#include "board.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
#include "u8g2_esp32_hal.h"
|
||||
|
||||
static const char *TAG = "u8g2_hal";
|
||||
static const unsigned int I2C_TIMEOUT_MS = 1000;
|
||||
|
||||
static spi_device_handle_t handle_spi; // SPI handle.
|
||||
static u8g2_esp32_hal_t u8g2_esp32_hal; // HAL state data.
|
||||
|
||||
#undef ESP_ERROR_CHECK
|
||||
#define ESP_ERROR_CHECK(x) do { esp_err_t rc = (x); if (rc != ESP_OK) { ESP_LOGE("err", "esp_err_t = %d", rc); assert(0 && #x);} } while(0);
|
||||
|
||||
/*
|
||||
* Initialze the ESP32 HAL.
|
||||
*/
|
||||
void u8g2_esp32_hal_init(u8g2_esp32_hal_t u8g2_esp32_hal_param) {
|
||||
u8g2_esp32_hal = u8g2_esp32_hal_param;
|
||||
} // u8g2_esp32_hal_init
|
||||
|
||||
/*
|
||||
* HAL callback function as prescribed by the U8G2 library. This callback is invoked
|
||||
* to handle SPI communications.
|
||||
*/
|
||||
uint8_t u8g2_esp32_spi_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) {
|
||||
ESP_LOGD(TAG, "spi_byte_cb: Received a msg: %d, arg_int: %d, arg_ptr: %p", msg, arg_int, arg_ptr);
|
||||
switch(msg) {
|
||||
case U8X8_MSG_BYTE_SET_DC:
|
||||
if (u8g2_esp32_hal.dc != U8G2_ESP32_HAL_UNDEFINED) {
|
||||
gpio_set_level(u8g2_esp32_hal.dc, arg_int);
|
||||
}
|
||||
break;
|
||||
|
||||
case U8X8_MSG_BYTE_INIT: {
|
||||
if (u8g2_esp32_hal.clk == U8G2_ESP32_HAL_UNDEFINED ||
|
||||
u8g2_esp32_hal.mosi == U8G2_ESP32_HAL_UNDEFINED ||
|
||||
u8g2_esp32_hal.cs == U8G2_ESP32_HAL_UNDEFINED) {
|
||||
break;
|
||||
}
|
||||
|
||||
spi_bus_config_t bus_config;
|
||||
memset(&bus_config, 0, sizeof(bus_config));
|
||||
bus_config.sclk_io_num = OLED_SCK; // CLK
|
||||
bus_config.mosi_io_num = OLED_MOSI; // MOSI
|
||||
bus_config.miso_io_num = -1; // MISO
|
||||
bus_config.quadwp_io_num = -1; // Not used
|
||||
bus_config.quadhd_io_num = -1; // Not used
|
||||
ESP_LOGI(TAG, "... Initializing bus.");
|
||||
ESP_ERROR_CHECK(spi_bus_initialize(HSPI_HOST, &bus_config, 1));
|
||||
|
||||
spi_device_interface_config_t dev_config;
|
||||
dev_config.address_bits = 0;
|
||||
dev_config.command_bits = 0;
|
||||
dev_config.dummy_bits = 0;
|
||||
dev_config.mode = 0;
|
||||
dev_config.duty_cycle_pos = 0;
|
||||
dev_config.cs_ena_posttrans = 0;
|
||||
dev_config.cs_ena_pretrans = 0;
|
||||
dev_config.clock_speed_hz = 10000;
|
||||
dev_config.spics_io_num = u8g2_esp32_hal.cs;
|
||||
dev_config.flags = 0;
|
||||
dev_config.queue_size = 200;
|
||||
dev_config.pre_cb = NULL;
|
||||
dev_config.post_cb = NULL;
|
||||
ESP_LOGI(TAG, "... Adding device bus.");
|
||||
ESP_ERROR_CHECK(spi_bus_add_device(HSPI_HOST, &dev_config, &handle_spi));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case U8X8_MSG_BYTE_SEND: {
|
||||
spi_transaction_t trans_desc;
|
||||
trans_desc.addr = 0;
|
||||
trans_desc.cmd = 0;
|
||||
trans_desc.flags = 0;
|
||||
trans_desc.length = 8 * arg_int; // Number of bits NOT number of bytes.
|
||||
trans_desc.rxlength = 0;
|
||||
trans_desc.tx_buffer = arg_ptr;
|
||||
trans_desc.rx_buffer = NULL;
|
||||
|
||||
ESP_LOGI(TAG, "... Transmitting %d bytes.", arg_int);
|
||||
ESP_ERROR_CHECK(spi_device_transmit(handle_spi, &trans_desc));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} // u8g2_esp32_spi_byte_cb
|
||||
|
||||
|
||||
/*
|
||||
* HAL callback function as prescribed by the U8G2 library. This callback is invoked
|
||||
* to handle callbacks for GPIO and delay functions.
|
||||
*/
|
||||
uint8_t u8g2_esp32_gpio_and_delay_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) {
|
||||
ESP_LOGD(TAG, "gpio_and_delay_cb: Received a msg: %d, arg_int: %d, arg_ptr: %p", msg, arg_int, arg_ptr);
|
||||
|
||||
switch(msg) {
|
||||
// Initialize the GPIO and DELAY HAL functions. If the pins for DC and RESET have been
|
||||
// specified then we define those pins as GPIO outputs.
|
||||
case U8X8_MSG_GPIO_AND_DELAY_INIT: {
|
||||
uint64_t bitmask = 0;
|
||||
if (u8g2_esp32_hal.dc != U8G2_ESP32_HAL_UNDEFINED) {
|
||||
bitmask = bitmask | (1ull<<u8g2_esp32_hal.dc);
|
||||
}
|
||||
if (u8g2_esp32_hal.reset != U8G2_ESP32_HAL_UNDEFINED) {
|
||||
bitmask = bitmask | (1ull<<u8g2_esp32_hal.reset);
|
||||
}
|
||||
if (u8g2_esp32_hal.cs != U8G2_ESP32_HAL_UNDEFINED) {
|
||||
bitmask = bitmask | (1ull<<u8g2_esp32_hal.cs);
|
||||
}
|
||||
|
||||
if (bitmask==0) {
|
||||
break;
|
||||
}
|
||||
gpio_config_t gpioConfig;
|
||||
gpioConfig.pin_bit_mask = bitmask;
|
||||
gpioConfig.mode = GPIO_MODE_OUTPUT;
|
||||
gpioConfig.pull_up_en = GPIO_PULLUP_DISABLE;
|
||||
gpioConfig.pull_down_en = GPIO_PULLDOWN_ENABLE;
|
||||
gpioConfig.intr_type = GPIO_INTR_DISABLE;
|
||||
gpio_config(&gpioConfig);
|
||||
break;
|
||||
}
|
||||
|
||||
// Set the GPIO reset pin to the value passed in through arg_int.
|
||||
case U8X8_MSG_GPIO_RESET:
|
||||
if (u8g2_esp32_hal.reset != U8G2_ESP32_HAL_UNDEFINED) {
|
||||
gpio_set_level(u8g2_esp32_hal.reset, arg_int);
|
||||
}
|
||||
break;
|
||||
// Set the GPIO client select pin to the value passed in through arg_int.
|
||||
case U8X8_MSG_GPIO_CS:
|
||||
if (u8g2_esp32_hal.cs != U8G2_ESP32_HAL_UNDEFINED) {
|
||||
gpio_set_level(u8g2_esp32_hal.cs, arg_int);
|
||||
}
|
||||
break;
|
||||
|
||||
// Delay for the number of milliseconds passed in through arg_int.
|
||||
case U8X8_MSG_DELAY_MILLI:
|
||||
vTaskDelay(arg_int/portTICK_PERIOD_MS);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
} // u8g2_esp32_gpio_and_delay_cb
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* u8g2_esp32_hal.h
|
||||
*
|
||||
* Created on: Feb 12, 2017
|
||||
* Author: kolban
|
||||
*/
|
||||
|
||||
#ifndef U8G2_ESP32_HAL_H_
|
||||
#define U8G2_ESP32_HAL_H_
|
||||
#include "clib/u8g2.h"
|
||||
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/spi_master.h"
|
||||
|
||||
#define U8G2_ESP32_HAL_UNDEFINED (-1)
|
||||
|
||||
#define I2C_MASTER_NUM I2C_NUM_1 // I2C port number for master dev
|
||||
#define I2C_MASTER_TX_BUF_DISABLE 0 // I2C master do not need buffer
|
||||
#define I2C_MASTER_RX_BUF_DISABLE 0 // I2C master do not need buffer
|
||||
#define I2C_MASTER_FREQ_HZ 50000 // I2C master clock frequency
|
||||
#define ACK_CHECK_EN 0x1 // I2C master will check ack from slave
|
||||
#define ACK_CHECK_DIS 0x0 // I2C master will not check ack from slave
|
||||
|
||||
typedef struct {
|
||||
int clk;
|
||||
int16_t mosi;
|
||||
gpio_num_t cs;
|
||||
gpio_num_t reset;
|
||||
gpio_num_t dc;
|
||||
} u8g2_esp32_hal_t ;
|
||||
|
||||
#define U8G2_ESP32_HAL_DEFAULT {U8G2_ESP32_HAL_UNDEFINED, U8G2_ESP32_HAL_UNDEFINED, gpio_num_t(U8G2_ESP32_HAL_UNDEFINED), gpio_num_t(U8G2_ESP32_HAL_UNDEFINED), gpio_num_t(U8G2_ESP32_HAL_UNDEFINED) }
|
||||
|
||||
void u8g2_esp32_hal_init(u8g2_esp32_hal_t u8g2_esp32_hal_param);
|
||||
uint8_t u8g2_esp32_spi_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8g2_esp32_i2c_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8g2_esp32_gpio_and_delay_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
#endif /* U8G2_ESP32_HAL_H_ */
|
||||
Reference in New Issue
Block a user