Demo to control 4 LEDs

Dependencies:   BSP_DISCO_F469NI mbed

Committer:
Faberge
Date:
Tue Oct 31 14:46:28 2017 +0000
Revision:
2:e6fc24fbd86c
Parent:
1:a6d179a9ffbb
Update

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Faberge 1:a6d179a9ffbb 1 /*
Faberge 1:a6d179a9ffbb 2 * app.cpp
Faberge 1:a6d179a9ffbb 3 *
Faberge 1:a6d179a9ffbb 4 * Copyright 2017 Faberge@TsarTeam
Faberge 1:a6d179a9ffbb 5 *
Faberge 1:a6d179a9ffbb 6 * This program is free software; you can redistribute it and/or modify
Faberge 1:a6d179a9ffbb 7 * it under the terms of the GNU General Public License as published by
Faberge 1:a6d179a9ffbb 8 * the Free Software Foundation; either version 2 of the License, or
Faberge 1:a6d179a9ffbb 9 * (at your option) any later version.
Faberge 1:a6d179a9ffbb 10 *
Faberge 1:a6d179a9ffbb 11 * This program is distributed in the hope that it will be useful,
Faberge 1:a6d179a9ffbb 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Faberge 1:a6d179a9ffbb 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Faberge 1:a6d179a9ffbb 14 * GNU General Public License for more details.
Faberge 1:a6d179a9ffbb 15 *
Faberge 1:a6d179a9ffbb 16 */
Faberge 1:a6d179a9ffbb 17
Faberge 1:a6d179a9ffbb 18 #include "app.h"
Faberge 1:a6d179a9ffbb 19
Faberge 1:a6d179a9ffbb 20 /* Screen functions */
Faberge 1:a6d179a9ffbb 21
Faberge 1:a6d179a9ffbb 22 void createSwitchScreen(Screen *scr)
Faberge 1:a6d179a9ffbb 23 {
Faberge 1:a6d179a9ffbb 24 scr -> reset(LCD_COLOR_BLACK);
Faberge 1:a6d179a9ffbb 25 scr -> add(new Textbox(320, 5, LCD_COLOR_BLACK, "Switch Demo"));
Faberge 1:a6d179a9ffbb 26
Faberge 1:a6d179a9ffbb 27 /* Create switches */
Faberge 1:a6d179a9ffbb 28 scr -> add(new Switch(10, 20, LCD_COLOR_BLUE, toggleBlueLED));
Faberge 1:a6d179a9ffbb 29 scr -> add(new Switch(10, 100, LCD_COLOR_RED, toggleRedLED));
Faberge 1:a6d179a9ffbb 30 scr -> add(new Switch(10, 180, LCD_COLOR_ORANGE, toggleOrangeLED));
Faberge 1:a6d179a9ffbb 31 scr -> add(new Switch(10, 260, LCD_COLOR_GREEN, toggleGreenLED));
Faberge 1:a6d179a9ffbb 32
Faberge 1:a6d179a9ffbb 33 scr -> exitOnWithCode(new Button(10, 390, LCD_COLOR_DARKCYAN, "BTN"), NEW_BUTTON_SCREEN);
Faberge 1:a6d179a9ffbb 34 scr -> exitOnWithCode(new Button(720, 390, LCD_COLOR_DARKCYAN, "TEXT"), NEW_TEXT_SCREEN);
Faberge 1:a6d179a9ffbb 35
Faberge 1:a6d179a9ffbb 36 HAL_Delay(300);
Faberge 1:a6d179a9ffbb 37 }
Faberge 1:a6d179a9ffbb 38
Faberge 1:a6d179a9ffbb 39 void createButtonScreen(Screen *scr)
Faberge 1:a6d179a9ffbb 40 {
Faberge 1:a6d179a9ffbb 41 scr -> reset(LCD_COLOR_BLACK);
Faberge 1:a6d179a9ffbb 42 scr -> add(new Textbox(320, 5, LCD_COLOR_BLACK, "Button Demo"));
Faberge 1:a6d179a9ffbb 43
Faberge 1:a6d179a9ffbb 44 /* Create buttons */
Faberge 1:a6d179a9ffbb 45 scr -> add(new Button(10, 20, LCD_COLOR_BLUE, "LED", toggleBlueLED));
Faberge 1:a6d179a9ffbb 46 scr -> add(new Button(10, 100, LCD_COLOR_RED, "LED", toggleRedLED));
Faberge 1:a6d179a9ffbb 47 scr -> add(new Button(10, 180, LCD_COLOR_ORANGE, "LED", toggleOrangeLED));
Faberge 1:a6d179a9ffbb 48 scr -> add(new Button(10, 260, LCD_COLOR_GREEN, "LED", toggleGreenLED));
Faberge 1:a6d179a9ffbb 49
Faberge 1:a6d179a9ffbb 50 scr -> exitOnWithCode(new Button(10, 390, LCD_COLOR_DARKCYAN, "TEXT"), NEW_TEXT_SCREEN);
Faberge 1:a6d179a9ffbb 51 scr -> exitOnWithCode(new Button(720, 390, LCD_COLOR_DARKCYAN, "SWCH"), NEW_SWITCH_SCREEN);
Faberge 1:a6d179a9ffbb 52
Faberge 1:a6d179a9ffbb 53 HAL_Delay(300);
Faberge 1:a6d179a9ffbb 54 }
Faberge 1:a6d179a9ffbb 55
Faberge 1:a6d179a9ffbb 56 void createTextScreen(Screen *scr)
Faberge 1:a6d179a9ffbb 57 {
Faberge 1:a6d179a9ffbb 58 scr -> reset(LCD_COLOR_BLACK);
Faberge 1:a6d179a9ffbb 59 scr -> add(new Textbox(340, 5, LCD_COLOR_BLACK, "Text Demo"));
Faberge 1:a6d179a9ffbb 60
Faberge 1:a6d179a9ffbb 61 /* Create textboxes */
Faberge 1:a6d179a9ffbb 62 scr -> add(new Textbox(10, 20, LCD_COLOR_BLACK, "Some text"));
Faberge 1:a6d179a9ffbb 63 scr -> add(new Textbox(10, 40, LCD_COLOR_BLACK, "Some more text..."));
Faberge 1:a6d179a9ffbb 64 scr -> add(new Textbox(10, 60, LCD_COLOR_BLACK, "This demo brought"));
Faberge 1:a6d179a9ffbb 65 scr -> add(new Textbox(10, 80, LCD_COLOR_BLACK, "to you by Faberge"));
Faberge 1:a6d179a9ffbb 66
Faberge 1:a6d179a9ffbb 67 scr -> exitOnWithCode(new Button(10, 390, LCD_COLOR_DARKCYAN, "SWCH"), NEW_SWITCH_SCREEN);
Faberge 1:a6d179a9ffbb 68 scr -> exitOnWithCode(new Button(720, 390, LCD_COLOR_DARKCYAN, "BTN"), NEW_BUTTON_SCREEN);
Faberge 1:a6d179a9ffbb 69
Faberge 1:a6d179a9ffbb 70 HAL_Delay(300);
Faberge 1:a6d179a9ffbb 71 }
Faberge 1:a6d179a9ffbb 72