{"id":538,"date":"2014-07-02T20:56:44","date_gmt":"2014-07-03T03:56:44","guid":{"rendered":"http:\/\/zethus.ca\/wp\/?p=538"},"modified":"2017-04-01T15:22:27","modified_gmt":"2017-04-01T22:22:27","slug":"geek-and-sundry","status":"publish","type":"post","link":"http:\/\/zethus.ca\/wp\/?p=538","title":{"rendered":"Geek and Sundry"},"content":{"rendered":"<p>Once again I&#8217;ve been remiss with my updates. \u00a0I&#8217;ve been working on a mini mame cabinet, my car computer died, I&#8217;ve been searching for laser engravers and 3d printers, all of which have been proceeding at a snail&#8217;s pace. \u00a0So I wont talk about any of those projects.<\/p>\n<div id=\"attachment_546\" style=\"width: 310px\" class=\"wp-caption alignright\"><a href=\"http:\/\/zethus.ca\/wp\/?attachment_id=546\" rel=\"attachment wp-att-546\"><img aria-describedby=\"caption-attachment-546\" loading=\"lazy\" class=\"size-medium wp-image-546 \" src=\"http:\/\/zethus.ca\/wp\/wp-content\/uploads\/2014\/07\/IMG_1075-300x225.jpg\" alt=\"DirtyPCBs\" width=\"300\" height=\"225\" srcset=\"http:\/\/zethus.ca\/wp\/wp-content\/uploads\/2014\/07\/IMG_1075-300x225.jpg 300w, http:\/\/zethus.ca\/wp\/wp-content\/uploads\/2014\/07\/IMG_1075-1024x768.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-546\" class=\"wp-caption-text\">DirtyPCBs<\/p><\/div>\n<p>I ordered a bunch of pcbs from dirtypcb.com to see what the boards look like. \u00a0Now I have 20 dice boards, 20 oled boards and 10 arcade input controller boards. \u00a0Nice!<\/p>\n<p>I repurposed onc of my dice boards to control a WS2811 LED strip with the intention of making a cool solar powered yard light. \u00a0Along the way I went down another rat hole. \u00a0I&#8217;m completely interrupt driven, I hope I can pop the stack some day. \u00a0Anyway. along the way I stumbled on Gitlab, and spent a couple of weekends getting it working on my raspberry pi. \u00a0For those of you unfamiliar with it, it is like GitHub Enterprise. \u00a0You can use your own servers and have your code in YOUR own cloud. \u00a0It works not too badly, if a little slowly. I&#8217;ll throw some links in at the end of the post. \u00a0So now I have a decent source code control server, no more CVS, SVN, RCS, or just standard git.<\/p>\n<div id=\"attachment_549\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/zethus.ca\/wp\/?attachment_id=549\" rel=\"attachment wp-att-549\"><img aria-describedby=\"caption-attachment-549\" loading=\"lazy\" class=\"size-medium wp-image-549 \" src=\"http:\/\/zethus.ca\/wp\/wp-content\/uploads\/2014\/07\/IMG_1092-300x225.jpg\" alt=\"RPi Gitlab Server\" width=\"300\" height=\"225\" \/><\/a><p id=\"caption-attachment-549\" class=\"wp-caption-text\">RPi Gitlab Server<\/p><\/div>\n<p>I&#8217;ve done tweaks to enable https, so I can open up my router to the external world if I feel like it. Getting the config files set up was a bear, and the PI is SUPER slow. \u00a0If you want to do this, use a VM first, and then copy the config files over to your pi, once it is all working. \u00a0I mount the gitlab repository from a NAS, although you probably wouldn&#8217;t have to, since source code is small, and SD cards are big these days. \u00a0I&#8217;m toying with the idea of putting the filesystem on a usbkey because I hear those are an order of magnitude faster on the pi. \u00a0That doesn&#8217;t really make sense to me since SD cards can be interfaced in 4-bit parallel mode. Enough about Gitlab.<\/p>\n<p>So once again I&#8217;ve used the arduino environment for my dice board. \u00a0I built it up with only the CPU and the reset switch (and the usb jack for power) \u00a0I&#8217;ve soldered a data line to PB0 for the LEDs (this was one of the through holes on the board) , <a href=\"http:\/\/zethus.ca\/wp\/?attachment_id=551\" rel=\"attachment wp-att-551\"><img loading=\"lazy\" class=\"size-medium wp-image-551 alignright\" src=\"http:\/\/zethus.ca\/wp\/wp-content\/uploads\/2014\/07\/IMG_1095-300x225.jpg\" alt=\"CdS Addon\" width=\"300\" height=\"225\" srcset=\"http:\/\/zethus.ca\/wp\/wp-content\/uploads\/2014\/07\/IMG_1095-300x225.jpg 300w, http:\/\/zethus.ca\/wp\/wp-content\/uploads\/2014\/07\/IMG_1095-1024x768.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>\u00a0I also soldered a CDS cell to PC0 (ADC0) with some minor rework to have it act as a voltage divider. Now I have a board that runs leds when it is dark out. \u00a0I&#8217;ve got a buck regulator that bucks down a car battery form 12 to 5v. \u00a0I have a big solar panel that i&#8217;ll just hook straight up to the same car battery with a diode to prevent draining the battery at night.<\/p>\n<div id=\"attachment_553\" style=\"width: 235px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/zethus.ca\/wp\/?attachment_id=553\" rel=\"attachment wp-att-553\"><img aria-describedby=\"caption-attachment-553\" loading=\"lazy\" class=\"size-medium wp-image-553 \" title=\"Dice Board Running LEDs\" src=\"http:\/\/zethus.ca\/wp\/wp-content\/uploads\/2014\/07\/IMG_1096-225x300.jpg\" alt=\"http:\/\/zethus.ca\/wp\/?attachment_id=553\" width=\"225\" height=\"300\" srcset=\"http:\/\/zethus.ca\/wp\/wp-content\/uploads\/2014\/07\/IMG_1096-225x300.jpg 225w, http:\/\/zethus.ca\/wp\/wp-content\/uploads\/2014\/07\/IMG_1096-768x1024.jpg 768w\" sizes=\"(max-width: 225px) 100vw, 225px\" \/><\/a><p id=\"caption-attachment-553\" class=\"wp-caption-text\">Dice Board Running LEDs<\/p><\/div>\n<p>This is lame, but I dont think I&#8217;m in any risk of overcharging the battery. \u00a0 There should be more interesting stuff coming down the pipe soon.<\/p>\n<p>Set up Gitlab on the <a title=\"http:\/\/midnightcodr.github.io\/blog\/2014\/01\/11\/install-gitlab-6-dot-4-on-raspberry-pi\/\" href=\"http:\/\/midnightcodr.github.io\/blog\/2014\/01\/11\/install-gitlab-6-dot-4-on-raspberry-pi\/\">PI<\/a><\/p>\n<p>Set up Gitlab with <a title=\"jonocoetzee.com\/gitlab-with-https-and-two-factor-auth\/\" href=\"http:\/\/jonocoetzee.com\/gitlab-with-https-and-two-factor-auth\/\">https<\/a><\/p>\n<p>Do you want to see some code that I&#8217;m not proud of? No? too bad here it is anyway:<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n#include &lt;Adafruit_NeoPixel.h&gt;\r\n#define PIN 8 \/\/ This is the dice board PB0\/ i.e. pin2 on the &quot;audio&quot; header&quot;\r\n\r\n\/\/ Parameter 1 = number of pixels in strip\r\n\/\/ Parameter 2 = pin number (most are valid)\r\n\/\/ Parameter 3 = pixel type flags, add together as needed:\r\n\/\/ \u00a0 NEO_RGB \u00a0 \u00a0 Pixels are wired for RGB bitstream\r\n\/\/ \u00a0 NEO_GRB \u00a0 \u00a0 Pixels are wired for GRB bitstream\r\n\/\/ \u00a0 NEO_KHZ400 \u00a0400 KHz bitstream (e.g. FLORA pixels)\r\n\/\/ \u00a0 NEO_KHZ800 \u00a0800 KHz bitstream (e.g. High Density LED strip)\r\nAdafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_RGB + NEO_KHZ800);\r\n\r\n\/* hack the prescaler to be a bit faster *\/\r\n#define CLOCK_PRESCALER_1 \u00a0 (0x0)\r\n#define CLOCK_PRESCALER_2 \u00a0 (0x1)\r\n#define CLOCK_PRESCALER_4 \u00a0 (0x2)\r\n#define CLOCK_PRESCALER_8 \u00a0 (0x3)\r\n#define CLOCK_PRESCALER_16 \u00a0(0x4)\r\n#define CLOCK_PRESCALER_32 \u00a0(0x5)\r\n#define CLOCK_PRESCALER_64 \u00a0(0x6)\r\n#define CLOCK_PRESCALER_128 (0x7)\r\n#define CLOCK_PRESCALER_256 (0x8)\r\n\/\/ Initialize global variable.\r\nstatic uint8_t __clock_prescaler = (CLKPR &amp; (_BV(CLKPS0) | _BV(CLKPS1) | _BV(CLKPS2) | _BV(CLKPS3)));\r\n\r\ninline void setClockPrescaler(uint8_t clockPrescaler) {\r\n\u00a0 if (clockPrescaler &lt;= CLOCK_PRESCALER_256) {\r\n\u00a0 \u00a0 \/\/ Disable interrupts.\r\n\u00a0 \u00a0 uint8_t oldSREG = SREG;\r\n\u00a0 \u00a0 cli();\r\n\u00a0 \u00a0 \/\/ Enable change.\r\n\u00a0 \u00a0 CLKPR = _BV(CLKPCE); \/\/ write the CLKPCE bit to one and all the other to zero\r\n\u00a0 \u00a0 \/\/ Change clock division.\r\n\u00a0 \u00a0 CLKPR = clockPrescaler; \/\/ write the CLKPS0..3 bits while writing the CLKPE bit to zero\r\n\u00a0 \u00a0 \/\/ Copy for fast access.\r\n\u00a0 \u00a0 __clock_prescaler = clockPrescaler;\r\n\u00a0 \u00a0 \/\/ Recopy interrupt register.\r\n\u00a0 \u00a0 SREG = oldSREG;\r\n\u00a0 }\r\n}\r\n\r\ninline uint8_t getClockPrescaler() {\r\n\u00a0 return (__clock_prescaler);\r\n}\r\n\r\nvoid setup() {\r\n\u00a0 \/* go fast *\/\r\n\u00a0 setClockPrescaler(0x00);\r\n\u00a0 strip.begin();\r\n\u00a0 strip.show(); \/\/ Initialize all pixels to 'off'\r\n\u00a0\u00a0\r\n\u00a0 analogReference(DEFAULT);\r\n}\r\nvoid loop() {\r\n\u00a0 \/* Determine if it is dark enough out to light leds *\/\r\n\u00a0 uint16_t k;\r\n\u00a0 k = analogRead(0);\r\n\u00a0 k=k\/50;\r\n\u00a0\u00a0\r\n \u00a0if (k&gt;2){\r\n\u00a0  rainbowCycle(20);\r\n\u00a0 }else{\r\n\u00a0   colorWipe(strip.Color(0, 0, 0), 50); \/\/ black\r\n  \u00a0 delay(200);\r\n\u00a0 }\r\n}\r\n\r\n\/\/ Fill the dots one after the other with a color\r\nvoid colorWipe(uint32_t c, uint8_t wait) {\r\n\u00a0 for(uint16_t i=0; i&lt;strip.numPixels(); i++) {\r\n\u00a0 \u00a0 \u00a0 strip.setPixelColor(i, c);\r\n\u00a0 \u00a0 \u00a0 strip.show();\r\n\u00a0 \u00a0 \u00a0 delay(wait);\r\n\u00a0 }\r\n}\r\n\r\n\/\/ Slightly different, this makes the rainbow equally distributed throughout\r\nvoid rainbowCycle(uint8_t wait) {\r\n\u00a0 uint16_t i, j;\r\n\r\n\u00a0 for(j=0; j&lt;256*5; j++) { \/\/ 5 cycles of all colors on wheel\r\n\u00a0 \u00a0 for(i=0; i&lt; strip.numPixels(); i++) {\r\n\u00a0 \u00a0 \u00a0 strip.setPixelColor(i, Wheel(((i * 256 \/ strip.numPixels()) + j) &amp; 255));\r\n\u00a0 \u00a0 }\r\n\u00a0 \u00a0 strip.show();\r\n\u00a0 \u00a0 delay(wait);\r\n\u00a0 }\r\n}\r\n\r\n\/\/ Input a value 0 to 255 to get a color value.\r\n\/\/ The colours are a transition r - g - b - back to r.\r\nuint32_t Wheel(byte WheelPos) {\r\n\u00a0 if(WheelPos &lt; 85) {\r\n\u00a0 \u00a0return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);\r\n\u00a0 } else if(WheelPos &lt; 170) {\r\n\u00a0 \u00a0WheelPos -= 85;\r\n\u00a0 \u00a0return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);\r\n\u00a0 } else {\r\n\u00a0 \u00a0WheelPos -= 170;\r\n\u00a0 \u00a0return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);\r\n\u00a0 }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Once again I&#8217;ve been remiss with my updates. \u00a0I&#8217;ve been working on a mini mame cabinet, my car computer died, I&#8217;ve been searching for laser engravers and 3d printers, all of which have been proceeding at a snail&#8217;s pace. \u00a0So &hellip; <a href=\"http:\/\/zethus.ca\/wp\/?p=538\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[14,5],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/zethus.ca\/wp\/index.php?rest_route=\/wp\/v2\/posts\/538"}],"collection":[{"href":"http:\/\/zethus.ca\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/zethus.ca\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/zethus.ca\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/zethus.ca\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=538"}],"version-history":[{"count":16,"href":"http:\/\/zethus.ca\/wp\/index.php?rest_route=\/wp\/v2\/posts\/538\/revisions"}],"predecessor-version":[{"id":749,"href":"http:\/\/zethus.ca\/wp\/index.php?rest_route=\/wp\/v2\/posts\/538\/revisions\/749"}],"wp:attachment":[{"href":"http:\/\/zethus.ca\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=538"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/zethus.ca\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=538"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/zethus.ca\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=538"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}