summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorFranklin Wei <frankhwei536@gmail.com>2014-08-31 18:52:51 -0400
committerFranklin Wei <frankhwei536@gmail.com>2014-08-31 18:56:12 -0400
commit304c28c13c849bd8df81cfaf7cfc594b0f32a5f5 (patch)
tree9a075c3d70b6cd4a5d98aabe73ccd98055315e37 /apps/plugins
parent95a4c3afcd53a1f8b835dec33de51f9c304de4d9 (diff)
downloadrockbox-304c28c13c849bd8df81cfaf7cfc594b0f32a5f5.zip
rockbox-304c28c13c849bd8df81cfaf7cfc594b0f32a5f5.tar.gz
rockbox-304c28c13c849bd8df81cfaf7cfc594b0f32a5f5.tar.bz2
rockbox-304c28c13c849bd8df81cfaf7cfc594b0f32a5f5.tar.xz
Added annoy-a-tron clone using piezo
Change-Id: I4ce6538bd349b5c408745e7539a902c5062a108e
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/annoyatron.c60
1 files changed, 60 insertions, 0 deletions
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);
+ }
+}