Seeed / 52Pi PiShow 2.8 device tree overlay

This post is about the PiShow 2.8″ Resistive Touch Display from Seeedstudio. I found this little 65K colors and 320×240 pixel touch display for $20 at one of there sales.

The documentation on there web page is not easy to understand and everything you need is already part of the standard operating system image.

I used some existing device tree overlay and merged them and changed the pins and adopted the settings from the seeed documentation.

The scree is showing the picture, the touch is working with my finger and the four buttons on the side are working too. I would call this a success.

Thanks to @notro for his guidance to make this example and his work in this area in general.

/*
 * Device Tree overlay for pishow 2.8
 *
 */

/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";

    fragment@0 {
    target = <&spi0>;
    __overlay__ {
        status = "okay";

        spidev@0{
        status = "disabled";
        };

        spidev@1{
        status = "disabled";
        };
    };
    };

    fragment@1 {
    target = <&gpio>;
    __overlay__ {
        pishow_display_pins: pishow_display_pins {
        brcm,pins = <18 23 24 25>;
        brcm,function = <1 1 1 0>; /* out out out in */
        brcm,pull = <0>; /* none */
        };
            pishow_ts_pins: pishow_ts_pins {
        brcm,pins = <22>;
        brcm,function = <0>; /* in */
        };
        keypad_pins: keypad_pins {
        brcm,pins = <16 20 21 26>;
        brcm,function = <0>; /* in */
        brcm,pull = <1>; /* down */
        };
    };
    };

    fragment@2 {
    target = <&spi0>;
    __overlay__ {
        /* needed to avoid dtc warning */
        #address-cells = <1>;
        #size-cells = <0>;

        pishow28: pishow28@0{
        compatible = "ilitek,ili9341";
        reg = <0>;
        pinctrl-names = "default";
        pinctrl-0 = <&pishow_display_pins>,
                <&pishow_ts_pins>;

        spi-max-frequency = <32000000>;
        rotate = <270>;
        bgr;
        fps = <30>;
        buswidth = <8>;
        reset-gpios = <&gpio 23 0>;
        dc-gpios = <&gpio 24 0>;
        led-gpios = <&gpio 18 1>;
        debug = <0>;
        };

        pishow28_ts: pishow28_ts@1 {
        compatible = "ti,ads7846";
        reg = <1>;

        spi-max-frequency = <2000000>;
        interrupts = <22 2>; /* high-to-low edge triggered */
        interrupt-parent = <&gpio>;
        ti,keep-vref-on = <1>;
        pendown-gpio = <&gpio 22 0>;
        /* driver defaults */
        ti,x-min = /bits/ 16 <230>;
        ti,y-min = /bits/ 16 <200>;
        ti,x-max = /bits/ 16 <3900>;
        ti,y-max = /bits/ 16 <3700>;
        ti,pressure-min = /bits/ 16 <0>;
        ti,pressure-max = /bits/ 16 <0xFFFF>;
        ti,x-plate-ohms = /bits/ 16 <80>;
        ti,swap-xy = <1>;
        };
    };
    };
    fragment@3 {
    target-path = "/soc";
    __overlay__ {
        keypad: keypad {
        compatible = "gpio-keys";
        #address-cells = <1>;
        #size-cells = <0>;
        pinctrl-names = "default";
        pinctrl-0 = <&keypad_pins>;
        #status = "disabled";
        autorepeat;
        button@16 {
            label = "GPIO KEY_UP";
            linux,code = <103>;
            gpios = <&gpio 16 0>;
        };
        button@26 {
            label = "GPIO KEY_DOWN";
            linux,code = <108>;
            gpios = <&gpio 26 0>;
        };
        button@20 {
            label = "GPIO KEY_LEFT";
            linux,code = <105>;
            gpios = <&gpio 20 0>;
        };
        button@21 {
            label = "GPIO KEY_RIGHT";
            linux,code = <106>;
            gpios = <&gpio 21 0>;
        };
        };
    };
    };
    __overrides__ {
    speed =   <&pishow28>,"spi-max-frequency:0";
    rotate =  <&pishow28>,"rotate:0";
    fps =     <&pishow28>,"fps:0";
    debug =   <&pishow28>,"debug:0";
    swapxy =  <&pishow28_ts>,"ti,swap-xy;0";
    xmin =    <&pishow28_ts>,"ti,x-min;0";
    ymin =    <&pishow28_ts>,"ti,y-min;0";
    xmax =    <&pishow28_ts>,"ti,x-max;0";
    ymax =    <&pishow28_ts>,"ti,y-max;0";
    pmin =    <&pishow28_ts>,"ti,pressure-min;0";
    pmax =    <&pishow28_ts>,"ti,pressure-max;0";
    xohms =   <&pishow28_ts>,"ti,x-plate-ohms;0";
    #keypad =  <&keypad>,"status";
    };
};

I used this script to install the device tree compiler dtc. After the compiler was installed this command creates the dtbo file:

sudo dtc -@ -I dts -O dtb -o /boot/overlays/pishow28.dtbo pishow28.dts

The last step is to add “dtoverlay=pishow28” to the end of the “/boot/config.txt” file.

Plus the /etc/X11/xorg.conf.d/99-ads7846-cal.conf file that swaps the X and Y axis:

Section "InputClass"
    Identifier "Touchscreen"
    MatchProduct "ADS7846 Touchscreen"
    Option "InvertX" "1"
    Option "InvertY" "1"
    Option "SwapAxes" "0"
    Option "Calibration" "215 3800 129 3676"
EndSection

I also added one line in /etc/udev/rules.d/95-ads7846.rules file:

SUBSYSTEM=="input", KERNEL=="event[0-9]*", ATTRS{name}=="ADS7846*", SYMLINK+="input/touchscreen"

As an extra I did install the frame buffer copy tool to copy the main frame buffer to the new touch display frame buffer.

30 Light Devield Eggs

18 Eggs (18 egg whites 6 egg yokes)

120g mayo
(4 Tbs fat free mayo
4 Tbs light mayo)

20g Mustard
(4 Tsp Mustard)

5ml vinegar
(1 Tsp vinegar)

3.5g (1/2 pack) gelatin + 10ml water (2 Tsp)

salt/pepper

For 30 half’s. Cut all the eggs in 1/2 and select the 30 best looking half’s. Put the 30 egg half on tray and cover with plastic rap and chill.
Take 6 yokes and the remaining 3 egg whites and put in a food processor with mayo and mustard and vinegar, salt and pepper to taste. Blend everything and scrape the side and blend again. Mix up gelatin and water and heat for 10 to 30 seconds in microwave to dissolve the gelatin. Add to egg yoke mixture right away and mix up quickly. Put all in a piping bag and chill in fridge for 30 minutes. Pipe a generous amount of the egg yoke mix in each half and cover and chill again until ready. If not covered the egg yolk will dry out.

Test GUI for Grbl without Arduino using the Simulator and virtual com port under GNU Linux.

My Arduino is not accabale right now but I wanted to look at a new GUI or gcode sender program for Grbl called SourceRabbit GCode Sender. I already had the simulator compiled and ready to go and the next step was just to find a way to connect both together. I found that the program socat can do just this:

socat -d -d pty,raw,echo=0,link=/tmp/ttyV0 pty,raw,echo=0,link=/tmp/ttyV1

This creates two virtual serial ports with the names /tmp/ttyV0 and /tmp/ttyV1 and connect both together. Now I just need to direct the output and input of Grbl to one of the virtual serial ports:

./grbl_sim -n > /tmp/ttyV0 < /tmp/ttyV0

To test if this works I can use a command line terminal program like miniterm and connect to the other virtual serial port

miniterm.py /tmp/ttyV1

Now that everything is working I can finally test the new SourceRabbit GCode Sender program.

chrubuntu: zram-config is working wonders if ram runs out… no more freezing desktop.

I’m using chrubuntu on a acer 710 since a long time and it works well, but sometime I ran out of ram and the PC freezes, this happens a lot with Chrome if I open multiple tabs. I was just looking for ways to limit Chrome ram uses but stumbled on the zram stuff and it looks like this helps. I was able to open 15 tabs with different pages and no crash.

sudo apt-get install zram-config

That’s it.

Linux image to laser g code converter

Screenshot-8

I did find imagecarve a GPL V2 open source program. After mapping the Z axis to S spindle values it looks like the g code it spits out could work with my laser. I only did test this with the greate grbl simulator, but I would guess after some more tweaking it should work on the real machine too.

Here is my Github project with the source files.

IMG_20140920_121713Looks like the image gets flipped when burned, but I flipped it back for this page. I think cardboard in not the best medium for laser engravings, it burns too fast.

real time spindle control aka laser mode for grbl

Screenshot-7$X
G20 G90 G64 G40
T0 M6
G17
G1 F500

G0 X0 Y0 Z0
G1 X20

G0 X0 Y5 Z0
G1 X10
G1 X20

G0 X0 Y10 Z0
M3 S64
G1 X10
S196
G1 X20
M5

G0 X0 Y20 Z0
M3
G1 X10 S255
G1 X20 S127
M5 s0

G0 X0 Y25 Z0
M3
G1 X5 S128
G1 X10 S300
G1 X15 S1000
G1 X20 S255
M5

M30

Here are the changes:
Github Link

Compile time option example:
#if defined(LASER_SPINDLE) && defined(USE_LINE_NUMBERS)
void plan_buffer_line(float *target, float feed_rate, uint8_t invert_feed_rate, float rpm, uint8_t direction, int32_t line_number);
#elif defined(LASER_SPINDLE)
void plan_buffer_line(float *target, float feed_rate, uint8_t invert_feed_rate, float rpm, uint8_t direction);
#elif defined(USE_LINE_NUMBERS)
void plan_buffer_line(float *target, float feed_rate, uint8_t invert_feed_rate, int32_t line_number);
#else
void plan_buffer_line(float *target, float feed_rate, uint8_t invert_feed_rate);
#endif

Grbl 0.9g settings for my Shapeoko

shapeoko

>>> $$
$0=10 (step pulse, usec)
$1=25 (step idle delay, msec)
$2=0 (step port invert mask:00000000)
$3=2 (dir port invert mask:00000010)
$4=0 (step enable invert, bool)
$5=0 (limit pins invert, bool)
$6=0 (probe pin invert, bool)
$10=3 (status report mask:00000011)
$11=0.050 (junction deviation, mm)
$12=0.002 (arc tolerance, mm)
$13=0 (report inches, bool)
$14=1 (auto start, bool)
$20=1 (soft limits, bool)
$21=0 (hard limits, bool)
$22=1 (homing cycle, bool)
$23=1 (homing dir invert mask:00000001)
$24=25.000 (homing feed, mm/min)
$25=250.000 (homing seek, mm/min)
$26=250 (homing debounce, msec)
$27=3.000 (homing pull-off, mm)
$100=87.489 (x, step/mm)
$101=87.489 (y, step/mm)
$102=640.000 (z, step/mm)
$110=4000.000 (x max rate, mm/min)
$111=4000.000 (y max rate, mm/min)
$112=650.000 (z max rate, mm/min)
$120=15.000 (x accel, mm/sec^2)
$121=15.000 (y accel, mm/sec^2)
$122=15.000 (z accel, mm/sec^2)
$130=204.000 (x max travel, mm)
$131=204.000 (y max travel, mm)
$132=54.000 (z max travel, mm)
ok

DD WRT OPENVPN setup for Firmware: DD-WRT v24-sp2 (03/25/13) mega

This is how I configured OPEN VPN on my DD WRT router:

All the key generation tutorials are still good, but with the new firmware most of the settings are now in GUI:


Internal local IP range: 192.168.0.0/24
VPN IP range 192.168.66.0/24

DNS extra settings:
interface=tun2

settings

push "route 192.168.0.0 255.255.255.0"
push "dhcp-option DNS 192.168.66.1"
push "comp-lzo no"

fire wall rules:

iptables -I INPUT 1 -p udp --dport 1194 -j ACCEPT
iptables -I FORWARD 1 --source 192.168.66.0/24 -j ACCEPT
iptables -I FORWARD -i br0 -o tun2 -j ACCEPT
iptables -I FORWARD -i tun2 -o br0 -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.66.0/24 -j MASQUERADE

Client File, like client1.ovpn:

remote xxx.dyndns.org 1194
client
remote-cert-tls server
dev tun0
proto udp
resolv-retry infinite
nobind
persist-key
persist-tun
float

-----BEGIN CERTIFICATE-----
SECRET blablabla
-----END CERTIFICATE-----

-----BEGIN CERTIFICATE-----
SECRET blablabla
-----END CERTIFICATE-----

-----BEGIN PRIVATE KEY-----
SECRET blablabla
-----END PRIVATE KEY-----