Add util scripts

This commit is contained in:
iabdalkader 2014-08-20 22:15:47 +02:00
parent 5d5f801051
commit abe423a3ee
4 changed files with 69 additions and 0 deletions

15
util/client.py Normal file
View File

@ -0,0 +1,15 @@
#! /usr/bin/env python
import time
import select
import socket
ADDR=('192.168.1.101', 8000)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(ADDR)
time.sleep(0.500)
s.send("HelloWorld")
time.sleep(0.500)
print (s.recv(10))
time.sleep(3)
print ("closing")
s.close()

20
util/draw_rainbow.py Executable file
View File

@ -0,0 +1,20 @@
#! /usr/bin/env python
import colorsys
from PIL import Image
NUM_COL=256
SAT=1.0
VAL=1.0
OFFSET=220
tup = [colorsys.hsv_to_rgb(1.0-(i/float(NUM_COL+OFFSET)), SAT, VAL) for i in range(OFFSET, NUM_COL+OFFSET)]
col = [(int(r*255), int(g*255), int(b*255)) for r,g,b in tup]
REPY=3
w=64
h=NUM_COL*REPY
im = Image.new('RGB', (w, h))
for y in range(0, h):
for x in range(0, w):
im.putpixel((x, y), col[y/REPY])
im.show()

23
util/gen_rainbow.py Executable file
View File

@ -0,0 +1,23 @@
#! /usr/bin/env python
import colorsys
NUM_COL=256
SAT=1.0
VAL=1.0
OFFSET=220
tup = [colorsys.hsv_to_rgb(1.0-(i/float(NUM_COL+OFFSET)), SAT, VAL) for i in range(OFFSET, NUM_COL+OFFSET)]
col = [((int(r*255)*31/255)&0x1F)<<11 |
((int(g*255)*63/255)&0x3F)<<5 |
((int(b*255)*31/255)&0x1F) for r,g,b in tup]
print \
"#include <stdint.h>\n"\
"const uint16_t rainbow_table[%d] = {"%(NUM_COL)
for i in range(0, NUM_COL):
if (i%4)==0 and i != (NUM_COL-1):
if i >0:
print ""
print " ",
print "0x%X,"%((col[i] & 0xff)<<8 |(col[i] & 0xff00) >> 8),
print "\n};"

11
util/pll.py Executable file
View File

@ -0,0 +1,11 @@
#! /usr/bin/env python
PLL_M = 6
PLL_N = 360
PLL_Q = 15
PLL_P = 4
HSE_VALUE = 12000000
PLL_VCO = (HSE_VALUE / PLL_M) * PLL_N
print ("PLL_VCO = %d"%PLL_VCO)
print ("SYSCLK = %d"%(PLL_VCO / PLL_P))
print ("USB/SDIO/RNG =%d"%(PLL_VCO / PLL_Q))