MicroHs-0.9.8.0: src/runtime/config-esp32.h
/*
* Various platform specific configuration.
*/
/*
* Include stdio functions.
* Without this none of the file I/O in System.IO is available.
*/
#define WANT_STDIO 0
/*
* Include ops for floating point arithmetic.
* Without this +,-,* etc will not be available for the Double type.
*/
#define WANT_FLOAT 1
/*
* Include <math.h>
* Without this, exp,sin, etc are not available.
*/
#define WANT_MATH 0
/*
* Include MD5 checksumming code
*/
#define WANT_MD5 0
/*
* Include profiling code
*/
#define WANT_TICK 0
/*
* Process argc, argv
*/
#define WANT_ARGS 0
/*
* Number of bits in a word. Only 32 and 64 are supported.
*/
//#define WORD_SIZE 32
/*
* Find First Set
* This macro must be defined.
* It return the number of the least significant bit that is set.
* Numberings starts from 1. If no bit is set, it should return 0.
*/
// #define FFS
/*
* This is the character used for comma-separation in printf.
* Defaults to "'".
*/
/* #define PCOMMA "'" */
/*
* Get a raw input character.
* If undefined, the default always returns -1
*/
/* #define GETRAW */
/*
* Get time since some epoch in milliseconds.
*/
/* #define GETTIMEMILLI */
/*
* The ERR macro should report an error and exit.
* If not defined, a generic one will be used.
*/
/* #define ERR(s) */
/* #define ERR1(s,a) */
#define GCRED 0 /* do some reductions during GC */
#define FASTTAGS 1 /* compute tag by pointer subtraction */
#define INTTABLE 1 /* use fixed table of small INT nodes */
#define SANITY 1 /* do some sanity checks */
#define STACKOVL 1 /* check for stack overflow */
#define HEAP_CELLS 4000
#define STACK_SIZE 500
#define MAIN void app_main(void)
#define INITIALIZATION
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "esp_log.h"
#include "led_strip.h"
#include "sdkconfig.h"
#define BLINK_GPIO CONFIG_BLINK_GPIO
static led_strip_handle_t led_strip;
void led_strip_set_pixel(led_strip_handle_t, int, int, int, int);
#if 0
static void blink_led(void)
{
#if 1
static int state = 0;
static int br = 16;
switch (state) {
case 0:
led_strip_set_pixel(led_strip, 0, br, 16-br, 0);
br--;
if (br == 0) { br = 16; state++; }
break;
case 1:
led_strip_set_pixel(led_strip, 0, 0, br, 16-br);
br--;
if (br == 0) { br = 16; state++; }
break;
case 2:
led_strip_set_pixel(led_strip, 0, 16-br, 0, br);
br--;
if (br == 0) { br = 16; state = 0; }
break;
}
led_strip_refresh(led_strip);
#else
/* If the addressable LED is enabled */
if (s_led_state) {
/* Set the LED pixel using RGB from 0 (0%) to 255 (100%) for each color */
led_strip_set_pixel(led_strip, 0, 16, 16, 16);
/* Refresh the strip to send data */
led_strip_refresh(led_strip);
} else {
/* Set all LED off to clear all pixels */
led_strip_clear(led_strip);
}
#endif
}
#endif
void
main_setup(void)
{
ESP_LOGI(TAG, "Example configured to blink addressable LED!");
/* LED strip initialization with the GPIO and pixels number*/
led_strip_config_t strip_config = {
.strip_gpio_num = BLINK_GPIO,
.max_leds = 1, // at least one LED on board
};
#if CONFIG_BLINK_LED_STRIP_BACKEND_RMT
led_strip_rmt_config_t rmt_config = {
.resolution_hz = 10 * 1000 * 1000, // 10MHz
.flags.with_dma = false,
};
ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip));
#elif CONFIG_BLINK_LED_STRIP_BACKEND_SPI
led_strip_spi_config_t spi_config = {
.spi_bus = SPI2_HOST,
.flags.with_dma = true,
};
ESP_ERROR_CHECK(led_strip_new_spi_device(&strip_config, &spi_config, &led_strip));
#else
#error "unsupported LED strip backend"
#endif
/* Set all LED off to clear all pixels */
led_strip_clear(led_strip);
}
void delay(int t)
{
vTaskDelay(t / portTICK_PERIOD_MS);
}