c

Fork of MyLib by gaku takasawa

Files at this revision

API Documentation at this revision

Comitter:
kikoaac
Date:
Sun Jan 14 01:06:35 2018 +0000
Parent:
10:d0b1160ee5c2
Commit message:
?

Changed in this revision

Nunchuck/Nunchuck.h Show annotated file Show diff for this revision Revisions of this file
PS3/PS3.cpp Show diff for this revision Revisions of this file
PS3/PS3.h Show diff for this revision Revisions of this file
diff -r d0b1160ee5c2 -r 827d1ccc8bec Nunchuck/Nunchuck.h
--- a/Nunchuck/Nunchuck.h	Thu May 11 12:55:05 2017 +0000
+++ b/Nunchuck/Nunchuck.h	Sun Jan 14 01:06:35 2018 +0000
@@ -5,7 +5,7 @@
 #include "mbed.h"
 
 #define NUNCHUCK_ANALOGDATA 1  //1 : analog   0 : degital
-#define NUNCHUCK_DEADZONE 6    //analog stick's deadzone
+#define NUNCHUCK_DEADZONE 0    //analog stick's deadzone
 #define NUNCHUCK_ADDR    0xA4  // 0x52 << 1
 
 #define PI 3.14159265358979
diff -r d0b1160ee5c2 -r 827d1ccc8bec PS3/PS3.cpp
--- a/PS3/PS3.cpp	Thu May 11 12:55:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +0,0 @@
-#include "PS3.h"
-
-        PS3::PS3(PinName TX, PinName RX) : Serial(TX, RX)
-        {
-            PS3Data[0] = 128;
-            PS3Data[1] = 0;
-            PS3Data[2] = 0;
-            PS3Data[3] = 64;
-            PS3Data[4] = 64;
-            PS3Data[5] = 64;
-            PS3Data[6] = 64;
-            PS3Data[7] = 0;
-            baud(2400);
-            Serial::attach(this, &PS3::getdata, Serial::RxIrq);
-        }
-        
-        bool PS3::maru()
-        {
-            return PS3Data[2] & MARU;
-        }
-        
-        bool PS3::batu()
-        {
-            return PS3Data[2] & BATU;
-        }
-        
-        bool PS3::sikaku()
-        {
-            return PS3Data[1] & SIKAKU;
-        }
-        
-        bool PS3::sankaku()
-        {
-            return PS3Data[2] & SANKAKU;
-        }
-        
-        bool PS3::ue()
-        {
-            return PS3Data[2] & UE && !(PS3Data[2] & SITA);
-        }
-        
-        bool PS3::sita()
-        {
-            return PS3Data[2] & SITA && !(PS3Data[2] & UE);
-        }
-        
-        bool PS3::start()
-        {
-            return PS3Data[2] & UE && PS3Data[2] & SITA;
-        }
-        
-        bool PS3::migi()
-        {
-            return PS3Data[2] & MIGI && !(PS3Data[2] & HIDARI);
-        }
-        
-        bool PS3::hidari()
-        {
-            return PS3Data[2] & HIDARI && !(PS3Data[2] & MIGI);
-        }
-        
-        bool PS3::select()
-        {
-            return PS3Data[2] & MIGI && PS3Data[2] & HIDARI;
-        }
-        
-        bool PS3::L1()
-        {
-            return PS3Data[1] & LEFT1;
-        }
-        
-        bool PS3::L2()
-        {
-            return PS3Data[1] & LEFT2;
-        }
-        
-        bool PS3::R1()
-        {
-            return PS3Data[1] & RIGHT1;
-        }
-        
-        bool PS3::R2()
-        {
-            return PS3Data[1] & RIGHT2;
-        }
-        
-        int8_t PS3::analogLX()
-        {
-            if(PS3Data[3] == 0)
-                PS3Data[3] = 1;
-            return PS3Data[3] - 64;
-        }
-        
-        int8_t PS3::analogLY()
-        {
-            if(PS3Data[4] == 0)
-                PS3Data[4] = 1;
-            return (PS3Data[4] - 64) * (-1);
-        }
-        
-        int8_t PS3::analogRX()
-        {
-            if(PS3Data[5] == 0)
-                PS3Data[5] = 1;
-            return PS3Data[5] - 64;
-        }
-        
-        int8_t PS3::analogRY()
-        {
-            if(PS3Data[6] == 0)
-                PS3Data[6] = 1;
-            return (PS3Data[6] - 64) * (-1);
-        }
-        
-        
-        
-        void PS3::getdata()
-        {
-            while(Serial::getc() != 128)
-            {
-            }
-            for(int i = 1; i < 8; i++)
-            {
-                GetData[i] = Serial::getc();
-            }
-            
-            sum = GetData[1] + GetData[2];
-            for(int i = 3; i < 7; i++)
-            {
-               sum += GetData[i] - 64;
-            }
-                
-            if(sum < 0)
-                 sum += 128;
-                    
-            if(sum == GetData[7])
-            {
-                for(int i = 0; i < 8; i++)
-                {
-                    PS3Data[i] = GetData[i];
-                }
-            }
-        }
\ No newline at end of file
diff -r d0b1160ee5c2 -r 827d1ccc8bec PS3/PS3.h
--- a/PS3/PS3.h	Thu May 11 12:55:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,173 +0,0 @@
-#ifndef PS3_H
-#define PS3_H
-#include "mbed.h"
-
-#define MARU 64
-#define BATU 32
-#define SIKAKU 1
-#define SANKAKU 16
-#define UE 1
-#define SITA 2
-#define MIGI 4
-#define HIDARI 8
-#define LEFT1 2
-#define LEFT2 4
-#define RIGHT1 8
-#define RIGHT2 16
-
-class PS3 : public Serial
-{
-    public:
-        PS3(PinName TX, PinName RX);
-        /*{
-            PS3Data[0] = 128;
-            PS3Data[1] = 0;
-            PS3Data[2] = 0;
-            PS3Data[3] = 64;
-            PS3Data[4] = 64;
-            PS3Data[5] = 64;
-            PS3Data[6] = 64;
-            PS3Data[7] = 0;
-            baud(2400);
-            Serial::attach(this, &PS3::getdata, Serial::RxIrq);
-        }*/
-        
-        bool maru();
-        /*{
-            return PS3Data[2] & MARU;
-        }*/
-        
-        bool batu();
-        /*{
-            return PS3Data[2] & BATU;
-        }*/
-        
-        bool sikaku();
-        /*{
-            return PS3Data[1] & SIKAKU;
-        }*/
-        
-        bool sankaku();
-        /*{
-            return PS3Data[2] & SANKAKU;
-        }*/
-        
-        bool ue();
-        /*{
-            return PS3Data[2] & UE && !(PS3Data[2] & SITA);
-        }*/
-        
-        bool sita();
-        /*{
-            return PS3Data[2] & SITA && !(PS3Data[2] & UE);
-        }*/
-        
-        bool start();
-        /*{
-            return PS3Data[2] & UE && PS3Data[2] & SITA;
-        }*/
-        
-        bool migi();
-        /*{
-            return PS3Data[2] & MIGI && !(PS3Data[2] & HIDARI);
-        }*/
-        
-        bool hidari();
-        /*{
-            return PS3Data[2] & HIDARI && !(PS3Data[2] & MIGI);
-        }*/
-        
-        bool select();
-        /*{
-            return PS3Data[2] & MIGI && PS3Data[2] & HIDARI;
-        }*/
-        
-        bool L1();
-        /*{
-            return PS3Data[1] & LEFT1;
-        }*/
-        
-        bool L2();
-        /*{
-            return PS3Data[1] & LEFT2;
-        }*/
-        
-        bool R1();
-        /*{
-            return PS3Data[1] & RIGHT1;
-        }*/
-        
-        bool R2();
-        /*{
-            return PS3Data[1] & RIGHT2;
-        }*/
-        
-        int8_t analogLX();
-        /*{
-            if(PS3Data[3] == 0)
-                PS3Data[3]=1;
-            return PS3Data[3]-64;
-        }*/
-        
-        int8_t analogLY();
-        /*{
-            if(PS3Data[4] == 0)
-                PS3Data[4]=1;
-            return (PS3Data[4]-64)*(-1);
-        }*/
-        
-        int8_t analogRX();
-        /*{
-            if(PS3Data[5] == 0)
-                PS3Data[5]=1;
-            return PS3Data[5]-64;
-        }*/
-        
-        int8_t analogRY();
-        /*{
-            if(PS3Data[6] == 0)
-                PS3Data[6]=1;
-            return (PS3Data[6]-64)*(-1);
-        }*/
-        
-        
-        
-    private:
-
-        int8_t sum;
-        uint8_t PS3Data[8];
-        uint8_t GetData[8];
-    
-        void getdata();
-        /*{
-            while(Serial::getc() != 128)
-            {
-            }
-            for(int i = 1;i < 8;i++)
-            {
-                GetData[i] = Serial::getc();
-            }
-            
-            sum = GetData[1] + GetData[2];
-            for(int i = 3;i < 7;i++)
-            {
-               sum += GetData[i] - 64;
-            }
-                
-            if(sum < 0)
-                 sum+=128;
-                    
-            if(sum == GetData[7])
-            {
-                for(int i = 0;i < 8;i++)
-                {
-                    PS3Data[i]=GetData[i];
-                }
-            }
-        }*/
-        
-};
-            
-#endif            
-            
-        
\ No newline at end of file