Commit 0581f5dd authored by liubryan's avatar liubryan
Browse files

Serial_Backpack_LCD.c - update third design, toggling tabs

parent 96b8fbd8
......@@ -2,6 +2,11 @@
#include <inttypes.h>
#include "Serial_Backpack_LCD.h"
uint8_t arrow_pos = 0;
uint8_t tab_state = 0;
uint8_t is_selecting = 1;
uint8_t mouse_map[160][110] = {{0,0},{0,0}};
void clear_screen() {
uint8_t tx_buf[2] = {CONTROL, 0x00};
MSS_UART_polled_tx(&g_mss_uart1, tx_buf, sizeof(tx_buf));
......@@ -92,6 +97,7 @@ void display_completed() {
int numToAscii(int num){
return num+48;
}
void write_temp(int temp){
uint8_t tx_buff[9];
tx_buff[0]='T';
......@@ -112,15 +118,37 @@ void fill(uint8_t start, uint8_t end) {
draw_erase_shape(LINE, start, BARSTART_Y, start, BAREND_Y, 1);
}
}
void show_options() {
uint8_t tx_buf[] = "Pick a Design...";
set_coordinates(30, 110);
MSS_UART_polled_tx(&g_mss_uart1, tx_buf, sizeof(tx_buf)-1);
//draw cube
draw_erase_shape(BOX, 10, 40, 40, 70, 1);
draw_erase_shape(BOX, 18, 48, 48, 78, 1);
draw_erase_shape(LINE, 10, 40, 18, 48, 1);
draw_erase_shape(LINE, 40, 70, 48, 78, 1);
delay(10000000);
uint8_t i = 10;
for (; i < 41 ; ++i) {
draw_erase_shape(LINE, i, 40, i, 70, 1);
}
for (i = 18 ; i < 49 ; ++i) {
draw_erase_shape(LINE, i, 48, i, 78, 1);
}
delay(10000000);
draw_erase_shape(BOX, 10, 40, 40, 70, 0);
draw_erase_shape(BOX, 20, 48, 48, 78, 0);
draw_erase_shape(LINE, 10, 40, 10, 70, 0);
draw_erase_shape(LINE, 10, 40, 40, 40, 0);
draw_erase_shape(LINE, 10, 70, 40, 70, 0);
draw_erase_shape(LINE, 40, 40, 40, 70, 0);
draw_erase_shape(LINE, 20, 48, 20, 78, 0);
draw_erase_shape(LINE, 20, 48, 48, 48, 0);
draw_erase_shape(LINE, 20, 78, 48, 78, 0);
draw_erase_shape(LINE, 48, 48, 48, 78, 0);
draw_erase_shape(LINE, 10, 40, 18, 48, 0);
draw_erase_shape(LINE, 40, 70, 48, 78, 0);
draw_erase_shape(LINE, 40, 40, 48, 48, 1);
draw_erase_shape(LINE, 10, 70, 18, 78, 1);
......@@ -129,7 +157,13 @@ void show_options() {
draw_erase_shape(LINE, 79, 44, 79, 74, 1);
draw_erase_shape(LINE, 80, 44, 80, 74, 1);
//draw ?????
//draw square path, to show errors in odometry
draw_erase_shape(BOX, 112, 40, 142, 70, 1);
draw_erase_shape(BOX, 120, 48, 150, 78, 1);
draw_erase_shape(LINE, 112, 40, 120, 48, 1);
draw_erase_shape(LINE, 142, 70, 150, 78, 1);
draw_erase_shape(LINE, 142, 40, 150, 48, 1);
draw_erase_shape(LINE, 112, 70, 120, 78, 1);
draw_arrow(DESIGN1_X, DESIGN_Y, 1);
}
......@@ -140,12 +174,12 @@ void draw_arrow(uint8_t x1, uint8_t y1, uint8_t draw_erase) {
draw_erase_shape(LINE, x1, y1, x1+7, y1-7, draw_erase);
}
void update_selection(uint8_t num) {
if (num == 0) {
void update_selection() {
if (arrow_pos == 0) {
draw_arrow(DESIGN2_X, DESIGN_Y, 0);
draw_arrow(DESIGN1_X, DESIGN_Y, 1);
}
else if (num == 1) {
else if (arrow_pos == 1) {
draw_arrow(DESIGN1_X, DESIGN_Y, 0);
draw_arrow(DESIGN3_X, DESIGN_Y, 0);
draw_arrow(DESIGN2_X, DESIGN_Y, 1);
......@@ -156,7 +190,8 @@ void update_selection(uint8_t num) {
}
}
void init_tabs(uint8_t sel) {
void init_tabs() {
clear_screen();
draw_erase_shape(LINE, 0, 112, 159, 112, 1);
draw_erase_shape(LINE, 45, 116, 45, 125, 1);
draw_erase_shape(LINE, 90, 116, 90, 125, 1);
......@@ -169,24 +204,46 @@ void init_tabs(uint8_t sel) {
set_coordinates(129, 124);
uint8_t tx_buf3[] = "TBKPW";
MSS_UART_polled_tx(&g_mss_uart1, tx_buf3, sizeof(tx_buf3)-1);
if (sel == 0) {
if (tab_state == 0) {
draw_erase_shape(BOX, 0, 114, 43, 127, 1);
} else {
draw_erase_shape(BOX, 47, 114, 88, 127, 1);
}
}
void toggle_view(uint8_t state) {
clear_screen();
init_tabs(state);
if (state == 0) {
void toggle_view() {
init_tabs();
if (tab_state == 0) {
display_inprogress();
} else {
} else if (tab_state == 1) {
show_error();
}
}
void display_mouse_path() {
int i = 0, j = 0;
for (; i < 160 ; ++i) {
for (; j < 110 ; ++j) {
delay(100000);
set_reset_pixel(i, j, mouse_map[i][j]);
}
}
}
void show_error() {
display_mouse_path();
if (arrow_pos == 0) {
//do nothing
} else if (arrow_pos == 1) {
draw_erase_shape(BOX, 65, 40, 95, 70, 1);
}
else if (arrow_pos == 2) {
draw_erase_shape(BOX, 50, 25, 110, 85, 1);
}
}
void delay() {
void delay(uint32_t count) {
uint32_t i = 0;
for (; i < 2000000 ; ++i) {}
for (; i < count ; ++i) {}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment