MAXREFDES63# Code Documentation  V01.00
8-Channel Digital Output MicroPLC
 All Files Functions Variables Macros Pages
menu.c
Go to the documentation of this file.
1 
30 /*
31 * Copyright (C) 2012 Maxim Integrated Products, Inc., All Rights Reserved.
32 *
33 * Permission is hereby granted, free of charge, to any person obtaining a
34 * copy of this software and associated documentation files (the "Software"),
35 * to deal in the Software without restriction, including without limitation
36 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
37 * and/or sell copies of the Software, and to permit persons to whom the
38 * Software is furnished to do so, subject to the following conditions:
39 *
40 * The above copyright notice and this permission notice shall be included
41 * in all copies or substantial portions of the Software.
42 *
43 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
44 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
45 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
46 * IN NO EVENT SHALL MAXIM INTEGRATED PRODUCTS BE LIABLE FOR ANY CLAIM, DAMAGES
47 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
48 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
49 * OTHER DEALINGS IN THE SOFTWARE.
50 *
51 * Except as contained in this notice, the name of Maxim Integrated Products
52 * shall not be used except as stated in the Maxim Integrated Products
53 * Branding Policy.
54 *
55 * The mere transfer of this software does not imply any licenses
56 * of trade secrets, proprietary technology, copyrights, patents,
57 * trademarks, maskwork rights, or any other form of intellectual
58 * property whatsoever. Maxim Integrated Products retains all ownership rights.
59 *
60 ***************************************************************************/
61 
62 #include "stdio.h"
63 #include "menu.h"
64 
73 {
74  // The following code will cause a clear screen event on Hyperterminal and many other terminal emulators
75  printf("\033[2J");
76 }
77 
78 
87 {
88  printf( "\r\n");
89  printf( "///////////////////////////////////////////////////////////////////\r\n");
90  printf( "// _____ _____ //\r\n");
91  printf( "// / __ \\ / __ \\ //\r\n");
92  printf( "// | | \\/ / / | | //\r\n");
93  printf( "// | | / / | | //\r\n");
94  printf( "// | | / \\ | | //\r\n");
95  printf( "// | | / /\\ \\ | | //\r\n");
96  printf( "// |_| /_/ \\_\\ |_| //\r\n");
97  printf( "// //\r\n");
98  printf( "///////////////////////////////////////////////////////////////////\r\n");
99  printf("\r\n");
100 }
101 
102 
111 {
112  printf( "\r\n");
113  printf( "///////////////////////////////////////////////////////////////////\r\n");
114  printf( "// ### ### //\r\n");
115  printf( "// ## ## //\r\n");
116  printf( "// //\r\n");
117  printf( "// ## _____ _____ ## //\r\n");
118  printf( "// / __ \\ / __ \\ //\r\n");
119  printf( "// ## | | \\/ / / | | ## //\r\n");
120  printf( "// | | / / | | //\r\n");
121  printf( "// | | / \\ | | //\r\n");
122  printf( "// ## | | / /\\ \\ | | ## //\r\n");
123  printf( "// |_| /_/ \\_\\ |_| //\r\n");
124  printf( "// ## ## //\r\n");
125  printf( "// //\r\n");
126  printf( "// ## ## //\r\n");
127  printf( "// ### ### //\r\n");
128  printf( "// //\r\n");
129  printf( "// M A X I M I N T E G R A T E D //\r\n");
130  printf( "// //\r\n");
131  printf( "///////////////////////////////////////////////////////////////////\r\n");
132 
133  printf("\r\n\r\n");
134 }
135 
144 {
145  printf("\r\n>> ");
146  fflush(stdout);
147 }
148 
149 
158 {
159  printf("----------------------------------------------------\r\n\r\n");
160 }
161 
162 
176 {
177  uint8_t uch_input;
178 
179  uch_input = getchar();
180 
181  if(uch_input==27) // Escape sequence (likely an arrow key)
182  {
183  uch_input = getchar();
184  if(uch_input==91) // Left bracket (part #2 of the 3 part escape sequence)
185  {
186  uch_input = getchar();
187  if(uch_input==65)
188  uch_input = KEYPRESS_ARROW_UP-10;
189  if(uch_input==66)
190  uch_input = KEYPRESS_ARROW_DOWN-10;
191  if(uch_input==67)
192  uch_input = KEYPRESS_ARROW_RIGHT-10;
193  if(uch_input==68)
194  uch_input = KEYPRESS_ARROW_LEFT-10;
195  if(uch_input==75)
196  uch_input = KEYPRESS_END - 10;
197  }
198  }
199  else if(uch_input>=48 && uch_input <=57) // digits 0..9
200  uch_input -=48; // subtract 48 to get the real number converted from the ASCII digit
201  else if(uch_input>=97 && uch_input<=122)
202  uch_input -=32; // convert lowercase to uppercase
203 
204  return(uch_input);
205 }
206 
214 {
216 
217  printf("Press any key to start output configuration\r\n");
218 
220 }
221 
229 {
230  maxim_menu_cls();
231  printf("The configuration byte controls the modes of the output ports\r\n");
232  printf("Each bit of the configuration byte sets the output mode for the corresponding \n\routput port\r\n");
233  printf("Configuration bit = 0, Output port = High-side mode\r\n");
234  printf("Configuration bit = 1, Output port = Push-pull mode\r\n");
235  printf("Example:\r\n");
236  printf("Configuration byte = 0xF0, output ports 0 to 3 are set to high-side mode,\r\n");
237  printf("and output ports 4 to 7 are set to push-pull mode\r\n");
238 }
239 
247 {
248  maxim_menu_cls();
249  printf("The data output byte controls the output states\r\n");
250  printf("Each bit of the data output byte sets the output state for the corresponding \n\routput port\r\n");
251  printf("Output bit = 0, Output = Low\r\n");
252  printf("Output bit = 1, Output = High\r\n");
253  printf("Example:\r\n");
254  printf("Data output byte = 0xF0, outputs 0 to 3 are set to low,\r\n");
255  printf("and output 4 to 7 are set to high\r\n");
256 }