Vitaliy Loginov
/
disp70
Riverdi 70
main.cpp@0:e46c1282b39f, 2020-06-18 (annotated)
- Committer:
- vitlog
- Date:
- Thu Jun 18 13:18:02 2020 +0000
- Revision:
- 0:e46c1282b39f
Riverdi EVE 70
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vitlog | 0:e46c1282b39f | 1 | #include "mbed.h" |
vitlog | 0:e46c1282b39f | 2 | #include "FT_Platform.h" |
vitlog | 0:e46c1282b39f | 3 | #include "HYT.h" |
vitlog | 0:e46c1282b39f | 4 | #include "display.h" |
vitlog | 0:e46c1282b39f | 5 | |
vitlog | 0:e46c1282b39f | 6 | // NUCLEO-F429ZI |
vitlog | 0:e46c1282b39f | 7 | HYT SENSOR (D14, D15); // sda, scl |
vitlog | 0:e46c1282b39f | 8 | FT813 TFT (D11, D12, D13, D10, D9, D8); // mosi, miso, sck, ss, int, pd |
vitlog | 0:e46c1282b39f | 9 | |
vitlog | 0:e46c1282b39f | 10 | Display disp(&TFT); |
vitlog | 0:e46c1282b39f | 11 | |
vitlog | 0:e46c1282b39f | 12 | /************************************************************************************************************************** |
vitlog | 0:e46c1282b39f | 13 | ************************** HYT sensor polling cycle *********************************************************************** |
vitlog | 0:e46c1282b39f | 14 | **************************************************************************************************************************/ |
vitlog | 0:e46c1282b39f | 15 | void dataUpdate(void) |
vitlog | 0:e46c1282b39f | 16 | { |
vitlog | 0:e46c1282b39f | 17 | SENSOR.MRCommand(); |
vitlog | 0:e46c1282b39f | 18 | wait_ms(100); |
vitlog | 0:e46c1282b39f | 19 | SENSOR.DFCommand(); |
vitlog | 0:e46c1282b39f | 20 | } |
vitlog | 0:e46c1282b39f | 21 | |
vitlog | 0:e46c1282b39f | 22 | /************************************************************************************************************************** |
vitlog | 0:e46c1282b39f | 23 | ************************** Main function ********************************************************************************** |
vitlog | 0:e46c1282b39f | 24 | **************************************************************************************************************************/ |
vitlog | 0:e46c1282b39f | 25 | |
vitlog | 0:e46c1282b39f | 26 | int main() |
vitlog | 0:e46c1282b39f | 27 | { |
vitlog | 0:e46c1282b39f | 28 | |
vitlog | 0:e46c1282b39f | 29 | disp.Calibration(); |
vitlog | 0:e46c1282b39f | 30 | |
vitlog | 0:e46c1282b39f | 31 | disp.activeScreen = MENU_SCREEN; |
vitlog | 0:e46c1282b39f | 32 | disp.pressedButton = NONE_PRESS; |
vitlog | 0:e46c1282b39f | 33 | |
vitlog | 0:e46c1282b39f | 34 | // change active screen depending on pressed area |
vitlog | 0:e46c1282b39f | 35 | while(1) { |
vitlog | 0:e46c1282b39f | 36 | dataUpdate(); |
vitlog | 0:e46c1282b39f | 37 | disp.pressedButton = disp.GetTouch(); |
vitlog | 0:e46c1282b39f | 38 | |
vitlog | 0:e46c1282b39f | 39 | // ---------------------------------------------------------------------------------------------- |
vitlog | 0:e46c1282b39f | 40 | // Main menu screen |
vitlog | 0:e46c1282b39f | 41 | if (disp.activeScreen == MENU_SCREEN) { |
vitlog | 0:e46c1282b39f | 42 | disp.MainMenu(SENSOR.humidity, SENSOR.temperature); |
vitlog | 0:e46c1282b39f | 43 | if (disp.pressedButton) { |
vitlog | 0:e46c1282b39f | 44 | wait_ms(150); |
vitlog | 0:e46c1282b39f | 45 | if (disp.pressedButton == CURR_TEMP_PRESS) { |
vitlog | 0:e46c1282b39f | 46 | disp.activeScreen = CURR_TEMP_SCREEN; |
vitlog | 0:e46c1282b39f | 47 | } else if (disp.pressedButton == CURR_HUM_PRESS) { |
vitlog | 0:e46c1282b39f | 48 | disp.activeScreen = CURR_HUM_SCREEN; |
vitlog | 0:e46c1282b39f | 49 | } |
vitlog | 0:e46c1282b39f | 50 | disp.pressedButton = NONE_PRESS; |
vitlog | 0:e46c1282b39f | 51 | } |
vitlog | 0:e46c1282b39f | 52 | |
vitlog | 0:e46c1282b39f | 53 | // ---------------------------------------------------------------------------------------------- |
vitlog | 0:e46c1282b39f | 54 | // Any other screen |
vitlog | 0:e46c1282b39f | 55 | } else { |
vitlog | 0:e46c1282b39f | 56 | // ---------------------------------------------------------------------------------------------- |
vitlog | 0:e46c1282b39f | 57 | // You can back to main menu from any screen |
vitlog | 0:e46c1282b39f | 58 | if (disp.pressedButton == MENU_PRESS) { |
vitlog | 0:e46c1282b39f | 59 | disp.pressedButton = NONE_PRESS; |
vitlog | 0:e46c1282b39f | 60 | disp.activeScreen = MENU_SCREEN; |
vitlog | 0:e46c1282b39f | 61 | } else { |
vitlog | 0:e46c1282b39f | 62 | // ---------------------------------------------------------------------------------------------- |
vitlog | 0:e46c1282b39f | 63 | // Screen with current temperature / humidity |
vitlog | 0:e46c1282b39f | 64 | if (disp.activeScreen == CURR_TEMP_SCREEN) { |
vitlog | 0:e46c1282b39f | 65 | disp.CurrentTemperature(SENSOR.temperature); |
vitlog | 0:e46c1282b39f | 66 | } else if (disp.activeScreen == CURR_HUM_SCREEN) { |
vitlog | 0:e46c1282b39f | 67 | disp.CurrentHumidity(SENSOR.humidity); |
vitlog | 0:e46c1282b39f | 68 | } |
vitlog | 0:e46c1282b39f | 69 | } |
vitlog | 0:e46c1282b39f | 70 | } |
vitlog | 0:e46c1282b39f | 71 | } |
vitlog | 0:e46c1282b39f | 72 | } |
vitlog | 0:e46c1282b39f | 73 |