Various tweaks
This commit is contained in:
parent
a1b22b436a
commit
58b9fb0bac
@ -7,13 +7,17 @@ import os
|
||||
import unicodedata
|
||||
from PIL import Image, ImageFont, ImageDraw
|
||||
|
||||
|
||||
sys.path.insert(0,"../")
|
||||
BASE_DIR = "../"
|
||||
|
||||
SOL_BLUE = (38, 139, 210)
|
||||
SOL_PINK = (195, 38, 114)
|
||||
SOL_PURPLE = (108, 113, 196)
|
||||
SOL_YELLOW = (181, 137, 0)
|
||||
SOL_GREEN = (133, 153, 0)
|
||||
SOL_RED = (220, 50, 47)
|
||||
SOL_BG = (7, 54, 66)
|
||||
SOL_BG = (0xcc, 0xcc, 0xcc) #586e75
|
||||
|
||||
SOL_BG = tuple([int(x * 1.2) for x in SOL_BG])
|
||||
|
||||
@ -44,7 +48,7 @@ except ImportError:
|
||||
import markjaml
|
||||
import pinout
|
||||
|
||||
output_dir = "api/img"
|
||||
output_dir = "img"
|
||||
|
||||
reload(sys)
|
||||
sys.setdefaultencoding('utf8')
|
||||
@ -82,7 +86,7 @@ def slugify(value):
|
||||
|
||||
def load_overlay(overlay):
|
||||
try:
|
||||
data = markjaml.load('src/{}/overlay/{}.md'.format(lang, overlay))['data']
|
||||
data = markjaml.load('{}/src/{}/overlay/{}.md'.format(BASE_DIR, lang, overlay))['data']
|
||||
slug = slugify(data['name'])
|
||||
data['slug'] = slug
|
||||
|
||||
@ -93,6 +97,7 @@ def load_overlay(overlay):
|
||||
|
||||
return data
|
||||
except IOError:
|
||||
print('Not found: {}/src/{}/overlay/{}.md'.format(BASE_DIR, lang, overlay))
|
||||
return None
|
||||
|
||||
|
||||
@ -147,8 +152,11 @@ for overlay in overlays:
|
||||
y = 1 - ((pin_number-1) % 2)
|
||||
x = (pin_number-1) // 2
|
||||
|
||||
if pin_number in [6, 9, 14, 20, 25, 30, 34, 39] and str(pin_number) in ground:
|
||||
img.putpixel((x, y), (0, 0, 0, 255))
|
||||
if pin_number in [6, 9, 14, 20, 25, 30, 34, 39]:
|
||||
if str(pin_number) in ground:
|
||||
img.putpixel((x, y), (0, 0, 0, 255))
|
||||
else:
|
||||
img.putpixel((x, y), (196, 196, 128, 255))
|
||||
|
||||
elif pin_number in [1, 17] and str(pin_number) in power: # 3v3
|
||||
img.putpixel((x, y), SOL_YELLOW)
|
||||
|
@ -47,6 +47,7 @@ def slugify(value):
|
||||
value = re.sub('[^\w\s-]', '', value).strip().lower()
|
||||
return re.sub('[-\s]+', '_', value)
|
||||
|
||||
product_map = {}
|
||||
|
||||
def load_overlay(overlay):
|
||||
try:
|
||||
@ -60,6 +61,11 @@ def load_overlay(overlay):
|
||||
details = []
|
||||
|
||||
if 'manufacturer' in loaded:
|
||||
if loaded['manufacturer'] == "Pimoroni":
|
||||
if 'buy' in loaded:
|
||||
product_slug = loaded['buy'].split('/')[-1]
|
||||
product_map[product_slug] = slugify(loaded['name'])
|
||||
|
||||
details.append('* Made by ' + loaded['manufacturer'])
|
||||
|
||||
if 'pincount' in loaded:
|
||||
@ -99,9 +105,10 @@ def load_overlay(overlay):
|
||||
if '3' in loaded['pin'] and '5' in loaded['pin']:
|
||||
pin_3 = loaded['pin']['3']
|
||||
pin_5 = loaded['pin']['5']
|
||||
if 'mode' in pin_3 and 'mode' in pin_5:
|
||||
if pin_3['mode'] == 'i2c' and pin_5['mode'] == 'i2c':
|
||||
details.append('* Uses I2C')
|
||||
if pin_3 is not None and pin_5 is not None:
|
||||
if 'mode' in pin_3 and 'mode' in pin_5:
|
||||
if pin_3['mode'] == 'i2c' and pin_5['mode'] == 'i2c':
|
||||
details.append('* Uses I2C')
|
||||
|
||||
if 'url' in loaded:
|
||||
details.append('* [More Information]({url})'.format(url=loaded['url']))
|
||||
@ -132,4 +139,5 @@ def load_md(filename):
|
||||
|
||||
overlays = map(load_overlay, overlays)
|
||||
|
||||
print(json.dumps(overlays))
|
||||
#print(json.dumps(overlays))
|
||||
print(json.dumps(product_map))
|
29
pinout.py
29
pinout.py
@ -1,5 +1,8 @@
|
||||
import json
|
||||
import time
|
||||
import os
|
||||
|
||||
print(__file__)
|
||||
|
||||
try:
|
||||
import yaml
|
||||
@ -11,11 +14,13 @@ PINOUT_FILE = 'pinout.yaml'
|
||||
SETTINGS_FILE = 'settings.yaml'
|
||||
STRINGS_FILE = 'localised.yaml'
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
pins = None
|
||||
settings = None
|
||||
|
||||
master_template = open('common/layout.html').read()
|
||||
twitter_template = open('common/twittercard.html').read()
|
||||
master_template = open(os.path.join(BASE_DIR,'common/layout.html')).read()
|
||||
twitter_template = open(os.path.join(BASE_DIR,'common/twittercard.html')).read()
|
||||
|
||||
|
||||
def get_setting(setting, default = None):
|
||||
@ -106,16 +111,24 @@ def physical_to(pin, scheme='bcm'):
|
||||
|
||||
def load(lang='en'):
|
||||
global pins, settings, strings
|
||||
|
||||
settings_path = os.path.join(BASE_DIR,'src/{}/{}'.format(lang, SETTINGS_FILE))
|
||||
strings_path = os.path.join(BASE_DIR,'src/{}/template/{}'.format(lang, STRINGS_FILE))
|
||||
pinout_path = os.path.join(BASE_DIR,'src/{}/template/{}'.format(lang, PINOUT_FILE))
|
||||
|
||||
if SETTINGS_FILE.endswith('.yaml'):
|
||||
settings = yaml.load(open('src/{}/{}'.format(lang, SETTINGS_FILE)).read())
|
||||
settings = yaml.load(open(settings_path).read())
|
||||
else:
|
||||
settings = json.load(open('src/{}/{}'.format(lang, SETTINGS_FILE)))
|
||||
settings = json.load(open(settings_path))
|
||||
|
||||
if STRINGS_FILE.endswith('.yaml'):
|
||||
strings = yaml.load(open('src/{}/template/{}'.format(lang, STRINGS_FILE)).read())
|
||||
strings = yaml.load(open(strings_path).read())
|
||||
else:
|
||||
strings = json.load(open('src/{}/template/{}'.format(lang, STRINGS_FILE)))
|
||||
strings = json.load(open(strings_path))
|
||||
|
||||
if PINOUT_FILE.endswith('.yaml'):
|
||||
pinout = yaml.load(open('src/{}/template/{}'.format(lang, PINOUT_FILE)).read())
|
||||
pinout = yaml.load(open(pinout_path).read())
|
||||
else:
|
||||
pinout = json.load(open('src/{}/template/{}'.format(lang, PINOUT_FILE)))
|
||||
pinout = json.load(open(pinout_path))
|
||||
|
||||
pins = pinout['pins']
|
||||
|
Loading…
Reference in New Issue
Block a user