Commit 941904bc authored by plyoung's avatar plyoung
Browse files
parents 0826021e 92cb1b8b
No preview for this file type
......@@ -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) {}
}
......@@ -37,11 +37,16 @@ void display_completed();
void show_options();
void draw_arrow(uint8_t x1, uint8_t y1, uint8_t draw_erase);
void update_selection(uint8_t num);
void update_selection();
void init_tabs(uint8_t sel);
void toggle_view(uint8_t state);
void display_mouse_path();
void show_error();
void delay();
void init_tabs();
void toggle_view();
void delay(uint32_t count);
#endif
......@@ -2,6 +2,11 @@
#include "drivers/mss_gpio/mss_gpio.h"
#include "drivers/CoreUARTapb/core_uart_apb.h"
extern uint8_t arrow_pos;
extern uint8_t tab_state;
extern uint8_t is_selecting;
extern uint8_t mouse_map[160][110];
/*
uint8_t total_progress = 0;
......@@ -23,9 +28,9 @@ void __FINISHED_INTERRUPT_HANDLER__() {
uint8_t arrow_pos = 0;
uint8_t tab_state = 0;
int progress=0;
uint8_t g_rx_buff[2];
int temp=0;
uint8_t g_rx_buff[6];
//clock/baudrate/16-1
#define BAUD_VALUE_115200 53
#define COREUARTAPB0_BASE_ADDR 0x40050000
......@@ -34,55 +39,78 @@ uint8_t tab_state = 0;
void __attribute__ ((interrupt)) GPIO0_IRQHandler( void )
{
//UART_send(&g_uart,"B1\r\n",sizeof("B1\r\n"));
arrow_pos = (arrow_pos == 2) ? 2 : arrow_pos+1;
update_selection(arrow_pos);
delay();
MSS_GPIO_clear_irq( MSS_GPIO_0 ); //clear interrupt and resume
if (is_selecting) {
arrow_pos = (arrow_pos == 0) ? 0 : arrow_pos-1;
update_selection(arrow_pos);
}
delay(3000000);
MSS_GPIO_clear_irq( MSS_GPIO_0 ); //clear interrupt and resume
}
void __attribute__ ((interrupt)) GPIO1_IRQHandler( void )
{
//UART_send(&g_uart,"B2\r\n",sizeof("B2\r\n"));
delay();
delay(3000000);
MSS_GPIO_clear_irq( MSS_GPIO_1 ); //clear interrupt and resume
}
void __attribute__ ((interrupt)) GPIO2_IRQHandler( void )
{
//UART_send(&g_uart,"B3\r\n",sizeof("B3\r\n"));
//PICK DESIGN AND GO TO LOADING SCREEN
display_inprogress();
delay();
if (is_selecting) {
//PICK DESIGN AND GO TO LOADING SCREEN
is_selecting = 0;
init_tabs();
display_inprogress();
} else {
tab_state = (tab_state == 0) ? 1 : 0;
toggle_view();
}
delay(3000000);
MSS_GPIO_clear_irq( MSS_GPIO_2 ); //clear interrupt and resume
}
void __attribute__ ((interrupt)) GPIO3_IRQHandler( void )
{
//UART_send(&g_uart,"B4\r\n",sizeof("B4\r\n"));
arrow_pos = (arrow_pos == 0) ? 0 : arrow_pos-1;
update_selection(arrow_pos);
delay();
if (is_selecting) {
arrow_pos = (arrow_pos == 2) ? 2 : arrow_pos+1;
update_selection(arrow_pos);
}
delay(3000000);
MSS_GPIO_clear_irq( MSS_GPIO_3 ); //clear interrupt and resume
}
void __attribute__ ((interrupt)) GPIO4_IRQHandler( void )
{
//UART_send(&g_uart,"B5\r\n",sizeof("B5\r\n"));
tab_state = (tab_state == 0) ? 1 : 0;
toggle_view(tab_state);
delay();
delay(3000000);
MSS_GPIO_clear_irq( MSS_GPIO_4 ); //clear interrupt and resume
}
void uart1_rx_handler( mss_uart_instance_t * this_uart )
{
int i=0;
for(i=0;i<100000;++i);
for(i=0;i<500000;++i);
MSS_UART_get_rx( this_uart, g_rx_buff, sizeof(g_rx_buff) );
erase_block( BARSTART_X, BARSTART_Y, BARSTART_X+100,BAREND_Y);
if(atoi(g_rx_buff[0])<100)
fill(BARSTART_X, BARSTART_X+atoi(g_rx_buff[0]));
else if(atoi(g_rx_buff[0])>=100){
fill(BARSTART_X, BARSTART_X+100);
display_completed();
progress=g_rx_buff[0];
temp=g_rx_buff[1];
if(tab_state==0){
MSS_UART_get_rx( this_uart, g_rx_buff, sizeof(g_rx_buff) );
erase_block( BARSTART_X, BARSTART_Y, BARSTART_X+100,BAREND_Y);
if(atoi(g_rx_buff[0])<100)
fill(BARSTART_X, BARSTART_X+atoi(g_rx_buff[0]));
else if(atoi(g_rx_buff[0])>=100){
fill(BARSTART_X, BARSTART_X+100);
display_completed();
}
write_temp(g_rx_buff[1]);
}
write_temp(g_rx_buff[1]);
signed char odox=g_rx_buff[2];
signed char odoy=g_rx_buff[3];
signed char mousex=g_rx_buff[4];
signed char mousey=g_rx_buff[5];
}
void initInterrupts(){
......@@ -110,9 +138,10 @@ int main() {
/*
uint8_t i = 1;
display_inprogress();
*/
MSS_UART_set_rx_handler( &g_mss_uart1, uart1_rx_handler, MSS_UART_FIFO_SINGLE_BYTE );
UART_init(&g_uart,COREUARTAPB0_BASE_ADDR,BAUD_VALUE_115200,(DATA_8_BITS|NO_PARITY));
*/
init_tabs(0);
while(1){}
......
No preview for this file type
Supports Markdown
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