From c8b3250f15ac75d60991b3ad2562209e853cc6f4 Mon Sep 17 00:00:00 2001 From: Brett Weiland Date: Fri, 1 Jan 2021 13:12:17 -0600 Subject: new file: gradient.h new file: led_clear.c new file: led_gradient.c new file: led_info.h new file: led_test.c new file: makefile new file: push.sh new file: shit.c --- shit.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 shit.c (limited to 'shit.c') diff --git a/shit.c b/shit.c new file mode 100644 index 0000000..cca992b --- /dev/null +++ b/shit.c @@ -0,0 +1,95 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "led_info.h" +#include "gradient.h" + + +void refresh_strip(ws2811_t *ledstring, split_t *splits, unsigned int split_amount) { + unsigned int on_led = 0; + for(unsigned int i = split_amount; i < split_amount; i++) { + for(; on_led < splits[i].size; on_led++) { + ledstring->channel[0].leds[on_led] = splits[i].color; + } + } + ws2811_render(&ledstring); +} + +unsigned int find_starting_pos(split_t *split, unsigned int index) { + unsigned int position = 0; + for(int i = 0; i < position; i++) position += split[i].size; + return(position); +} + +int main() { + split_t *splits = malloc(sizeof(split_t) * 1); + memcpy(splits, 0, sizeof(split_t)); + unsigned int split_amount = 1; + + int exited = 1; + int selection_mode = 0; + int section_highlighted = 0; + char usr_chr; + unsigned int selected_split = 0; + int selection_state = 0; + int ui_selection = 0; + unsigned int i = 0; + int modification_mode = 0; + + + char *usage_msg = "Press [n] to create a new split.\nSelect your section by pressing the arrow keys, and press enter to modify.\n"; + char *newsplit_msg = "Press the arrow keys to select an option, and enter to modify.\nPress escape once done configuring.\n"; + + char *ui_segment_options[5] = {"Red", "Green", "Blue", "Subdivide", "Delete"}; + + ws2811_return_t ret; + + if ((ret = ws2811_init(&ledstring)) != WS2811_SUCCESS) { + printf("Error initilizing ws2811 strip: %s\n", ws2811_get_return_t_str(ret)); + return 1; + } + + initscr(); + cbreak(); + noecho(); + + + while(!exited) { + clear(); + wprintf("%s", usage_msg); + if (selection_mode) { + halfdelay(10); + wprintf("Segment %i selected.\nPress enter to modify.", selected_split); + } + else if (modification_mode) { + cbreak(); + wprintf("Segment %i selected.\nPress the arrow keys to navigate, and press enter on the action or value you wish to modify."); + } + else { + cbreak(); + } + refresh(); + + printw("%s", usage_msg); + if((usr_chr = getch()) != ERR) { + switch(getch()) { + } + + } + else { + // selection_mode is set, we've timed out + // TODO: test to see if were actually timed out and handle error approprietly + for(i = find_starting_pos(splits, selection); i < split[selection].size; i++) { + ledstring.channel[0].leds[i] = (selection_state ? (i % 2) : ((i+1) % 2)) ? 0xffffff : 0; //what the fuck is wrong with me + } + selection_state ? 0 : 1; + ws2811_render(&ledstring); + } + + return 0; +} -- cgit v1.2.3