Project

General

Profile

Statistics
| Revision:

root / branches / library_refactor / behaviors / library_test / main.c @ 1084

History | View | Annotate | Download (1.87 KB)

1
#include <dragonfly_lib.h>
2
//#include "smart_run_around_fsm.h"
3

    
4
// Martin "deffi" Herrmann Test
5

    
6
uint8_t motors_on=0;
7

    
8
static void color_circle ()
9
{
10
   while(1)
11
   {
12
                for (uint8_t part=0; part<6; ++part)
13
                {
14
                        for (uint8_t up=0; up<255; ++up)
15
                        {
16
                                uint8_t dn=255-up;
17
                                uint8_t on=255;
18
                                uint8_t of=0;
19
                                
20
                                if (1)
21
                                {
22
                                        // Maximum brightness mode
23
                                        switch (part)
24
                                        {
25
                                                case 0: orb_set (on, up, of); break;
26
                                                case 1: orb_set (dn, on, of); break;
27
                                                case 2: orb_set (of, on, up); break;
28
                                                case 3: orb_set (of, dn, on); break;
29
                                                case 4: orb_set (up, of, on); break;
30
                                                case 5: orb_set (on, of, dn); break;
31
                                        }
32
                                }
33
                                else
34
                                {
35
                                        // Constant brightness mode (not very constant though)
36
                                        switch (part%3)
37
                                        {
38
                                                case 0: orb_set (dn, up, of); break;
39
                                                case 1: orb_set (of, dn, up); break;
40
                                                case 2: orb_set (up, of, dn); break;
41
                                        }
42
                                }
43
                                
44
                                delay_ms (2);
45
                        }
46
                }
47
        }
48
}
49

    
50
static void acl()
51
{
52
        #define redval 255
53
        #define greenval 150
54
        #define interval 1300
55
        #define flash 20
56
        #define pause 200
57

    
58
        #define def do { orb1_set(redval,0,0); orb2_set(0,greenval,0); } while (0)
59
        #define wht do { orb_set(255,255,255); } while (0)
60
        
61
        while (1)
62
        {
63
                wht; delay_ms (flash);
64
                def; delay_ms (pause-flash);
65
                wht; delay_ms (flash);
66
                def; delay_ms (pause-flash);
67
                def; delay_ms (interval-2*pause-2*flash);
68
        }
69
}
70

    
71

    
72
int main(void) {
73
//        dragonfly_init(ALL_ON);
74
        dragonfly_init(0);
75
        
76
        //encoders_init ();
77
    //analog_init(ADC_START);
78
        //analog_init(0);
79
    //range_init();
80

    
81
        orb_init ();
82
        orb_enable ();
83

    
84
        orb_set(0,0,0); delay_ms (1000);
85

    
86
        usb_init ();
87
        
88
        usb_puts ("Startup\r\n");
89
        usb_puth (0x1234); usb_puts ("\r\n");
90
        usb_puth (0xFFFF); usb_puts ("\r\n");
91
        usb_puth (0); usb_puts ("\r\n");
92
        usb_puth (0x12345); usb_puts ("\r\n");
93
        
94

    
95
        // Do some lighting and wheel controlled motors on BTN1
96
        if (!button2_read ())
97
                acl ();
98
        else
99
                color_circle ();
100

    
101
}