Touchscreen digit recognition.
Dependencies: mbed TFT_fonts SPI_TFT_ILI9341 Adafruit_GFX FT6206 MMA8451Q
orientation.cpp@2:1ab6ba7c2c90, 2020-01-17 (annotated)
- Committer:
- atomicle
- Date:
- Fri Jan 17 08:33:46 2020 +0000
- Revision:
- 2:1ab6ba7c2c90
Project demo finished.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
atomicle | 2:1ab6ba7c2c90 | 1 | #include "orientation.hpp" |
atomicle | 2:1ab6ba7c2c90 | 2 | |
atomicle | 2:1ab6ba7c2c90 | 3 | int get_orientation() { |
atomicle | 2:1ab6ba7c2c90 | 4 | static bool horizontal = true; |
atomicle | 2:1ab6ba7c2c90 | 5 | float x = abs(acc.getAccX()); |
atomicle | 2:1ab6ba7c2c90 | 6 | float y = abs(acc.getAccY()); |
atomicle | 2:1ab6ba7c2c90 | 7 | float z = abs(acc.getAccZ()); |
atomicle | 2:1ab6ba7c2c90 | 8 | horizontal = z < 0.5 ? y > x : horizontal; |
atomicle | 2:1ab6ba7c2c90 | 9 | return horizontal ? LANDSCAPE : PORTRAIT; |
atomicle | 2:1ab6ba7c2c90 | 10 | } |