Display Steuerung für Lampen per Relais. https://www.youtube.com/watch?v=_CupBMcZ8Xc

Dependencies:   BSP_DISCO_F746NG F746_GUI LCD_DISCO_F746NG TS_DISCO_F746NG mbed

Revision:
1:f316de154ff7
Parent:
0:da00b5dd65c6
--- a/main.cpp	Mon Jan 30 20:58:13 2017 +0000
+++ b/main.cpp	Sun Apr 23 17:15:53 2017 +0000
@@ -1,75 +1,90 @@
+/*=============================================================================================
+        section 1 - includes
+ ==============================================================================================*/
+/* imported libs */
 #include "mbed.h"
 #include "F746_GUI.hpp"
+
+/* project files */
+#include "relay.h"
 #include "flash.h"
+#include "lightAutomatic.h"
 
-/************************************
- local variables / objects 
- ************************************/
-static DigitalOut light1Fet1(D4, 0);
-static DigitalOut light1Fet2(D5, 0);
-static DigitalOut light2Fet1(D6, 0);
-static DigitalOut light2Fet2(D7, 0);
-static uint8_t flashData[FLASH_DATA_SIZE];
+/*=============================================================================================
+        section 2 - private defines / enumerations
+ ==============================================================================================*/
 
-/************************************
- local function declaration 
- ************************************/
- 
-static void _switchButton(DigitalOut out1, DigitalOut out2, uint8_t *toggleByte);
+/*=============================================================================================
+        section 3 - private typedefs
+ ==============================================================================================*/
 
-/************************************
- local function definition 
- ************************************/
+/*=============================================================================================
+        section 4 - private macros
+ ==============================================================================================*/
  
-static void _switchButton(DigitalOut out1, DigitalOut out2, uint8_t *toggleByte) {
-    /* toggle byte invertieren */
-    *toggleByte = !(*toggleByte);
-    /* schreibe Daten ins Flash. Stellt Datenkonsistenz zwischen RAM und ROM sicher. */
-    flash_write(flashData); 
-    
-    /* Je nach Stellung des toggle Bytes,
-       wird Ausgang 1 oder 2 kurzzeitig geschaltet (Spannung angelegt). */
-    if(*toggleByte){
-        out1 = 1;
-        wait(0.5);
-        out1 = 0;
-    } else{
-        out2 = 1;
-        wait(0.5);
-        out2 = 0;
-    }  
-}
+/*=============================================================================================
+        section 5 - public constants definition
+ ==============================================================================================*/
+
+/*=============================================================================================
+        section 6 - public variables/pointers definition
+ ==============================================================================================*/
+/* inputs */
+DigitalIn g_doorSensor(D3, PullUp);
+DigitalIn g_lightSensor(D2, PullDown);
+
+/* outputs */
+DigitalOut g_light1Fet1(D4, 0);
+DigitalOut g_light1Fet2(D5, 0);
+DigitalOut g_light2Fet1(D6, 0);
+DigitalOut g_light2Fet2(D7, 0);
+
+/*=============================================================================================
+        section 7 - private constants definition
+ ==============================================================================================*/
 
-/************************************
- global function definition
- ************************************/
- 
-int main() {    
+/*=============================================================================================
+        section 8 - private variables/objects/pointers definition
+ ==============================================================================================*/
+
+/*=============================================================================================
+        section 9 - private functions - declaration
+ ==============================================================================================*/
+
+/*=============================================================================================
+        section 10 - private functions - implementation (definition)
+ ==============================================================================================*/
+
+/*=============================================================================================
+        section 11 - public functions - implementation (definition)
+ ==============================================================================================*/
+int main() 
+{      
+    /* GUI Ojects */
+    Label labelTop(240, 2, "Display Steuerung v0.2", Label::CENTER, Font16);
+
     /***************************
      init 
-     ***************************/
-    /* GUI Ojects */
-    Label label1(240, 2, "Display Steuerung v0.1", Label::CENTER, Font16);
-    Button btnLight1(10, 40, 70, 40, "Lampe 1");
-    Button btnLight2(90, 40, 70, 40, "Lampe 2");
-    
-    /* flash */
+     ***************************/   
+    relay_init();
     flash_init();    
-    flash_read(flashData); /* Lese Daten von flash (ROM) in das RAM */
+    lightAutomatic_init(); 
     
     /***************************
      main loop 
      ***************************/
-    while(1) {
-        /* prüft ob button "btnLight1" gerade gedrück ist */  
-        if (btnLight1.Touched()){
-            _switchButton(light1Fet1, light1Fet2, flashData + FLASH_TOGGLE_BYTE_LIGHT1);
-            btnLight1.Draw();
-        }
-        /* prüft ob button "btnLight2" gerade gedrück ist */  
-        if (btnLight2.Touched()){
-            _switchButton(light2Fet1, light2Fet2, flashData + FLASH_TOGGLE_BYTE_LIGHT2);
-            btnLight2.Draw();
-        }
+    while(1) 
+    { 
+        relay_task();
+        lightAutomatic_task();
+        flash_task();
     }
-}
\ No newline at end of file
+}
+
+/*=============================================================================================
+        section 12 - interrupt service routines (ISRs)
+ ==============================================================================================*/
+
+/*=============================================================================================
+        end of file
+ ==============================================================================================*/
\ No newline at end of file