f
Embed:
(wiki syntax)
Show/hide line numbers
Command.h
00001 #include "mbed.h" 00002 typedef unsigned char BYTE; 00003 00004 class Command { 00005 00006 private: 00007 BYTE M[6]; 00008 00009 public: 00010 Command() 00011 { 00012 M[0] = 0x03; 00013 M[1] = 0x00; 00014 M[2] = 0x00; 00015 M[3] = 0x00; 00016 M[4] = 0x00; 00017 M[5] = 0x00; 00018 } 00019 00020 void set() 00021 { 00022 M[0] = 0x03; 00023 M[1] = 0x00; 00024 M[2] = 0x00; 00025 M[3] = 0x00; 00026 M[4] = 0x00; 00027 M[5] = 0x00; 00028 } 00029 00030 void LIGHT(int value) 00031 { 00032 M[4] = value; 00033 } 00034 00035 void TH_L(int L) 00036 { 00037 if (L>0) 00038 { 00039 M[5] = M[5] | 4; 00040 M[1] = L; 00041 } 00042 else if (L<0) 00043 { 00044 M[5] = M[5] & (~4); 00045 M[1] = L * -1; 00046 } 00047 else if (L==0) 00048 { 00049 M[1] = L; 00050 } 00051 } 00052 00053 void TH_R(int R) 00054 { 00055 if (R>0) 00056 { 00057 M[5] = M[5] | 8; 00058 M[2] = R; 00059 } 00060 else if (R<0) 00061 { 00062 M[5] = M[5] & (~8); 00063 M[2] = R * -1; 00064 } 00065 else if (R==0) 00066 { 00067 M[2] = R; 00068 } 00069 } 00070 00071 void TH_H(int H) 00072 { 00073 if (H>0) 00074 { 00075 M[5] = M[5] & (~16); 00076 M[3] = H; 00077 } 00078 else if (H<0) 00079 { 00080 M[5] = M[5] | 16; 00081 M[3] = H * -1; 00082 } 00083 else if (H==0) 00084 { 00085 M[3] = H; 00086 } 00087 } 00088 00089 BYTE* Re() 00090 { 00091 return M; 00092 } 00093 00094 }; // Class Command 00095
Generated on Fri Nov 4 2022 02:05:23 by
1.7.2