Project

General

Profile

Revision 992

Added by ttf about 15 years ago

View differences:

testmain.c
3 3
#include "testhoming.h"
4 4
#include "bayboard_lib.h"
5 5

  
6
#include<stdio.h>
7
#include<stdlib.h>
8
#include <i2c.h>
9
#include "../libbayboard/orb.h"
10
#include <avr/interrupt.h>
11
#include "../libwireless/lib/wireless.h"
12
#include "../libwireless/lib/wl_token_ring.h"
13

  
14

  
15
void colonet_receive (char type, int source, unsigned char* packet,int length);
16

  
17

  
18

  
19
volatile int red;
20
volatile int blue;
21
volatile int green;
22

  
6 23
int main(void){
7
	bayboard_init(ALL_ON);
24
    red=255;
25
    blue=0;
26
    green=0;
27
    bayboard_init(ALL_ON);
28
	
29
    set_orb(255,255,255);
30
	wl_init();
31
    PacketGroupHandler colonetHandler = {7, NULL, NULL, &colonet_receive, NULL};
32
  wl_register_packet_group(&colonetHandler);
33
    while(1){
34
	  wl_send_global_packet(7, 'a', NULL, 0, 0);
35
	wl_do();}
36
 
37
}
8 38

  
9
  usb_puts("welcome\n");
10
  testHoming();
39
void colonet_receive (char type, int source, unsigned char* packet,int length)
40
{
41
  switch (type)
42
  {
43
    case 'a':
44
        if(red == 255){
45
            blue = 255;
46
            red = 0;
47
            green = 0;
48
        }
49
        else if(blue == 255){
50
            green = 255;
51
            red = 0;
52
            blue = 0;
53
        }
54
        else if(green ==255){
55
            red =255;
56
            green =0;
57
            blue =0;
58
        }
59
        set_orb(red, green, blue);
60
		delay_ms(2000);
61
        wl_send_global_packet(7, 'a', NULL, 0, 0);
62
		wl_do();
63
  }
11 64
}

Also available in: Unified diff