Versión de Firmware con funciones de RAM incorporadas.
Dependencies: mbed
Fork of VmRecorderV1dot1 by
ScreenManager/ScreenManager.cpp@2:e818c80e6d5c, 2015-07-14 (annotated)
- Committer:
- JuanManuelAmador
- Date:
- Tue Jul 14 08:34:11 2015 +0000
- Revision:
- 2:e818c80e6d5c
- Parent:
- 0:3d456b8ce449
Funciones de memoria RAM introducidas.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JuanManuelAmador | 0:3d456b8ce449 | 1 | /** |
JuanManuelAmador | 0:3d456b8ce449 | 2 | * @author Juan Manuel Amador Olivares (virtualmech) |
JuanManuelAmador | 0:3d456b8ce449 | 3 | */ |
JuanManuelAmador | 0:3d456b8ce449 | 4 | |
JuanManuelAmador | 0:3d456b8ce449 | 5 | #include "ScreenManager.h" |
JuanManuelAmador | 0:3d456b8ce449 | 6 | |
JuanManuelAmador | 0:3d456b8ce449 | 7 | ScreenManager::ScreenManager(DogMLCD* lcdScreen){ |
JuanManuelAmador | 0:3d456b8ce449 | 8 | currentGroupID = 0; |
JuanManuelAmador | 0:3d456b8ce449 | 9 | currentScreen = 0; |
JuanManuelAmador | 0:3d456b8ce449 | 10 | lastScreen = 0; |
JuanManuelAmador | 0:3d456b8ce449 | 11 | for(int i = 0; i < NIDIOMAS; i++){ |
JuanManuelAmador | 0:3d456b8ce449 | 12 | nScreens[i] = 0; |
JuanManuelAmador | 0:3d456b8ce449 | 13 | } |
JuanManuelAmador | 0:3d456b8ce449 | 14 | lcd = lcdScreen; |
JuanManuelAmador | 0:3d456b8ce449 | 15 | } |
JuanManuelAmador | 0:3d456b8ce449 | 16 | |
JuanManuelAmador | 0:3d456b8ce449 | 17 | void ScreenManager::selectGroup(int groupID){ |
JuanManuelAmador | 0:3d456b8ce449 | 18 | currentGroupID = groupID; |
JuanManuelAmador | 0:3d456b8ce449 | 19 | } |
JuanManuelAmador | 0:3d456b8ce449 | 20 | |
JuanManuelAmador | 0:3d456b8ce449 | 21 | int ScreenManager::addScreen(Screen* screen, char name[16], int groupID){ // Devuelve el índice asignado a la nueva pantalla |
JuanManuelAmador | 0:3d456b8ce449 | 22 | screens[groupID][nScreens[groupID]] = screen; |
JuanManuelAmador | 0:3d456b8ce449 | 23 | strcpy(screenName[groupID][nScreens[groupID]],name); |
JuanManuelAmador | 0:3d456b8ce449 | 24 | nScreens[groupID]++; |
JuanManuelAmador | 0:3d456b8ce449 | 25 | return nScreens[groupID] - 1; |
JuanManuelAmador | 0:3d456b8ce449 | 26 | } |
JuanManuelAmador | 0:3d456b8ce449 | 27 | |
JuanManuelAmador | 0:3d456b8ce449 | 28 | void ScreenManager::changeScreen(char nameNextScreen[16]){ |
JuanManuelAmador | 0:3d456b8ce449 | 29 | // se busca el identificador numérico de la lista de pantallas según el nombre pasado a la función |
JuanManuelAmador | 0:3d456b8ce449 | 30 | // para ello se recorre la lista de pantallas |
JuanManuelAmador | 0:3d456b8ce449 | 31 | int nextScreen; |
JuanManuelAmador | 0:3d456b8ce449 | 32 | for(int i = 0; i < nScreens[currentGroupID]; i++){ |
JuanManuelAmador | 0:3d456b8ce449 | 33 | if(strcmp(nameNextScreen, screenName[currentGroupID][i]) == 0){ |
JuanManuelAmador | 0:3d456b8ce449 | 34 | nextScreen = i; |
JuanManuelAmador | 0:3d456b8ce449 | 35 | } |
JuanManuelAmador | 0:3d456b8ce449 | 36 | } |
JuanManuelAmador | 0:3d456b8ce449 | 37 | // Se selecciona la siguiente pantala |
JuanManuelAmador | 0:3d456b8ce449 | 38 | lastScreen = currentScreen; |
JuanManuelAmador | 0:3d456b8ce449 | 39 | currentScreen = nextScreen; |
JuanManuelAmador | 0:3d456b8ce449 | 40 | // Se borra la pantalla para dejar paso a la pantalla siguiente |
JuanManuelAmador | 0:3d456b8ce449 | 41 | lcd->Clear(); |
JuanManuelAmador | 0:3d456b8ce449 | 42 | lcd->Flush(); |
JuanManuelAmador | 0:3d456b8ce449 | 43 | // Se inicializa la pantalla siguiente |
JuanManuelAmador | 0:3d456b8ce449 | 44 | screens[currentGroupID][currentScreen]->initialize(lcd); |
JuanManuelAmador | 0:3d456b8ce449 | 45 | } |
JuanManuelAmador | 0:3d456b8ce449 | 46 | |
JuanManuelAmador | 0:3d456b8ce449 | 47 | char *ScreenManager::getCurrentScreen(){ |
JuanManuelAmador | 0:3d456b8ce449 | 48 | return screenName[currentGroupID][currentScreen]; |
JuanManuelAmador | 0:3d456b8ce449 | 49 | } |
JuanManuelAmador | 0:3d456b8ce449 | 50 | |
JuanManuelAmador | 0:3d456b8ce449 | 51 | int ScreenManager::getnScreen(int groupID){ |
JuanManuelAmador | 0:3d456b8ce449 | 52 | return nScreens[groupID]; |
JuanManuelAmador | 0:3d456b8ce449 | 53 | } |
JuanManuelAmador | 0:3d456b8ce449 | 54 | |
JuanManuelAmador | 0:3d456b8ce449 | 55 | void ScreenManager::getLastScreen(char buff[]){ |
JuanManuelAmador | 0:3d456b8ce449 | 56 | strcpy(buff, screenName[currentGroupID][lastScreen]); |
JuanManuelAmador | 0:3d456b8ce449 | 57 | } |
JuanManuelAmador | 0:3d456b8ce449 | 58 | |
JuanManuelAmador | 0:3d456b8ce449 | 59 | int ScreenManager::getCurrentGroupID(){ |
JuanManuelAmador | 0:3d456b8ce449 | 60 | return currentGroupID; |
JuanManuelAmador | 0:3d456b8ce449 | 61 | } |
JuanManuelAmador | 0:3d456b8ce449 | 62 | |
JuanManuelAmador | 0:3d456b8ce449 | 63 | void ScreenManager::backScreen(){ |
JuanManuelAmador | 0:3d456b8ce449 | 64 | changeScreen(screenName[currentGroupID][lastScreen]); |
JuanManuelAmador | 0:3d456b8ce449 | 65 | } |
JuanManuelAmador | 0:3d456b8ce449 | 66 | |
JuanManuelAmador | 0:3d456b8ce449 | 67 | void ScreenManager::initialize(){ |
JuanManuelAmador | 0:3d456b8ce449 | 68 | screens[currentGroupID][currentScreen]->initialize(lcd); |
JuanManuelAmador | 0:3d456b8ce449 | 69 | } |
JuanManuelAmador | 0:3d456b8ce449 | 70 | |
JuanManuelAmador | 0:3d456b8ce449 | 71 | void ScreenManager::update(){ |
JuanManuelAmador | 0:3d456b8ce449 | 72 | screens[currentGroupID][currentScreen]->update(lcd); |
JuanManuelAmador | 0:3d456b8ce449 | 73 | } |