Documentation
parent
9aa8af017f
commit
632bfbe61e
|
@ -1,3 +1,9 @@
|
|||
///
|
||||
//
|
||||
// leds.h defines structs and functions for addressing an HD107s ledstrip over serial using the GPIO pins.
|
||||
//
|
||||
///
|
||||
|
||||
#ifndef _potion_leds_h
|
||||
#define _potion_leds_h
|
||||
|
||||
|
@ -58,7 +64,7 @@ void send_leds() {
|
|||
gpio_set_level(DATA, write_next);
|
||||
|
||||
os_delay_us(10);
|
||||
// set clock to low, triggering a falling edge
|
||||
// set clock to low, triggering a falling edge, flushing the LEDs shift registers
|
||||
gpio_set_level(CLOCK, 0);
|
||||
os_delay_us(10);
|
||||
|
||||
|
@ -112,6 +118,7 @@ void lerp_points_between(const struct gradient_point_t from, const struct gradie
|
|||
for(int led = from.offset; led < to.offset; ++led) {
|
||||
t = (float)(led - from.offset) / (float)dif;
|
||||
lerp_led(g_leds + led, &from.led, &to.led, t);
|
||||
LOGLN("%f", t);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
///
|
||||
//
|
||||
// server.h manages the WiFi access point created for the quests.
|
||||
// wifi_init() and softap_init() HAVE TO be called in order.
|
||||
//
|
||||
///
|
||||
|
||||
#ifndef _server_h
|
||||
#define _server_h
|
||||
|
||||
|
|
|
@ -7,24 +7,51 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
// starts the basic subsystems we will be using
|
||||
static
|
||||
void init_esp(void) {
|
||||
// start the networking interface
|
||||
ESP_ERROR_CHECK(esp_netif_init());
|
||||
// start the event loop
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
}
|
||||
|
||||
void app_main(void) {
|
||||
LOGLN("---- starting");
|
||||
|
||||
// start hardware subsystems
|
||||
init_esp();
|
||||
// startup leds and send initial state
|
||||
leds_init();
|
||||
send_leds();
|
||||
// start wifi subsystem
|
||||
wifi_init();
|
||||
// configure wifi hardware to act as an access point
|
||||
softap_init();
|
||||
// start listening for HTTP signals
|
||||
server_init();
|
||||
|
||||
os_delay_us(10000);
|
||||
send_leds();
|
||||
// TEST: after a delay, set the leds to a gradient of red - black
|
||||
os_delay_us(1000);
|
||||
|
||||
struct gradient_point_t points[2];
|
||||
points[0].offset = 0;
|
||||
points[0].led.components = (struct led_components_t) {
|
||||
.global = 0xE | 10,
|
||||
.red = 255,
|
||||
.green = 10,
|
||||
.blue = 10,
|
||||
};
|
||||
|
||||
points[1].offset = 60;
|
||||
points[1].led.components = (struct led_components_t){
|
||||
.global = 0xE0,
|
||||
.red = 0,
|
||||
.green = 0,
|
||||
.blue = 0,
|
||||
};
|
||||
|
||||
leds_set_gradient(points, 2);
|
||||
|
||||
LOGLN("---- finished setting up");
|
||||
}
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
///
|
||||
//
|
||||
// server.h
|
||||
// Call server_init() to start up an http webserver.
|
||||
// listens on '/' for POST queries with a url query format like
|
||||
// ?l=*&r0=*&g0=*&b0=*&a0=*&t0=* ... &rl=*&gl=*&bl=*&al=*&tl=*
|
||||
// Where l is the number of points on a gradient. And each point of the gradient has a r* g* b* a* and t* where * is the index.
|
||||
// r g and b are the red green and blue 8-bit colour components of a point on the gradient. A is the 5-bit global component of the led at that point.
|
||||
// t is the offset from the start measured in leds.
|
||||
//
|
||||
///
|
||||
|
||||
#ifndef _potion_party_server_h
|
||||
#define _potion_party_server_h
|
||||
|
||||
|
@ -13,6 +25,7 @@
|
|||
static
|
||||
httpd_handle_t g_http_server = NULL;
|
||||
|
||||
// Parse a gradient query
|
||||
static
|
||||
void parse_leds_query(char* query_string, size_t query_size) {
|
||||
char query_value[16];
|
||||
|
@ -61,6 +74,7 @@ void parse_leds_query(char* query_string, size_t query_size) {
|
|||
leds_set_gradient(points, gradient_point_count);
|
||||
}
|
||||
|
||||
// receives HTTP POST requests on root
|
||||
static
|
||||
esp_err_t on_http_post(httpd_req_t* request) {
|
||||
LOGLN("POST received on '/'.");
|
||||
|
@ -83,7 +97,6 @@ esp_err_t on_http_post(httpd_req_t* request) {
|
|||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
httpd_uri_t post = {
|
||||
.uri="/",
|
||||
.method=HTTP_POST,
|
||||
|
@ -91,6 +104,7 @@ httpd_uri_t post = {
|
|||
.user_ctx = NULL
|
||||
};
|
||||
|
||||
// Configure and enable the http server.
|
||||
static
|
||||
httpd_handle_t start_webserver(void) {
|
||||
httpd_handle_t server = NULL;
|
||||
|
@ -106,6 +120,7 @@ httpd_handle_t start_webserver(void) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// Start an http server and store it's handle in g_http_server.
|
||||
static
|
||||
void server_init(void) {
|
||||
g_http_server = start_webserver();
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
///
|
||||
//
|
||||
// shared.h contains some shared settings and functionality
|
||||
//
|
||||
///
|
||||
|
||||
#ifndef _shared_h
|
||||
#define _shared_h
|
||||
|
||||
|
@ -6,12 +12,13 @@
|
|||
#include <esp_wifi.h>
|
||||
#include "esp_system.h"
|
||||
|
||||
// wifi configuration
|
||||
#define SSID "ESP8266"
|
||||
#define PASSW "XR-Lab2023"
|
||||
#define WIFI_CONFIG
|
||||
|
||||
static const char* APP_TAG="CINEKID_LEDS";
|
||||
|
||||
// print a line with the app tag as a prefix to easilly separate our own logging from system logging
|
||||
#define LOGLN(...) do {\
|
||||
printf("%s | ", APP_TAG);\
|
||||
printf(__VA_ARGS__);\
|
||||
|
|
12
sdkconfig
12
sdkconfig
|
@ -61,14 +61,14 @@ CONFIG_ESPTOOLPY_AFTER_HARD_RESET=y
|
|||
CONFIG_ESPTOOLPY_AFTER="hard_reset"
|
||||
# CONFIG_ESPTOOLPY_MONITOR_BAUD_9600B is not set
|
||||
# CONFIG_ESPTOOLPY_MONITOR_BAUD_57600B is not set
|
||||
CONFIG_ESPTOOLPY_MONITOR_BAUD_74880B=y
|
||||
# CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B is not set
|
||||
# CONFIG_ESPTOOLPY_MONITOR_BAUD_74880B is not set
|
||||
CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y
|
||||
# CONFIG_ESPTOOLPY_MONITOR_BAUD_230400B is not set
|
||||
# CONFIG_ESPTOOLPY_MONITOR_BAUD_921600B is not set
|
||||
# CONFIG_ESPTOOLPY_MONITOR_BAUD_2MB is not set
|
||||
# CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER is not set
|
||||
CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER_VAL=74880
|
||||
CONFIG_ESPTOOLPY_MONITOR_BAUD=74880
|
||||
CONFIG_ESPTOOLPY_MONITOR_BAUD=115200
|
||||
CONFIG_PARTITION_TABLE_SINGLE_APP=y
|
||||
# CONFIG_PARTITION_TABLE_TWO_OTA is not set
|
||||
# CONFIG_PARTITION_TABLE_CUSTOM is not set
|
||||
|
@ -452,14 +452,14 @@ CONFIG_FLASHMODE_QIO=y
|
|||
# CONFIG_FLASHMODE_DOUT is not set
|
||||
# CONFIG_MONITOR_BAUD_9600B is not set
|
||||
# CONFIG_MONITOR_BAUD_57600B is not set
|
||||
CONFIG_MONITOR_BAUD_74880B=y
|
||||
# CONFIG_MONITOR_BAUD_115200B is not set
|
||||
# CONFIG_MONITOR_BAUD_74880B is not set
|
||||
CONFIG_MONITOR_BAUD_115200B=y
|
||||
# CONFIG_MONITOR_BAUD_230400B is not set
|
||||
# CONFIG_MONITOR_BAUD_921600B is not set
|
||||
# CONFIG_MONITOR_BAUD_2MB is not set
|
||||
# CONFIG_MONITOR_BAUD_OTHER is not set
|
||||
CONFIG_MONITOR_BAUD_OTHER_VAL=74880
|
||||
CONFIG_MONITOR_BAUD=74880
|
||||
CONFIG_MONITOR_BAUD=115200
|
||||
CONFIG_OPTIMIZATION_LEVEL_DEBUG=y
|
||||
# CONFIG_OPTIMIZATION_LEVEL_RELEASE is not set
|
||||
CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y
|
||||
|
|
|
@ -9,7 +9,7 @@ CONFIG_IDF_TARGET="esp8266"
|
|||
# SDK tool configuration
|
||||
#
|
||||
CONFIG_SDK_TOOLPREFIX="xtensa-lx106-elf-"
|
||||
CONFIG_SDK_PYTHON="python"
|
||||
CONFIG_SDK_PYTHON="python2"
|
||||
# CONFIG_SDK_MAKE_WARN_UNDEFINED_VARIABLES is not set
|
||||
CONFIG_BOOTLOADER_INIT_SPI_FLASH=y
|
||||
# CONFIG_BOOTLOADER_DISABLE_JTAG_IO is not set
|
||||
|
|
Loading…
Reference in New Issue