2011-12-23 20:50:55 +01:00
|
|
|
/*
|
|
|
|
* CTHN.de MiniLEDCube
|
|
|
|
*
|
2011-12-27 13:00:48 +01:00
|
|
|
* By Kai Lauterbach (klaute at web dot de) 12/2011
|
2011-12-23 20:50:55 +01:00
|
|
|
*
|
|
|
|
* Based on http://mosfetkiller.de/?s=miniledcube
|
|
|
|
*
|
|
|
|
* License: General Public License (GPL v3)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <usb.h>
|
|
|
|
#include <argtable2.h>
|
|
|
|
|
2011-12-28 01:19:02 +01:00
|
|
|
#include "globals.h"
|
|
|
|
|
|
|
|
#include "../firmware/globals.h"
|
2011-12-23 20:50:55 +01:00
|
|
|
|
2011-12-25 12:35:51 +01:00
|
|
|
// External functions to control the ledcube.
|
|
|
|
extern void lc_setFrame(unsigned long);
|
|
|
|
extern void lc_setMode(int);
|
2011-12-31 18:24:05 +01:00
|
|
|
extern int lc_saveFrame(unsigned long, int, int);
|
2011-12-25 12:35:51 +01:00
|
|
|
extern void lc_init(void);
|
|
|
|
extern void lc_close(void);
|
2011-12-23 20:50:55 +01:00
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2011-12-25 11:58:42 +01:00
|
|
|
|
2011-12-23 20:50:55 +01:00
|
|
|
lc_init();
|
|
|
|
|
2011-12-31 18:24:05 +01:00
|
|
|
if (argc == 2 && !strcmp((char*)argv[1], "--stop"))
|
|
|
|
{
|
|
|
|
printf("stop animation loop\n");
|
|
|
|
lc_setMode(MODE_ANIMATION_STOP);
|
|
|
|
}
|
|
|
|
else if (argc == 2 && !strcmp((char*)argv[1], "--loop"))
|
|
|
|
{
|
|
|
|
printf("starting animation loop\n");
|
|
|
|
lc_setMode(MODE_ANIMATION_LOOP);
|
|
|
|
}
|
2012-01-04 14:25:50 +01:00
|
|
|
else if (argc == 2 && !strcmp((char*)argv[1], "--single"))
|
|
|
|
{
|
|
|
|
printf("starting animation as single shot\n");
|
|
|
|
lc_setMode(MODE_ANIMATION_SINGLE);
|
|
|
|
}
|
|
|
|
else if (argc == 5 && !strcmp((char*)argv[1], "--view"))
|
|
|
|
{
|
|
|
|
|
|
|
|
lc_setMode(MODE_ANIMATION_STOP);
|
|
|
|
unsigned int frame = 0;
|
|
|
|
if ( sscanf((char*)argv[4], "0x%08x", &frame) )
|
|
|
|
{
|
|
|
|
printf("view frame: data=0x%08x\n", frame);
|
|
|
|
lc_setFrame(frame);
|
|
|
|
}
|
|
|
|
}
|
2011-12-31 18:24:05 +01:00
|
|
|
else if (argc == 5 && !strcmp((char*)argv[1], "--save"))
|
2011-12-30 13:04:26 +01:00
|
|
|
{
|
2011-12-31 18:24:05 +01:00
|
|
|
|
|
|
|
lc_setMode(MODE_ANIMATION_STOP);
|
|
|
|
|
|
|
|
// TODO parse commandline parameters
|
|
|
|
unsigned int pos = 0;
|
|
|
|
if ( sscanf((char*)argv[2], "%d", &pos) )
|
|
|
|
{
|
|
|
|
unsigned int delay = 0;
|
|
|
|
if ( sscanf((char*)argv[3], "%d", &delay) )
|
|
|
|
{
|
|
|
|
unsigned int frame = 0;
|
|
|
|
if ( sscanf((char*)argv[4], "0x%08x", &frame) )
|
|
|
|
{
|
|
|
|
printf("saving frame: index=%d delay=%d frame=0x%08x\n", pos, delay, frame);
|
|
|
|
//lc_setFrame(frame);
|
|
|
|
lc_saveFrame(frame, delay, pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-30 13:04:26 +01:00
|
|
|
}
|
|
|
|
|
2011-12-23 20:50:55 +01:00
|
|
|
lc_close();
|
2011-12-25 11:58:42 +01:00
|
|
|
|
|
|
|
return 0;
|
2011-12-23 20:50:55 +01:00
|
|
|
}
|
|
|
|
|