Touch-screen Controllor

Hi,
I’ve been playing around with developing a Touch-screen controller for my LIFX light that could replace a traditional light switch, so my Wife and guest can control the lights without the need for their phone.
At the moment it’s only a proof of concept and the code has more than a few bugs (leaning as I go)
The hardware I’m using is a 5” multi touch screen panel with a GSL16880 controller from BuyDisplay’s and a Photon from Particle.io
I’ve dumped the code up on github (http://github.com/riplatt/LIFX-Touch-Switch) for now and I’ll update as I get things working

I’m start this thread in the hope it will kick me into gear and I’ll start moving forward with this again.

Feel free to comment or help with code and all question are welcome.

2 Likes

Thanks for sharing, I was thinking of something like this and love using the Photon for Particle.io. I’m going to take a look and see how it works. I don’t have any of the same display’s your using but I have some Nextion displays so maybe I can get it working with one of them.

I didn’t see the main ino file.

xc0de, should be up there now, thank for letting me know :slightly_smiling:

Small update:
Got a power toggle working (YouTube) and some frankenstein photos of the project so far (Google Photos)

Now that I know I can control the lifx with just the photon I think I need to rewrite my touch recognition, the building block are here just need to make them robust.

That is beautiful. It looks like the response is almost instantaneous.

I bought one of Amazon’s Dash buttons to play with, but there’s too much of a delay for it to be very useful as just an on/off switch. A co-worker loaned me his particle internet button to play with, so I guess that’s going to be the better route to go down.

Update:
Got a working Brightness Control going (YouTube).

Its a bit hard to see the lamp changing but its nice a quick (got the phone there so you can see a change is happening)

still a few bugs but thing are getting there, updated github dev with what I have done so far, mite get a bit more time in a month or two to play again. Enjoy…

1 Like

Update:
Got most of the function working (YouTube), small run-down:

  • Claiming lamp(s) for control: two finger tap in opposed corners, with the lamp on that you want to control.
  • Toggle on and off: one finger tap.
  • Adjust brightness: one finger slide in the Y axis (up/down).
  • Adjust colour: two finger slide in the Y axis.
  • Switch between Colours and Whites: one finger swap in the X axis (right/left)

Time to start designing a safe power supply to go in the wall and a 3d printed case, so I can get the wife to put this prototype to work :slight_smile:

Also I’m thinking of doing a rotary encoder (dimmer switch) and push button switch version, because the unadventurous (i.e. mother in-law) won’t know how to tap a blank light plate thing on the wall to turn on the lights.

Talking about light, Hey good LIFX people do you have any discounts for devs, I think I would need about 20 lights to fit out the house :wink:

As always code update on github dev branch.

Very impressive! Any idea how to address the power supply issue? How would you put one into a wall?

In my day job I work with some smart Electrical Engineer that like to play with electronics, I think we should be able to come up with a safe design that we can mount on the back of a wall switch.

But no design just yet if you have any suggestion feel free to share :wink:

Edit:
small update: it looks like the easiest solution would be to mount a pcb power supply (like -> link) and built a case around it.

This is so awesome! I just bought the photon and display because of this thread. Beautiful work! I may need a hand in getting the code on the device, but I’ll give it a go on my own first. Thanks for this!

Hope you didn’t forget the ‘ZIF Connector’ as I did when I bought the display. :grin:

It looked important and for $0.16 I figured better safe than sorry.

Still kicking this around, But work and Life gets in the way.

Small update I’ve added some new hardware an encoder and switch as the wife keep forgetting that the touch screen was the light switch, so back to a more traditional dimmer a switch.

still working the bugs out of the code but if you want to give it a go use the “lifx-dimmer-switch.ino” up at github (dev) https://github.com/riplatt/LIFX-Touch-Switch/tree/Dev

and a small photo:

1 Like

Two thoughts. 1 - you can mount a cheap android table on your wall, and use the lifx app - which is what I do for my living room. 2. You can use the logitech pop switch and ifttt, which I have found to be the moist reliable way to turn my lights on and off. My wife lives it, because she hates touch screens and prefers a hard switch.

I know this post has been quiet for a while but im wondering if anyone else is trying this currently and has managed to get any further than I. I have compiled the code and attached the screen and all wired up the same but seem to get no response doing anything to the screen. I have opened the console to see if anything output at all but nothing happens and i have no clue where to start troubleshooting

Hi @Jonny_rhodes,
I would strip the program back to just the touch screen controller and some debug prints. we I get some free time I’ll do up a example program and we can go from there.

Hi @Jonny_rhodes,

here is a quick touchscreen test program, (use the same common.h, gsl1680.h, gsl1680.cpp and gslX680firmware.h from the project):

// This #include statement was automatically added by the Particle IDE.
#include "common.h"
#include "gsl1680.h"

#define LOGGING_ON TRUE

#if (LOGGING_ON)
SerialLogHandler logHandler(LOG_LEVEL_WARN,
                            {{"app", LOG_LEVEL_ALL},
                             {"app.touch", LOG_LEVEL_ALL}});
#endif

Logger touchLog("app.touch");

int WAKE = D4;
int INTRPT = D2;
int LED = D7;

bool led = false;
bool Interrupt = false;

uint32_t now;
uint32_t lastInterrupt = 0;

// Objects
gsl1680 GSL = gsl1680();

void debugEvent(touchScreenEvent e)
{
    touchLog.info("Number of Fingers: %d", e.numberOfFingers);
    touchLog.info("Finger 1 Postion[X,Y]: %d, %d", e.fingerPositions[0].x, e.fingerPositions[0].y);
    touchLog.info("Finger 2 Postion[X,Y]: %d, %d", e.fingerPositions[1].x, e.fingerPositions[1].y);
    touchLog.info("Finger 3 Postion[X,Y]: %d, %d", e.fingerPositions[2].x, e.fingerPositions[2].y);
    touchLog.info("Finger 4 Postion[X,Y]: %d, %d", e.fingerPositions[3].x, e.fingerPositions[3].y);
    touchLog.info("Finger 5 Postion[X,Y]: %d, %d", e.fingerPositions[4].x, e.fingerPositions[4].y);
}

void setup()
{

    Serial.begin(115200);
    delay(1000);

    // Log some debug info
    Log.info("Starting up...");
    Log.info("System version: %s", System.version().c_str());
    Log.info("Device ID: %s", System.deviceID().c_str());
    Log.info("IP: %d.%d.%d.%d", WiFi.localIP()[0], WiFi.localIP()[1], WiFi.localIP()[2], WiFi.localIP()[3]);
    Log.info("Subnet: %d.%d.%d.%d", WiFi.subnetMask()[0], WiFi.subnetMask()[1], WiFi.subnetMask()[2], WiFi.subnetMask()[3]);
    Log.info("Gateway: %d.%d.%d.%d", WiFi.gatewayIP()[0], WiFi.gatewayIP()[1], WiFi.gatewayIP()[2], WiFi.gatewayIP()[3]);
    Log.info("SSID: %s", WiFi.SSID());
    // Setup IO
    pinMode(LED, OUTPUT);
    pinMode(WAKE, OUTPUT);
    pinMode(INTRPT, INPUT_PULLUP);

    digitalWrite(LED, HIGH);

    GSL.initialise(WAKE);

    digitalWrite(LED, LOW);
    //get status on start up.
}

void loop()
{
    now = millis();

    // Check for touchscreen input data
    if (digitalRead(INTRPT) == HIGH)
    {

        led = !led; //flick led
        digitalWrite(LED, led);

        bool success = GSL.readData();
        if (success == 1)
        {
            debugEvent(GSL.event);

            Interrupt = true;
            lastInterrupt = now;
        }
        else
        {
            touchLog.error("Interrupt High: Failed Read...");
        }
    }
    else
    {
        if (Interrupt == true && (now - 100 > lastInterrupt))
        {

            bool success = GSL.readData();
            if (success == 1)
            {
                int fCount = GSL.event.numberOfFingers;

                if (fCount > 0)
                {
                    Interrupt = true;
                    lastInterrupt = now;
                }
                else
                {
                    Interrupt = false;
                }
                debugEvent(GSL.event);
            }
            else
            {
                touchLog.error("Interrupt Low: Failed Read...");
                Interrupt = true;
                lastInterrupt = now;
            }
        }
    }
}

Start up the serial monitor and you should see something like:

0000027468 [app.touch] INFO: Number of Fingers: 2
0000027468 [app.touch] INFO: Finger 0 Postion[X,Y]: 80, 459
0000027469 [app.touch] INFO: Finger 1 Postion[X,Y]: 238, 409
0000027469 [app.touch] INFO: Finger 2 Postion[X,Y]: 0, 0
0000027469 [app.touch] INFO: Finger 3 Postion[X,Y]: 0, 0
0000027470 [app.touch] INFO: Finger 4 Postion[X,Y]: 0, 0
0000027488 [app.touch] INFO: Number of Fingers: 2
0000027488 [app.touch] INFO: Finger 0 Postion[X,Y]: 78, 462
0000027489 [app.touch] INFO: Finger 1 Postion[X,Y]: 237, 411
0000027489 [app.touch] INFO: Finger 2 Postion[X,Y]: 0, 0
0000027489 [app.touch] INFO: Finger 3 Postion[X,Y]: 0, 0
0000027489 [app.touch] INFO: Finger 4 Postion[X,Y]: 0, 0
0000027526 [app.touch] INFO: Number of Fingers: 2
0000027526 [app.touch] INFO: Finger 0 Postion[X,Y]: 72, 469
0000027527 [app.touch] INFO: Finger 1 Postion[X,Y]: 230, 414
0000027527 [app.touch] INFO: Finger 2 Postion[X,Y]: 0, 0
0000027527 [app.touch] INFO: Finger 3 Postion[X,Y]: 0, 0
0000027527 [app.touch] INFO: Finger 4 Postion[X,Y]: 0, 0

Let us know how you go.

Regards

I am getting an irc read error 3 80 when i try to use the serial monitor but the wiring all seems fine. I also cant find any info online about what to troubleshoot on this.
I feel i have definitey dived in the deep end with trying this. :joy:
Even though im only trying to replicate a project :upside_down_face:

HI @Jonny_rhodes,
Kind of sound like you are not talking to the GSL chip; Can you confirm you wiring, do you have photos?

The wiring should be,

GSL16880 Pin Function Partical Photon
1 SCL D1
2 SDA D0
3 VDD (3v3) 3v3
4 Wake Not Connected
5 Int D2
6 Gnd Gnd

The breakout board I got for my ZIF connector was in reverse order to the GSL16880 ribbon cable so pin 1 on the GSL was pin 6 on the breakout board; it best to check continuity from the Photon pin to the back of the ZIF connector.

I have come back to try to and figure out why i cannot get it to work. i have checked the wiring and mine matches wht yours describes but has no response to the test code or the lifx code.
This is leading me to believe that the screen itself might be broken but again i wouldnt know how to test for that without using the photon.
I am actually at a point where im willing to pay for someone to make this work or just completely get rid of it.
:expressionless::weary: