class pah8011 for mbed
pixart_pah8011.h@6:d196b612b14a, 2019-01-23 (annotated)
- Committer:
- bell_huang
- Date:
- Wed Jan 23 08:01:57 2019 +0000
- Revision:
- 6:d196b612b14a
- Parent:
- 5:37451de228e4
Remove mbed
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bell_huang | 0:242cf8f28bf2 | 1 | #ifndef __pixart_pah8011_h__ |
bell_huang | 0:242cf8f28bf2 | 2 | #define __pixart_pah8011_h__ |
bell_huang | 0:242cf8f28bf2 | 3 | |
bell_huang | 0:242cf8f28bf2 | 4 | |
bell_huang | 0:242cf8f28bf2 | 5 | #include <mbed.h> |
bell_huang | 0:242cf8f28bf2 | 6 | |
bell_huang | 0:242cf8f28bf2 | 7 | #include <cstdint> |
bell_huang | 0:242cf8f28bf2 | 8 | |
bell_huang | 0:242cf8f28bf2 | 9 | |
bell_huang | 0:242cf8f28bf2 | 10 | namespace pixart { |
bell_huang | 0:242cf8f28bf2 | 11 | |
bell_huang | 0:242cf8f28bf2 | 12 | |
bell_huang | 0:242cf8f28bf2 | 13 | class pah8011 { |
bell_huang | 0:242cf8f28bf2 | 14 | public: |
bell_huang | 5:37451de228e4 | 15 | typedef void (*DEBUG_PRINT_HANDLE)(const char *fmt, ...); |
bell_huang | 5:37451de228e4 | 16 | |
bell_huang | 0:242cf8f28bf2 | 17 | struct task_result { |
bell_huang | 0:242cf8f28bf2 | 18 | // ppg |
bell_huang | 4:cbc49829af39 | 19 | int32_t *data; |
bell_huang | 0:242cf8f28bf2 | 20 | uint32_t num_per_ch; |
bell_huang | 0:242cf8f28bf2 | 21 | uint32_t ch_num; |
bell_huang | 0:242cf8f28bf2 | 22 | |
bell_huang | 0:242cf8f28bf2 | 23 | // touch |
bell_huang | 0:242cf8f28bf2 | 24 | bool is_touched; |
bell_huang | 0:242cf8f28bf2 | 25 | }; |
bell_huang | 0:242cf8f28bf2 | 26 | |
bell_huang | 0:242cf8f28bf2 | 27 | public: |
bell_huang | 6:d196b612b14a | 28 | pah8011(I2C &i2c, uint8_t slave_id = 0x15); |
bell_huang | 6:d196b612b14a | 29 | pah8011(SPI &spi, DigitalOut &cs); |
bell_huang | 0:242cf8f28bf2 | 30 | ~pah8011(); |
bell_huang | 0:242cf8f28bf2 | 31 | |
bell_huang | 5:37451de228e4 | 32 | void enable_debug_print(DEBUG_PRINT_HANDLE handler); |
bell_huang | 5:37451de228e4 | 33 | |
bell_huang | 6:d196b612b14a | 34 | bool init(); |
bell_huang | 0:242cf8f28bf2 | 35 | |
bell_huang | 0:242cf8f28bf2 | 36 | // operations |
bell_huang | 0:242cf8f28bf2 | 37 | bool enable_ppg(); |
bell_huang | 0:242cf8f28bf2 | 38 | bool disable_ppg(); |
bell_huang | 0:242cf8f28bf2 | 39 | bool enable_touch(); |
bell_huang | 0:242cf8f28bf2 | 40 | bool disable_touch(); |
bell_huang | 0:242cf8f28bf2 | 41 | |
bell_huang | 0:242cf8f28bf2 | 42 | // tasking |
bell_huang | 0:242cf8f28bf2 | 43 | bool task(); |
bell_huang | 0:242cf8f28bf2 | 44 | bool get_result(task_result &result); |
bell_huang | 6:d196b612b14a | 45 | |
bell_huang | 6:d196b612b14a | 46 | // access |
bell_huang | 6:d196b612b14a | 47 | I2C* get_i2c() const; |
bell_huang | 6:d196b612b14a | 48 | uint8_t get_i2c_slave_id() const; |
bell_huang | 6:d196b612b14a | 49 | SPI* get_spi() const; |
bell_huang | 6:d196b612b14a | 50 | DigitalOut* get_spi_cs() const; |
bell_huang | 0:242cf8f28bf2 | 51 | |
bell_huang | 0:242cf8f28bf2 | 52 | private: |
bell_huang | 1:4e43ab5ba1e2 | 53 | pah8011(const pah8011&); // = delete; |
bell_huang | 1:4e43ab5ba1e2 | 54 | pah8011& operator=(const pah8011&); // = delete; |
bell_huang | 1:4e43ab5ba1e2 | 55 | |
bell_huang | 0:242cf8f28bf2 | 56 | bool select_mode(); |
bell_huang | 0:242cf8f28bf2 | 57 | |
bell_huang | 1:4e43ab5ba1e2 | 58 | private: |
bell_huang | 6:d196b612b14a | 59 | // i2c |
bell_huang | 6:d196b612b14a | 60 | I2C *m_i2c; |
bell_huang | 6:d196b612b14a | 61 | uint8_t m_i2c_slave_id; |
bell_huang | 6:d196b612b14a | 62 | |
bell_huang | 6:d196b612b14a | 63 | // spi |
bell_huang | 6:d196b612b14a | 64 | SPI *m_spi; |
bell_huang | 6:d196b612b14a | 65 | DigitalOut *m_spi_cs; |
bell_huang | 6:d196b612b14a | 66 | |
bell_huang | 6:d196b612b14a | 67 | // state |
bell_huang | 6:d196b612b14a | 68 | bool m_is_ppg_enabled; |
bell_huang | 6:d196b612b14a | 69 | bool m_is_touch_enabled; |
bell_huang | 0:242cf8f28bf2 | 70 | |
bell_huang | 0:242cf8f28bf2 | 71 | }; |
bell_huang | 0:242cf8f28bf2 | 72 | |
bell_huang | 0:242cf8f28bf2 | 73 | |
bell_huang | 0:242cf8f28bf2 | 74 | } |
bell_huang | 0:242cf8f28bf2 | 75 | |
bell_huang | 0:242cf8f28bf2 | 76 | |
bell_huang | 0:242cf8f28bf2 | 77 | #endif // header guard |