Display-O-Tron 3000

… one last one - how can I turn off the backlight? or find a list of options I can do without trying to take apart the sample code ?

Thanks =:-)

You can use: backlight.rgb(0,0,0) which will definitely turn it off.

As for list of options, you can try Python’s dir() and help() commands, which should be useful:

pi@maxim ~/Development/dot3k/python/examples/advanced $ sudo python
Python 2.7.3 (default, Mar 18 2014, 05:13:23)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dot3k.backlight
>>> dir(dot3k.backlight)
['LED_L_B', 'LED_L_G', 'LED_L_R', 'LED_M_B', 'LED_M_G', 'LED_M_R', 'LED_R_B', 'LED_R_G', 'LED_R_R', '__builtins__', '__doc__', '__file__', '__name__', '__package__', 'colorsys', 'g_channel_gamma', 'hue', 'hue_to_rgb', 'i', 'leds', 'left_hue', 'left_rgb', 'math', 'mid_hue', 'mid_rgb', 'r_channel_gamma', 'rgb', 'right_hue', 'right_rgb', 'set', 'set_bar', 'set_graph', 'sn3218', 'sweep', 'update', 'use_rbg', 'value', 'w_channel_gamma']

I’m starting to suspect I should add an off() command. It’d be a convenience method that would call:

dot3k.backlight.rgb(0,0,0)

Thanks … got a nice little script running a treat - all good !

I have pushed a new version of Dot3k up to pip, this includes two new methods in Dot3k backlight:

  • off() - turns off all the LEDs
  • use_rbg() - changes the LED order for those of you with early Dot3k boards

I want to get the DOT3K running when I switch my Pi on, is there a script I can add to start up to switch it on?

At present, I’m manually entering:

\curl https://get.pimoroni.com/dot3k | bash

…then going through the process of saying that I do want to enable IC2, etc. and saying that I don’t want to reinstall files. It feels very clunky. Am I doing this all correctly? I just want to turn it on.

Apologies, by the way: I’m very new to all this. I’m having a great time using the Pi though!

That’s the process of installing Dot3k, you only have to do it once.

Once done, you should see a folder in your home directory. This is usually the directory you’re in when you start up your Pi, otherwise you can get to it by typing this into a terminal:

cd ~

Once there, you should look at the contents:

ls

And you should see a Pimoroni folder. Enter it:

cd Pimoroni

And you’ll hopefully find the example code for Dot3k, which you can run to make it do various out-of-the-box things. Try this for example:

cd ~/Pimoroni/dot3k/advanced
sudo ./menu.py

Good luck!

So what I’m doing everytime is reinstalling it, then opening the python files for the DOT3K? Whoops!

Thank you so much! That’s a massive help.

Has anyone tried getting this working with Arch linux or is it only possible with Raspian?

It think it’s possible under Arch Linux, but we only officially support Raspbian and I’ve not run Arch on a Pi for about 2 years.

The install script explicitly looks for Raspbian because I have absolutely no idea what might explode if it does the same steps under Arch Linux, and I don’t want people to trash their systems with untested code.

You can probably set up i2c/spi separately, and then:

sudo pip install dot3k
git clone https://github.com/pimoroni/dot3k

And run the examples from the cloned GitHub directory.

Yup, did that part but it seems blocked on the kernel module. I’ll see if I can get it working for Arch. If not then Raspian is just an SD Card flash away. :) I was just hopig to avoid setting everything back up if I didn’t have to.

Hello,

I buy a Dot3k and try to use.
Do any one know how print ♥ on Dot3K?
I use python.
Thanks.

I just got my Dot3k today but looking here:

https://github.com/pimoroni/dot3k/blob/master/python/library/dot3k/lcd.py

it seems theres a

 `def create_char(char_pos, char_map)`: 

method which should do what you want and you can see examples of it being used here:

https://github.com/pimoroni/dot3k/blob/master/python/examples/advanced/animations.py

The bit I missed out is that I don’t think (@Gadgetoid might correct me) there is a heart in the default character set (at least not in the reference I found on twitter by googling!) but you can define your own as an 8x8 sprite.

If you want a really simple custom character example…

import dot3k.lcd as lcd
lcd.create_char(0,[0,31,5,1,0,2,8,7])
lcd.set_cursor_position(0,0)
lcd.write('Hello ' + chr(0))

each number in the list is a row of 8 dots expresses as binary, so if you wanted just the last dot of the first row to be “on” you’d make the first number (for the first row) a 1, if you wanted the second to last dot on you’d make the first number a 2, for both the last two dots 3, and so on. Think of each row as a number in binary and then convert. There is an example above where this makes a nice heart:

[0x00,0x0a,0x1f,0x1f,0x1f,0x0e,0x04,0x00]

Indeed, there’s no heart and lcd.create_char is the way to go about it!

See page 5 here for the built-in characters: http://www.lcd-module.com/eng/pdf/doma/dog-me.pdf

Here’s an easy way to express characters in Python, note that like Gisky says each row is represented by a single binary number- however there are only 5 dots a row ( the letters are 5 wide, 8 tall ). These are the least significant bits of each row number; ie: 0b000XXXXX

So for each binary number, which we can express in Python as 0b00000000, we ignore the first 3 bits.

To draw a box:

lcd.create_char(0,  # Index of the character ( 0 - 7 )
[
0b00011111,
0b00010001,
0b00010001,
0b00010001,
0b00010001,
0b00010001,
0b00010001,
0b00011111
]
)

Notice that you can quite clearly see what the graphic is, from which bits are 1 and which are 0.

So let’s convert Gisky’s heart into binary:

lcd.create_char(0,  # Index of the character ( 0 - 7 )
[
0b00000000,
0b00001010,
0b00011111,
0b00011111,
0b00011111,
0b00001110,
0b00000100,
0b00000000
]
)

Okay, the heart isn’t quite so clear because our font is much taller than it is wide- but it’s an easy way to play with icons on Dot3k!

The chr(0) ( you can use chr(0) to chr(7) tells the LCD which custom character you want to display. Once you’ve displayed it, the character will automatically change every time you call lcd.create_char, so you can run an interactive Python shell and test all the patterns you might need.

###Random Python bin/hex stuff…

In Python you’ll find the bin and hex functions useful for converting to binary and hex, but you can also just type a binary or hex number in to an interactive Python shell to convert back:

>>> hex(1)
'0x1'
>>> bin(1)
'0b1'
>>> 0x567
1383
>>> 0b101010101
341

Binary is base 2, and hex is base 16, so to convert these string representations back to their numeric variants in python you would use:

>>> int('0xfc',16)
252
>>> int('0b001110',2)
14
1 Like

Ok, I’m getting errors on a new install on a new RPi2. This is the error message I get:

Traceback (most recent call last):
  File "./menu.py", line 5, in <module>
    import dot3k.backlight as backlight
  File "/usr/local/lib/python2.7/dist-packages/dot3k/backlight.py", line 1, in <module>
    import sn3218, colorsys, math
  File "/usr/local/lib/python2.7/dist-packages/sn3218.py", line 98, in <module>
    enable_leds(0b111111111111111111)
  File "/usr/local/lib/python2.7/dist-packages/sn3218.py", line 55, in enable_leds
    i2c.write_i2c_block_data(address, CMD_ENABLE_LEDS, [enable_mask & 0x3F, (enable_mask >> 6) & 0x3F, (enable_mask >> 12) & 0X3F])
IOError: [Errno 5] Input/output error

Any ideas? I’ve ran sudo apt-get update and sudo apt-get upgrade etc etc (I had it working before), but for some reason is not on this RPi2.

FYI - I did install the Piglow and was using as a system monitor for my headless usenet downloader, but I wanted to use the DOT3K instead because it is fancier.

Hang on. I tried the old re-plugin method and it seemed to work (as in I unplugged the DOT3K then plugged it back in). Odd.

Update - It is now not performing properly - the backlights don’t seem to work properly (not lighting up very well) and then when I select the menu.py example in the advanced folder, it jumps around all over the place.

Update 2 - It was my Piglow script running at the same time that caused the issues. I stopped this from starting at boot and then tried the DOT3K menu.py example and hey-presto. Sorry for all the posts. Didn’t realise I could edit!

1 Like

quick note to say: the latest Raspbian Wheezy updates to raspberrypi-bootloader, libraspberrypi, i2c-tools and python-smbus (available as part of the Raspbian 2015-05-05 image, and pulled from repo at this point in time) left my dot3k fully functioning!

Of course that is the whole point, but since I have been holding back till the weekend, I thought I’d post in case anyone was unsure about taking the plunge ;-)

2 Likes

Does anybody know if the DOT3K is compatible with OpenELEC / Kodi? There is a way to enable LCD support in OpenELEC’s configuration programme, but it asks for specific drivers etc…

I have absolutely no idea how that even works- presumably it’s using LCDProc.

My key is that a custom driver would need writing, in C, which exposes the right interface and uses a GPIO library ( probably WiringPi ) to drive Dot3k.

I’m sure this is possible. Have you tried looking for an LCDProc driver for the “ST7036” which is the controller used in the Dot3k display?

A quick look at the LCDProc changelog reveals:

`
v0.5.3

  • hd44780 driver: add lineaddress option to support ST7036 (Malte Poeggel)`

This would suggest that hd44780 is the correct driver choice for Dot3k, but whether or not any of the off-the-shelf drivers would actually work remains to be seen. I’d expect not.

Someone with the time/inclination ( that might be me if this stick in the back of my head, but I’m short on time ) needs to reconcile:

with

https://github.com/pimoroni/st7036/blob/master/python/st7036.py

And add support for the SN3218 backlight driver, too!

( There’s an RPi driver which will certainly be useful, but it’s for the display in 4-bit mode, which is not how we have it hooked up on Dot3k: https://github.com/kierank/lcdproc/blob/master/server/drivers/hd44780-rpi.c )