02-23-2013 04:21 PM
I'm looking for a way to manipulate the blinking frequency of the device LED using Cascades.
So far I'm able to access the LED and change its color. I can't find any mention about the blinking frequency in the API documentation. Does one have a pointer on how to achieve this?
Thanks
Chris
Solved! Go to Solution.
02-25-2013 06:09 AM
Looking at this http://developer.blackberry.com/cascades/reference![]()
02-25-2013 03:57 PM
Thanks for your answer and your reference to the documentation. Too bad this isn't possible.
02-25-2013 06:40 PM
there's currently an open feature request to be able to do more with the LED api
suggest your use case & hopefully they'll do it, there's several other reasons why the api should be updated
02-27-2013 08:44 PM
[x] Done.
Thanks for the pointer.
02-28-2013 02:50 AM
02-28-2013 09:45 AM
for apps working with the led is it possible to tell if a incoming message has been read & stop it then
03-03-2013 03:56 PM - edited 03-03-2013 03:57 PM
I don't get it to work. Is it possible to show me a code snippet illustrating this?
Edit: I mean the use of led() with a timer.
03-03-2013 04:57 PM
I've created a test project where you can move the slider to set the led frequency.
'Start' button starts the blinking.
Download:
Test.hpp:
namespace bb { namespace device { class Led; }}
class QTimer;
class Test : public QObject
{
Q_OBJECT
public:
Test(bb::cascades::Application *app);
virtual ~Test() {}
Q_INVOKABLE void blink(int frequency);
Q_INVOKABLE void stopBlinking();
public slots:
void onTimer();
protected:
QTimer *timer_;
bb::device::Led *led_;
};
Test.cpp:
#include <bb/device/Led>
#include <QTimer>
using namespace bb::cascades;
using namespace bb::device;
Test::Test(bb::cascades::Application *app)
: QObject(app)
{
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(th is);
qml->setContextProperty("app", this);
AbstractPane *root = qml->createRootObject<AbstractPane>();
app->setScene(root);
led_ = new Led(LedColor::Green, this);
timer_ = new QTimer(this);
QObject::connect(timer_, SIGNAL(timeout()),
this, SLOT(onTimer()));
}
void Test::blink(int frequency)
{
timer_->start(frequency);
led_->flash();
}
void Test::stopBlinking()
{
led_->cancel();
timer_->stop();
}
void Test::onTimer()
{
led_->cancel();
led_->flash();
}
Test.pro:
LIBS += -lbbdevice
bar-descriptor.xml:
<permission>access_led_control</permission>
main.qml:
import bb.cascades 1.0
Page {
property bool stopped: true
Container {
Slider {
id: frequencySlider
fromValue: 1000
toValue: 30
value: 500
onValueChanged: {
if (!stopped)
app.blink(frequencySlider.value)
}
}
Label {
text: 'Frequency: ' + Math.floor(frequencySlider.value) + ' msec'
}
Button {
text: "Start"
onClicked: {
app.blink(frequencySlider.value)
stopped = false
}
}
Button {
text: "Stop"
onClicked: {
app.stopBlinking()
stopped = true
}
}
}
}
03-05-2013 06:01 PM