Li Weiyi
/
LED_DZ
work fine
Diff: Microduino_MatrixBase.cpp
- Revision:
- 1:14b7c3a3ec60
- Parent:
- 0:5ca227682ee7
- Child:
- 2:487a727d6181
--- a/Microduino_MatrixBase.cpp Tue May 31 15:32:03 2016 +0000 +++ b/Microduino_MatrixBase.cpp Wed Jun 01 13:38:30 2016 +0000 @@ -30,18 +30,19 @@ #define MICRODUINO_MATRIXBASE_CPP #include "Microduino_MatrixBase.h" #include "MicroduinoPinNames.h" -//extern const uint8_t alphabetBitmap[95][FONE_SIZE_X + 1]; +extern Serial pc; uint8_t MatrixCount = 0; // the total number of attached keys -I2C g_i2c(SDA, SCL); +I2C g_i2c(P0_11, P0_10); -uint8_t pgm_read_byte(uint8_t *p) +uint8_t pgm_read_byte(const uint8_t *p) { return *p; } LedControl::LedControl() { + g_i2c.frequency(400000); if ( MatrixCount < 64) { this->matrixIndex = MatrixCount++; // assign a key index to this instance this->Devices_addr = 64 - MatrixCount; @@ -101,7 +102,8 @@ Wire.endTransmission(); // stop transmitting #else char cmd = 0x60; - g_i2c.write((int)(this->Devices_addr + 1), &cmd, 1); + int ret = g_i2c.write((this->Devices_addr + 1)<<1, &cmd, 1); + //pc.printf("clear led ret = %d\r\n", ret); #endif } @@ -119,7 +121,8 @@ Wire.write(temp, 4); // sends five bytes Wire.endTransmission(); // stop transmitting #else - g_i2c.write(this->Devices_addr + 1, (char*)temp, 4); + g_i2c.write((this->Devices_addr + 1)<<1, (char*)temp, 4, false); + //pc.printf("ret = %d\r\n", ret); #endif } @@ -135,7 +138,7 @@ Wire.write(temp, 2); // sends five bytes Wire.endTransmission(); // stop transmitting #else - g_i2c.write(this->Devices_addr + 1, (char*)temp, 2); + g_i2c.write((this->Devices_addr + 1) << 1, (char*)temp, 2); #endif } @@ -151,6 +154,8 @@ this->setLedColor(_row, _col, this->value_color[0], this->value_color[1], this->value_color[2]); } else this->setLedColorFast(_row, _col, 0, 0, 0); + + wait_ms(1); } void LedControl::setRow(uint8_t _row, uint8_t _value)