Blame view

tests/atmega2560/ledControl/ledControl.c 657 Bytes
7bb9b8f1   pfrison   Tests d'avr sur a...
1
2
  #include <avr/io.h>
  #include <util/delay.h>
9ce6804b   pfrison   ledDriver test a ...
3
4
5
6
7
  #include <math.h>
  
  #define	NB_DRIVERS 3
  #define MAX_VALUE 85 //TODO tbd !
  #define DELAY 100
7bb9b8f1   pfrison   Tests d'avr sur a...
8
9
  
  int main(void){
9ce6804b   pfrison   ledDriver test a ...
10
11
12
  	// Initialisation
  	unsigned int ledValues[NB_DRIVERS * DLED_CHANNELS];
  	init_LED_Drivers(NB_DRIVERS);
7bb9b8f1   pfrison   Tests d'avr sur a...
13
  
9ce6804b   pfrison   ledDriver test a ...
14
15
  	// Animation
  	unsigned int animTick = 0;
7bb9b8f1   pfrison   Tests d'avr sur a...
16
  	while(1){
9ce6804b   pfrison   ledDriver test a ...
17
18
19
20
21
  		// Build animation
  		for(int i=0; i<NB_DRIVERS * DLED_CHANNELS; i++){
  			double sinIn = (double) animTick / 8;
  			unsigned int val = (unsigned int) (0.5 + (sin(sinIn) * 0.5));
  			ledValues[i] = val * MAX_VALUE;
7bb9b8f1   pfrison   Tests d'avr sur a...
22
  		}
9ce6804b   pfrison   ledDriver test a ...
23
24
25
26
27
28
  		animTick++;
  		if(animTick >= 10000)
  			animTick = 0;
  
  		set_LED_Drivers(groupes, NB_DRIVERS);
  		_delay_ms(100);
7bb9b8f1   pfrison   Tests d'avr sur a...
29
30
31
  	}
  	return 0;
  }