potion_party_leds/main/potion_party.c

59 lines
1.3 KiB
C
Raw Normal View History

2023-09-18 20:41:46 +00:00
#include "leds.h"
2023-09-15 06:21:00 +00:00
#include "shared.h"
#include "network.h"
2023-09-18 20:41:46 +00:00
#include "server.h"
2023-09-15 06:21:00 +00:00
#include "rom/ets_sys.h"
#include <stdio.h>
#include <string.h>
2023-09-19 08:34:06 +00:00
// starts the basic subsystems we will be using
2023-09-18 20:41:46 +00:00
static
void init_esp(void) {
2023-09-19 08:34:06 +00:00
// start the networking interface
2023-09-18 20:41:46 +00:00
ESP_ERROR_CHECK(esp_netif_init());
2023-09-19 08:34:06 +00:00
// start the event loop
2023-09-18 20:41:46 +00:00
ESP_ERROR_CHECK(esp_event_loop_create_default());
}
void app_main(void) {
LOGLN("---- starting");
2023-09-15 06:21:00 +00:00
2023-09-19 08:34:06 +00:00
// start hardware subsystems
2023-09-18 20:41:46 +00:00
init_esp();
2023-09-19 08:34:06 +00:00
// startup leds and send initial state
2023-09-18 20:41:46 +00:00
leds_init();
send_leds();
2023-09-19 08:34:06 +00:00
// start wifi subsystem
2023-09-15 06:21:00 +00:00
wifi_init();
2023-09-19 08:34:06 +00:00
// configure wifi hardware to act as an access point
2023-09-15 06:21:00 +00:00
softap_init();
2023-09-19 08:34:06 +00:00
// start listening for HTTP signals
2023-09-18 20:41:46 +00:00
server_init();
2023-09-19 08:34:06 +00:00
// 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);
2023-09-15 06:21:00 +00:00
2023-09-18 20:41:46 +00:00
LOGLN("---- finished setting up");
2023-09-15 06:21:00 +00:00
}