From 13fc357565e753dceca30435b43f77febd00cea3 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Wed, 30 Aug 2017 15:56:11 +0200 Subject: [PATCH] switch to arduino framework due to FastLED depending on Arduino --- platformio.ini | 7 +-- src/main.ino | 26 +++++++++ src/main_esp32.cpp | 34 ------------ src/main_esp8266.cpp | 85 ----------------------------- src/sdkconfig.h | 125 ------------------------------------------- 5 files changed, 27 insertions(+), 250 deletions(-) create mode 100644 src/main.ino delete mode 100644 src/main_esp32.cpp delete mode 100644 src/main_esp8266.cpp delete mode 100644 src/sdkconfig.h diff --git a/platformio.ini b/platformio.ini index 4ba39df..cbb5c69 100644 --- a/platformio.ini +++ b/platformio.ini @@ -10,12 +10,7 @@ [env:nodemcuv2] platform = espressif8266 -framework = esp8266-rtos-sdk +framework = arduino board = nodemcuv2 lib_deps = FastLED - -[env:esp32thing] -platform = espressif32_stage -framework = espidf -board = esp32thing diff --git a/src/main.ino b/src/main.ino new file mode 100644 index 0000000..988dd83 --- /dev/null +++ b/src/main.ino @@ -0,0 +1,26 @@ +#include +#include "ESP8266WiFi.h" + +#include + +static constexpr uint8_t LED_PIN = D2; +static constexpr uint8_t PIR_PIN = D1; +uint16_t brightness = 96; +uint16_t speed = 20; +#define LED_TYPE WS2812 +#define COLOR_ORDER GRB + +static constexpr uint8_t NUM_LEDS = 50; + +CRGB leds[NUM_LEDS]; + +uint8_t noise[NUM_LEDS]; + +CRGBPalette16 currentPalette( PartyColors_p ); + +void setup() { +} + +void loop() { + delay(5000); +} diff --git a/src/main_esp32.cpp b/src/main_esp32.cpp deleted file mode 100644 index d655aa9..0000000 --- a/src/main_esp32.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* Hello World Example - - This example code is in the Public Domain (or CC0 licensed, at your option.) - - Unless required by applicable law or agreed to in writing, this - software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - CONDITIONS OF ANY KIND, either express or implied. -*/ - -#ifdef ESP32 -#include -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "esp_system.h" -#include "nvs_flash.h" - -void hello_task(void *pvParameter) -{ - printf("Hello world!\n"); - for (int i = 10; i >= 0; i--) { - printf("Restarting in %d seconds...\n", i); - vTaskDelay(1000 / portTICK_RATE_MS); - } - printf("Restarting now.\n"); - fflush(stdout); - esp_restart(); -} - -extern "C" void app_main() -{ - nvs_flash_init(); - xTaskCreate(&hello_task, "hello_task", 2048, NULL, 5, NULL); -} -#endif diff --git a/src/main_esp8266.cpp b/src/main_esp8266.cpp deleted file mode 100644 index a6095ac..0000000 --- a/src/main_esp8266.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#ifdef ESP8266 -#include "esp_common.h" - -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" - -#include - -static constexpr uint8_t LED_PIN = D2; -static constexpr uint8_t PIR_PIN = D1; -uint16_t brightness = 96; -uint16_t speed = 20; -#define LED_TYPE WS2812 -#define COLOR_ORDER GRB - -static constexpr uint8_t NUM_LEDS = 50; - -CRGB leds[NUM_LEDS]; - -uint8_t noise[NUM_LEDS]; - -CRGBPalette16 currentPalette( PartyColors_p ); - -/****************************************************************************** - * FunctionName : user_rf_cal_sector_set - * Description : SDK just reversed 4 sectors, used for rf init data and paramters. - * We add this function to force users to set rf cal sector, since - * we don't know which sector is free in user's application. - * sector map for last several sectors : ABCCC - * A : rf cal - * B : rf init data - * C : sdk parameters - * Parameters : none - * Returns : rf cal sector -*******************************************************************************/ -extern "C" uint32 user_rf_cal_sector_set(void) -{ - flash_size_map size_map = system_get_flash_size_map(); - uint32 rf_cal_sec = 0; - - switch (size_map) { - case FLASH_SIZE_4M_MAP_256_256: - rf_cal_sec = 128 - 5; - break; - - case FLASH_SIZE_8M_MAP_512_512: - rf_cal_sec = 256 - 5; - break; - - case FLASH_SIZE_16M_MAP_512_512: - case FLASH_SIZE_16M_MAP_1024_1024: - rf_cal_sec = 512 - 5; - break; - - case FLASH_SIZE_32M_MAP_512_512: - case FLASH_SIZE_32M_MAP_1024_1024: - rf_cal_sec = 1024 - 5; - break; - case FLASH_SIZE_64M_MAP_1024_1024: - rf_cal_sec = 2048 - 5; - break; - case FLASH_SIZE_128M_MAP_1024_1024: - rf_cal_sec = 4096 - 5; - break; - default: - rf_cal_sec = 0; - break; - } - - return rf_cal_sec; -} - -extern "C" void ICACHE_FLASH_ATTR user_init() -{ - os_printf("SDK version:%s\n", system_get_sdk_version()); - - LEDS.addLeds(leds,NUM_LEDS); - LEDS.setBrightness(brightness); - - loop(); -} - -void loop() { -} -#endif diff --git a/src/sdkconfig.h b/src/sdkconfig.h deleted file mode 100644 index 64ef778..0000000 --- a/src/sdkconfig.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * - * Automatically generated file; DO NOT EDIT. - * Espressif IoT Development Framework Configuration - * - */ -#define CONFIG_GATTC_ENABLE 1 -#define CONFIG_ESP32_PHY_MAX_TX_POWER 20 -#define CONFIG_PHY_ENABLED 1 -#define CONFIG_TRACEMEM_RESERVE_DRAM 0x0 -#define CONFIG_FREERTOS_MAX_TASK_NAME_LEN 16 -#define CONFIG_BLE_SMP_ENABLE 1 -#define CONFIG_IPC_TASK_STACK_SIZE 1024 -#define CONFIG_ESPTOOLPY_FLASHFREQ "40m" -#define CONFIG_NEWLIB_STDOUT_ADDCR 1 -#define CONFIG_TASK_WDT_CHECK_IDLE_TASK 1 -#define CONFIG_ESPTOOLPY_FLASHSIZE "2MB" -#define CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER 1 -#define CONFIG_ETHERNET 1 -#define CONFIG_INT_WDT 1 -#define CONFIG_ESPTOOLPY_FLASHFREQ_40M 1 -#define CONFIG_LOG_BOOTLOADER_LEVEL_INFO 1 -#define CONFIG_ESPTOOLPY_FLASHSIZE_2MB 1 -#define CONFIG_AWS_IOT_MQTT_PORT 8883 -#define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 1 -#define CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM 10 -#define CONFIG_LOG_DEFAULT_LEVEL_INFO 1 -#define CONFIG_BT_RESERVE_DRAM 0x10000 -#define CONFIG_ESP32_PANIC_PRINT_REBOOT 1 -#define CONFIG_CONSOLE_UART_BAUDRATE 115200 -#define CONFIG_LWIP_MAX_SOCKETS 10 -#define CONFIG_EMAC_TASK_PRIORITY 20 -#define CONFIG_TIMER_TASK_STACK_DEPTH 2048 -#define CONFIG_FATFS_CODEPAGE 1 -#define CONFIG_ESP32_DEFAULT_CPU_FREQ_160 1 -#define CONFIG_ULP_COPROC_RESERVE_MEM 0 -#define CONFIG_ESPTOOLPY_BAUD 115200 -#define CONFIG_INT_WDT_CHECK_CPU1 1 -#define CONFIG_FLASHMODE_DIO 1 -#define CONFIG_ESPTOOLPY_AFTER_RESET 1 -#define CONFIG_TOOLPREFIX "xtensa-esp32-elf-" -#define CONFIG_FREERTOS_IDLE_TASK_STACKSIZE 1024 -#define CONFIG_ESP32_WIFI_AMPDU_ENABLED 1 -#define CONFIG_CONSOLE_UART_NUM 0 -#define CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC 1 -#define CONFIG_ESPTOOLPY_BAUD_115200B 1 -#define CONFIG_LWIP_THREAD_LOCAL_STORAGE_INDEX 0 -#define CONFIG_FOUR_UNIVERSAL_MAC_ADDRESS 1 -#define CONFIG_CONSOLE_UART_DEFAULT 1 -#define CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN 16384 -#define CONFIG_NUMBER_OF_UNIVERSAL_MAC_ADDRESS 4 -#define CONFIG_ESPTOOLPY_FLASHSIZE_DETECT 1 -#define CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE 1 -#define CONFIG_BTDM_CONTROLLER_RUN_CPU 0 -#define CONFIG_TCPIP_TASK_STACK_SIZE 2560 -#define CONFIG_TASK_WDT 1 -#define CONFIG_MAIN_TASK_STACK_SIZE 4096 -#define CONFIG_TASK_WDT_TIMEOUT_S 5 -#define CONFIG_INT_WDT_TIMEOUT_MS 300 -#define CONFIG_ESPTOOLPY_FLASHMODE "dio" -#define CONFIG_BTC_TASK_STACK_SIZE 3072 -#define CONFIG_BLUEDROID_ENABLED 1 -#define CONFIG_ESPTOOLPY_BEFORE "default_reset" -#define CONFIG_LOG_DEFAULT_LEVEL 3 -#define CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION 1 -#define CONFIG_TIMER_QUEUE_LENGTH 10 -#define CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM 32 -#define CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER 20 -#define CONFIG_ESP32_RTC_CLK_CAL_CYCLES 1024 -#define CONFIG_ESP32_WIFI_NVS_ENABLED 1 -#define CONFIG_AWS_IOT_SDK 1 -#define CONFIG_DMA_RX_BUF_NUM 10 -#define CONFIG_TCP_SYNMAXRTX 6 -#define CONFIG_PYTHON "python" -#define CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1 1 -#define CONFIG_ESPTOOLPY_COMPRESSED 1 -#define CONFIG_PARTITION_TABLE_FILENAME "partitions_singleapp.csv" -#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1 -#define CONFIG_PARTITION_TABLE_SINGLE_APP 1 -#define CONFIG_WIFI_ENABLED 1 -#define CONFIG_LWIP_DHCP_DOES_ARP_CHECK 1 -#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE 4096 -#define CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY 2000 -#define CONFIG_ESP32_APPTRACE_DEST_NONE 1 -#define CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET 0x10000 -#define CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM 32 -#define CONFIG_FATFS_CODEPAGE_ASCII 1 -#define CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1 1 -#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 160 -#define CONFIG_FREERTOS_HZ 100 -#define CONFIG_LOG_COLORS 1 -#define CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE 1 -#define CONFIG_FREERTOS_ASSERT_FAIL_ABORT 1 -#define CONFIG_ESP32_XTAL_FREQ 0 -#define CONFIG_MONITOR_BAUD_115200B 1 -#define CONFIG_LOG_BOOTLOADER_LEVEL 3 -#define CONFIG_SMP_ENABLE 1 -#define CONFIG_ESPTOOLPY_BEFORE_RESET 1 -#define CONFIG_ESPTOOLPY_BAUD_OTHER_VAL 115200 -#define CONFIG_ESP32_XTAL_FREQ_AUTO 1 -#define CONFIG_TCP_MAXRTX 12 -#define CONFIG_ESPTOOLPY_AFTER "hard_reset" -#define CONFIG_DMA_TX_BUF_NUM 10 -#define CONFIG_ESP32_DEBUG_OCDAWARE 1 -#define CONFIG_TIMER_TASK_PRIORITY 1 -#define CONFIG_BT_ENABLED 1 -#define CONFIG_MONITOR_BAUD 115200 -#define CONFIG_FREERTOS_CORETIMER_0 1 -#define CONFIG_PARTITION_TABLE_CUSTOM_FILENAME "partitions.csv" -#define CONFIG_MBEDTLS_HAVE_TIME 1 -#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1 -#define CONFIG_GATTS_ENABLE 1 -#define CONFIG_FREERTOS_ISR_STACKSIZE 1536 -#define CONFIG_OPENSSL_ASSERT_DO_NOTHING 1 -#define CONFIG_AWS_IOT_MQTT_HOST "" -#define CONFIG_SYSTEM_EVENT_QUEUE_SIZE 32 -#define CONFIG_BT_ACL_CONNECTIONS 4 -#define CONFIG_FATFS_MAX_LFN 255 -#define CONFIG_ESP32_WIFI_TX_BUFFER_TYPE 1 -#define CONFIG_APP_OFFSET 0x10000 -#define CONFIG_MEMMAP_SMP 1 -#define CONFIG_SPI_FLASH_ROM_DRIVER_PATCH 1 -#define CONFIG_MONITOR_BAUD_OTHER_VAL 115200 -#define CONFIG_ESPTOOLPY_PORT "/dev/ttyUSB0" -#define CONFIG_OPTIMIZATION_LEVEL_RELEASE 1