Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ESP-IDF examples and config files #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakelists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
idf_component_register(SRCS "tm1638.c" "TM1638_platform.c"
INCLUDE_DIRS "."
REQUIRES driver)
22 changes: 22 additions & 0 deletions Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
menu "TM1638 config"

config TM1638_CLK_GPIO
int "TM1638 CLK Pin"
default 0
help
GPIO number (IOxx) for the TM638 CLK pin.


config TM1638_DIO_GPIO
int "TM1638 DIO Pin"
default 1
help
GPIO number (IOxx) for the TM638 DIO pin.

config TM1638_STB_GPIO
int "TM1638 STB Pin"
default 2
help
GPIO number (IOxx) for the TM638 STB pin.

endmenu # TM1638
10 changes: 5 additions & 5 deletions TM1638_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ extern "C" {
// #define TM1638_PLATFORM_STM32 // HAL Functions
// #define TM1638_PLATFORM_ESP32_IDF // ESP-IDF


#if defined(TM1638_PLATFORM_AVR)
/**
* @brief Specify IO Pins of AVR connected to TM1638
Expand Down Expand Up @@ -79,13 +78,14 @@ extern "C" {
#define TM1638_STB_GPIO GPIOA
#define TM1638_STB_PIN GPIO_PIN_2

#elif defined(TM1638_PLATFORM_ESP32_IDF)
#elif defined(TM1638_PLATFORM_ESP32_IDF) || defined(ESP_PLATFORM)
/**
* @brief Specify IO Pins of ESP32 connected to TM1638
* @note `ESP_PLATFORM` automatically activates (value TRUE) when building with ESP-IDF build chain
*/
#define TM1638_CLK_GPIO GPIO_NUM_0
#define TM1638_DIO_GPIO GPIO_NUM_1
#define TM1638_STB_GPIO GPIO_NUM_2
#define TM1638_CLK_GPIO (gpio_num_t)CONFIG_TM1638_CLK_GPIO
#define TM1638_DIO_GPIO (gpio_num_t)CONFIG_TM1638_DIO_GPIO
#define TM1638_STB_GPIO (gpio_num_t)CONFIG_TM1638_STB_GPIO
#endif


Expand Down
8 changes: 8 additions & 0 deletions examples/esp32/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)

set(EXTRA_COMPONENT_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(tm1638)
2 changes: 2 additions & 0 deletions examples/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
idf_component_register(SRCS "main.c"
INCLUDE_DIRS "")
19 changes: 19 additions & 0 deletions examples/esp32/main/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "TM1638.h"
#include "TM1638_platform.h"

void app_main(void)
{
TM1638_Handler_t Handler;

TM1638_Platform_Init(&Handler);
TM1638_Init(&Handler, TM1638DisplayTypeComCathode);
TM1638_ConfigDisplay(&Handler, 7, TM1638DisplayStateON);

while (1)
{
// Display the number 8 and Decimal Point in the SEG1
TM1638_SetSingleDigit_HEX(&Handler, 8 | TM1638DecimalPoint, 0);
}

TM1638_DeInit(&Handler);
}
11 changes: 11 additions & 0 deletions idf_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "2.0.0"

description: TM1638 driver for AVR (ATmega32), STM32 (HAL) and ESP32 (esp-idf)
url: https://github.com/MahdaSystem/TM1638
repository: https://github.com/MahdaSystem/TM1638.git
documentation: https://github.com/MahdaSystem/TM1638#readme
issues: https://github.com/MahdaSystem/TM1638/issues

dependencies:
# Required IDF version
idf: ">=4.2"