Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (2.53 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
#include "hardware.h"
13

    
14
#define ESC 27
15

    
16
void station_sensors_menu (void)
17
{
18
        while (1)
19
        {
20
                usb_puts ("# Dump station sensors menu: (d)ynamos, (w)all, (t)urntable, (i)bom, (a)dc" NL);
21

    
22
                char choice = usb_getc ();
23
                switch (choice) {
24
                        case 'd': case 'D': dump_station_dynamos   ();           break;
25
                        case 'w': case 'W': dump_station_wall      ();           break;
26
                        case 't': case 'T': dump_station_turntable ();           break;
27
                        case 'i': case 'I': dump_station_ibom      ();           break;
28
                        case 'a': case 'A': dump_station_adc       (0, 16, 100); break;
29
                        case ESC: return;
30
                        default: break;
31
                }
32
        }
33
}
34

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

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

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

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

    
72

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

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

    
89
void interactive_main (void)
90
{
91
  hardware_init();
92

    
93
        while (1)
94
        {
95
                // Set the orbs to green/green
96
                orbs_set (0,255,0, 0,255,0);
97

    
98
                usb_puts (NL);
99
                usb_puts ("# Diagnostic station interactive mode" NL);
100

    
101
                main_menu ();
102
        }
103
}