From 98a90be025f1b69334049ecb7a960bc796f9641b Mon Sep 17 00:00:00 2001 From: pikesley Date: Thu, 4 Sep 2014 23:03:01 +0100 Subject: [PATCH 1/5] Ed Balls --- EMF2014/AppManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EMF2014/AppManager.cpp b/EMF2014/AppManager.cpp index 4395aaa..c122d68 100644 --- a/EMF2014/AppManager.cpp +++ b/EMF2014/AppManager.cpp @@ -48,7 +48,7 @@ static const AppDefinition APPS[] = { AppDefinition("Badge ID", BadgeIdApp::New), AppDefinition("Snake", SnakeApp::New), AppDefinition("Tetris", TetrisApp::New), - // AppDefinition("HelloWorld", HelloWorldApp::New), // Uncomment this + AppDefinition("Ed Balls", HelloWorldApp::New), AppDefinition("Sponsors", SponsorsApp::New) }; From 365df77b45e2c7dc27534c26da4636751fc5e59c Mon Sep 17 00:00:00 2001 From: pikesley Date: Fri, 5 Sep 2014 16:59:07 +0100 Subject: [PATCH 2/5] Ed Balls --- EMF2014/AppManager.cpp | 3 +- EMF2014/EdBallsApp.cpp | 85 ++++++++++++++++++++++++++++++++++++++++++ EMF2014/EdBallsApp.h | 58 ++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 EMF2014/EdBallsApp.cpp create mode 100644 EMF2014/EdBallsApp.h diff --git a/EMF2014/AppManager.cpp b/EMF2014/AppManager.cpp index c122d68..ae9cdfb 100644 --- a/EMF2014/AppManager.cpp +++ b/EMF2014/AppManager.cpp @@ -36,6 +36,7 @@ #include "BadgeIdApp.h" #include "SnakeApp.h" #include "HelloWorldApp.h" +#include "EdBallsApp.h" #include "ScheduleApp.h" #include "TetrisApp.h" #include "WeatherApp.h" @@ -48,7 +49,7 @@ static const AppDefinition APPS[] = { AppDefinition("Badge ID", BadgeIdApp::New), AppDefinition("Snake", SnakeApp::New), AppDefinition("Tetris", TetrisApp::New), - AppDefinition("Ed Balls", HelloWorldApp::New), + AppDefinition("Ed Balls", EdBallsApp::New), AppDefinition("Sponsors", SponsorsApp::New) }; diff --git a/EMF2014/EdBallsApp.cpp b/EMF2014/EdBallsApp.cpp new file mode 100644 index 0000000..4e9b4e3 --- /dev/null +++ b/EMF2014/EdBallsApp.cpp @@ -0,0 +1,85 @@ +/* + TiLDA Mk2 + + Task + + The MIT License (MIT) + + Copyright (c) 2014 Electromagnetic Field LTD + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + */ + +#include +#include +#include "EdBallsApp.h" +#include "Tilda.h" +#include +#include +#include "GUITask.h" +#include + +// Use this as a boilerplate app class. If you create a new one, make sure to also register it in the AppManager +// otherwise it won't show up on the HomeScreen + +App* EdBallsApp::New() { + return new EdBallsApp; +} + +EdBallsApp::EdBallsApp() { + mButtonSubscription = Tilda::createButtonSubscription(UP | DOWN); // Define the buttons you're interested in here +} + +EdBallsApp::~EdBallsApp() { + delete mButtonSubscription; +} + +String EdBallsApp::getName() const { + return "EdBallsApp"; +} + +bool EdBallsApp::keepAlive() const { + return false; // Should this app be suspended or killed when another app is started? +} + +void EdBallsApp::task() { + // Do some setup in here + Tilda::getGUITask().clearRoot(); // Clean screen + GLCD.SetRotation(ROTATION_90); // Orientation + + Tilda::setLedColor({0, 0, 0}); // LEDs off + + while(true) { // Make sure this loop goes on forever + GLCD.SelectFont(System5x7); // Font + GLCD.CursorToXY(8, 60); // Position cursor + GLCD.print("Ed Balls"); // Write text + Button button = mButtonSubscription->waitForPress(1000); // Wait for up to a second for a button press + // Make sure all the buttons you're interested in are defined in the constructor + if (button == UP) { + Tilda::setLedColor({250, 129, 0}); // orange + } else if (button == DOWN) { + Tilda::setLedColor({171, 205, 239}); // turquoise + } else { + Tilda::setLedColor({0, 0, 0}); // LEDs off + } + } +} + +void EdBallsApp::afterSuspension() {} // If keepAlive() is true this is being called when the task is suspended +void EdBallsApp::beforeResume() {} // If keepAlive() is true this is being called when the task is resumed diff --git a/EMF2014/EdBallsApp.h b/EMF2014/EdBallsApp.h new file mode 100644 index 0000000..a312a6e --- /dev/null +++ b/EMF2014/EdBallsApp.h @@ -0,0 +1,58 @@ +/* + TiLDA Mk2 + + HelloWorldApp + Play around in this app or use it as a skeleton for your own one + + The MIT License (MIT) + + Copyright (c) 2014 Electromagnetic Field LTD + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + */ + +#pragma once + +#include +#include +#include "EMF2014Config.h" +#include "App.h" +#include "RGBTask.h" +#include "GUITask.h" +#include "ButtonSubscription.h" + +class EdBallsApp: public App { +public: + static App* New(); + + String getName() const; +protected: +private: + EdBallsApp(); + ~EdBallsApp(); + EdBallsApp(const EdBallsApp&); + + bool keepAlive() const; + + void task(); + void afterSuspension(); + void beforeResume(); +private: + ButtonSubscription* mButtonSubscription; +}; From ee877327b84338672c5d977c55e1e9c1df562fff Mon Sep 17 00:00:00 2001 From: pikesley Date: Fri, 5 Sep 2014 17:05:34 +0100 Subject: [PATCH 3/5] Ed Balls --- EMF2014/EdBallsApp.cpp | 23 ++++++++++------------- EMF2014/EdBallsApp.h | 3 +-- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/EMF2014/EdBallsApp.cpp b/EMF2014/EdBallsApp.cpp index 4e9b4e3..69e5122 100644 --- a/EMF2014/EdBallsApp.cpp +++ b/EMF2014/EdBallsApp.cpp @@ -1,7 +1,7 @@ /* TiLDA Mk2 - Task + Ed Balls The MIT License (MIT) @@ -35,15 +35,14 @@ #include "GUITask.h" #include -// Use this as a boilerplate app class. If you create a new one, make sure to also register it in the AppManager -// otherwise it won't show up on the HomeScreen +// Ed Balls App* EdBallsApp::New() { return new EdBallsApp; } EdBallsApp::EdBallsApp() { - mButtonSubscription = Tilda::createButtonSubscription(UP | DOWN); // Define the buttons you're interested in here + mButtonSubscription = Tilda::createButtonSubscription(UP | DOWN); } EdBallsApp::~EdBallsApp() { @@ -55,22 +54,20 @@ String EdBallsApp::getName() const { } bool EdBallsApp::keepAlive() const { - return false; // Should this app be suspended or killed when another app is started? + return false; } void EdBallsApp::task() { - // Do some setup in here Tilda::getGUITask().clearRoot(); // Clean screen - GLCD.SetRotation(ROTATION_90); // Orientation + GLCD.SetRotation(ROTATION_90); - Tilda::setLedColor({0, 0, 0}); // LEDs off + Tilda::setLedColor({0, 0, 0}); while(true) { // Make sure this loop goes on forever - GLCD.SelectFont(System5x7); // Font - GLCD.CursorToXY(8, 60); // Position cursor - GLCD.print("Ed Balls"); // Write text - Button button = mButtonSubscription->waitForPress(1000); // Wait for up to a second for a button press - // Make sure all the buttons you're interested in are defined in the constructor + GLCD.SelectFont(System5x7); + GLCD.CursorToXY(8, 60); + GLCD.print("Ed Balls"); // Ed Balls + Button button = mButtonSubscription->waitForPress(1000); if (button == UP) { Tilda::setLedColor({250, 129, 0}); // orange } else if (button == DOWN) { diff --git a/EMF2014/EdBallsApp.h b/EMF2014/EdBallsApp.h index a312a6e..b61d7dc 100644 --- a/EMF2014/EdBallsApp.h +++ b/EMF2014/EdBallsApp.h @@ -1,8 +1,7 @@ /* TiLDA Mk2 - HelloWorldApp - Play around in this app or use it as a skeleton for your own one + Ed Balls The MIT License (MIT) From 000f13c2907d9937aab6495b43621a282fbe3883 Mon Sep 17 00:00:00 2001 From: pikesley Date: Fri, 5 Sep 2014 17:28:26 +0100 Subject: [PATCH 4/5] Ed Balls --- EMF2014/AppManager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/EMF2014/AppManager.cpp b/EMF2014/AppManager.cpp index ae9cdfb..a8398d5 100644 --- a/EMF2014/AppManager.cpp +++ b/EMF2014/AppManager.cpp @@ -49,7 +49,8 @@ static const AppDefinition APPS[] = { AppDefinition("Badge ID", BadgeIdApp::New), AppDefinition("Snake", SnakeApp::New), AppDefinition("Tetris", TetrisApp::New), - AppDefinition("Ed Balls", EdBallsApp::New), +// AppDefinition("Ed Balls", EdBallsApp::New), +// AppDefinition("Hello World", HelloWorldApp::New), AppDefinition("Sponsors", SponsorsApp::New) }; From 3a00e4aa3a67ca9182edb0897bafc3fccfb5b077 Mon Sep 17 00:00:00 2001 From: pikesley Date: Sat, 6 Sep 2014 18:06:52 +0100 Subject: [PATCH 5/5] Ed Balls --- EMF2014/AppManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EMF2014/AppManager.cpp b/EMF2014/AppManager.cpp index a8398d5..2b763a0 100644 --- a/EMF2014/AppManager.cpp +++ b/EMF2014/AppManager.cpp @@ -50,7 +50,7 @@ static const AppDefinition APPS[] = { AppDefinition("Snake", SnakeApp::New), AppDefinition("Tetris", TetrisApp::New), // AppDefinition("Ed Balls", EdBallsApp::New), -// AppDefinition("Hello World", HelloWorldApp::New), +// AppDefinition("HelloWorld", HelloWorldApp::New), AppDefinition("Sponsors", SponsorsApp::New) };