summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorFranklin Wei <frankhwei536@gmail.com>2016-06-08 23:23:54 -0400
committerFranklin Wei <frankhwei536@gmail.com>2016-06-08 23:23:54 -0400
commitded52e72923fc8dc85f47a66013de5f0b1687841 (patch)
tree3b7578b3390c65dcf07cc2f04893239c20b8e13e /apps/plugins
parent9a6700d52e8dfb2e93623e7143204ae34f798bbf (diff)
parent8af536f7d95d99e182d8bb072e7f8ffbaedb585e (diff)
downloadrockbox-ded52e72923fc8dc85f47a66013de5f0b1687841.zip
rockbox-ded52e72923fc8dc85f47a66013de5f0b1687841.tar.gz
rockbox-ded52e72923fc8dc85f47a66013de5f0b1687841.tar.bz2
rockbox-ded52e72923fc8dc85f47a66013de5f0b1687841.tar.xz
Merge branch 'annoyatron' into working
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/CATEGORIES1
-rw-r--r--apps/plugins/SOURCES3
-rw-r--r--apps/plugins/annoyatron.c60
3 files changed, 64 insertions, 0 deletions
diff --git a/apps/plugins/CATEGORIES b/apps/plugins/CATEGORIES
index 2824880..7f46613 100644
--- a/apps/plugins/CATEGORIES
+++ b/apps/plugins/CATEGORIES
@@ -1,6 +1,7 @@
2048,games
alpine_cdc,apps
alarmclock,apps
+annoyatron,apps
autostart,apps
battery_bench,apps
bench_scaler,apps
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES
index c7a8cb6..93626bf 100644
--- a/apps/plugins/SOURCES
+++ b/apps/plugins/SOURCES
@@ -256,3 +256,6 @@ test_touchscreen.c
#endif
test_viewports.c
#endif /* HAVE_TEST_PLUGINS */
+#if defined(HAVE_HARDWARE_CLICK) && !defined(SIMULATOR)
+annoyatron.c
+#endif
diff --git a/apps/plugins/annoyatron.c b/apps/plugins/annoyatron.c
new file mode 100644
index 0000000..43aa5ca
--- /dev/null
+++ b/apps/plugins/annoyatron.c
@@ -0,0 +1,60 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2014 Franklin Wei
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+#include "plugin.h"
+#include "lib/pluginlib_actions.h"
+
+#define MIN_TIME 1//(60*HZ)
+#define MAX_TIME HZ//(120*HZ)
+
+static const struct button_mapping *plugin_contexts[] = { pla_main_ctx };
+
+enum plugin_status plugin_start(const void* param)
+{
+ (void)param;
+ rb->splash(0, "Press any key to begin...");
+ rb->button_get(true);
+ rb->srand(*rb->current_tick);
+ for(;;)
+ {
+ long beep_time=*rb->current_tick+(rb->rand()%(MAX_TIME-MIN_TIME)+MIN_TIME);
+ rb->splashf(0, "beeping at tick %ld", beep_time);
+ while(*rb->current_tick<beep_time)
+ {
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
+ rb->cpu_boost(false);
+#endif
+ int button=pluginlib_getaction(0, plugin_contexts, ARRAYLEN(plugin_contexts));
+ if(button==PLA_CANCEL)
+ return PLUGIN_OK;
+ }
+ int beep_ms=rb->rand()%1000+500;
+ unsigned int freq=2000;
+ int r=rb->rand()%3;
+ if(r==0)
+ freq=2000;
+ else if(r==1)
+ freq=12000;
+ else
+ freq=15000;
+ rb->splashf(0, "Freq: %d", freq);
+ rb->piezo_play(beep_ms*1000, freq, true);
+ }
+}