
Hover! test program.
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "MjHover.h" 00003 00004 using namespace matsujirushi; 00005 00006 Serial pc(USBTX, USBRX); 00007 00008 I2C i2c(p28, p27); 00009 DigitalInOut hover_ts(p21); 00010 DigitalInOut hover_reset_n(p22); 00011 00012 int main() 00013 { 00014 pc.baud(115200); 00015 i2c.frequency(400000); 00016 00017 #if 0 // 1:MjHover, 0:MjHover2 00018 00019 pc.printf("MjHover class.\r\n"); 00020 00021 MjHover hover(&i2c, 0x84, &hover_ts, &hover_reset_n); 00022 00023 hover.begin(); 00024 00025 for (;;) 00026 { 00027 if (hover.getStatus() == false) 00028 { 00029 uint8_t event = hover.getEvent(); 00030 hover.setRelease(); 00031 00032 const char* output_string = hover.getEventString(event); 00033 if (event != 0) 00034 { 00035 pc.printf("%02x:[%s]\r\n", event, hover.getEventString(event)); 00036 } 00037 } 00038 } 00039 00040 #else 00041 00042 pc.printf("MjHover2 class.\r\n"); 00043 00044 MjHover2 hover(&i2c, 0x84, &hover_ts, &hover_reset_n); 00045 hover.Reset(); 00046 for (;;) 00047 { 00048 hover.Task(); 00049 00050 if (hover.SensorData.GestureInfoValid) printf("GestureInfo %d\r\n", hover.SensorData.GestureInfo); 00051 // if (hover.SensorData.TouchInfoValid) printf("TouchInfo %04x\r\n", hover.SensorData.TouchInfo); 00052 // if (hover.SensorData.XyzPositionValid) printf("XyzPosition %5u,%5u,%5u\r\n", hover.SensorData.XyzPosition.X, hover.SensorData.XyzPosition.Y, hover.SensorData.XyzPosition.Z); 00053 00054 } 00055 00056 #endif 00057 }
Generated on Sat Jul 16 2022 02:02:13 by
