vanity-convert: add Makefile
[hackover2013-badge-firmware.git] / project / commands / drawing / cmd_tswait.c
1 /**************************************************************************/
2 /*!
3 @file cmd_tswait.c
4 @author K. Townsend (microBuilder.eu)
5
6 @brief Code to execute for cmd_tswait in the 'core/cmd'
7 command-line interpretter.
8
9 @section LICENSE
10
11 Software License Agreement (BSD License)
12
13 Copyright (c) 2010, microBuilder SARL
14 All rights reserved.
15
16 Redistribution and use in source and binary forms, with or without
17 modification, are permitted provided that the following conditions are met:
18
19 1. Redistributions of source code must retain the above copyright
20 notice, this list of conditions and the following disclaimer.
21 2. Redistributions in binary form must reproduce the above copyright
22 notice, this list of conditions and the following disclaimer in the
23 documentation and/or other materials provided with the distribution.
24 3. Neither the name of the copyright holders nor the
25 names of its contributors may be used to endorse or promote products
26 derived from this software without specific prior written permission.
27
28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
29 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
30 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
32 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
33 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
35 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 */
39 /**************************************************************************/
40 #include <stdio.h>
41 #include <string.h>
42
43 #include "projectconfig.h"
44 #include "core/cmd/cmd.h"
45 #include "project/commands.h" // Generic helper functions
46
47 #ifdef CFG_TFTLCD
48 #include "drivers/displays/tft/touchscreen.h"
49
50 /**************************************************************************/
51 /*!
52 Waits for a touch screen event and returns the co-ordinates
53 */
54 /**************************************************************************/
55 void cmd_tswait(uint8_t argc, char **argv)
56 {
57 tsTouchData_t data;
58 int32_t delay;
59 int32_t error = 0;
60
61 if (argc == 1)
62 {
63 getNumber (argv[0], &delay);
64 }
65 else
66 {
67 delay = 0;
68 }
69
70 // Validate delay
71 if (delay < 0)
72 {
73 printf("Invalid timeout%s", CFG_PRINTF_NEWLINE);
74 return;
75 }
76
77 // Blocking delay until a valid touch event occurs
78 error = tsWaitForEvent(&data, delay > 0 ? (uint32_t)delay : 0);
79
80 if (error == TS_ERROR_NONE)
81 {
82 // A valid touch event occurred ... parse data
83 printf("%d,%d%s",(int)data.xlcd, (int)data.ylcd, CFG_PRINTF_NEWLINE);
84 }
85 else
86 {
87 // Display error code
88 printf("%d%s", (int)error, CFG_PRINTF_NEWLINE);
89 }
90
91 return;
92 }
93
94 #endif
This page took 0.054637 seconds and 5 git commands to generate.