f-log

just another web log

30 Jan 2014:
Flatlands many dimensions and Enders battle with battle school
Over the years I have heard two names come up under "books you must read" and in most cases the reference has indicated that at this age you should have already read them.
Book one is over 120 years old! Well not my copy but the original printing.

"Flatland - A Romance of Many Dimensions"
This just about the most unexpected thing you can imagine coming from 1884. It is in the broadest sense Science Fiction, but do not let that put you off. It is an amazingly detailed journey into a two dimensional world and eventually a one,zero and three dimensional worlds.
It is difficult to explain but basically a entity in the two dimensional world explains in painful detail how his world works, from the physical to political, through social and bit of religion. All from his point of view. Then he travels in to the third dimension but cannot express the experience to anyone else. Followed by a trip to one dimensional world finding himself unable to communicate with the beings there and then a zero dimension where there is nothing but a single entity that believes itself to be all there is in the universe.
What is so remarkable about this book is simply the fact it works perfectly well in the twenty first century as it did when it was published. I really had a lot of fun reading this and it has made me think about the possibility of a forth or more dimensions.
It's only 83 pages long so go and get it and read it now!

Book two is also not particularly new, originally published in 1985 it has recently been made into a film, that I am reliably informed is terrible.

"Ender's Game" by Orson Scott Card.
I was concerned this was a kids si-fi book, but I should not have been concerned. This gritty drama is played from almost exclusively one character, Ender. Who at the beginning of the book is just 6 years old but very quickly has to grow up. The other main characters in the book are his siblings who concoct a political plot but this is very much in the background. All the focus is on Ender and his ability to face and pass just about any test that the "teachers" throw at him in battle school. You see, Ender is the last hope for mankind and they will stop at nothing to ensure his final success.
This is compelling stuff, but I now unsure if I should obtain other books from the series, the story is pretty wrapped up. Still, I can see why people rate it so highly, go get it!

FYI the next fiction book I have in the wings is "Do Androids Dream of Electric Sheep", but that may have to wait as I have a number of non-fiction titles in the queue.
28 Jan 2014:
HTML5 colour sphere gradient picker
This HTML5 colour sphere picker/grouper thingy is cool!
http://mudcu.be/sphere/

It has multiple grouping options, from grouped(together) to deliberately clashing colours and many other in between. You can view the sphere as a vision impaired person would see it, eight variations. You can set it to only show All, WebSmart or WebSafe colours.

You can export gradients to Illustrator, Photoshop and you can set a Dark or Light theme while using it, which seems frivolous but makes a huge difference, try it.

Oh and did I mention its is open source ?
https://github.com/mudcube/Color.Picker.js/tree/master/Mini-Sphere

28 Jan 2014:
PiGlow makes me pi eyed
I got various geeky bits for Christmas, including a Dilbert calendar and couple of electronic hacking books, but what I really wanted to play with was the PiGlow.
http://www.amazon.co.uk/PiGlow-visual-feedback-your-Raspberry/dp/B00EOP1N1M

Cheap(£10<), Cheerful(pre-build) and Dangerous(eyeball burningly bright).

The board is quite small and sits very neatly on the Raspberry Pi with no overlap. Apparently it will fit within most cases due to its low profile.

But what is it?
Put bluntly is is a collection of eighteen individually addressable super bright LEDs arranged in a spiral sitting on a pre-built small, low profile board that attached to the Raspberry Pi The LEDs colour cannot be changed but the layout gives you a surprising number of options.

Overhead photo of the PiGlow attached to a Raspberry Pi

The setup was dead easy and very similar to the Pi Matrix

Edit the /etc/modules file and making sure the linesi2c-dev
i2c-bcm2708
are in there(or adding them).
Editing the /etc/modprobe.d/raspi-blacklist.conf file and making sure blacklist spi-bcm2708
blacklist i2c-bcm2708
are commented out i.e. #blacklist spi-bcm2708
#blacklist i2c-bcm2708

Installing Python support and i2csudo apt-get install python-smbus
Reboot...

and at this point I wanted to try the Pi Matrix i2c tricks but neither sudo i2cdetect -y 1
sudo i2cdetect -y 0
returned any results :(

The demo code is a single Python scriptwget https://github.com/pimoroni/piglow/blob/master/examples/piglow-example.py

!WARNING! before running the demo cover the PiGlow with at least two sheets of paper, this puppy is *BRIGHT*

python piglow-example.py
Seriously, I just ran it and I now had spots before my eyes, VERY BRIGHT!
The Demo has all the LEDs on but at different levels of intensity, with a progression of each LED changing intensity in turn. Difficult to explain but nice and pretty.

First job, turn down the intensity. The code is quite short and I quickly identified this array as the intensity levels.
values = [0x01,0x02,0x04,0x08,0x10,0x18,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xA0,0xC0,0xE0,0xFF]
So changing that to some smaller values such as values = [0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0F,0x10,0x11,0x12]
made the animation a bit more bearable, still quite bright but not so eye melting.

The march of the animation does not seem to follow a logical pattern so I quickly copied the example Python script and made it only turn on the LED I passed to the script from the command line. One by one I mapped the number to the following diagram.

Overhead photo of the PiGlow over laid with numeric labels indicating their addresses

Once I had those it was easy(ish) to make the PiGlow arms animate in sequence, getting faster and faster.


# PiGlow code that creates an animation of the arms steadily increasing in speed
#
# Based on the demo code from: https://github.com/pimoroni/piglow
#
# LEDs are cleared once animation is complete

import time
import sys
from smbus import SMBus

# command register addresses for the SN3218 IC used in PiGlow
CMD_ENABLE_OUTPUT = 0x00
CMD_ENABLE_LEDS = 0x13
CMD_SET_PWM_VALUES = 0x01
CMD_UPDATE = 0x16

class PiGlow:
    i2c_addr = 0x54 # fixed i2c address of SN3218 ic
    bus = None

    def __init__(self, i2c_bus=1):
        self.bus = SMBus(i2c_bus)

        # first we tell the SN3218 to enable output (turn on)
        self.write_i2c(CMD_ENABLE_OUTPUT, 0x01)

        # then we ask it to enable each bank of LEDs (0-5, 6-11, and 12-17)
        self.write_i2c(CMD_ENABLE_LEDS, [0xFF, 0xFF, 0xFF])

    def update_leds(self, values):
        print "update pwm"
        self.write_i2c(CMD_SET_PWM_VALUES, values)
        self.write_i2c(CMD_UPDATE, 0xFF)

    # a helper that writes the given value or list of values to the SN3218 IC
    # over the i2c protocol
    def write_i2c(self, reg_addr, value):
        # if a single value is provided then wrap it in a list so we can treat
        # all writes in teh(*sic) same way
        if not isinstance(value, list):
            value = [value];

        # write the data to the SN3218
        self.bus.write_i2c_block_data(self.i2c_addr, reg_addr, value)

# create an instance of our PiGlow class and tell it that "1" is the I2C bus
# index (should be 0 for old old old Pis)
piglow = PiGlow(1)

# set a block of LEDs and clear them after a delay
def setLeds(ids,delay) :
    values=[]
    for i in range(0,18) :
        values.append(0x00)
    
    for id in ids :
        values[id]=0x01 # set this to 0xFF for eye burning brightness

    piglow.update_leds(values)
    sleep = float(delay)/10
    time.sleep(sleep)

    values = [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]
    piglow.update_leds(values)

for delay in range (8,0,-1) :
    ids=[0,1,2,3,14,12]
    setLeds(ids,delay)
    ids=[17,16,15,13,11,10]
    setLeds(ids,delay)
    ids=[4,5,6,7,8,9]
    setLeds(ids,delay)

# add 10 extra spins at high speed for fun
for counter in range (0,10) :
    ids=[0,1,2,3,14,12]
    setLeds(ids,0.5)
    ids=[17,16,15,13,11,10]
    setLeds(ids,0.5)
    ids=[4,5,6,7,8,9]
    setLeds(ids,0.5)


For the money the PiGlow is well recommended!
17 Jan 2014:
Tasty KitKat fixes Moto G sideloading woes
News update ...

That thing that I was going to discuss that was a wrinkle for the Moto G has been fixed!

It was that I could not side-load any apps on the phone. Understand any of that?
Apps for the Android phone are delivered in .APK files (that are just renamed zip files). If you install from the Google Play store then the store app has permission to install the .APK file and everything just works. But, if you want to use another app store like
http://www.amazon.co.uk/appstore
or
https://f-droid.org/

Then their store apps have to be able to install the .APK files but due to a bug that was not possible on the Moto G.
Perhaps more annoying was you could not separately download one of these .APK files and install it yourself, this includes developers producing .APK files.

But there was a little light at the end of the tunnel. If you had the phone physically attached to a computer running the Android development tools then you could install from there.

The way I had to install .APK files was to download them to the phone, then upload them to Google drive and then try and open them from Google drive, as that app had permissions to install.

(FYI. I had enabled "install from other sources" which is what normally stops you installing .APK files by accident on Android phones.

The update to KitKat has fixed it.

and a quick KitKat tit-bit;

Goto "Settings" and "About Phone", keep tapping the version number and then keep tapping the big "K", when the red KitKat wrapper comes up hold your finger on it and it will transform into a tile animation.
A colleague at work tried the same on his Jelly Bean Android phone and he got a Jelly Bean animation.
loading results, please wait loading animateloading animateloading animate
[More tags]
rss feed

email

root

flog archives


Disclaimer:
This page is by me for me, if you are not me then please be aware of the following
I am not responsible for anything that works or does not work including files and pages made available at www.jumpstation.co.uk I am also not responsible for any information(or what you or others do with it) available at www.jumpstation.co.uk
In fact I'm not responsible for anything ever, so there!

[Pay4Foss banner long]