Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / diagnostic_station / station / comm_interactive.c @ 1246

History | View | Annotate | Download (2.38 KB)

1
#include "comm_interactive.h"
2

    
3
#include <dragonfly_lib.h>
4

    
5
#include "global.h"
6
#include "tests.h"
7
#include "self_test.h"
8

    
9
#include "dump_robot.h"
10
#include "dump_station.h"
11

    
12
#define ESC 27
13

    
14
void station_sensors_menu (void)
15
{
16
        while (1)
17
        {
18
                usb_puts ("# Dump station sensors menu: (e)ncoders, (w)all, (t)urntable, (r)bom" NL);
19

    
20
                char choice = usb_getc ();
21
                switch (choice) {
22
                        case 'e': case 'E': dump_station_encoders  (); break;
23
                        case 'w': case 'W': dump_station_wall      (); break;
24
                        case 't': case 'T': dump_station_turntable (); break;
25
                        case 'r': case 'R': dump_station_rbom      (); break;
26
                        case ESC: return;
27
                        default: break;
28
                }
29
        }
30
}
31

    
32
void robot_sensors_menu (void)
33
{
34
        while (1)
35
        {
36
                usb_puts ("# Dump robot sensors menu: (e)ncoders, (r)angefinders, (b)om" NL);
37

    
38
                char choice = usb_getc ();
39
                switch (choice) {
40
                        case 'e': case 'E': dump_robot_encoders     (); break;
41
                        case 'r': case 'R': dump_robot_rangefinders (); break;
42
                        case 'b': case 'B': dump_robot_bom          (); break;
43
                        case ESC: return;
44
                        default: break;
45
                }
46
        }
47
}
48

    
49
void tests_menu (void)
50
{
51
        while (1)
52
        {
53
                usb_puts ("# Tests menu: (a)ll, (c)omm, (b)om, (r)angefinders, (m)otors, (e)ncoders" NL);
54

    
55
                char choice = usb_getc ();
56
                switch (choice) {
57
                        case 'a': case 'A': test_all ();                                    break; // test_all will test comm itself
58
                        case 'c': case 'C': test_comm ();                                   break;
59
                        case 'b': case 'B': if (require_comm ()) test_bom_all (true, true); break;
60
                        case 'r': case 'R': if (require_comm ()) test_rangefinder_all ();   break;
61
                        case 'm': case 'M': if (require_comm ()) test_motor_all ();         break;
62
                        case 'e': case 'E': if (require_comm ()) test_encoder_all ();       break;
63
                        case ESC: return;
64
                        default: break;
65
                }
66
        }
67
}
68

    
69

    
70
void main_menu (void)
71
{
72
        while (1)
73
        {
74
                usb_puts ("# Main menu: (t)ests, dump (s)tation sensors, dump (r)obot sensors" NL);
75

    
76
                char choice = usb_getc ();
77
                switch (choice) {
78
                        case 't': tests_menu ();           break;
79
                        case 's': station_sensors_menu (); break;
80
                        case 'r': robot_sensors_menu ();   break;
81
                        case ESC: return;
82
                }
83
        }
84
}
85

    
86
void interactive_main (void)
87
{
88

    
89
        while (1)
90
        {
91
                // Set the orbs to green/green
92
                orbs_set (0,255,0, 0,255,0);
93

    
94
                usb_puts (NL);
95
                usb_puts ("# Diagnostic station interactive mode" NL);
96

    
97
                main_menu ();
98
        }
99
}