1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
//*****************************************************************************
//
// rgb_commands.c - Command line functionality implementation
//
// Copyright (c) 2012-2014 Texas Instruments Incorporated. All rights reserved.
// Software License Agreement
//
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
//
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
//
// This is part of revision 2.1.0.12573 of the EK-TM4C123GXL Firmware Package.
//
//*****************************************************************************
#include <stdint.h>
#include <stdbool.h>
#include "qs-rgb.h"
#include "drivers/rgb.h"
#include "inc/hw_types.h"
#include "utils/ustdlib.h"
#include "utils/uartstdio.h"
#include "utils/cmdline.h"
#include "rgb_commands.h"
//*****************************************************************************
//
// Table of valid command strings, callback functions and help messages. This
// is used by the cmdline module.
//
//*****************************************************************************
tCmdLineEntry g_psCmdTable[] =
{
{"help", CMD_help, " : Display list of commands" },
{"hib", CMD_hib, " : Place system into hibernate mode"},
{"rand", CMD_rand, " : Start automatic color sequencing"},
{"intensity",CMD_intensity, " : Adjust brightness 0 to 100 percent"},
{"rgb", CMD_rgb, " : Adjust color 000000-FFFFFF HTML notation"},
{ 0, 0, 0 }
};
//*****************************************************************************
//
// Command: help
//
// Print the help strings for all commands.
//
//*****************************************************************************
int
CMD_help(int argc, char **argv)
{
int32_t i32Index;
(void)argc;
(void)argv;
//
// Start at the beginning of the command table
//
i32Index = 0;
//
// Get to the start of a clean line on the serial output.
//
UARTprintf("\nAvailable Commands\n------------------\n\n");
//
// Display strings until we run out of them.
//
while(g_psCmdTable[i32Index].pcCmd)
{
UARTprintf("%17s %s\n", g_psCmdTable[i32Index].pcCmd,
g_psCmdTable[i32Index].pcHelp);
i32Index++;
}
//
// Leave a blank line after the help strings.
//
UARTprintf("\n");
return (0);
}
//*****************************************************************************
//
// Command: hib
//
// Force the device into hibernate mode now.
//
//*****************************************************************************
int
CMD_hib(int argc, char **argv)
{
//
// Keep the compiler happy.
//
(void)argc;
(void)argv;
//
// Enter hibernate state.
//
AppHibernateEnter();
return (0);
}
//*****************************************************************************
//
// Command: rand
//
// Starts the automatic light sequence immediately.
//
//*****************************************************************************
int
CMD_rand(int argc, char **argv)
{
//
// Keep the compiler happy.
//
(void)argc;
(void)argv;
//
// Turn on automatic mode.
//
g_sAppState.ui32Mode = APP_MODE_AUTO;
return (0);
}
//*****************************************************************************
//
// Command: intensity
//
// Takes a single argument that is between zero and one hundred. The argument
// must be an integer. This is interpreted as the percentage of maximum
// brightness with which to display the current color.
//
//*****************************************************************************
int
CMD_intensity(int argc, char **argv)
{
uint32_t ui32Intensity;
//
// This command requires one parameter.
//
if(argc == 2)
{
//
// Extract the intensity from the command line parameter.
//
ui32Intensity = ustrtoul(argv[1], 0, 10);
//
// Convert the value to a fractional floating point value.
//
g_sAppState.fIntensity = ((float) ui32Intensity) / 100.0f;
//
// Set the intensity of the RGB LED.
//
RGBIntensitySet(g_sAppState.fIntensity);
}
return(0);
}
//*****************************************************************************
//
// Command: rgb
//
// Takes a single argument that is a string between 000000 and FFFFFF.
// This is the HTML color code that should be used to set the RGB LED color.
//
// http://www.w3schools.com/html/html_colors.asp
//
//*****************************************************************************
int
CMD_rgb(int argc, char **argv)
{
uint32_t ui32HTMLColor;
//
// This command requires one parameter.
//
if(argc == 2)
{
//
// Extract the required color from the command line parameter.
//
ui32HTMLColor = ustrtoul(argv[1], 0, 16);
//
// Decompose teh color into red, green and blue components.
//
g_sAppState.ui32Colors[RED] = (ui32HTMLColor & 0xFF0000) >> 8;
g_sAppState.ui32Colors[GREEN] = (ui32HTMLColor & 0x00FF00);
g_sAppState.ui32Colors[BLUE] = (ui32HTMLColor & 0x0000FF) << 8;
//
// Turn off automatic mode and set the desired LED color.
//
g_sAppState.ui32Mode = APP_MODE_REMOTE;
g_sAppState.ui32ModeTimer = 0;
RGBColorSet(g_sAppState.ui32Colors);
}
return (0);
}
|