Modified version of the DmTftLibrary, optimized for the LPC4088 Experiment Base Board
Dependents: lpc4088_ebb_dm_calc lpc4088_ebb_dm_bubbles
Fork of DmTftLibrary by
Revision 3:02c19cbc707c, committed 2014-05-21
- Comitter:
- displaymodule
- Date:
- Wed May 21 14:43:08 2014 +0000
- Parent:
- 2:59be7fca4581
- Child:
- 4:92d019216e28
- Commit message:
- Fixed bug in Touch.cpp. Added delays in the pulse_* macros to lower the clock frequency in the simulated SPI communication.
Changed in this revision
--- a/DmTouch.cpp Tue May 20 12:21:43 2014 +0200 +++ b/DmTouch.cpp Wed May 21 14:43:08 2014 +0000 @@ -50,7 +50,7 @@ _width = 240; _height = 320; break; - + case DmTouch::DM_TFT28_105: _cs = D4; _irq = D2; @@ -92,14 +92,14 @@ _calibInvertedTouch = true; break; - case DmTouch::DM_TFT35_107: + case DmTouch::DM_TFT35_107: _calibLowX = 912; _calibLowY = 422 ; _calibModifierX = 3.25; _calibModifierY = 1.175; _calibInvertedTouch = false; break; - + case DmTouch::DM_TFT28_105: default: _calibLowX = 260; @@ -145,8 +145,9 @@ //cbi(_pinCS, _bitmaskCS); } else { _pinCLK = new DigitalOut((PinName)_clk); - _pinMISO = new DigitalOut((PinName)_miso); + _pinMISO = new DigitalIn((PinName)_miso); _pinMOSI = new DigitalOut((PinName)_mosi); + sbi(_pinCLK, _bitmaskCLK); } #endif @@ -203,7 +204,6 @@ else { uint8_t count=0; uint8_t temp = data; - cbi(_pinCLK, _bitmaskCLK); for(count=0;count<8;count++) { if(temp&0x80) { sbi(_pinMOSI, _bitmaskMOSI); @@ -234,8 +234,7 @@ } else { uint8_t count=0; uint8_t temp=0; - cbi(_pinCLK, _bitmaskCLK); - cbi(_pinMOSI, _bitmaskMOSI); + cbi(_pinMOSI, _bitmaskMOSI); // same as using 0x00 as dummy byte for(count=0;count<8;count++) { pulse_low(_pinCLK, _bitmaskCLK); @@ -316,6 +315,7 @@ posX=((TP_X-_calibLowX)/_calibModifierX); posY=((TP_Y-_calibLowY)/_calibModifierY); } + printf("Raw: %5u, %5u, Calibrated: %3u, %u\n", TP_X, TP_Y, posX, posY); //#if defined (DM_TOOLCHAIN_ARDUINO) if (posX >= 0 && posX <= _width && posY >= 0 && posY <= _height) { @@ -344,6 +344,3 @@ return (*_pinIrq == 0); #endif } - - -
--- a/DmTouch.h Tue May 20 12:21:43 2014 +0200 +++ b/DmTouch.h Wed May 21 14:43:08 2014 +0000 @@ -53,8 +53,8 @@ regsize _bitmaskDC, _bitmaskCS, _bitmaskCLK, _bitmaskMOSI, _bitmaskMISO, _bitmaskIrq; uint8_t _spiSettings; #elif defined (DM_TOOLCHAIN_MBED) - DigitalOut *_pinDC, *_pinCS, *_pinCLK, *_pinMOSI, *_pinMISO, *_led; - DigitalIn *_pinIrq; + DigitalOut *_pinDC, *_pinCS, *_pinCLK, *_pinMOSI, *_led; + DigitalIn *_pinIrq, *_pinMISO; SPI *_spi; #endif
--- a/dm_platform.h Tue May 20 12:21:43 2014 +0200 +++ b/dm_platform.h Wed May 21 14:43:08 2014 +0000 @@ -60,11 +60,27 @@ // Clear bit, Set bit, High pulse, Low pulse, Boundary limits and Delay macros #define sbi(reg, _bitmask) (*(reg) = 1) #define cbi(reg, _bitmask) (*(reg) = 0) - #define pulse_high(reg, _bitmask) do { *(reg) = 1; *(reg) = 0; } while(0) - #define pulse_low(reg, _bitmask) do { *(reg) = 0; *(reg) = 1; } while(0) #define constrain(amt,low,high) ((amt)<=(low)?(low):((amt)>(high)?(high):(amt))) #define delay(ms) wait_ms(ms) + // On Arduino no extra delay is needed, but on faster platforms the simulated + // SPI bus may get a too high frequency so a delay here will lower it. This + // delay should ideally be configurable per platform but for now it will have + // to be ok to lower the frequency to 500KHz + #define pulse_delay() wait_us(1) + #define pulse_high(reg, _bitmask) do {\ + *(reg) = 1; \ + pulse_delay(); \ + *(reg) = 0; \ + pulse_delay(); \ + } while(0) + #define pulse_low(reg, _bitmask) do {\ + *(reg) = 0; \ + pulse_delay(); \ + *(reg) = 1; \ + pulse_delay(); \ + } while(0) + // Map of mandatory pin names, from Arduino names to D* and A* #if defined(__LPC407x_8x_177x_8x_H__) #define D0 p10