Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (2.06 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
static uint8_t hex_digit(uint8_t x)
72
{
73
        if (x>15) return '?';
74
        return "0123456789ABCDEF"[x];
75
}
76

    
77

    
78
static void usb_puth(int i)
79
{
80
        usb_putc(hex_digit((i>>12)&0xF));
81
        usb_putc(hex_digit((i>>8)&0xF));
82
        usb_putc(hex_digit((i>>4)&0xF));
83
        usb_putc(hex_digit(i&0xF));
84
}
85

    
86
static void usb_puth8(uint8_t i)
87
{
88
        usb_putc(hex_digit((i>>4)&0xF));
89
        usb_putc(hex_digit(i&0xF));
90
}
91

    
92

    
93
int main(void) {
94
//        dragonfly_init(ALL_ON);
95
        dragonfly_init(0);
96
        
97
        //encoders_init ();
98
    //analog_init(ADC_START);
99
        //analog_init(0);
100
    //range_init();
101

    
102
        orb_init ();
103
        orb_enable ();
104

    
105
        orb_set(0,0,0); delay_ms (1000);
106
        
107
        usb_puts ("Startup\r\n");
108

    
109

    
110
        // Do some lighting and wheel controlled motors on BTN1
111
        if (!button2_read ())
112
                acl ();
113
        else
114
                color_circle ();
115

    
116
}