123

Dependents:  

Fork of Ventiel by Temp27

Files at this revision

API Documentation at this revision

Comitter:
Sven3010
Date:
Sun Sep 07 12:07:49 2014 +0000
Parent:
3:0a998c16eead
Commit message:
070914;

Changed in this revision

ventiel.cpp Show annotated file Show diff for this revision Revisions of this file
ventiel.h Show annotated file Show diff for this revision Revisions of this file
--- a/ventiel.cpp	Wed Aug 20 12:18:47 2014 +0000
+++ b/ventiel.cpp	Sun Sep 07 12:07:49 2014 +0000
@@ -1,8 +1,9 @@
-
+#include "MODSERIAL.h"
 #include "ventiel.h"
 
 extern Serial pc;                       // definiert in main
-extern Serial com;                      // definiert in main
+extern Serial com;
+//extern MODSERIAL com;                      // definiert in main
 
 //--------------------------------------------------------
 // Construktor initialisiert das Ventiel
@@ -15,7 +16,7 @@
 {
   uint8_t wert1 = 0;
   
-  pc.printf("\nmagnet.set alt =  %02x parmeter = %d",v_var,val);
+  //pc.printf("\nmagnet.set alt =  %02x parmeter = %d",v_var,val);
   
   
   if (val < 8)
@@ -33,23 +34,66 @@
   pc.printf("\nmagnet.set neu =  %02x verknuepfung = %02x\n",v_var,wert1); 
   
   // Alle Kanäle ausschalten
-  com.putc('9');        
+  //com.putc('9');        
   
   
   // aktive Kanäle einschalten
+ 
   for (uint8_t n = 0; n < 8; n++)
   {
     
     if ((v_var & (1 << n)) != 0)
     {
         char ch = 0x31 + n;
-        com.putc(ch); 
-        pc.printf("\nZeichenausgabe =  %c \n",ch);
-        wait_ms(10);  
+        //com.putc(ch); 
+        //pc.printf("\nZeichenausgabe =  %c \n",ch);
+        //wait_ms(10);  
     }
               
   } 
+   com.printf(":AA0201%02xA5\n",v_var);
+}
+
+void ventiel::toggle(uint8_t val)
+{
+  uint8_t wert1 = 0;
   
+  //pc.printf("\nmagnet.toggle alt =  %02x parmeter = %d",v_var,val);
+  
+  
+  if (val < 8)
+  {
+    // interne Variabel setzen
+    wert1 = (1 << val);
+    if((v_var & wert1)==0){
+        v_var |= wert1; 
+        }else{
+        v_var &= ~wert1;    
+            
+        }
+  }
+ 
+  pc.printf("\nmagnet.toggle neu =  %02x verknuepfung = %02x\n",v_var,wert1); 
+  
+  // Alle Kanäle ausschalten
+  //com.putc('9');        
+  
+  
+  // aktive Kanäle einschalten
+ 
+  for (uint8_t n = 0; n < 8; n++)
+  {
+    
+    if ((v_var & (1 << n)) != 0)
+    {
+        char ch = 0x31 + n;
+        //com.putc(ch); 
+        //pc.printf("\nZeichenausgabe =  %c \n",ch);
+        //wait_ms(10);  
+    }
+              
+  } 
+   com.printf(":AA0201%02xA5\n",v_var);
 }
 
 void ventiel::reset(uint8_t val)
@@ -57,7 +101,7 @@
 
   uint8_t wert1 = 0;
   
-  pc.printf("\nmagnet.reset alt =  %02x parameter = %d",v_var,val);
+  //pc.printf("\nmagnet.reset alt =  %02x parameter = %d",v_var,val);
   
   if (val < 8)
   {
@@ -74,7 +118,10 @@
   pc.printf("\nmagnet.reset neu =  %02x, verknuepfung = %02x\n",v_var,wert1);  
    
    // Alle Kanäle ausschalten
-  com.putc('9');        
+//com.putc('9');        
+  
+  com.printf(":AA0201%02xA5\n",v_var);
+ 
   
   // aktive Kanäle einschalten
   for (uint8_t n = 0; n < 8; n++)
@@ -82,9 +129,9 @@
     if ((v_var & (1 << n)) != 0) 
     {
         char ch = 0x31 + n;
-        com.putc(ch);
-        pc.printf("\nZeichenausgabe =  %c \n",ch);
-        wait_ms(10);
+        //com.putc(ch);
+        //pc.printf("\nZeichenausgabe =  %c \n",ch);
+        //wait_ms(10);
     }             
   }  
 
--- a/ventiel.h	Wed Aug 20 12:18:47 2014 +0000
+++ b/ventiel.h	Sun Sep 07 12:07:49 2014 +0000
@@ -8,6 +8,7 @@
   uint8_t v_var;
   
   ventiel(); 
+  void toggle(uint8_t val);
   void set(uint8_t val);
   void reset(uint8_t val);
   bool get(uint8_t val);