forked from j3d1/fiatlux
add toogle button for signal led in http frontend
This commit is contained in:
parent
006d281ad6
commit
8c775e9705
3 changed files with 24 additions and 1 deletions
|
@ -109,6 +109,19 @@
|
|||
<canvas id="chartCanvas" style="height:100px"></canvas>
|
||||
</article>
|
||||
</div>
|
||||
<div>
|
||||
<article class="card">
|
||||
<header>
|
||||
<h3>I/O</h3>
|
||||
</header>
|
||||
<footer>
|
||||
<label>
|
||||
<input type="checkbox" name="onoffswitch" id="led-switch" onclick="gpio()">
|
||||
<span class="toggle button">toggle signal led</span>
|
||||
</label>
|
||||
</footer>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
|
|
@ -17,7 +17,7 @@ const int gpio4 = 4;
|
|||
const int gpio5 = 5;
|
||||
|
||||
extern "C" void signal_led(bool state) {
|
||||
gpio_write(signal_led_pin, state);
|
||||
gpio_write(signal_led_pin, !state);
|
||||
}
|
||||
|
||||
extern "C" void lux_task(void *pvParameters) {
|
||||
|
|
|
@ -226,6 +226,16 @@ void websocket_cb(struct tcp_pcb *pcb, char *data, u16_t data_len, uint8_t mode)
|
|||
char cmd = '0';
|
||||
|
||||
switch (data[0]) {
|
||||
case 'D': // Disable LED
|
||||
signal_led(false);
|
||||
val = 1;
|
||||
cmd = 'G';
|
||||
break;
|
||||
case 'E': // Enable LED
|
||||
signal_led(true);
|
||||
val = 0;
|
||||
cmd = 'G';
|
||||
break;
|
||||
default:
|
||||
printf("[websocket_callback]:\n%.*s\n", (int) data_len, (char *) data);
|
||||
printf("Unknown command\n");
|
||||
|
|
Loading…
Reference in a new issue