This commit is contained in:
j3d1 2021-11-18 00:09:40 +01:00
parent 084161eba9
commit 875b3a8999
6 changed files with 123 additions and 9 deletions

View file

@ -29,14 +29,13 @@ void gpio_intr_handler(uint8_t gpio_num);
void manual_switch(void); 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); 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); gpio_set_interrupt(SWITCH_PIN, int_type, gpio_intr_handler);
uint32_t last = 0; uint32_t last = 0;
while(1) { while (1) {
uint32_t button_ts; uint32_t button_ts;
xQueueReceive(*tsqueue, &button_ts, portMAX_DELAY); xQueueReceive(*tsqueue, &button_ts, portMAX_DELAY);
button_ts *= portTICK_PERIOD_MS; button_ts *= portTICK_PERIOD_MS;

View file

@ -30,7 +30,7 @@ void system_clear_config() {
spiflash_erase_sector(start + i * sdk_flashchip.sector_size); spiflash_erase_sector(start + i * sdk_flashchip.sector_size);
} }
if(sysparam_create_area(start, num_sectors, true) == SYSPARAM_OK) { if(sysparam_create_area(start, num_sectors, true) == SYSPARAM_OK) {
sysparam_init(start, 0); sysparam_init(start, start + 0x2000);
} }
sysparam_init(start, start + 0x2000); sysparam_init(start, start + 0x2000);
sdk_system_restart(); sdk_system_restart();
@ -39,13 +39,13 @@ void system_clear_config() {
void system_init_config() { void system_init_config() {
uint32_t base_addr = 0x00100000; uint32_t base_addr = 0x00100000;
uint32_t num_sectors; 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) { if(sysparam_get_info(&base_addr, &num_sectors) != SYSPARAM_OK) {
syslog("Warning: WiFi config, sysparam not initialized\n"); syslog("Warning: WiFi config, sysparam not initialized\n");
num_sectors = 0x2000 / sdk_flashchip.sector_size; num_sectors = 0x2000 / sdk_flashchip.sector_size;
//base_addr = sdk_flashchip.chip_size - (5 + num_sectors) * 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) { 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(); sdk_system_restart();
} }

View file

@ -325,6 +325,30 @@ void websocket_cb(struct tcp_pcb *pcb, char *data, u16_t data_len,
} }
cmd = 'C'; cmd = 'C';
break; 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': { case 'S': {
if(data[1] == 'E') if(data[1] == 'E')
en = 1; en = 1;

View file

@ -10,7 +10,7 @@ canvas {
width: 100%; 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; display: none;
} }

View file

@ -18,6 +18,7 @@
<div class="menu"> <div class="menu">
<a href="/#" class="button icon-picture">Dashboard</a> <a href="/#" class="button icon-picture">Dashboard</a>
<a href="/#io" class="button icon-puzzle">I/O</a> <a href="/#io" class="button icon-puzzle">I/O</a>
<a href="/#noctis" class="button icon-puzzle">Time</a>
<a href="/#wifi" class="button icon-puzzle">Wifi Settings</a> <a href="/#wifi" class="button icon-puzzle">Wifi Settings</a>
<a href="/#ota" class="button icon-picture">System</a> <a href="/#ota" class="button icon-picture">System</a>
</div> </div>
@ -131,6 +132,61 @@
</div> </div>
</article> </article>
</section> </section>
<section id="noctis">
<h2>Time</h2>
<article class="card">
<header>
<h3>Times</h3>
</header>
<div class="table">
<div class="row">
<label>Sunrise Start</label>
<span><input type="time" class="plain" id="sunrise_start" value="07:30"/></span>
</div>
<div class="row">
<label>Sunrise End</label>
<span><input type="time" class="plain" id="sunrise_end" value="08:00"/></span>
</div>
<div class="row">
<label>Sunrise Limit</label>
<span><input type="time" class="plain" id="sunrise_shutdown" value="09:00"/></span>
</div>
<div class="row">
<label>Sunset</label>
<span><input type="time" class="plain" id="sunset_time" value="22:00"/></span>
</div>
<div class="row">
<span><input type="reset" class="button"/></span>
<span><input onclick="noctis_times();" type="submit" value="Save"></span>
</div>
</div>
</article>
<article class="card">
<header>
<h3>Output</h3>
</header>
<div class="table">
<div class="row">
<label>Leds</label>
<span><input type="number" min="0" step="1" class="plain" id="noctisnumber"/></span>
</div>
<div class="row">
<label>Mode</label>
<span>
<select id="noctismode">
<option value="W">WS2812</option>
<option value="A">APA102C</option>
<option value="Z">APA102C-Z</option>
</select>
</span>
</div>
<div class="row">
<span><input type="reset" class="button"/></span>
<span><input onclick="noctis_output();" type="submit" value="Save"></span>
</div>
</div>
</article>
</section>
<section id="wifi"> <section id="wifi">
<h2>Wifi Settings</h2> <h2>Wifi Settings</h2>
<article class="card"> <article class="card">
@ -502,6 +558,42 @@
wsWrite(buffer); 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 makeCRCTable = function () {
var c; var c;
var crcTable = []; var crcTable = [];

File diff suppressed because one or more lines are too long