Skip to content

Commit 9896245

Browse files
author
Clang Robot
committed
Committing clang-format changes
1 parent 9dcd6c0 commit 9896245

File tree

2 files changed

+43
-34
lines changed

2 files changed

+43
-34
lines changed

src/include/TouchCypress.cpp

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ void Touch::tsShutdown()
177177
*/
178178
void Touch::tsGetRawData(uint8_t *b)
179179
{
180-
tsReadI2CRegs(CYPRESS_TOUCH_BASE_ADDR, b, 16);
180+
tsReadI2CRegs(CYPRESS_TOUCH_BASE_ADDR, b, 16);
181181
}
182182

183183
/**
@@ -200,7 +200,8 @@ uint8_t Touch::tsGetData(uint16_t *xPos, uint16_t *yPos, uint8_t *z)
200200
struct cypressTouchData _touchReport;
201201

202202
// Check for the null-pointer.
203-
if (xPos == NULL || yPos == NULL) return 0;
203+
if (xPos == NULL || yPos == NULL)
204+
return 0;
204205

205206
// Fill the array with zeros.
206207
xPos[0] = 0;
@@ -216,14 +217,16 @@ uint8_t Touch::tsGetData(uint16_t *xPos, uint16_t *yPos, uint8_t *z)
216217
}
217218

218219
// Check the flag for the new data.
219-
if (!_tsFlag) return 0;
220+
if (!_tsFlag)
221+
return 0;
220222

221223
// If there is new data, clear the interrupt flag.
222224
_tsFlag = false;
223225

224226
// Read the new data from the touchscreen controller IC.
225227
// Return zero detected fingers if reading has failed.
226-
if (!tsGetTouchData(&_touchReport)) return 0;
228+
if (!tsGetTouchData(&_touchReport))
229+
return 0;
227230

228231
// Scale it to fit the screen.
229232
tsScale(&_touchReport, E_INK_WIDTH - 1, E_INK_HEIGHT - 1, false, true, true);
@@ -252,25 +255,25 @@ uint8_t Touch::tsGetData(uint16_t *xPos, uint16_t *yPos, uint8_t *z)
252255
// Check for each finger.
253256
for (int i = 0; i < _touchReport.fingers; i++)
254257
{
255-
switch(getRotation())
258+
switch (getRotation())
256259
{
257-
case 1:
258-
// Rotation clockwise (to the right - aka. portrait mode).
259-
_temp = xPos[i];
260-
xPos[i] = map(yPos[i], 0, E_INK_HEIGHT, 0, E_INK_HEIGHT);
261-
yPos[i] = map(_temp, 0, E_INK_WIDTH - 1, E_INK_WIDTH - 1, 0);
262-
break;
263-
case 2:
264-
// Flipped by 180 deg.
265-
xPos[i] = map(xPos[i], 0, E_INK_WIDTH - 1, E_INK_WIDTH - 1, 0);
266-
yPos[i] = map(yPos[i], 0, E_INK_HEIGHT - 1, E_INK_HEIGHT - 1, 0);
267-
break;
268-
case 3:
269-
// Rotation counter-clockwise from default rotation (90 degs to the left).
270-
_temp = xPos[i];
271-
xPos[i] = map(yPos[i], 0, E_INK_HEIGHT - 1, E_INK_HEIGHT - 1, 0);
272-
yPos[i] = map(_temp, 0, E_INK_WIDTH - 1, 0, E_INK_WIDTH - 1);
273-
break;
260+
case 1:
261+
// Rotation clockwise (to the right - aka. portrait mode).
262+
_temp = xPos[i];
263+
xPos[i] = map(yPos[i], 0, E_INK_HEIGHT, 0, E_INK_HEIGHT);
264+
yPos[i] = map(_temp, 0, E_INK_WIDTH - 1, E_INK_WIDTH - 1, 0);
265+
break;
266+
case 2:
267+
// Flipped by 180 deg.
268+
xPos[i] = map(xPos[i], 0, E_INK_WIDTH - 1, E_INK_WIDTH - 1, 0);
269+
yPos[i] = map(yPos[i], 0, E_INK_HEIGHT - 1, E_INK_HEIGHT - 1, 0);
270+
break;
271+
case 3:
272+
// Rotation counter-clockwise from default rotation (90 degs to the left).
273+
_temp = xPos[i];
274+
xPos[i] = map(yPos[i], 0, E_INK_HEIGHT - 1, E_INK_HEIGHT - 1, 0);
275+
yPos[i] = map(_temp, 0, E_INK_WIDTH - 1, 0, E_INK_WIDTH - 1);
276+
break;
274277
}
275278
}
276279
}
@@ -281,19 +284,20 @@ uint8_t Touch::tsGetData(uint16_t *xPos, uint16_t *yPos, uint8_t *z)
281284

282285
/**
283286
* @brief Get the new touch event data from the touchscreen controller.
284-
*
287+
*
285288
* @param struct cypressTouchData _touchData
286289
* Pointer to the structure for the touch report data (such as X, Y and
287-
* Z values of each touch channel, nuber of fingers etc.)
288-
*
290+
* Z values of each touch channel, nuber of fingers etc.)
291+
*
289292
* @return bool
290293
* true - Touch data is successfully read and the data is valid.
291294
* false - Touch data read has failed.
292295
*/
293296
bool Touch::tsGetTouchData(struct cypressTouchData *_touchData)
294297
{
295298
// Check for the null-pointer trap.
296-
if (_touchData == NULL) return false;
299+
if (_touchData == NULL)
300+
return false;
297301

298302
// Clear struct for touchscreen data.
299303
memset(_touchData, 0, sizeof(cypressTouchData));
@@ -303,7 +307,8 @@ bool Touch::tsGetTouchData(struct cypressTouchData *_touchData)
303307

304308
// Read registers for the touch data (32 bytes of data).
305309
// If read failed for some reason, return false.
306-
if (!tsReadI2CRegs(CYPRESS_TOUCH_BASE_ADDR, _regs, sizeof(_regs))) return false;
310+
if (!tsReadI2CRegs(CYPRESS_TOUCH_BASE_ADDR, _regs, sizeof(_regs)))
311+
return false;
307312

308313
// Send a handshake.
309314
tsHandshake();
@@ -335,21 +340,22 @@ bool Touch::tsGetTouchData(struct cypressTouchData *_touchData)
335340

336341
/**
337342
* @brief Method scales, flips and swaps X and Y cooridinates to ensure X and Y matches the screen.
338-
*
343+
*
339344
* @param struct cypressTouchData _touchData
340-
* Defined in cypressTouchTypedefs.h. Filled touch data report.
345+
* Defined in cypressTouchTypedefs.h. Filled touch data report.
341346
* @param uint16_t _xSize
342347
* Screen size in pixels for X axis.
343348
* @param uint16_t _ySize
344349
* Screen size in pixels for Y axis.
345350
* @param bool _flipX
346351
* Flip the direction of the X axis.
347-
* @param bool _flipY
352+
* @param bool _flipY
348353
* Flip the direction of the Y axis.
349354
* @param bool _swapXY
350355
* Swap X and Y cooridinates.
351356
*/
352-
void Touch::tsScale(struct cypressTouchData *_touchData, uint16_t _xSize, uint16_t _ySize, bool _flipX, bool _flipY, bool _swapXY)
357+
void Touch::tsScale(struct cypressTouchData *_touchData, uint16_t _xSize, uint16_t _ySize, bool _flipX, bool _flipY,
358+
bool _swapXY)
353359
{
354360
// Temp. variables for the mapped value.
355361
uint16_t _mappedX = 0;
@@ -359,8 +365,10 @@ void Touch::tsScale(struct cypressTouchData *_touchData, uint16_t _xSize, uint16
359365
for (int i = 0; i < _touchData->fingers; i++)
360366
{
361367
// Check for the flip.
362-
if (_flipX) _touchData->x[i] = CYPRESS_TOUCH_MAX_X - _touchData->x[i];
363-
if (_flipY) _touchData->y[i] = CYPRESS_TOUCH_MAX_Y - _touchData->y[i];
368+
if (_flipX)
369+
_touchData->x[i] = CYPRESS_TOUCH_MAX_X - _touchData->x[i];
370+
if (_flipY)
371+
_touchData->y[i] = CYPRESS_TOUCH_MAX_Y - _touchData->y[i];
364372

365373
// Check for X and Y swap.
366374
if (_swapXY)

src/include/TouchCypress.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ class Touch : virtual public Expander
106106
bool tsGetTouchData(struct cypressTouchData *_touchData);
107107

108108
// Scale touch data report to fit screen (and also rotation).
109-
void tsScale(struct cypressTouchData *_touchData, uint16_t _xSize, uint16_t _ySize, bool _flipX, bool _flipY, bool _swapXY);
109+
void tsScale(struct cypressTouchData *_touchData, uint16_t _xSize, uint16_t _ySize, bool _flipX, bool _flipY,
110+
bool _swapXY);
110111

111112
// Disable touchscreen.
112113
void tsEnd();

0 commit comments

Comments
 (0)