diff --git a/EMF2014/AppManager.cpp b/EMF2014/AppManager.cpp index 4395aaa..2b763a0 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,8 @@ 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", EdBallsApp::New), +// AppDefinition("HelloWorld", HelloWorldApp::New), AppDefinition("Sponsors", SponsorsApp::New) }; diff --git a/EMF2014/EdBallsApp.cpp b/EMF2014/EdBallsApp.cpp new file mode 100644 index 0000000..69e5122 --- /dev/null +++ b/EMF2014/EdBallsApp.cpp @@ -0,0 +1,82 @@ +/* + TiLDA Mk2 + + Ed Balls + + 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 + +// Ed Balls + +App* EdBallsApp::New() { + return new EdBallsApp; +} + +EdBallsApp::EdBallsApp() { + mButtonSubscription = Tilda::createButtonSubscription(UP | DOWN); +} + +EdBallsApp::~EdBallsApp() { + delete mButtonSubscription; +} + +String EdBallsApp::getName() const { + return "EdBallsApp"; +} + +bool EdBallsApp::keepAlive() const { + return false; +} + +void EdBallsApp::task() { + Tilda::getGUITask().clearRoot(); // Clean screen + GLCD.SetRotation(ROTATION_90); + + Tilda::setLedColor({0, 0, 0}); + + while(true) { // Make sure this loop goes on forever + 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) { + 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..b61d7dc --- /dev/null +++ b/EMF2014/EdBallsApp.h @@ -0,0 +1,57 @@ +/* + TiLDA Mk2 + + Ed Balls + + 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; +};