Commit fb6d782d authored by liubryan's avatar liubryan
Browse files

Update main.c

parent 2f4d90a3
......@@ -6,6 +6,7 @@ extern uint8_t arrow_pos;
extern uint8_t tab_state;
extern uint8_t is_selecting;
extern uint8_t mouse_map[160][110];
extern uint8_t map_resolution;
/*
uint8_t total_progress = 0;
......@@ -88,6 +89,7 @@ void __FINISHED_INTERRUPT_HANDLER__() {
MSS_GPIO_clear_irq( MSS_GPIO_4 ); //clear interrupt and resume
}
void uart1_rx_handler( mss_uart_instance_t * this_uart )
{
int i=0;
......@@ -95,6 +97,10 @@ void __FINISHED_INTERRUPT_HANDLER__() {
MSS_UART_get_rx( this_uart, g_rx_buff, sizeof(g_rx_buff) );
//erase_block( BARSTART_X, BARSTART_Y, BARSTART_X+100,BAREND_Y);
progress=g_rx_buff[0];
uint8_t xcoord = g_rx_buff[4] / map_resolution;
uint8_t ycoord = g_rx_buff[5] / map_resolution;
mouse_map[xcoord][ycoord] = (mouse_map[xcoord][ycoord] == 0) ? 1 : 0;
if(tab_state==0 && !is_selecting){
//MSS_UART_get_rx( this_uart, g_rx_buff, sizeof(g_rx_buff) );
erase_block( BARSTART_X+1, BARSTART_Y+1, BARSTART_X+99,BAREND_Y-1);
......@@ -108,14 +114,17 @@ void __FINISHED_INTERRUPT_HANDLER__() {
display_stepper((int8_t)g_rx_buff[2], (int8_t)g_rx_buff[3]);
display_mouse((int8_t)g_rx_buff[4], (int8_t)g_rx_buff[5]);
display_orientation((uint16_t)g_rx_buff[6] | (uint16_t)g_rx_buff[7] << 8);
set_reset_pixel(xcoord, ycoord, mouse_map[xcoord][ycoord]);
}
/*
signed char odox=g_rx_buff[2]; //cent
signed char odoy=g_rx_buff[3];
signed char mousex=g_rx_buff[4]; //cent/1000
signed char mousey=g_rx_buff[5];
uint16_t orientation = (g_rx_buff[6]) | ((uint16_t)g_rx_buff[7] << 8); //deg
*/
*/
}
void initInterrupts(){
......@@ -141,6 +150,7 @@ int main() {
initialize(20);
initInterrupts();
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));
......
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