From 304c28c13c849bd8df81cfaf7cfc594b0f32a5f5 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Sun, 31 Aug 2014 18:52:51 -0400 Subject: Added annoy-a-tron clone using piezo Change-Id: I4ce6538bd349b5c408745e7539a902c5062a108e --- apps/plugins/annoyatron.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 apps/plugins/annoyatron.c 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_tickcpu_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); + } +} -- cgit v1.1 From 8af536f7d95d99e182d8bb072e7f8ffbaedb585e Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Sun, 31 Aug 2014 18:53:31 -0400 Subject: Fixed conflict Change-Id: Ie5ff414d78bdd1d141d5c34b26e13d4576286ecd --- apps/plugins/CATEGORIES | 1 + apps/plugins/SOURCES | 3 +++ 2 files changed, 4 insertions(+) diff --git a/apps/plugins/CATEGORIES b/apps/plugins/CATEGORIES index 626dca0..0fd3b1a 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 a051e2d..14bf1ad 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES @@ -260,3 +260,6 @@ test_touchscreen.c #endif test_viewports.c #endif /* HAVE_TEST_PLUGINS */ +#if defined(HAVE_HARDWARE_CLICK) && !defined(SIMULATOR) +annoyatron.c +#endif -- cgit v1.1