fork of seeed studio 4-digit display for st nucleo board
Dependencies: Data_Clock_Pair Seeed_Chainable_LED Seeed_Four_Digit_Disp Seeed_IR_Temp_Sensor Seeed_Led_Bar
Fork of Seeed_Grove_4_Digit_Display_Clock by
Revision 20:2e72ddd68cda, committed 2017-06-22
- Comitter:
- tulanthoar
- Date:
- Thu Jun 22 12:17:29 2017 -0600
- Parent:
- 19:ad7bc3db9f1a
- Commit message:
- add q touch which doesn't work yet
Changed in this revision
SeeedQTouch.h | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r ad7bc3db9f1a -r 2e72ddd68cda SeeedQTouch.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SeeedQTouch.h Thu Jun 22 12:17:29 2017 -0600 @@ -0,0 +1,72 @@ +#ifndef MBED_SEEED_Q_TOUCH_H +#define MBED_SEEED_Q_TOUCH_H +#include "mbed.h" +#include "DataClockPair.h" + +#define QTOUCH_REG_RESET 0X39 // reset +class SeeedQTouch { + + static const int devAddr_ = 0x1b; + int readOpCode_; + int writeOpCode_; + static const int stateReg_ = 0x03; + static const int calibrateReg_ = 0x38; + I2C i2c_; + int read_register_(int address, Serial* pc); + int read_state_(Serial* pc); + public: + SeeedQTouch(DataClockPair pins); + int key_touch(Serial* pc); +}; + +SeeedQTouch::SeeedQTouch(DataClockPair pins) : i2c_(pins.dataPin, pins.clockPin) { + /* readOpCode_ = devAddr_ | 0x01; */ + /* writeOpCode_ = devAddr_ & 0xFE; */ + /* writeOpCode_ = devAddr_ | 0x00; */ + readOpCode_ = devAddr_; + writeOpCode_ = devAddr_; +} + +int SeeedQTouch::read_register_(int address, Serial* pc) { + int success; + char dataWrite[2]; + char resetWrite[2]; + char dataRead[2]; +dataWrite[0] = 0x00; +dataWrite[1] = 0x55; +resetWrite[0] = QTOUCH_REG_RESET; +resetWrite[1] = 0x55; + /* int success = i2c_.write(devAddr_, dataWrite, 1, 0); */ + /* if( pc ) pc->printf("requesting register %i success is %i", dataWrite[0], success); */ +/* dataWrite[0] = 0x55; */ + success = i2c_.write(writeOpCode_, resetWrite, 2); + success = i2c_.write(writeOpCode_, dataWrite, 2); + if( pc ) pc->printf("requesting register %i success is %i", dataWrite[0], success); + /* dataWrite[0] = stateReg_; */ + /* wait_ms(1); */ + /* i2c_.start(); */ + /* wait_ms(1); */ + /* success = i2c_.write(devAddr_, dataWrite, 1, 1); */ + /* wait_ms(1); */ + success = i2c_.read(readOpCode_, dataRead, 2); + if( pc ) pc->printf("return value is %i or %i success is %i", dataRead[0] , dataRead[1], success); + /* i2c_.stop(); */ + wait_ms(1); + /* int result; */ + /* i2c_.start(); */ + wait_ms(1); + /* result = i2c_.read(1); */ + wait_ms(1); + /* i2c_.stop(); */ + return dataRead[0]; +} + +int SeeedQTouch::read_state_(Serial* pc) { + return read_register_(0x03, pc); +} + +int SeeedQTouch::key_touch(Serial* pc = 0) { + int keys = read_state_(pc); + return(keys); +} +#endif
diff -r ad7bc3db9f1a -r 2e72ddd68cda main.cpp --- a/main.cpp Thu Jun 22 12:16:02 2017 -0600 +++ b/main.cpp Thu Jun 22 12:17:29 2017 -0600 @@ -15,7 +15,7 @@ void blink_led() { for(DigitalOut led(PF_12);; Thread::wait(1000) ) { - led = !led + led = !led; } } } // namespace