Merge branch 'master' of github.com:r0ket/r0ket
This commit is contained in:
commit
d88250fc5a
|
@ -198,7 +198,7 @@ static inline uint32_t popcount(uint32_t *buf, uint8_t n){
|
||||||
|
|
||||||
uint8_t mesh_recvqloop_work(void){
|
uint8_t mesh_recvqloop_work(void){
|
||||||
__attribute__ ((aligned (4))) uint8_t buf[32];
|
__attribute__ ((aligned (4))) uint8_t buf[32];
|
||||||
int len;
|
unsigned int len;
|
||||||
|
|
||||||
len=nrf_rcv_pkt_poll_dec(sizeof(buf),buf,NULL);
|
len=nrf_rcv_pkt_poll_dec(sizeof(buf),buf,NULL);
|
||||||
|
|
||||||
|
@ -249,6 +249,8 @@ uint8_t mesh_recvqloop_work(void){
|
||||||
(*(
|
(*(
|
||||||
(uint32_t*)(MO_BODY(buf)+6)
|
(uint32_t*)(MO_BODY(buf)+6)
|
||||||
))++;
|
))++;
|
||||||
|
if(GLOBAL(privacy)==0)
|
||||||
|
uint32touint8p(GetUUID32(),MO_BODY(buf)+20);
|
||||||
MO_TIME_set(mpkt->pkt,0);
|
MO_TIME_set(mpkt->pkt,0);
|
||||||
};
|
};
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#define M_RECVTIM 100
|
#define M_RECVTIM 100
|
||||||
|
|
||||||
#define MESH_CHANNEL 83
|
#define MESH_CHANNEL 83
|
||||||
#define MESH_MAC "MESHB"
|
#define MESH_MAC "BMESH"
|
||||||
|
|
||||||
#define MO_TYPE(x) (x[0])
|
#define MO_TYPE(x) (x[0])
|
||||||
#define MO_TYPE_set(x,y) (x[0]=y)
|
#define MO_TYPE_set(x,y) (x[0]=y)
|
||||||
|
|
|
@ -151,8 +151,7 @@ int nrf_rcv_pkt_poll_dec(int maxsize, uint8_t * pkt, uint32_t const key[4]){
|
||||||
if(len <=0)
|
if(len <=0)
|
||||||
return len;
|
return len;
|
||||||
|
|
||||||
if(key==NULL)
|
// if(key==NULL) return len;
|
||||||
return len;
|
|
||||||
|
|
||||||
cmpcrc=crc16(pkt,len-2);
|
cmpcrc=crc16(pkt,len-2);
|
||||||
if(key!=NULL)
|
if(key!=NULL)
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
#include <sysinit.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "basic/basic.h"
|
||||||
|
#include "basic/config.h"
|
||||||
|
|
||||||
|
#include "lcd/render.h"
|
||||||
|
#include "lcd/print.h"
|
||||||
|
|
||||||
|
#include "usetable.h"
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
|
||||||
|
void ram(void) {
|
||||||
|
lcdClear();
|
||||||
|
lcdPrintln("r0ket");
|
||||||
|
lcdPrintln("Release: ");
|
||||||
|
lcdPrintln(IntToStrX(getrelease(),8));
|
||||||
|
lcdRefresh();
|
||||||
|
while(!getInputRaw())work_queue();
|
||||||
|
};
|
|
@ -77,5 +77,5 @@ int main(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int getrelease(void){
|
int getrelease(void){
|
||||||
return 0x00000104;
|
return 0x00000105;
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,6 +28,14 @@ div
|
||||||
}
|
}
|
||||||
|
|
||||||
div.score
|
div.score
|
||||||
|
{
|
||||||
|
color: #33FF33;
|
||||||
|
background-color: transparent;
|
||||||
|
width: 640px;
|
||||||
|
font-size: 20px;
|
||||||
|
font-family: courier new;
|
||||||
|
}
|
||||||
|
div.player
|
||||||
{
|
{
|
||||||
color: #33FF33;
|
color: #33FF33;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
|
@ -46,5 +54,7 @@ div.score
|
||||||
</input>
|
</input>
|
||||||
<div style="font-size:14;color:black;background-color:white;" id="socket">s_data...</div>
|
<div style="font-size:14;color:black;background-color:white;" id="socket">s_data...</div>
|
||||||
<div style="font-size:14;color:black;background-color:white;" id="debug">debug</div>
|
<div style="font-size:14;color:black;background-color:white;" id="debug">debug</div>
|
||||||
|
<div class="player" style="text-align:left" id="player_left">0</div>
|
||||||
|
<div class="player" style="text-align:right" id="player_right">0</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Initialisation
|
// Initialisation
|
||||||
var socket = "ws://83.133.179.198:8888/data";
|
var socket = "ws://127.0.0.1:8888/data";
|
||||||
var field= { w: 320, h: 240 };
|
var field= { w: 320, h: 240 };
|
||||||
var paddle = { w: 2, h: 30 };
|
var paddle = { w: 2, h: 30 };
|
||||||
var ball = { w: 5, h: 5, s: 5 };
|
var ball = { w: 5, h: 5, s: 5 };
|
||||||
|
@ -12,6 +12,9 @@ function pong() {
|
||||||
this.score = {};
|
this.score = {};
|
||||||
this.score.left = {};
|
this.score.left = {};
|
||||||
this.score.right = {};
|
this.score.right = {};
|
||||||
|
this.cnt = {};
|
||||||
|
this.cnt.left = {};
|
||||||
|
this.cnt.right = {};
|
||||||
this.field = {};
|
this.field = {};
|
||||||
this.game = { run: 0 };
|
this.game = { run: 0 };
|
||||||
|
|
||||||
|
@ -40,6 +43,12 @@ function pong() {
|
||||||
setupavatar(this.right);
|
setupavatar(this.right);
|
||||||
setupavatar(this.field);
|
setupavatar(this.field);
|
||||||
|
|
||||||
|
this.cnt.left.avatar=$('div#player_left');
|
||||||
|
this.cnt.right.avatar=$('div#player_right');
|
||||||
|
|
||||||
|
$('div#player_left').css({top: 2*this.field.size.h-30});
|
||||||
|
$('div#player_right').css({top: 2*this.field.size.h-30});
|
||||||
|
|
||||||
this.field.avatar.focus();
|
this.field.avatar.focus();
|
||||||
|
|
||||||
this.score.left.pts=0;
|
this.score.left.pts=0;
|
||||||
|
@ -207,12 +216,17 @@ pong.prototype.socketstart = function(uri){
|
||||||
$('#socket').html(data);
|
$('#socket').html(data);
|
||||||
if(data.slice(0,1)=="{"){
|
if(data.slice(0,1)=="{"){
|
||||||
var result=JSON.parse(data);
|
var result=JSON.parse(data);
|
||||||
if (result.right){
|
if ("right" in result){
|
||||||
this.setright(result.right);
|
game.setright(result.right);
|
||||||
} else if (result.left){
|
} ;
|
||||||
this.setleft(result.left);
|
if ("left" in result){
|
||||||
}else {
|
game.setleft(result.left);
|
||||||
// unknown json input
|
};
|
||||||
|
if ("cntl" in result){
|
||||||
|
game.cnt.left.avatar.html(result.cntl);
|
||||||
|
};
|
||||||
|
if ("cntr" in result){
|
||||||
|
game.cnt.right.avatar.html(result.cntr);
|
||||||
};
|
};
|
||||||
}else{
|
}else{
|
||||||
// unknown non-json input
|
// unknown non-json input
|
||||||
|
|
|
@ -9,35 +9,80 @@ import os.path
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
import socket
|
import socket
|
||||||
|
import time
|
||||||
|
|
||||||
from tornado.options import define, options
|
from tornado.options import define, options
|
||||||
|
|
||||||
define("port", default=8888, help="run on the given port", type=int)
|
define("port", default=8888, help="run on the given port", type=int)
|
||||||
|
|
||||||
pong=None
|
pong=None
|
||||||
pos=0.5
|
left=0.0
|
||||||
|
right=0.0
|
||||||
|
cntr=0
|
||||||
|
cntl=0
|
||||||
|
info={}
|
||||||
|
|
||||||
def sendpos():
|
def sendpos():
|
||||||
|
global right, left
|
||||||
|
global cntr, cntl
|
||||||
|
global info
|
||||||
|
sstr="{ \"right\": %s, \"cntr\": %s , \"cntl\": %s, \"left\": %s }"%(right,cntr,cntl,left)
|
||||||
if pong:
|
if pong:
|
||||||
pong.write_message("{ \"right\": "+str(pos)+" }")
|
pong.write_message(sstr)
|
||||||
threading.Timer(.5,sendpos).start()
|
# print sstr
|
||||||
|
threading.Timer(.1,sendpos).start()
|
||||||
|
for (id,(b,t,r)) in info.items():
|
||||||
|
if(t+5<time.time()):
|
||||||
|
# print "time=%s"%(time.time())
|
||||||
|
del info[id]
|
||||||
|
sumr=0.0
|
||||||
|
suml=0.0
|
||||||
|
cntr=0.0
|
||||||
|
cntl=0.0
|
||||||
|
for (id,(b,t,r)) in info.items():
|
||||||
|
if r==1:
|
||||||
|
cntr+=1
|
||||||
|
else:
|
||||||
|
cntl+=1
|
||||||
|
if b&1==1:
|
||||||
|
if r==1:
|
||||||
|
sumr-=1
|
||||||
|
else:
|
||||||
|
suml-=1
|
||||||
|
if b&2==2:
|
||||||
|
if r==1:
|
||||||
|
sumr+=1
|
||||||
|
else:
|
||||||
|
suml+=1
|
||||||
|
# print "summing: suml=%s cntl=%s sumr=%s cntr=%s"%(suml,cntl,sumr,cntr)
|
||||||
|
if cntr==0:
|
||||||
|
right=0
|
||||||
|
else:
|
||||||
|
right=sumr/cntr
|
||||||
|
if cntl==0:
|
||||||
|
left=0
|
||||||
|
else:
|
||||||
|
left=suml/cntl
|
||||||
|
# print "right=%s left=%s"%(right,left)
|
||||||
|
|
||||||
sendpos()
|
sendpos()
|
||||||
|
|
||||||
def receivedPacket(packet):
|
|
||||||
global pos
|
|
||||||
if isinstance(packet,r0ketrem0te.packets.Button):
|
|
||||||
if packet.button == 2:
|
|
||||||
pos+=.01
|
|
||||||
if packet.button == 1:
|
|
||||||
pos-=.01
|
|
||||||
if pos <0:
|
|
||||||
pos=0
|
|
||||||
if pos >1:
|
|
||||||
pos=1
|
|
||||||
|
|
||||||
def workPacket(data, addr):
|
def workPacket(data, addr):
|
||||||
print "new packet:", list(data), addr
|
global right, left
|
||||||
|
global cntr, cntl
|
||||||
|
global reid
|
||||||
|
global r0id
|
||||||
|
global button
|
||||||
|
global info
|
||||||
|
# print "new packet:", list(data), addr
|
||||||
|
reid=ord(data[4])*256 + ord(data[5])
|
||||||
|
r0id=ord(data[19])*256*256*256 + ord(data[20])*256*256+ord(data[21])*256+ord(data[22])
|
||||||
|
button=ord(data[27])
|
||||||
|
rl=1
|
||||||
|
if reid == 1123:
|
||||||
|
rl=2
|
||||||
|
info[r0id]=(button,time.time(),rl)
|
||||||
|
print "added rl=%s r0=%s bu=%s"%(rl,r0id,button)
|
||||||
|
|
||||||
def readerThread():
|
def readerThread():
|
||||||
sock = socket.socket( socket.AF_INET, # Internet
|
sock = socket.socket( socket.AF_INET, # Internet
|
||||||
|
|
|
@ -37,8 +37,8 @@ if($cmd =~ /^r/){
|
||||||
$cmd=~s/r//;
|
$cmd=~s/r//;
|
||||||
$cmd+=1;
|
$cmd+=1;
|
||||||
my $fmt=shift;
|
my $fmt=shift;
|
||||||
while($cmd-->0){
|
|
||||||
my $read="";
|
my $read="";
|
||||||
|
while($cmd-->0){
|
||||||
while($read !~ /\\1.*\\0/){
|
while($read !~ /\\1.*\\0/){
|
||||||
my $rr="";
|
my $rr="";
|
||||||
if (@fh = $sel->can_read(100)) {
|
if (@fh = $sel->can_read(100)) {
|
||||||
|
@ -46,20 +46,34 @@ if($cmd =~ /^r/){
|
||||||
$read.=$rr;
|
$read.=$rr;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
print "Read: <"; sprint $read; print ">\n";
|
while ($read =~ s/\\1(.*?)\\0//){
|
||||||
$read =~ s/^\\1//;
|
my $str=$1;
|
||||||
|
my $cs=substr($str,0,30);
|
||||||
|
my $crc=unpack("n",substr($str,30,2));
|
||||||
|
my $crc2= crcccitt($cs),"\n";
|
||||||
if($fmt eq "m"){
|
if($fmt eq "m"){
|
||||||
print "M [",substr($read,0,1),"] ";
|
my $i=substr($str,0,1);
|
||||||
print "g=",unpack("C",substr($read,1,1))," ";
|
print "M [",substr($str,0,1),"] ";
|
||||||
print "t=",unpack("N",substr($read,2,4))," ";
|
print "g=",unpack("C",substr($str,1,1))," ";
|
||||||
print "beacon=",unpack("H*",substr($read,26,4))," ";
|
if($i eq "T"){
|
||||||
|
print "t=",unpack("N",substr($str,2,4))," ";
|
||||||
|
print "(",scalar gmtime unpack("N",substr($str,2,4)),") ";
|
||||||
|
print "beacon=",unpack("H*",substr($str,26,4))," ";
|
||||||
|
}elsif($i eq "B"){
|
||||||
|
print "t=",unpack("N",substr($str,2,4))," ";
|
||||||
|
print "ID=",unpack("c",substr($str,6,1))," ";
|
||||||
|
print "HOP=",unpack("n",substr($str,11,4))," ";
|
||||||
|
};
|
||||||
|
# print "\n";
|
||||||
|
}else{
|
||||||
|
print "Read: <"; sprint $str; print ">\n";
|
||||||
|
};
|
||||||
|
print "CRCFAIL" if ($crc ne $crc2);
|
||||||
print "\n";
|
print "\n";
|
||||||
};
|
};
|
||||||
my $cs=substr($read,0,30);
|
|
||||||
my $crc=substr($read,30,2);
|
|
||||||
print unpack("n",$crc),"<>";
|
|
||||||
print crcccitt($cs),"\n";
|
|
||||||
};
|
};
|
||||||
|
print "rest: <"; sprint $read; print ">\n";
|
||||||
|
exit;
|
||||||
}elsif ($cmd eq "mt"){
|
}elsif ($cmd eq "mt"){
|
||||||
my $par=pack("H*",shift);
|
my $par=pack("H*",shift);
|
||||||
print "Write: <"; sprint $par; print ">\n";
|
print "Write: <"; sprint $par; print ">\n";
|
||||||
|
@ -120,7 +134,7 @@ if($cmd =~ /^r/){
|
||||||
}elsif($scmd eq "b"){
|
}elsif($scmd eq "b"){
|
||||||
$par.="B";
|
$par.="B";
|
||||||
$par.=chr(shift); #gen
|
$par.=chr(shift); #gen
|
||||||
$par.=pack("N",scalar(time)+1*60*60+ 300);
|
$par.=pack("N",scalar(time)+1*60*60+ 600);
|
||||||
|
|
||||||
$par.= pack("C",shift||0);
|
$par.= pack("C",shift||0);
|
||||||
$par.= pack("C",0);
|
$par.= pack("C",0);
|
||||||
|
@ -137,6 +151,7 @@ if($cmd =~ /^r/){
|
||||||
};
|
};
|
||||||
|
|
||||||
$par.=pack("n",crcccitt($par));
|
$par.=pack("n",crcccitt($par));
|
||||||
|
# $par.="00";
|
||||||
print "Write: <"; sprint $par; print ">\n";
|
print "Write: <"; sprint $par; print ">\n";
|
||||||
while($cmd-->0){
|
while($cmd-->0){
|
||||||
syswrite(SER, '\1'.$par.'\0');
|
syswrite(SER, '\1'.$par.'\0');
|
||||||
|
|
|
@ -6,6 +6,7 @@ setup:
|
||||||
cp ../../firmware/l0dable/*nik files
|
cp ../../firmware/l0dable/*nik files
|
||||||
cp ../../firmware/l0dable/*int files
|
cp ../../firmware/l0dable/*int files
|
||||||
cp ../../firmware/l0dable/files/* files
|
cp ../../firmware/l0dable/files/* files
|
||||||
|
mv files/debug.int 1files/debug.int
|
||||||
cp ../font/binary/*f0n files
|
cp ../font/binary/*f0n files
|
||||||
cp ../image/lcd/*lcd files
|
cp ../image/lcd/*lcd files
|
||||||
cp ../image/lcd/i42.lcd files/nick.lcd
|
cp ../image/lcd/i42.lcd files/nick.lcd
|
||||||
|
|
|
@ -17,7 +17,6 @@ fi
|
||||||
umount /dev/$dev 2>/dev/null || true
|
umount /dev/$dev 2>/dev/null || true
|
||||||
./generate-keys
|
./generate-keys
|
||||||
mount /dev/$dev -t vfat $dir/$dev
|
mount /dev/$dev -t vfat $dir/$dev
|
||||||
cp files/* $dir/$dev
|
|
||||||
cp \
|
cp \
|
||||||
1files/invaders.c0d \
|
1files/invaders.c0d \
|
||||||
1files/mandel.c0d \
|
1files/mandel.c0d \
|
||||||
|
@ -29,6 +28,7 @@ cp \
|
||||||
1files/r0type.c0d \
|
1files/r0type.c0d \
|
||||||
1files/beaconid.c0d \
|
1files/beaconid.c0d \
|
||||||
1files/people.c0d \
|
1files/people.c0d \
|
||||||
|
1files/release.c0d \
|
||||||
1files/starfld.c0d \
|
1files/starfld.c0d \
|
||||||
1files/static.c0d \
|
1files/static.c0d \
|
||||||
1files/sendcard.c0d \
|
1files/sendcard.c0d \
|
||||||
|
@ -44,7 +44,7 @@ cp \
|
||||||
1files/scope.c0d \
|
1files/scope.c0d \
|
||||||
1files/Geigerct.c0d \
|
1files/Geigerct.c0d \
|
||||||
1files/voltage.c0d \
|
1files/voltage.c0d \
|
||||||
files/debug.int \
|
1files/debug.int \
|
||||||
files/* \
|
files/* \
|
||||||
$dir/$dev
|
$dir/$dev
|
||||||
#sync
|
#sync
|
||||||
|
|
Loading…
Reference in New Issue