Demo to control 4 LEDs
Dependencies: BSP_DISCO_F469NI mbed
main.cpp
- Committer:
- Faberge
- Date:
- 2017-10-11
- Revision:
- 0:e06404fdff2f
- Child:
- 1:a6d179a9ffbb
File content as of revision 0:e06404fdff2f:
/* * main.cpp * * Copyright 2017 Faberge@TsarTeam * * 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 program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ #include "Screen.h" #include "Textbox.h" #include "Button.h" #include "Switch.h" #include "user.h" int state; Screen *scr; int main() { /* Init LEDs */ BSP_LED_Init(DISCO_LED_BLUE); BSP_LED_Init(DISCO_LED_RED); BSP_LED_Init(DISCO_LED_ORANGE); BSP_LED_Init(DISCO_LED_GREEN); /* Dummy screen */ scr = new Screen(LCD_COLOR_BLACK); state = 1; while(1) { /* Create screens */ switch(state) { case 0: break; case 1: { delete scr; scr = new Screen(LCD_COLOR_BLACK); scr -> add(new Textbox(320, 5, LCD_COLOR_BLACK, "Switch Demo")); /* Create switches */ scr -> add(new Switch(10, 20, LCD_COLOR_BLUE, blueLedOn, blueLedOff)); scr -> add(new Switch(10, 100, LCD_COLOR_RED, redLedOn, redLedOff)); scr -> add(new Switch(10, 180, LCD_COLOR_ORANGE, orangeLedOn, orangeLedOff)); scr -> add(new Switch(10, 260, LCD_COLOR_GREEN, greenLedOn, greenLedOff)); scr -> exitOnWithCode(new Button(10, 390, LCD_COLOR_DARKCYAN, "BTN"), 2); scr -> exitOnWithCode(new Button(720, 390, LCD_COLOR_DARKCYAN, "TEXT"), 3); HAL_Delay(300); break; } case 2: { delete scr; scr = new Screen(LCD_COLOR_BLACK); scr -> add(new Textbox(320, 5, LCD_COLOR_BLACK, "Button Demo")); /* Create buttons */ scr -> add(new Button(10, 20, LCD_COLOR_BLUE, "LED", blueLedOn, blueLedOff)); scr -> add(new Button(10, 100, LCD_COLOR_RED, "LED", redLedOn, redLedOff)); scr -> add(new Button(10, 180, LCD_COLOR_ORANGE, "LED", orangeLedOn, orangeLedOff)); scr -> add(new Button(10, 260, LCD_COLOR_GREEN, "LED", greenLedOn, greenLedOff)); scr -> exitOnWithCode(new Button(10, 390, LCD_COLOR_DARKCYAN, "TEXT"), 3); scr -> exitOnWithCode(new Button(720, 390, LCD_COLOR_DARKCYAN, "SWCH"), 1); HAL_Delay(300); break; } case 3: { delete scr; scr = new Screen(LCD_COLOR_BLACK); scr -> add(new Textbox(340, 5, LCD_COLOR_BLACK, "Text Demo")); /* Create textboxes */ scr -> add(new Textbox(10, 20, LCD_COLOR_BLACK, "Some text")); scr -> add(new Textbox(10, 100, LCD_COLOR_BLACK, "Some more text...")); scr -> add(new Textbox(10, 180, LCD_COLOR_BLACK, "This demo brought")); scr -> add(new Textbox(10, 260, LCD_COLOR_BLACK, "to you by Faberge")); scr -> exitOnWithCode(new Button(10, 390, LCD_COLOR_DARKCYAN, "SWCH"), 1); scr -> exitOnWithCode(new Button(720, 390, LCD_COLOR_DARKCYAN, "BTN"), 2); HAL_Delay(300); break; } } /* Check and upadte */ state = scr -> update(); /* Small delay for stability */ HAL_Delay(10); } }