diff --git a/firmware/fiatlux.c b/firmware/fiatlux.c index fe19578..5533fe0 100644 --- a/firmware/fiatlux.c +++ b/firmware/fiatlux.c @@ -29,14 +29,13 @@ void gpio_intr_handler(uint8_t gpio_num); void manual_switch(void); -void buttonIntTask(void *pvParameters) -{ +_Noreturn void buttonIntTask(void *pvParameters) { printf("Waiting for button press interrupt on gpio %d...\r\n", SWITCH_PIN); - QueueHandle_t *tsqueue = (QueueHandle_t *)pvParameters; + QueueHandle_t *tsqueue = (QueueHandle_t *) pvParameters; gpio_set_interrupt(SWITCH_PIN, int_type, gpio_intr_handler); uint32_t last = 0; - while(1) { + while (1) { uint32_t button_ts; xQueueReceive(*tsqueue, &button_ts, portMAX_DELAY); button_ts *= portTICK_PERIOD_MS; diff --git a/firmware/system.c b/firmware/system.c index f12b19b..d8e1fcc 100644 --- a/firmware/system.c +++ b/firmware/system.c @@ -30,7 +30,7 @@ void system_clear_config() { spiflash_erase_sector(start + i * sdk_flashchip.sector_size); } if(sysparam_create_area(start, num_sectors, true) == SYSPARAM_OK) { - sysparam_init(start, 0); + sysparam_init(start, start + 0x2000); } sysparam_init(start, start + 0x2000); sdk_system_restart(); @@ -39,13 +39,13 @@ void system_clear_config() { void system_init_config() { uint32_t base_addr = 0x00100000; uint32_t num_sectors; - sysparam_init(base_addr, 0); + sysparam_init(base_addr, base_addr + 0x2000); if(sysparam_get_info(&base_addr, &num_sectors) != SYSPARAM_OK) { syslog("Warning: WiFi config, sysparam not initialized\n"); num_sectors = 0x2000 / sdk_flashchip.sector_size; //base_addr = sdk_flashchip.chip_size - (5 + num_sectors) * sdk_flashchip.sector_size; if(sysparam_create_area(base_addr, num_sectors, true) == SYSPARAM_OK) { - sysparam_init(base_addr, 0); + sysparam_init(base_addr, base_addr + 0x2000); } sdk_system_restart(); } diff --git a/firmware/web.cpp b/firmware/web.cpp index 82e7789..24149cf 100644 --- a/firmware/web.cpp +++ b/firmware/web.cpp @@ -325,6 +325,30 @@ void websocket_cb(struct tcp_pcb *pcb, char *data, u16_t data_len, } cmd = 'C'; break; + case 'T': { + auto A = *(int32_t *) &data[4]; + auto B = *(int32_t *) &data[8]; + auto C = *(int32_t *) &data[12]; + auto D = *(int32_t *) &data[16]; + /*sysparam_set_int32("noctis_A", A); + sysparam_set_int32("noctis_B", B); + sysparam_set_int32("noctis_C", C); + sysparam_set_int32("noctis_D", D);*/ + } + cmd = 'T'; + break; + case 'N': { + if(data[1] == 'W') + printf("WS2812\n"); + else if(data[1] == 'A') + printf("APA103C\n"); + else if(data[1] == 'Z') + printf("APA103C-Z\n"); + auto num_leds = *(uint16_t *) &data[2]; + /*sysparam_set_int32("noctis_leds", num_leds);*/ + } + cmd = 'N'; + break; case 'S': { if(data[1] == 'E') en = 1; diff --git a/firmware/webdir/css/style.css b/firmware/webdir/css/style.css index c84c3d9..3a452de 100644 --- a/firmware/webdir/css/style.css +++ b/firmware/webdir/css/style.css @@ -10,7 +10,7 @@ canvas { width: 100%; } -main section:target ~ section, main section#io, main section#wifi, main section#ota { +main section:target ~ section, main section#io, main section#wifi, main section#noctis, main section#ota { display: none; } diff --git a/firmware/webdir/index.html b/firmware/webdir/index.html index 41d3897..5528358 100644 --- a/firmware/webdir/index.html +++ b/firmware/webdir/index.html @@ -18,6 +18,7 @@ @@ -131,6 +132,61 @@ +
+

Time

+
+
+

Times

+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+

Output

+
+
+
+ + +
+
+ + + + +
+
+ + +
+
+
+

Wifi Settings

@@ -502,6 +558,42 @@ wsWrite(buffer); } + var sunrise_start = document.getElementById("sunrise_start"); + var sunrise_end = document.getElementById("sunrise_end"); + var sunrise_shutdown = document.getElementById("sunrise_shutdown"); + var sunset_time = document.getElementById("sunset_time"); + + var noctisnumber = document.getElementById("noctisnumber"); + var noctismode = document.getElementById("noctismode"); + + function noctis_times() { + const buffer = new ArrayBuffer(20); + const view1 = new DataView(buffer); + var tx_len = 0; + view1.setChar(tx_len, 'T'); + tx_len += 4; + view1.setUint32(tx_len, sunrise_start.valueAsNumber); + tx_len += 4; + view1.setUint32(tx_len, sunrise_end.valueAsNumber); + tx_len += 4; + view1.setUint32(tx_len, sunrise_shutdown.valueAsNumber); + tx_len += 4; + view1.setUint32(tx_len, sunset_time.valueAsNumber); + tx_len += 4; + wsWrite(buffer); + } + + function noctis_output() { + const buffer = new ArrayBuffer(4); + const view1 = new DataView(buffer); + var tx_len = 0; + view1.setChar(tx_len++, 'N'); + view1.setChar(tx_len++, noctismode.value); + view1.setUint16(tx_len, noctisnumber.valueAsNumber); + tx_len += 2; + wsWrite(buffer); + } + var makeCRCTable = function () { var c; var crcTable = []; diff --git a/firmware/webdir/index.htmll b/firmware/webdir/index.htmll deleted file mode 100644 index 6599b06..0000000 --- a/firmware/webdir/index.htmll +++ /dev/null @@ -1 +0,0 @@ - fiatlux v0.2

System

Firmware Update

Restart

Reset Config

I/O

Protocols

Station Mode current connection

Wifi Settings

AP Mode

AP IP N/A
AP MAC N/A

Station Mode current connection

Sation IP N/A
Station MAC N/A

Status

System

Chip ID N/A
Hostname N/A
Firmware Version N/A
Flash ID N/A
Flash size N/A KiB
Free heap N/A bytes
Uptime N/A s

Network current connection

Mode N/A
Station SSID N/A
Station IP N/A
Station MAC N/A
AP SSID N/A
AP IP N/A
AP MAC N/A

Power

Input 5V12V
Output 11.2V

I/O

\ No newline at end of file