Merge branch 'master' into feature/testing
This commit is contained in:
commit
26c539174d
107 changed files with 49697 additions and 3689 deletions
|
|
@ -52,7 +52,7 @@ void user_init(void)
|
|||
IP4_ADDR(&first_client_ip, 172, 16, 0, 2);
|
||||
dhcpserver_start(&first_client_ip, 4);
|
||||
|
||||
xTaskCreate(telnetTask, (signed char *)"telnetTask", 512, NULL, 2, NULL);
|
||||
xTaskCreate(telnetTask, "telnetTask", 512, NULL, 2, NULL);
|
||||
}
|
||||
|
||||
/* Telnet task listens on port 23, returns some status information and then closes
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ void user_init(void) {
|
|||
gpio_write(GPIO_LED, 1);
|
||||
|
||||
publish_queue = xQueueCreate(3, 16);
|
||||
xTaskCreate(&wifi_task, (int8_t *) "wifi_task", 256, NULL, 2, NULL);
|
||||
xTaskCreate(&beat_task, (int8_t *) "beat_task", 256, NULL, 2, NULL);
|
||||
xTaskCreate(&mqtt_task, (int8_t *) "mqtt_task", 2048, NULL, 2, NULL);
|
||||
xTaskCreate(&wifi_task, "wifi_task", 256, NULL, 2, NULL);
|
||||
xTaskCreate(&beat_task, "beat_task", 256, NULL, 2, NULL);
|
||||
xTaskCreate(&mqtt_task, "mqtt_task", 2048, NULL, 2, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,6 @@ void blinkenRegisterTask(void *pvParameters)
|
|||
void user_init(void)
|
||||
{
|
||||
uart_set_baud(0, 115200);
|
||||
xTaskCreate(blinkenTask, (signed char *)"blinkenTask", 256, NULL, 2, NULL);
|
||||
//xTaskCreate(blinkenRegisterTask, (signed char *)"blinkenRegisterTask", 256, NULL, 2, NULL);
|
||||
xTaskCreate(blinkenTask, "blinkenTask", 256, NULL, 2, NULL);
|
||||
//xTaskCreate(blinkenRegisterTask, "blinkenRegisterTask", 256, NULL, 2, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,10 +113,10 @@ void user_init(void)
|
|||
mainqueue = xQueueCreate(10, sizeof(my_event_t));
|
||||
|
||||
// Create user interface task
|
||||
xTaskCreate(bmp180_task, (signed char *)"bmp180_task", 256, &mainqueue, 2, NULL);
|
||||
xTaskCreate(bmp180_task, "bmp180_task", 256, &mainqueue, 2, NULL);
|
||||
|
||||
// Create Timer (Trigger a measurement every second)
|
||||
timerHandle = xTimerCreate((signed char *)"BMP180 Trigger", 1000/portTICK_RATE_MS, pdTRUE, NULL, bmp180_i2c_timer_cb);
|
||||
timerHandle = xTimerCreate("BMP180 Trigger", 1000/portTICK_RATE_MS, pdTRUE, NULL, bmp180_i2c_timer_cb);
|
||||
|
||||
if (timerHandle != NULL)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -106,8 +106,8 @@ void user_init(void)
|
|||
i2c_init(scl_pin, sda_pin);
|
||||
|
||||
#ifdef MODE_FORCED
|
||||
xTaskCreate(bmp280_task_forced, (signed char *)"bmp280_task", 256, NULL, 2, NULL);
|
||||
xTaskCreate(bmp280_task_forced, "bmp280_task", 256, NULL, 2, NULL);
|
||||
#else
|
||||
xTaskCreate(bmp280_task_normal, (signed char *)"bmp280_task", 256, NULL, 2, NULL);
|
||||
xTaskCreate(bmp280_task_normal, "bmp280_task", 256, NULL, 2, NULL);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,6 +79,6 @@ void user_init(void)
|
|||
gpio_enable(gpio, GPIO_INPUT);
|
||||
|
||||
tsqueue = xQueueCreate(2, sizeof(uint32_t));
|
||||
xTaskCreate(buttonIntTask, (signed char *)"buttonIntTask", 256, &tsqueue, 2, NULL);
|
||||
xTaskCreate(buttonPollTask, (signed char*)"buttonPollTask", 256, NULL, 1, NULL);
|
||||
xTaskCreate(buttonIntTask, "buttonIntTask", 256, &tsqueue, 2, NULL);
|
||||
xTaskCreate(buttonPollTask, "buttonPollTask", 256, NULL, 1, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,6 @@ void dhtMeasurementTask(void *pvParameters)
|
|||
void user_init(void)
|
||||
{
|
||||
uart_set_baud(0, 115200);
|
||||
xTaskCreate(dhtMeasurementTask, (signed char *)"dhtMeasurementTask", 256, NULL, 2, NULL);
|
||||
xTaskCreate(dhtMeasurementTask, "dhtMeasurementTask", 256, NULL, 2, NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,6 +119,6 @@ void user_init(void)
|
|||
sdk_wifi_set_opmode(STATION_MODE);
|
||||
sdk_wifi_station_set_config(&config);
|
||||
|
||||
xTaskCreate(&broadcast_temperature, (signed char *)"broadcast_temperature", 256, NULL, 2, NULL);
|
||||
xTaskCreate(&broadcast_temperature, "broadcast_temperature", 256, NULL, 2, NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,6 +73,6 @@ void print_temperature(void *pvParameters) {
|
|||
void user_init(void) {
|
||||
uart_set_baud(0, 115200);
|
||||
|
||||
xTaskCreate(&print_temperature, (signed char *)"print_temperature", 256, NULL, 2, NULL);
|
||||
xTaskCreate(&print_temperature, "print_temperature", 256, NULL, 2, NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,5 +37,5 @@ void user_init(void)
|
|||
|
||||
ds3231_Init(scl, sda);
|
||||
|
||||
xTaskCreate(task1, (signed char *)"tsk1", 256, NULL, 2, NULL);
|
||||
xTaskCreate(task1, "tsk1", 256, NULL, 2, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ void frc2_handler(void)
|
|||
void user_init(void)
|
||||
{
|
||||
uart_set_baud(0, 115200);
|
||||
xTaskCreate(timerRegTask, (signed char *)"timerRegTask", 1024, NULL, 2, NULL);
|
||||
xTaskCreate(timerRegTask, "timerRegTask", 1024, NULL, 2, NULL);
|
||||
|
||||
TIMER(0).CTRL = VAL2FIELD(TIMER_CTRL_CLKDIV, TIMER_CLKDIV_256) | TIMER_CTRL_RELOAD;
|
||||
TIMER(0).LOAD = 0x200000;
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ void user_init(void)
|
|||
test_sign_extension();
|
||||
|
||||
xTaskHandle taskHandle;
|
||||
xTaskCreate(test_system_interaction, (signed char *)"interactionTask", 256, &taskHandle, 2, NULL);
|
||||
xTaskCreate(test_system_interaction, "interactionTask", 256, &taskHandle, 2, NULL);
|
||||
}
|
||||
|
||||
static volatile bool frc1_ran;
|
||||
|
|
|
|||
8
examples/fatfs/Makefile
Normal file
8
examples/fatfs/Makefile
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
PROGRAM = fatfs
|
||||
EXTRA_COMPONENTS = extras/sdio extras/fatfs
|
||||
#ESPBAUD = 460800
|
||||
|
||||
# FatFS parameters, see extras/fatfs/defaults.mk
|
||||
FATFS_CODE_PAGE = 866
|
||||
|
||||
include ../../common.mk
|
||||
132
examples/fatfs/main.c
Normal file
132
examples/fatfs/main.c
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* Example of using FatFs
|
||||
*
|
||||
* Part of esp-open-rtos
|
||||
* Copyright (C) 2016 Ruslan V. Uss <unclerus@gmail.com>
|
||||
* BSD Licensed as described in the file LICENSE
|
||||
*/
|
||||
#include <esp/uart.h>
|
||||
#include <espressif/esp_common.h>
|
||||
#include <stdio.h>
|
||||
#include <fatfs/ff.h>
|
||||
|
||||
#define CS_GPIO_PIN 2
|
||||
#define TEST_FILENAME "/test_loooong_filename.txt"
|
||||
#define TEST_CONTENTS "Hello! It's FatFs on esp8266 with ESP Open RTOS!"
|
||||
#define READBUF_SIZE 256
|
||||
#define DELAY_MS 3000
|
||||
|
||||
static const char contents[] = TEST_CONTENTS;
|
||||
|
||||
static const char *results[] = {
|
||||
[FR_OK] = "Succeeded",
|
||||
[FR_DISK_ERR] = "A hard error occurred in the low level disk I/O layer",
|
||||
[FR_INT_ERR] = "Assertion failed",
|
||||
[FR_NOT_READY] = "The physical drive cannot work",
|
||||
[FR_NO_FILE] = "Could not find the file",
|
||||
[FR_NO_PATH] = "Could not find the path",
|
||||
[FR_INVALID_NAME] = "The path name format is invalid",
|
||||
[FR_DENIED] = "Access denied due to prohibited access or directory full",
|
||||
[FR_EXIST] = "Access denied due to prohibited access",
|
||||
[FR_INVALID_OBJECT] = "The file/directory object is invalid",
|
||||
[FR_WRITE_PROTECTED] = "The physical drive is write protected",
|
||||
[FR_INVALID_DRIVE] = "The logical drive number is invalid",
|
||||
[FR_NOT_ENABLED] = "The volume has no work area",
|
||||
[FR_NO_FILESYSTEM] = "There is no valid FAT volume",
|
||||
[FR_MKFS_ABORTED] = "The f_mkfs() aborted due to any problem",
|
||||
[FR_TIMEOUT] = "Could not get a grant to access the volume within defined period",
|
||||
[FR_LOCKED] = "The operation is rejected according to the file sharing policy",
|
||||
[FR_NOT_ENOUGH_CORE] = "LFN working buffer could not be allocated",
|
||||
[FR_TOO_MANY_OPEN_FILES] = "Number of open files > _FS_LOCK",
|
||||
[FR_INVALID_PARAMETER] = "Given parameter is invalid"
|
||||
};
|
||||
|
||||
static char readbuf[READBUF_SIZE];
|
||||
|
||||
static bool failed(FRESULT res)
|
||||
{
|
||||
bool fail = res != FR_OK;
|
||||
if (fail)
|
||||
printf("\n Error: ");
|
||||
printf("\n %s\n", results[res]);
|
||||
return fail;
|
||||
}
|
||||
|
||||
void check_fatfs()
|
||||
{
|
||||
const char *vol = f_gpio_to_volume(CS_GPIO_PIN);
|
||||
|
||||
printf("\nCreating test file\n----------------------------\n");
|
||||
|
||||
FATFS fs;
|
||||
// Mount filesystem
|
||||
printf("f_mount(&fs, \"%s\")", vol);
|
||||
if (failed(f_mount(&fs, vol, 1)))
|
||||
return;
|
||||
|
||||
// Set default drive
|
||||
printf("f_chdrive(\"%s\")", vol);
|
||||
if (failed(f_chdrive(vol)))
|
||||
return;
|
||||
|
||||
FIL f;
|
||||
// Create test file
|
||||
printf("f_open(&f, \"%s\", FA_WRITE | FA_CREATE_ALWAYS)", TEST_FILENAME);
|
||||
if (failed(f_open(&f, TEST_FILENAME, FA_WRITE | FA_CREATE_ALWAYS)))
|
||||
return;
|
||||
|
||||
size_t written;
|
||||
// Write test string
|
||||
printf("f_write(&f, \"%s\")", contents);
|
||||
if (failed(f_write(&f, contents, sizeof(contents) - 1, &written)))
|
||||
return;
|
||||
printf(" Bytes written: %d\n", written);
|
||||
|
||||
// Close file
|
||||
printf("f_close(&f)");
|
||||
if (failed(f_close(&f)))
|
||||
return;
|
||||
|
||||
printf("\nReading test file\n----------------------------\n");
|
||||
|
||||
// Open test file
|
||||
printf("f_open(&f, \"%s\", FA_READ)", TEST_FILENAME);
|
||||
if (failed(f_open(&f, TEST_FILENAME, FA_READ)))
|
||||
return;
|
||||
|
||||
printf(" File size: %u\n", (uint32_t)f_size(&f));
|
||||
|
||||
size_t readed;
|
||||
// Read file
|
||||
printf("f_read(&f, ...)");
|
||||
if (failed(f_read(&f, readbuf, sizeof(readbuf) - 1, &readed)))
|
||||
return;
|
||||
readbuf[readed] = 0;
|
||||
|
||||
printf(" Readed %u bytes, test file contents: %s\n", readed, readbuf);
|
||||
|
||||
// Close file
|
||||
printf("f_close(&f)");
|
||||
if (failed(f_close(&f)))
|
||||
return;
|
||||
|
||||
// Unmount
|
||||
printf("f_mount(NULL, \"%s\")", vol);
|
||||
if (failed(f_mount(NULL, vol, 0)))
|
||||
return;
|
||||
}
|
||||
|
||||
void user_init(void)
|
||||
{
|
||||
uart_set_baud(0, 115200);
|
||||
printf("SDK version:%s\n\n", sdk_system_get_sdk_version());
|
||||
|
||||
while (true)
|
||||
{
|
||||
printf("***********************************\nTesting FAT filesystem\n***********************************\n");
|
||||
check_fatfs();
|
||||
printf("\n\n");
|
||||
for (size_t i = 0; i < DELAY_MS; i ++)
|
||||
sdk_os_delay_us(1000);
|
||||
}
|
||||
}
|
||||
8
examples/fatfs_rtc/Makefile
Normal file
8
examples/fatfs_rtc/Makefile
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
PROGRAM = fatfs
|
||||
EXTRA_COMPONENTS = extras/sdio extras/fatfs extras/i2c extras/ds1307
|
||||
ESPBAUD = 460800
|
||||
|
||||
# We provide uint32_t get_fattime() based on the RTC
|
||||
FATFS_FS_NORTC = 0
|
||||
|
||||
include ../../common.mk
|
||||
15
examples/fatfs_rtc/README.md
Normal file
15
examples/fatfs_rtc/README.md
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
This example shows how to use real-time clock (e.g. ds1307)
|
||||
with FatFs for real timestamps on the filesystem objects.
|
||||
|
||||
1. Set `FATFS_FS_NORTC` to 0 (it's 1 by default) in application makefile.
|
||||
2. Define function `uint32_t get_fattime()` which will return current time in
|
||||
timestamp format:
|
||||
|
||||
Bits | Date part
|
||||
-------|----------
|
||||
0..4 | Second / 2 (0..29)
|
||||
5..10 | Minute (0..59)
|
||||
11..15 | Hour (0..23)
|
||||
16..20 | Day (1..31)
|
||||
21..24 | Month (1..12)
|
||||
25..31 | Year origin from 1980 (0..127)
|
||||
133
examples/fatfs_rtc/main.c
Normal file
133
examples/fatfs_rtc/main.c
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
* Example of using FatFs with RTC clock
|
||||
*
|
||||
* Part of esp-open-rtos
|
||||
* Copyright (C) 2016 Ruslan V. Uss <unclerus@gmail.com>
|
||||
* BSD Licensed as described in the file LICENSE
|
||||
*/
|
||||
#include <esp/uart.h>
|
||||
#include <espressif/esp_common.h>
|
||||
#include <stdio.h>
|
||||
#include <fatfs/ff.h>
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
#include <i2c/i2c.h>
|
||||
#include <ds1307/ds1307.h>
|
||||
|
||||
// SD card
|
||||
#define CS_GPIO_PIN 2
|
||||
|
||||
// ds1307
|
||||
#define SCL_PIN 5
|
||||
#define SDA_PIN 4
|
||||
|
||||
#define TEST_FILENAME "/test_rtc_file.txt"
|
||||
#define TEST_CONTENTS "Hello! It's a test file and it can be deleted!"
|
||||
#define DELAY_MS 3000
|
||||
|
||||
// This function called by FatFs
|
||||
uint32_t get_fattime()
|
||||
{
|
||||
struct tm time;
|
||||
ds1307_get_time(&time);
|
||||
|
||||
return ((uint32_t)(time.tm_year - 1980) << 25)
|
||||
| ((uint32_t)time.tm_mon << 21)
|
||||
| ((uint32_t)time.tm_mday << 16)
|
||||
| ((uint32_t)time.tm_hour << 11)
|
||||
| ((uint32_t)time.tm_min << 5)
|
||||
| ((uint32_t)time.tm_sec >> 1);
|
||||
}
|
||||
|
||||
static const char contents[] = TEST_CONTENTS;
|
||||
static FATFS fs;
|
||||
|
||||
static void dump_fileinfo()
|
||||
{
|
||||
FILINFO info;
|
||||
printf("File: %s\n", TEST_FILENAME);
|
||||
if (f_stat(TEST_FILENAME, &info) != FR_OK)
|
||||
{
|
||||
printf("Cannot get file status\n");
|
||||
return;
|
||||
}
|
||||
printf("File size: %u bytes\n", (uint32_t)info.fsize);
|
||||
printf(
|
||||
"Modified: %04d-%02d-%02d %02d:%02d:%02d\n",
|
||||
(info.fdate >> 9) + 1980, // year
|
||||
(info.fdate >> 5) & 0x0f, // month
|
||||
info.fdate & 0x1f, // day
|
||||
info.ftime >> 11, // hours
|
||||
(info.ftime >> 5) & 0x3F, // minutes
|
||||
(info.ftime & 0x1f) << 1 // seconds
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
void rewrite_file_task(void *p)
|
||||
{
|
||||
const char *volume = f_gpio_to_volume(CS_GPIO_PIN);
|
||||
|
||||
while (true)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (f_mount(&fs, volume, 1) != FR_OK)
|
||||
{
|
||||
printf("Cannot mount volume %s\n", volume);
|
||||
break;
|
||||
}
|
||||
|
||||
if (f_chdrive(volume) != FR_OK)
|
||||
{
|
||||
printf("Cannot set default drive %s\n", volume);
|
||||
break;
|
||||
}
|
||||
|
||||
printf("\nTest file\n----------------------------\n");
|
||||
|
||||
dump_fileinfo();
|
||||
|
||||
printf("\nRe-creating test file\n----------------------------\n");
|
||||
|
||||
FIL f; //< It's big and it's on the stack! We need larger stack size
|
||||
|
||||
if (f_open(&f, TEST_FILENAME, FA_WRITE | FA_CREATE_ALWAYS) != FR_OK)
|
||||
{
|
||||
printf("Cannot create file %s\n", TEST_FILENAME);
|
||||
break;
|
||||
}
|
||||
|
||||
size_t bw;
|
||||
if (f_write(&f, contents, sizeof(contents) - 1, &bw))
|
||||
{
|
||||
printf("Cannot write to file\n");
|
||||
break;
|
||||
}
|
||||
printf("Bytes written: %d\n", bw);
|
||||
|
||||
if (f_close(&f) != FR_OK)
|
||||
{
|
||||
printf("Cannot close file\n");
|
||||
break;
|
||||
}
|
||||
|
||||
dump_fileinfo();
|
||||
|
||||
f_mount(NULL, volume, 0);
|
||||
}
|
||||
while (false);
|
||||
|
||||
vTaskDelay(DELAY_MS / portTICK_RATE_MS);
|
||||
}
|
||||
}
|
||||
|
||||
void user_init(void)
|
||||
{
|
||||
uart_set_baud(0, 115200);
|
||||
printf("SDK version:%s\n\n", sdk_system_get_sdk_version());
|
||||
|
||||
i2c_init (SCL_PIN, SDA_PIN);
|
||||
|
||||
xTaskCreate(rewrite_file_task, "task1", 512, NULL, 2, NULL);
|
||||
}
|
||||
6
examples/hd44780_lcd/Makefile
Normal file
6
examples/hd44780_lcd/Makefile
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
PROGRAM = hd44780_lcd
|
||||
EXTRA_COMPONENTS = extras/hd44780
|
||||
|
||||
HD44780_I2C = 0
|
||||
|
||||
include ../../common.mk
|
||||
62
examples/hd44780_lcd/main.c
Normal file
62
examples/hd44780_lcd/main.c
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Example of using HD44780 driver with LCD
|
||||
* connected directly to GPIO pins
|
||||
*
|
||||
* Part of esp-open-rtos
|
||||
* Copyright (C) 2016 Ruslan V. Uss <unclerus@gmail.com>
|
||||
* BSD Licensed as described in the file LICENSE
|
||||
*/
|
||||
#include <esp/uart.h>
|
||||
#include <espressif/esp_common.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <hd44780/hd44780.h>
|
||||
|
||||
static const uint8_t char_data[] = {
|
||||
0x04, 0x0e, 0x0e, 0x0e, 0x1f, 0x00, 0x04, 0x00,
|
||||
0x1f, 0x11, 0x0a, 0x04, 0x0a, 0x11, 0x1f, 0x00
|
||||
};
|
||||
|
||||
void user_init(void)
|
||||
{
|
||||
uart_set_baud(0, 115200);
|
||||
printf("SDK version:%s\n", sdk_system_get_sdk_version());
|
||||
|
||||
hd44780_t lcd = {
|
||||
.font = HD44780_FONT_5X8,
|
||||
.lines = 2,
|
||||
.pins = {
|
||||
.rs = 5,
|
||||
.e = 4,
|
||||
.d4 = 0,
|
||||
.d5 = 2,
|
||||
.d6 = 14,
|
||||
.d7 = 12,
|
||||
.bl = HD44780_NOT_USED
|
||||
}
|
||||
};
|
||||
|
||||
hd44780_init(&lcd);
|
||||
hd44780_upload_character(&lcd, 0, char_data);
|
||||
hd44780_upload_character(&lcd, 1, char_data + 8);
|
||||
|
||||
hd44780_gotoxy(&lcd, 0, 0);
|
||||
hd44780_puts(&lcd, "\x08 Hello world!");
|
||||
hd44780_gotoxy(&lcd, 0, 1);
|
||||
hd44780_puts(&lcd, "\x09 ");
|
||||
|
||||
char time[16];
|
||||
|
||||
while (true)
|
||||
{
|
||||
hd44780_gotoxy(&lcd, 2, 1);
|
||||
|
||||
snprintf(time, 7, "%u ", sdk_system_get_time() / 1000000);
|
||||
time[sizeof(time) - 1] = 0;
|
||||
|
||||
hd44780_puts(&lcd, time);
|
||||
|
||||
for (uint32_t i = 0; i < 1000; i++)
|
||||
sdk_os_delay_us(1000);
|
||||
}
|
||||
}
|
||||
BIN
examples/hd44780_lcd/schematics.png
Normal file
BIN
examples/hd44780_lcd/schematics.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
|
|
@ -126,6 +126,6 @@ void user_init(void)
|
|||
sdk_wifi_set_opmode(STATION_MODE);
|
||||
sdk_wifi_station_set_config(&config);
|
||||
|
||||
xTaskCreate(&http_get_task, (signed char *)"get_task", 256, NULL, 2, NULL);
|
||||
xTaskCreate(&http_get_task, "get_task", 256, NULL, 2, NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -333,5 +333,5 @@ void user_init(void)
|
|||
sdk_wifi_set_opmode(STATION_MODE);
|
||||
sdk_wifi_station_set_config(&config);
|
||||
|
||||
xTaskCreate(&http_get_task, (signed char *)"get_task", 2048, NULL, 2, NULL);
|
||||
xTaskCreate(&http_get_task, "get_task", 2048, NULL, 2, NULL);
|
||||
}
|
||||
|
|
|
|||
6
examples/i2c_lcd_test/Makefile
Normal file
6
examples/i2c_lcd_test/Makefile
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
PROGRAM = i2c_lcd_test
|
||||
EXTRA_COMPONENTS = extras/i2c extras/pcf8574 extras/hd44780
|
||||
|
||||
HD44780_I2C = 1
|
||||
|
||||
include ../../common.mk
|
||||
BIN
examples/i2c_lcd_test/i2c_lcd.png
Normal file
BIN
examples/i2c_lcd_test/i2c_lcd.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
71
examples/i2c_lcd_test/main.c
Normal file
71
examples/i2c_lcd_test/main.c
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Example of using driver for text LCD
|
||||
* connected to I2C by PCF8574
|
||||
*
|
||||
* Part of esp-open-rtos
|
||||
* Copyright (C) 2016 Ruslan V. Uss <unclerus@gmail.com>
|
||||
* BSD Licensed as described in the file LICENSE
|
||||
*/
|
||||
#include <esp/uart.h>
|
||||
#include <espressif/esp_common.h>
|
||||
#include <i2c/i2c.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <hd44780/hd44780.h>
|
||||
|
||||
#define SCL_PIN 5
|
||||
#define SDA_PIN 4
|
||||
#define ADDR 0x27
|
||||
|
||||
static const uint8_t char_data[] = {
|
||||
0x04, 0x0e, 0x0e, 0x0e, 0x1f, 0x00, 0x04, 0x00,
|
||||
0x1f, 0x11, 0x0a, 0x04, 0x0a, 0x11, 0x1f, 0x00
|
||||
};
|
||||
|
||||
void user_init(void)
|
||||
{
|
||||
uart_set_baud(0, 115200);
|
||||
printf("SDK version:%s\n", sdk_system_get_sdk_version());
|
||||
|
||||
i2c_init(SCL_PIN, SDA_PIN);
|
||||
|
||||
hd44780_t lcd = {
|
||||
.addr = ADDR,
|
||||
.font = HD44780_FONT_5X8,
|
||||
.lines = 2,
|
||||
.pins = {
|
||||
.rs = 0,
|
||||
.e = 2,
|
||||
.d4 = 4,
|
||||
.d5 = 5,
|
||||
.d6 = 6,
|
||||
.d7 = 7,
|
||||
.bl = 3
|
||||
},
|
||||
.backlight = true
|
||||
};
|
||||
|
||||
hd44780_init(&lcd);
|
||||
hd44780_upload_character(&lcd, 0, char_data);
|
||||
hd44780_upload_character(&lcd, 1, char_data + 8);
|
||||
|
||||
hd44780_gotoxy(&lcd, 0, 0);
|
||||
hd44780_puts(&lcd, "\x08 Hello world!");
|
||||
hd44780_gotoxy(&lcd, 0, 1);
|
||||
hd44780_puts(&lcd, "\x09 ");
|
||||
|
||||
char time[16];
|
||||
|
||||
while (true)
|
||||
{
|
||||
hd44780_gotoxy(&lcd, 2, 1);
|
||||
|
||||
snprintf(time, 7, "%u ", sdk_system_get_time() / 1000000);
|
||||
time[sizeof(time) - 1] = 0;
|
||||
|
||||
hd44780_puts(&lcd, time);
|
||||
|
||||
for (uint32_t i = 0; i < 1000; i++)
|
||||
sdk_os_delay_us(1000);
|
||||
}
|
||||
}
|
||||
|
|
@ -193,5 +193,5 @@ void user_init(void)
|
|||
{
|
||||
uart_set_baud(0, 115200);
|
||||
|
||||
xTaskCreate(play_task, (signed char *)"test_task", 1024, NULL, 2, NULL);
|
||||
xTaskCreate(play_task, "test_task", 1024, NULL, 2, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,5 +108,5 @@ void user_init(void)
|
|||
{
|
||||
uart_set_baud(0, 115200);
|
||||
printf("SDK version:%s\n", sdk_system_get_sdk_version());
|
||||
xTaskCreate(json_test, (signed char *)"jsont", 1024, NULL, 2, NULL);
|
||||
xTaskCreate(json_test, "jsont", 1024, NULL, 2, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ void user_init(void)
|
|||
|
||||
vSemaphoreCreateBinary(wifi_alive);
|
||||
publish_queue = xQueueCreate(3, PUB_MSG_LEN);
|
||||
xTaskCreate(&wifi_task, (int8_t *)"wifi_task", 256, NULL, 2, NULL);
|
||||
xTaskCreate(&beat_task, (int8_t *)"beat_task", 256, NULL, 3, NULL);
|
||||
xTaskCreate(&mqtt_task, (int8_t *)"mqtt_task", 1024, NULL, 4, NULL);
|
||||
xTaskCreate(&wifi_task, "wifi_task", 256, NULL, 2, NULL);
|
||||
xTaskCreate(&beat_task, "beat_task", 256, NULL, 3, NULL);
|
||||
xTaskCreate(&mqtt_task, "mqtt_task", 1024, NULL, 4, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,5 +138,5 @@ void user_init(void)
|
|||
|
||||
printf("Starting TFTP server...");
|
||||
ota_tftp_init_server(TFTP_PORT);
|
||||
xTaskCreate(&tftp_client_task, (signed char *)"tftp_client", 2048, NULL, 2, NULL);
|
||||
xTaskCreate(&tftp_client_task, "tftp_client", 2048, NULL, 2, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,5 +46,5 @@ void user_init(void)
|
|||
printf("pwm_start()\n");
|
||||
pwm_start();
|
||||
|
||||
xTaskCreate(task1, (signed char *)"tsk1", 256, NULL, 2, NULL);
|
||||
xTaskCreate(task1, "tsk1", 256, NULL, 2, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,6 @@ void user_init(void)
|
|||
uart_set_baud(0, 115200);
|
||||
printf("SDK version:%s\n", sdk_system_get_sdk_version());
|
||||
mainqueue = xQueueCreate(10, sizeof(uint32_t));
|
||||
xTaskCreate(task1, (signed char *)"tsk1", 256, &mainqueue, 2, NULL);
|
||||
xTaskCreate(task2, (signed char *)"tsk2", 256, &mainqueue, 2, NULL);
|
||||
xTaskCreate(task1, "tsk1", 256, &mainqueue, 2, NULL);
|
||||
xTaskCreate(task2, "tsk2", 256, &mainqueue, 2, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,5 +61,5 @@ extern "C" void user_init(void)
|
|||
{
|
||||
uart_set_baud(0, 115200);
|
||||
printf("SDK version:%s\n", sdk_system_get_sdk_version());
|
||||
xTaskCreate(task1, (signed char *)"tsk1", 256, NULL, 2, NULL);
|
||||
xTaskCreate(task1, "tsk1", 256, NULL, 2, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,6 +74,6 @@ void user_init(void)
|
|||
sdk_wifi_set_opmode(STATION_MODE);
|
||||
sdk_wifi_station_set_config(&config);
|
||||
|
||||
xTaskCreate(sntp_tsk, (signed char *)"SNTP", 1024, NULL, 1, NULL);
|
||||
xTaskCreate(sntp_tsk, "SNTP", 1024, NULL, 1, NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,5 +114,5 @@ void user_init(void)
|
|||
{
|
||||
uart_set_baud(0, 115200);
|
||||
|
||||
xTaskCreate(test_task, (signed char *)"test_task", 1024, NULL, 2, NULL);
|
||||
xTaskCreate(test_task, "test_task", 1024, NULL, 2, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -242,5 +242,5 @@ void user_init(void)
|
|||
{
|
||||
uart_set_baud(0, 115200);
|
||||
|
||||
xTaskCreate(sysparam_editor_task, (signed char *)"sysparam_editor_task", 512, NULL, 2, NULL);
|
||||
xTaskCreate(sysparam_editor_task, "sysparam_editor_task", 512, NULL, 2, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -254,5 +254,5 @@ void user_init(void)
|
|||
sdk_wifi_set_opmode(STATION_MODE);
|
||||
sdk_wifi_station_set_config(&config);
|
||||
|
||||
xTaskCreate(&tls_server_task, (signed char *)"server_task", 2048, NULL, 2, NULL);
|
||||
xTaskCreate(&tls_server_task, "server_task", 2048, NULL, 2, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,5 +65,5 @@ void user_init(void)
|
|||
uart_set_baud(0, 115200);
|
||||
i2c_init(SCL_PIN, SDA_PIN);
|
||||
|
||||
xTaskCreate(tsl2561MeasurementTask, (signed char *)"tsl2561MeasurementTask", 256, NULL, 2, NULL);
|
||||
xTaskCreate(tsl2561MeasurementTask, "tsl2561MeasurementTask", 256, NULL, 2, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,5 +79,5 @@ void user_init(void)
|
|||
{
|
||||
uart_set_baud(0, 115200);
|
||||
|
||||
xTaskCreate(&demo, (signed char *)"ws2812_i2s", 256, NULL, 10, NULL);
|
||||
xTaskCreate(&demo, "ws2812_i2s", 256, NULL, 10, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,6 +148,6 @@ void user_init(void)
|
|||
// notice the glitches due to NMI.
|
||||
|
||||
printf("Starting a task. There may be glitches!\r\n");
|
||||
xTaskCreate(&demo, (signed char *)"strip demo", 256, NULL, 10, NULL);
|
||||
xTaskCreate(&demo, "strip demo", 256, NULL, 10, NULL);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue