Hover! test program.

Dependencies:   MjHover mbed

Committer:
matsujirushi
Date:
Sat Apr 04 14:51:39 2015 +0000
Revision:
2:93729c9dad56
Parent:
1:514827ffb84a
Added MjHover2 class.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
matsujirushi 0:6f474427ba37 1 #include "mbed.h"
matsujirushi 0:6f474427ba37 2 #include "MjHover.h"
matsujirushi 0:6f474427ba37 3
matsujirushi 0:6f474427ba37 4 using namespace matsujirushi;
matsujirushi 0:6f474427ba37 5
matsujirushi 0:6f474427ba37 6 Serial pc(USBTX, USBRX);
matsujirushi 0:6f474427ba37 7
matsujirushi 0:6f474427ba37 8 I2C i2c(p28, p27);
matsujirushi 0:6f474427ba37 9 DigitalInOut hover_ts(p21);
matsujirushi 0:6f474427ba37 10 DigitalInOut hover_reset_n(p22);
matsujirushi 0:6f474427ba37 11
matsujirushi 0:6f474427ba37 12 int main()
matsujirushi 0:6f474427ba37 13 {
matsujirushi 0:6f474427ba37 14 pc.baud(115200);
matsujirushi 2:93729c9dad56 15 i2c.frequency(400000);
matsujirushi 0:6f474427ba37 16
matsujirushi 2:93729c9dad56 17 #if 0 // 1:MjHover, 0:MjHover2
matsujirushi 2:93729c9dad56 18
matsujirushi 2:93729c9dad56 19 pc.printf("MjHover class.\r\n");
matsujirushi 0:6f474427ba37 20
matsujirushi 2:93729c9dad56 21 MjHover hover(&i2c, 0x84, &hover_ts, &hover_reset_n);
matsujirushi 2:93729c9dad56 22
matsujirushi 0:6f474427ba37 23 hover.begin();
matsujirushi 0:6f474427ba37 24
matsujirushi 2:93729c9dad56 25 for (;;)
matsujirushi 0:6f474427ba37 26 {
matsujirushi 0:6f474427ba37 27 if (hover.getStatus() == false)
matsujirushi 0:6f474427ba37 28 {
matsujirushi 0:6f474427ba37 29 uint8_t event = hover.getEvent();
matsujirushi 0:6f474427ba37 30 hover.setRelease();
matsujirushi 0:6f474427ba37 31
matsujirushi 0:6f474427ba37 32 const char* output_string = hover.getEventString(event);
matsujirushi 0:6f474427ba37 33 if (event != 0)
matsujirushi 0:6f474427ba37 34 {
matsujirushi 0:6f474427ba37 35 pc.printf("%02x:[%s]\r\n", event, hover.getEventString(event));
matsujirushi 0:6f474427ba37 36 }
matsujirushi 0:6f474427ba37 37 }
matsujirushi 0:6f474427ba37 38 }
matsujirushi 2:93729c9dad56 39
matsujirushi 2:93729c9dad56 40 #else
matsujirushi 2:93729c9dad56 41
matsujirushi 2:93729c9dad56 42 pc.printf("MjHover2 class.\r\n");
matsujirushi 2:93729c9dad56 43
matsujirushi 2:93729c9dad56 44 MjHover2 hover(&i2c, 0x84, &hover_ts, &hover_reset_n);
matsujirushi 2:93729c9dad56 45 hover.Reset();
matsujirushi 2:93729c9dad56 46 for (;;)
matsujirushi 2:93729c9dad56 47 {
matsujirushi 2:93729c9dad56 48 hover.Task();
matsujirushi 2:93729c9dad56 49
matsujirushi 2:93729c9dad56 50 if (hover.SensorData.GestureInfoValid) printf("GestureInfo %d\r\n", hover.SensorData.GestureInfo);
matsujirushi 2:93729c9dad56 51 // if (hover.SensorData.TouchInfoValid) printf("TouchInfo %04x\r\n", hover.SensorData.TouchInfo);
matsujirushi 2:93729c9dad56 52 // if (hover.SensorData.XyzPositionValid) printf("XyzPosition %5u,%5u,%5u\r\n", hover.SensorData.XyzPosition.X, hover.SensorData.XyzPosition.Y, hover.SensorData.XyzPosition.Z);
matsujirushi 2:93729c9dad56 53
matsujirushi 2:93729c9dad56 54 }
matsujirushi 2:93729c9dad56 55
matsujirushi 2:93729c9dad56 56 #endif
matsujirushi 0:6f474427ba37 57 }