-
Notifications
You must be signed in to change notification settings - Fork 1
/
RedBlinkingFor20sChoreographyMaker.java
60 lines (53 loc) · 2.03 KB
/
RedBlinkingFor20sChoreographyMaker.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import jNab.core.choreography.Choreography;
import jNab.ext.persistency.Serializer;
import java.io.File;
import java.io.IOException;
/**
* Exemple of application generating a choreography.
*
* This choreography consists in putting down the ears and making the belly leds blink in red at 1Hz for 20s.
*
* @author Sylvain Gizard
* @author Sebastien Jean
*/
public class RedBlinkingFor20sChoreographyMaker
{
/**
* Application's main
* @param args <i>(unused)</i>.
*/
public static void main(String[] args)
{
System.out.println("Generating choreography");
// Creating a new choreography
Choreography choreography = new Choreography("RedBlinking");
// Setting tempo frequency to 1s (100/100 Hz)
choreography.addTempoCommand(0, 100);
// Putting down both ears
choreography.addAbsoluteEarMoveCommand(0, Choreography.EAR_LEFT, 10, Choreography.DIRECTION_FORWARD);
choreography.addAbsoluteEarMoveCommand(0, Choreography.EAR_RIGHT, 10, Choreography.DIRECTION_FORWARD);
// Making the belly leds blink in read at 1Hz for 20s
choreography.addLedColorCommand(0, Choreography.LED_LEFT, 255, 0, 0);
for (int i = 0; i < 9; i++)
{
choreography.addLedColorCommand(0, Choreography.LED_CENTER, 255, 0, 0);
choreography.addLedColorCommand(0, Choreography.LED_RIGHT, 255, 0, 0);
choreography.addLedColorCommand(1, Choreography.LED_LEFT, 0, 0, 0);
choreography.addLedColorCommand(0, Choreography.LED_CENTER, 0, 0, 0);
choreography.addLedColorCommand(0, Choreography.LED_RIGHT, 0, 0, 0);
if (i < 9) choreography.addLedColorCommand(1, Choreography.LED_LEFT, 255, 0, 0);
}
// Saving the choreography to a file (here destination file is ./files/choreographies/RedBlinking.chor)
Serializer serializer = new Serializer(new File("./files"));
try
{
serializer.saveChoreography(choreography);
}
catch (IOException e)
{
System.err.println("unable to save choreography ("+e.getMessage()+")");
return;
}
System.out.println("Done");
}
}