diff --git a/driver/Makefile b/driver/Makefile index 6353eb8..c3b752a 100644 --- a/driver/Makefile +++ b/driver/Makefile @@ -3,25 +3,33 @@ # Author: Tristan Krause # Creation Date: 2019-03-22 -# Umgebungseinstellungen +# Environment COMPILER_PATH = g++ - -OUTPUT = main -CFLAGS = -std=c++14 -O3 -Wall -Wextra -LDFLAGS = -OBJECTS = main.o drv/usart.o drv/b15f.o drv/plottyfile.o drv/dot.o +# Options +OUT_MAIN = main +OBJ_MAIN = main.o +OUT_CLI = cli +OBJ_CLI = cli.o +CFLAGS = -std=c++14 -O3 -Wall -Wextra +LDFLAGS = +OBJECTS = drv/usart.o drv/b15f.o drv/plottyfile.o drv/dot.o COMPILE = $(COMPILER_PATH) $(CFLAGS) -B15F: $(OBJECTS) +main: $(OBJECTS) $(OBJ_MAIN) @echo "Linking..." - $(COMPILE) $(OBJECTS) -o $(OUTPUT) $(LDFLAGS) + $(COMPILE) $(OBJ_MAIN) $(OBJECTS) -o $(OUT_MAIN) $(LDFLAGS) + +cli: $(OBJECTS) $(OBJ_CLI) + @echo "Linking..." + $(COMPILE) $(OBJ_CLI) $(OBJECTS) -o $(OUT_CLI) $(LDFLAGS) help: @echo "This Makefile has the following rules:" - @echo "make B15F .... to compile (default)" - @echo "make clean ... to delete objects, elf and hex file" + @echo "make main .... to compile main.cpp" + @echo "make cli .... to compile Command Line Interface" + @echo "make clean ... to delete objects and executables" clean: @echo "Cleaning..." diff --git a/driver/cli b/driver/cli new file mode 100755 index 0000000..8ae139b Binary files /dev/null and b/driver/cli differ diff --git a/driver/cli.cpp b/driver/cli.cpp new file mode 100644 index 0000000..7254a58 --- /dev/null +++ b/driver/cli.cpp @@ -0,0 +1,91 @@ +#include +#include // sudo apt-get install libncurses5-dev + +#define WIDTH 30 +#define HEIGHT 10 + +int startx = 0; +int starty = 0; + +char *choices[] = { + "Choice 1", + "Choice 2", + "Choice 3", + "Choice 4", + "Exit", + }; +int n_choices = sizeof(choices) / sizeof(char *); +void print_menu(WINDOW *menu_win, int highlight); + +int main() +{ WINDOW *menu_win; + int highlight = 1; + int choice = 0; + int c; + + initscr(); + clear(); + noecho(); + cbreak(); /* Line buffering disabled. pass on everything */ + startx = (80 - WIDTH) / 2; + starty = (24 - HEIGHT) / 2; + + menu_win = newwin(HEIGHT, WIDTH, starty, startx); + keypad(menu_win, TRUE); + mvprintw(0, 0, "Use arrow keys to go up and down, Press enter to select a choice"); + refresh(); + print_menu(menu_win, highlight); + while(1) + { c = wgetch(menu_win); + switch(c) + { case KEY_UP: + if(highlight == 1) + highlight = n_choices; + else + --highlight; + break; + case KEY_DOWN: + if(highlight == n_choices) + highlight = 1; + else + ++highlight; + break; + case 10: + choice = highlight; + break; + default: + mvprintw(24, 0, "Charcter pressed is = %3d Hopefully it can be printed as '%c'", c, c); + refresh(); + break; + } + print_menu(menu_win, highlight); + if(choice != 0) /* User did a choice come out of the infinite loop */ + break; + } + mvprintw(23, 0, "You chose choice %d with choice string %s\n", choice, choices[choice - 1]); + clrtoeol(); + refresh(); + endwin(); + return 0; +} + + +void print_menu(WINDOW *menu_win, int highlight) +{ + int x, y, i; + + x = 2; + y = 2; + box(menu_win, 0, 0); + for(i = 0; i < n_choices; ++i) + { if(highlight == i + 1) /* High light the present choice */ + { wattron(menu_win, A_REVERSE); + mvwprintw(menu_win, y, x, "%s", choices[i]); + wattroff(menu_win, A_REVERSE); + } + else + mvwprintw(menu_win, y, x, "%s", choices[i]); + ++y; + } + wrefresh(menu_win); +} diff --git a/driver/gnuplotscript.gp b/driver/gnuplotscript.gp index a53b822..06749ca 100644 --- a/driver/gnuplotscript.gp +++ b/driver/gnuplotscript.gp @@ -11,9 +11,9 @@ set label at 4,7 'U_{GS} [V] = 480' left set label at 3,13 'U_{GS} [V] = 500' left set label at 2,22 'U_{GS} [V] = 520' left set label at 1,33 'U_{GS} [V] = 540' left -set label at 0,38 'U_{GS} [V] = 560' left -set label at 0,38 'U_{GS} [V] = 580' left -set label at 0,38 'U_{GS} [V] = 600' left +set label at 0,39 'U_{GS} [V] = 560' left +set label at 0,39 'U_{GS} [V] = 580' left +set label at 0,39 'U_{GS} [V] = 600' left unset output set terminal qt unset output diff --git a/driver/main.cpp b/driver/main.cpp index 4519a31..eb0c66c 100644 --- a/driver/main.cpp +++ b/driver/main.cpp @@ -1,6 +1,5 @@ #include #include -#include "drv/usart.h" #include "drv/b15f.h" #include "drv/plottyfile.h" diff --git a/driver/test_plot b/driver/test_plot index cdc226e..e71ea12 100644 Binary files a/driver/test_plot and b/driver/test_plot differ diff --git a/firmware/B15F.elf b/firmware/B15F.elf index 16170e8..d557f06 100755 Binary files a/firmware/B15F.elf and b/firmware/B15F.elf differ diff --git a/firmware/requests.cpp b/firmware/requests.cpp index 8d068ff..a44eb73 100644 --- a/firmware/requests.cpp +++ b/firmware/requests.cpp @@ -197,7 +197,6 @@ void rqAdcDacStroke() int16_t count = static_cast(usart.readInt()); count *= delta; - dio1.writePortA(0xFF); for(int16_t i = start; i < count; i += delta) { diff --git a/firmware/usart.cpp b/firmware/usart.cpp index 658a01b..d039fcf 100644 --- a/firmware/usart.cpp +++ b/firmware/usart.cpp @@ -61,7 +61,6 @@ void USART::handleRX(void) volatile void USART::handleTX(void) volatile { - dio0.writePortA(send_pos); if(send_pos < send_len) { while (!(UCSR0A & (1<