Toggle an LED from within Qt



  • I have Qt up and running on my custom AT91SAM9G45 hardware using Linux 2.6.30 kernel and all of the Demos work nicely with my touchscreen and 480x272 LCD. So, I figured that I am a good point so far. Now, I have only messed with Qt for two days and I have a very simple question I hope.

    How, do I toggle an LED. (I have my Qt books coming from Amazon next week so sorry of this was a stupid question). I am assuming that Qt can access all of the hardware that Linux can access?

    My LED driver(s) location:
    /sys/devices/platform/leds-gpio/leds:led1
    or
    /sys/devices/platform/leds-atmel-pwm/leds:led2

    My LED variable:
    brightness (can be zero or one)

    From the console I can:
    echo "1" > brightness
    echo "0" > brightness
    or
    cat brightness

    Thanks, Gary



  • Hi,

    I haven't personally done anything with Qt in a custom embedded environment like this, so it's entirely possible that I'm wrong about this, but you will probably be able to use normal file i/o (QFile and friends) to write to the device file which "brightness" is a symlink to.

    Cheers,
    Chris.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.