Merge branch 'master' of git://github.com/r0ket/r0ket

This commit is contained in:
Thammi 2011-08-11 17:36:12 +02:00
commit 9c9c052145
14 changed files with 305 additions and 16 deletions

View File

@ -108,6 +108,7 @@ void tick_default(void) {
EVERY(50,0){
/*
if(GLOBAL(chargeled)){
IOCON_PIO1_11 = 0x0;
gpioSetDir(RB_LED3, gpioDirection_Output);
@ -116,6 +117,7 @@ void tick_default(void) {
else
gpioSetValue (RB_LED3, 0);
};
*/
if(GetVoltage()<3600){
IOCON_PIO1_11 = 0x0;

View File

@ -415,9 +415,21 @@ static int process(char * input){
puts_plus(" ");
puts_plus(IntToStrX( uint8ptouint32(buf+8),8 ));
}else if(type=='b'){
if(filter)
if(filter=='.' || filter=='u')
if(uint8ptouint32(buf+8)!=uint8ptouint32(filterdata))
continue;
if(filter=='0' && buf[3] != 0x00)
continue;
if(filter=='5' && buf[3] != 0x55)
continue;
if(filter=='a' && buf[3] != 0xaa)
continue;
if(filter=='A' && buf[3] != 0xaa)
continue;
if(filter=='f' && buf[3] != 0xff)
continue;
if(filter=='F' && buf[3] != 0xff)
continue;
puts_plus("R ");
puts_plus(IntToStrX( buf[0],2 ));
puts_plus(" ");

View File

@ -28,7 +28,7 @@ struct CDESC the_config[]= {
{"flamemaxw", 255, 1, 255, 1, CFG_TYPE_FLAME},
{"flameminw", 0x8f, 1, 255, 1, CFG_TYPE_FLAME},
{"l0nick", 0, 0, 1 , 0, 0},
{"chargeled", 0, 0, 1 , 0, 0},
{"chargeled", 0, 0, 1 , 0, CFG_TYPE_GONE},
{"positionleds", 0, 0, 1 , 0, 0},
{ NULL, 0, 0, 0 , 0, 0},
};

View File

@ -18,6 +18,7 @@ struct CDESC {
#define CFG_TYPE_BASIC 0
#define CFG_TYPE_DEVEL 1
#define CFG_TYPE_FLAME 2
#define CFG_TYPE_GONE 3
#define MAXNICK 17
extern struct CDESC the_config[];

View File

@ -104,14 +104,14 @@ systickGetTicks
uint32touint8p
uint8ptouint32
#Add stuff here
o_init
o_path_new
o_move_to
o_line_to
o_curve_to
o_close
o_set_gray
o_fill
o_set_shader
o_identity
o_transform
#o_init
#o_path_new
#o_move_to
#o_line_to
#o_curve_to
#o_close
#o_set_gray
#o_fill
#o_set_shader
#o_identity
#o_transform

View File

@ -24,9 +24,13 @@ LDSRCFILE=ram.ld
LDFILE=loadable.ld
CFLAGS+=-mlong-calls -fno-toplevel-reorder
CRYPT=cp
DOCRYPT=0
CRYPT=../../tools/crypto/xxtea
CRYPTFLAGS=-p
skey=`cd .. && ./getkey.pl l0dable_sign`
ekey=`cd .. && ./getkey.pl l0dable_crypt`
all: $(OBJS) $(ELFS) $(BINS) $(CODS) $(NIKS) 1boot.int debug.int
$(LDFILE):
@ -47,7 +51,13 @@ $(LDFILE):
$(OBJCOPY) $(OCFLAGS) -O binary $< $@
%.c0d: %.bin
$(CRYPT) $(CRYPTFLAGS) $< $@
ifeq "$(DOCRYPT)" "1"
$(CRYPT) -e -k $(ekey) -o $<.tmp $<
$(CRYPT) -s -k $(skey) -o $@ $<.tmp
rm -f $<.tmp
else
cp $< $@
endif
%.nik: .PHONY
@a=$@;a=nick_$${a%.nik}.c0d;echo mv $$a $@;mv $$a $@

View File

@ -27,6 +27,7 @@ void ram (void)
int angle;
int scale;
int velocity = 0;
frame_no=0;
while ((inpt = getInputRaw()) != BTN_ENTER)
{

View File

@ -0,0 +1,67 @@
#include <sysinit.h>
#include "basic/basic.h"
#include "lcd/lcd.h"
#include "lcd/print.h"
#include "filesystem/ff.h"
#include "usetable.h"
//shows *.lcd
void ram(void)
{
char filename[13];
char key;
int i=500;
// Image or Animation?
lcdClear();
lcdPrintln("Image | Anim?");
lcdPrintln("Up=Image");
lcdPrintln("Down=Anim");
lcdRefresh();
key = getInputWait();
delayms(230);
// Show file
if( key == BTN_DOWN ){
// Choose animation speed
while ( key != BTN_ENTER ){
lcdClear();
lcdPrintln("Choose speed:");
lcdPrintln("");
lcdPrint(" ");
lcdPrint(IntToStr(i,5,0));
lcdPrintln("ms");
lcdRefresh();
key = getInputWait();
if ( key == BTN_UP ){
if ( i < 60000 )
i+=10;
} else if ( key == BTN_DOWN ){
if ( i > 10 )
i-=10;
}
delayms(100);
}
// Select file
lcdClear();
delayms(230);
selectFile(filename,"LCD");
// Load as animation
lcdShowAnim(filename, i);
} else if ( key == BTN_UP ){
// Select file
lcdClear();
delayms(230);
selectFile(filename,"LCD");
// Load as image
lcdLoadImage(filename);
lcdRefresh();
} else {
// Exit
return;
}
getInputWait();
}

194
firmware/l0dable/snake.c Normal file
View File

@ -0,0 +1,194 @@
#include <sysinit.h>
#include "basic/basic.h"
#include "basic/config.h"
#include "lcd/lcd.h"
#include "lcd/print.h"
#include "usetable.h"
struct elem
{
int x,y;
};
void reset(struct elem snake[],size_t *snake_size,int *dirc,
int*speed, int*points,int*point_s);
void o_rectangle (int x0, int y0, int width, int height);
struct elem rnd(void);
#define MAX_SNAKE_LEN (40)
#define SNAKE_DEM (3)
#define MIN_SPEED (25)
#define MAX_SPEED (3)
#define SIZE_X (RESX)
#define SIZE_Y (RESY)
void ram(void)
{
int inpt,dirc,c,grows = 0,dx,dy,points,point_s=1;
size_t n = 0, snake_size = 5, speed=MIN_SPEED;
struct elem snake[MAX_SNAKE_LEN], food;
char test[512]; /* scratch space */
o_init (test, sizeof(test));
reset(snake,&snake_size,&dirc,&speed,&points,&point_s);
food = rnd();
while (1)
{
head:
if(!(++c % speed))
{
inpt = getInputRaw();
dx=DoString(0,0,IntToStrX(points,2));
dx=(SIZE_X-dx)/2;
if(dx<0)
dx=0;
dy=(SIZE_Y-getFontHeight())/2;
lcdFill(255);
o_rectangle(1,0,SIZE_X-2,SIZE_Y-2);
o_set_gray (0);
o_fill ();
//o_identity (); /* reset tranforms */
o_set_gray (50);
setExtFont("UBUNTU29");
lcdSetPixel(1,1,1);
DoString(dx,dy,IntToStrX(points,2));
o_set_gray (255);
for(n=0;n<snake_size;++n)
{
o_rectangle
(snake[n].x*SNAKE_DEM,snake[n].y*SNAKE_DEM,SNAKE_DEM,SNAKE_DEM); /*
fill background with black */
o_fill (); /* fill with 50% {
reset(snake,&snake_size);
goto head;
}gray */
}
o_rectangle
(food.x*SNAKE_DEM,food.y*SNAKE_DEM,SNAKE_DEM,SNAKE_DEM); /* fill
background with black */
o_fill ();
lcdDisplay();
if (inpt == BTN_UP && dirc != 1)
{
dirc = 3;
}
else if (inpt == BTN_DOWN && dirc != 3)
{
dirc = 1;
}
else if (inpt == BTN_LEFT && dirc != 0)
{
dirc = 2;
}
else if (inpt == BTN_RIGHT && dirc !=2)
{
dirc = 0;
}
//
struct elem t = snake[snake_size-1];
if(dirc == 0)
++t.x;
else if(dirc == 1)
++t.y;
else if(dirc == 2)
--t.x;
else if(dirc == 3)
--t.y;
if(t.x < 0 || t.y < 0 || t.y > SIZE_Y/SNAKE_DEM-1 ||
t.x > SIZE_X/SNAKE_DEM)
{
reset(snake,&snake_size,&dirc,&speed,&points,&point_s);
goto head;
}
for(n=0;n<snake_size-1;++n)
{
if(snake[n].x == t.x && snake[n].y == t.y)
{
reset(snake,&snake_size,&dirc,&speed,&points,&point_s);
goto head;
}
else if(snake[n].x == food.x && snake[n].y == food.y)
{
grows = 1;
++snake_size;
++points;
if(speed > MAX_SPEED) --speed;
food = rnd();
}
}
if(!grows)
{
for(n=0;n<snake_size-1;++n)
{
snake[n] = snake[n+1];
}
}
else
grows = 0;
snake[snake_size-1] = t;
}
else
delayms(3);
}
}
struct elem rnd(void)
{
struct elem res;
res.x = getRandom() % (SIZE_X/SNAKE_DEM-1) +1;
res.y = getRandom() % (SIZE_Y/SNAKE_DEM-1) + 1;
return res;
}
void reset(struct elem snake[],size_t *snake_size,int *dirc,
int*speed, int*points,int* point_s)
{
size_t n = 0;
for(n=0;n<MAX_SNAKE_LEN;++n)
{ snake[n].x=5;snake[n].y=5; }
*snake_size = 5;
*dirc = 0;
*speed = MIN_SPEED;
*points=0;
*point_s=1;
}
void o_rectangle (int x0, int y0, int width, int height)
{
o_path_new ();
o_move_to (x0, y0);
o_line_to (x0 + width, y0);
o_line_to (x0 + width, y0+height+1);
o_line_to (x0, y0+height+1);
o_close ();
}

View File

@ -35,7 +35,7 @@
*/
#define O_ENABLE_FILL
#define O_ENABLE_STROKE
//#define O_ENABLE_STROKE
#define O_ENABLE_USER_SHADER
#define O_ENABLE_BW /* pick one ,. */
//#define O_ENABLE_GRAY

2
tools/.gitignore vendored
View File

@ -2,3 +2,5 @@ lpcfix.exe
lpcfix
xxtea.exe
xxtea
generate-keys.exe
generate-keys

Binary file not shown.

Binary file not shown.

Binary file not shown.