hoge

Dependents:   2017_Bteam_jushinkun-gamma

Files at this revision

API Documentation at this revision

Comitter:
Komazawa_sun
Date:
Thu Aug 17 06:34:06 2017 +0000
Commit message:
jushinkun_for_gamma_ctrl;

Changed in this revision

gamma_ctrl.cpp Show annotated file Show diff for this revision Revisions of this file
gamma_ctrl.h Show annotated file Show diff for this revision Revisions of this file
gamma_defines.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gamma_ctrl.cpp	Thu Aug 17 06:34:06 2017 +0000
@@ -0,0 +1,26 @@
+#include "gamma_ctrl.h"
+
+gamma_ctrl::gamma_ctrl(int baudlate_g)
+    :ctrl_serial(baudlate_g,GAMMA_DATA_SIZE)
+{
+}
+    
+void gamma_ctrl::get_data()
+{
+    //printf("sub class\r\n");
+    if(allready_set_data == true)
+    {
+        for(int t = 0;t < GAMMA_DATA_SIZE;t++)
+        {
+            pack.all_data[t] = ctrl_data[t];
+            //printf("%x",ctrl_data[t]);
+        }
+        allready_set_data = false;
+        //printf("\r\n"); 
+    }
+    /*else
+    {
+        for(int t = 0;t < GAMMA_DATA_SIZE;t++)
+            pack.all_data[t] = 0;
+    }*/
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gamma_ctrl.h	Thu Aug 17 06:34:06 2017 +0000
@@ -0,0 +1,47 @@
+#ifndef GAMMA_CTRL_H_
+#define GAMMA_CTRL_H_
+
+#include "ctrl_serial.h"
+
+class gamma_ctrl : public ctrl_serial
+{
+    public:
+        gamma_ctrl(int baudrate_g);
+        void get_data();
+        
+        union gamma_packet
+        {
+            char all_data[GAMMA_DATA_SIZE];
+            struct 
+            {
+                unsigned char start_byte:8;
+                signed int rx :8;
+                signed int ry :8;
+                signed int lx :8;
+                unsigned int r_sw1 :1;
+                unsigned int r_sw2 :1;
+                unsigned int r_sw3 :1;
+                unsigned int r_sw4 :1;
+                unsigned int r_s_sw1 :1;
+                unsigned int r_s_sw2 :1;
+                unsigned int l_sw1 :1;
+                unsigned int l_sw2 :1;
+                unsigned int l_sw3 :1;
+                unsigned int l_sw4 :1;
+                unsigned int l_s_sw1 :1;
+                unsigned int l_s_sw2 :1;
+                unsigned int mode1 :1;
+                unsigned int mode2 :1;
+                signed int r_srd :8;
+                signed int l_srd :8;
+                unsigned int no_data :2;
+                unsigned char phecksum:8;
+                unsigned char stop_byte :8;
+            }data;
+        };
+        
+        gamma_packet pack;
+
+};
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gamma_defines.h	Thu Aug 17 06:34:06 2017 +0000
@@ -0,0 +1,6 @@
+#ifndef GAMMA_DEFINES_H_
+
+#define GAMMA_DATA_SIZE 10
+#define GAMMA_ADDRESS 0x12
+
+#endif
\ No newline at end of file