diff --git a/README.md b/README.md index cb3ae20..894f212 100644 --- a/README.md +++ b/README.md @@ -16,35 +16,49 @@ them, how they can better support translation and any other suggestions you migh #Contributing -The contents of this GitHub repository are used to build http://pi.gadgetoid.com/pinout. +If you have a board you'd like to contribute, raise an issue and we'll consider it! -If you have a board you'd like to contribute, you should look at these folders: +#Translating -* [overlay/](overlay/) -* [description/overlay/](description/overlay/) +The contents of this GitHub repository are used to build http://pinout.xyz and its translated subdomains. + +Current known contributors are: + +* tr-TR - @Ardakilic +* fr-FR - @RogueM + +We're looking for ( based on traffic ): + +* German, de-DE +* Italian, it-IT +* Spanish ( Spain ), es-ES +* Polish pl-PL +* And any others! + +You should start by duplicating the `src/en-GB` directory to the +appropriate culture. For example if you want to create a German translation you would create the folder `src/de-DE`. + +At the moment cultures are not fully supported, so you can't have `src/fr-CA` ( sorry! ), and there are no plans for this. + +Once you've made your translation, build and preview it with, for example: + +```bash +make serve LANG=de-DE +``` + +And then open: http://127.0.0.1:5000 in your browser. + +Please do not attempt to translate the `/resources` folder, this is shared between sites on the server and should be generic. + +Feel free to modify the template with links relevent to your country, and your Twitter handle but don't fiddle with the structure! + +Submit your finished translation as a pull request and I'll get it live on pinout.xyz. #Roadmap -##Phase 1 - -Replace the current Pinout site with a generated version built from this repository, aim for 100% compatibility. - -* Drop ancient and redundant boards such as ladder, Clockatoo -* Replace things like Arduino with more relevant and up-to-date alternatives ( Alex's PiDuino ) -* Compliment Pibrella with Explorer HAT (Pro) - -##Phase 2 - -Redesign UI to support browsing a wider variety of boards and viewing their pinouts, description, links to library -+ buy links etc. - +* Redesign UI to support browsing a wider variety of boards and viewing their pinouts ( partially done with drop down ) * Replace top tabs with some sort of search functionality or easy categorised UI for finding boards * Allow for slightly longer descriptions of Pin functions ( baloons? ), current width is very restrictive - -##Phase 3 - -Introduce advanced functionality such as board compatibility checks and more detailed overlays on Pin alt functions. - * Does X board work with Y board -* What extra functions does this pin have -* Convert WiringPi to GPIO to BCM and back +* What extra functions does this pin have ( mostly done with ALT functions tables, but needs descriptions ) +* Tool to convert WiringPi to GPIO to BCM and back \ No newline at end of file diff --git a/generate-html.py b/generate-html.py index 31eb2c6..3701fc3 100755 --- a/generate-html.py +++ b/generate-html.py @@ -14,67 +14,6 @@ import urlmapper reload(sys) sys.setdefaultencoding('utf8') -lang = "en-GB" -default_strings = { - 'made_by': '* Made by {manufacturer}', - 'type_hat': '* HAT form-factor', - 'type_classic': '* Classic form-factor', - 'pin_header': '* {} pin header', - 'uses_i2c': '* Uses I2C', - 'wiring_pi_pin': 'Wiring Pi pin {}' -} - -if len(sys.argv) > 1: - lang = sys.argv[1] - -alternate_urls = urlmapper.generate_urls(lang) - -pinout.load(lang) - -overlays = pinout.settings['overlays'] - -strings = pinout.get_setting('strings',{}) - -if type(strings) == list: - _strings = {} - for item in strings: - _strings[item.keys()[0]] = item.values()[0] - strings = _strings - -for key, val in default_strings.items(): - if key not in strings: - strings[key] = val - - -base_url = pinout.get_setting('base_url','/pinout/') # '/pinout-tr/pinout/' -resource_url = pinout.get_setting('resource_url','/resources/') # '/pinout-tr/resources/' -url_suffix = pinout.get_setting('url_suffix','') # '.html' - -template = open('src/{}/template/layout.html'.format(lang)).read() - -pages = {} -navs = {} -select_overlays = [] - -overlays_html = '' - - -if not os.path.isdir('output'): - try: - os.mkdir('output') - except OSError: - exit('Failed to create output dir') -if not os.path.isdir('output/{}'.format(lang)): - try: - os.mkdir('output/{}'.format(lang)) - except OSError: - exit('Failed to create output/{} dir'.format(lang)) -if not os.path.isdir('output/{}/pinout'.format(lang)): - try: - os.mkdir('output/{}/pinout'.format(lang)) - except OSError: - exit('Failed to create output/{}/pinout dir'.format(lang)) - def cssify(value): value = slugify(value); if value[0] == '3' or value[0] == '5': @@ -356,6 +295,102 @@ def render_nav(url, overlay=None): '''.format(html_odd, html_even) +def get_hreflang_urls(src): + hreflang = [] + for lang in alternate_urls: + if src in alternate_urls[lang]: + url = alternate_urls[lang][src] + hreflang.append(''.format( + lang=lang, + url=url + )) + return hreflang + + +def get_lang_urls(src): + urls = [] + for url_lang in alternate_urls: + if src in alternate_urls[url_lang]: + img_css = '' + if url_lang == lang: + img_css = ' class="grayscale"' + url = alternate_urls[url_lang][src] + urls.append('
  • '.format( + lang=url_lang, + url=url, + resource_url=resource_url, + css=img_css + )) + return urls + + + +''' +Main Program Flow +''' + + +lang = "en-GB" +default_strings = { + 'made_by': '* Made by {manufacturer}', + 'type_hat': '* HAT form-factor', + 'type_classic': '* Classic form-factor', + 'pin_header': '* {} pin header', + 'uses_i2c': '* Uses I2C', + 'wiring_pi_pin': 'Wiring Pi pin {}' +} + +if len(sys.argv) > 1: + lang = sys.argv[1] + +alternate_urls = urlmapper.generate_urls(lang) + +pinout.load(lang) + +overlays = pinout.settings['overlays'] + +strings = pinout.get_setting('strings',{}) + +if type(strings) == list: + _strings = {} + for item in strings: + _strings[item.keys()[0]] = item.values()[0] + strings = _strings + +for key, val in default_strings.items(): + if key not in strings: + strings[key] = val + + +base_url = pinout.get_setting('base_url','/pinout/') # '/pinout-tr/pinout/' +resource_url = pinout.get_setting('resource_url','/resources/') # '/pinout-tr/resources/' +url_suffix = pinout.get_setting('url_suffix','') # '.html' + +template = open('src/{}/template/layout.html'.format(lang)).read() + +pages = {} +navs = {} +select_overlays = [] + +overlays_html = '' + + +if not os.path.isdir('output'): + try: + os.mkdir('output') + except OSError: + exit('Failed to create output dir') +if not os.path.isdir('output/{}'.format(lang)): + try: + os.mkdir('output/{}'.format(lang)) + except OSError: + exit('Failed to create output/{} dir'.format(lang)) +if not os.path.isdir('output/{}/pinout'.format(lang)): + try: + os.mkdir('output/{}/pinout'.format(lang)) + except OSError: + exit('Failed to create output/{}/pinout dir'.format(lang)) + overlays = map(load_overlay,overlays) @@ -381,24 +416,12 @@ for pin in range(1,len(pinout.pins)+1): if pin_url == None: continue - hreflang = [] - - src = 'pin{}'.format(pin) - - for code in alternate_urls: - if src in alternate_urls[code]: - alt = alternate_urls[code][src] - code_lang = code.split('-')[0] + '.' - if code_lang == 'en.': - code_lang = '' - hreflang.append(''.format( - lang=code_lang, - alt=alt, - code=code - )) + hreflang = get_hreflang_urls('pin{}'.format(pin)) + langlinks = get_lang_urls('pin{}'.format(pin)) pin_nav = render_nav(pin_url) pin_html = pinout.render_html(template, + lang_links="\n\t\t".join(langlinks), hreflang = "\n\t\t".join(hreflang), nav = pin_nav, content = pin_html, @@ -420,32 +443,16 @@ for url in pages: content = pages[url]['rendered_html'] nav = navs[url] hreflang = [] + langlinks = [] if url == 'index': - for code in alternate_urls: - code_lang = code.split('-')[0] + '.' - if code_lang == 'en.': - code_lang = '' - hreflang.append(''.format( - lang=code_lang, - alt=alt, - code=code - )) + hreflang = get_hreflang_urls('index') + langlinks = get_lang_urls('index') if 'src' in pages[url]: src = pages[url]['src'] - - for code in alternate_urls: - if src in alternate_urls[code]: - alt = alternate_urls[code][src] - code_lang = code.split('-')[0] + '.' - if code_lang == 'en.': - code_lang = '' - hreflang.append(''.format( - lang=code_lang, - alt=alt, - code=code - )) + hreflang = get_hreflang_urls(src) + langlinks = get_lang_urls(src) if not 'description' in pages[url]: pages[url]['description'] = pinout.settings['default_desc'] @@ -456,6 +463,7 @@ for url in pages: pages[url]['name'] = pinout.settings['default_title'] html = pinout.render_html(template, + lang_links="\n\t\t".join(langlinks), hreflang = "\n\t\t".join(hreflang), nav = nav, content = content, diff --git a/resources/gb.png b/resources/en-GB.png similarity index 100% rename from resources/gb.png rename to resources/en-GB.png diff --git a/resources/fr-FR.png b/resources/fr-FR.png new file mode 100755 index 0000000..8332c4e Binary files /dev/null and b/resources/fr-FR.png differ diff --git a/resources/tr.png b/resources/tr-TR.png similarity index 100% rename from resources/tr.png rename to resources/tr-TR.png diff --git a/src/en-GB/overlay/spi.md b/src/en-GB/overlay/spi.md index 34e04f8..2424228 100644 --- a/src/en-GB/overlay/spi.md +++ b/src/en-GB/overlay/spi.md @@ -44,23 +44,19 @@ pin: --> #SPI - Serial Peripheral Interface -###Known as the four-wire serial bus, SPI lets you daisy-chain multiple compatible devices off a single set of pins by assigning them different addresses. +###Known as the four-wire serial bus, SPI lets you daisy-chain multiple compatible devices off a single set of pins by assigning them different chip-select pins. -A simple example of an SPI peripheral is the MCP23S17 digital IO expander chip Note the S in place of the 0 found on the I2C version. Using it in WiringPi2 is a doddle: +A useful example of an SPI peripheral is the MCP23S17 digital IO expander chip Note the S in place of the 0 found on the I2C version. + +To talk to an SPI device, you assert its corresponding chip-select pin. By default the Pi has CE0 and CE1. ```python -import wiringpi2 as wiringpi -HIGH = 1 -OUTPUT = 1 -PIN_BASE = 65 -SPI_ADDR = 0x20 -wiringpi.wiringPiSetup() -wiringpi.mcp23S17Setup(PIN_BASE,SPI_ADDR) -# 16 pins including the starting pin -mcp23S17pins = range(PIN_BASE,PIN_BASE+15) -for pin in mcp23S17pins: - wiringpi.pinMode(pin,OUTPUT) - wiringpi.digitalWrite(pin,HIGH) +import spidev + +spi = spidev.SpiDev() +spi.open(0, CHIP_SELECT_0_OR_1) +spi.max_speed_hz = 1000000 +spi.xfer([value_8bit]) ``` You can also use the SPI port to "Bit-Bang" an ATmega 328, loading Arduino sketches onto it with Gordon's modified version of AVRDude. diff --git a/src/en-GB/settings.yaml b/src/en-GB/settings.yaml index b9cc54f..b4d3abf 100644 --- a/src/en-GB/settings.yaml +++ b/src/en-GB/settings.yaml @@ -5,6 +5,7 @@ default_title: Raspberry Pi GPIO Pinout - Pi 1, B+, Pi 2 title_suffix: " at Raspberry Pi GPIO Pinout" base_url: /pinout/ resource_url: /resources/ +domain: pinout.xyz url_suffix: urls: GND: ground diff --git a/src/en-GB/template/layout.html b/src/en-GB/template/layout.html index 18a5e2f..8459510 100755 --- a/src/en-GB/template/layout.html +++ b/src/en-GB/template/layout.html @@ -24,12 +24,11 @@

    Raspberry Pinout

    diff --git a/src/fr-FR/settings.yaml b/src/fr-FR/settings.yaml index 2af5b36..90b55b1 100644 --- a/src/fr-FR/settings.yaml +++ b/src/fr-FR/settings.yaml @@ -5,6 +5,7 @@ default_title: Raspberry Pi GPIO Pinout - Pi 1, B+, Pi 2 title_suffix: " at Raspberry Pi GPIO Pinout" base_url: /pinout/ resource_url: /resources/ +domain: fr.pinout.xyz url_suffix: urls: GND: ground diff --git a/src/fr-FR/template/layout.html b/src/fr-FR/template/layout.html index 6c07810..a8808c9 100644 --- a/src/fr-FR/template/layout.html +++ b/src/fr-FR/template/layout.html @@ -2,6 +2,7 @@ {{title}} + @@ -9,6 +10,7 @@ + {{hreflang}}
    -

    Raspberry Pinout

    +

    Raspberry Pinout

    Raspberry Pi Eklenti kartları ve özellikleri