Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (2.2 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
#define ESC 27
10

    
11
/*
12
Main menu: (t)ests, (s)tation sensors, (r)obot sensors
13
Tests menu: (b)om, (r)angefindrs, (e)ncoders, (m)otors
14
Station sensors menu: (e)ncoders, (w)all, (t)urntable
15
Robot sensors menu: (e)ncoders, (b)om, (r)angefinders
16
*/
17

    
18
void station_sensors_menu (void)
19
{
20
        while (1)
21
        {
22
                usb_puts ("# Station sensors menu: (e)ncoders" NL);
23

    
24
                char choice = usb_getc ();
25
                switch (choice) {
26
                        case 'e': case 'E': /*dump_station_encoders ()*/; break;
27
                        case ESC: return;
28
                        default: break;
29
                }
30
        }
31
}
32

    
33
void robot_sensors_menu (void)
34
{
35
        while (1)
36
        {
37
                usb_puts ("# Robot sensors menu: (e)ncoders" NL);
38

    
39
                char choice = usb_getc ();
40
                switch (choice) {
41
                        case 'e': case 'E': /*dump_robot_encoders ()*/; break;
42
                        case ESC: return;
43
                        default: break;
44
                }
45
        }
46
}
47

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

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

    
68

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

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

    
85
void interactive_main (void)
86
{
87

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

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

    
96
                main_menu ();
97
        }
98
}