From 0d1e2c977dcfc1e4b481ff0377d0c35075127c05 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Rzepecki?= Date: Wed, 8 Jul 2009 15:06:32 +0200 Subject: [PATCH] Blinking. --- res/layout/main.xml | 94 +++++++++++++++++++++++++++++ res/values/strings.xml | 4 ++ src/pl/blip/divide/ledtester/LedTester.java | 21 ++++++- 3 files changed, 116 insertions(+), 3 deletions(-) diff --git a/res/layout/main.xml b/res/layout/main.xml index f7589bd..a41cf9d 100644 --- a/res/layout/main.xml +++ b/res/layout/main.xml @@ -111,4 +111,98 @@ android:gravity="right" /> + + + + + + + + + + + + + + + + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index cf9e320..ffed395 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -22,4 +22,8 @@ Red: Green: Blue: + Blink: + on for + off for + ms diff --git a/src/pl/blip/divide/ledtester/LedTester.java b/src/pl/blip/divide/ledtester/LedTester.java index 9c3fcce..e049a73 100644 --- a/src/pl/blip/divide/ledtester/LedTester.java +++ b/src/pl/blip/divide/ledtester/LedTester.java @@ -65,6 +65,10 @@ public class LedTester extends Activity { private TextView blueLabel; private NotificationManager notificationManager; private Notification notification; + private SeekBar onBar; + private TextView onLabel; + private TextView offLabel; + private SeekBar offBar; /** Called when the activity is first created. */ @Override @@ -75,19 +79,25 @@ public class LedTester extends Activity { redBar = (SeekBar) findViewById(R.id.red); greenBar = (SeekBar) findViewById(R.id.green); blueBar = (SeekBar) findViewById(R.id.blue); - + onBar = (SeekBar) findViewById(R.id.on_ms); + offBar = (SeekBar) findViewById(R.id.off_ms); + redLabel = (TextView) findViewById(R.id.red_label); greenLabel = (TextView) findViewById(R.id.green_label); blueLabel = (TextView) findViewById(R.id.blue_label); + onLabel = (TextView) findViewById(R.id.on_ms_label); + offLabel = (TextView) findViewById(R.id.off_ms_label); redBar.setOnSeekBarChangeListener(new LabelUpdatingOnSeekBarChangeListener(redLabel)); greenBar.setOnSeekBarChangeListener(new LabelUpdatingOnSeekBarChangeListener(greenLabel)); blueBar.setOnSeekBarChangeListener(new LabelUpdatingOnSeekBarChangeListener(blueLabel)); + onBar.setOnSeekBarChangeListener(new LabelUpdatingOnSeekBarChangeListener(onLabel)); + offBar.setOnSeekBarChangeListener(new LabelUpdatingOnSeekBarChangeListener(offLabel)); notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notification = new Notification(); notification.ledOffMS = 0; - notification.ledOnMS = 1000; + notification.ledOnMS = 5000; notification.flags = Notification.FLAG_SHOW_LIGHTS; printSystemInfo(); @@ -130,8 +140,13 @@ public class LedTester extends Activity { int blue = blueBar.getProgress(); int color = 0xff000000 | (red << 16) | (green << 8) | blue; + notification.ledARGB = color; - notificationManager.notify(0, notification); + + notification.ledOffMS = offBar.getProgress(); + notification.ledOnMS = onBar.getProgress(); + + notificationManager.notify(0, notification); } @Override -- 2.11.4.GIT