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
|
//*****************************************************************************
//
// rgb_commands.c - Command line functionality implementation
//
// Copyright (c) 2012 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 9453 of the EK-LM4F120XL Firmware Package.
//
//*****************************************************************************
#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.
//
//*****************************************************************************
tCmdLineEntry g_sCmdTable[] =
{
{"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 }
};
const int NUM_CMD = sizeof(g_sCmdTable)/sizeof(tCmdLineEntry);
//*****************************************************************************
//
// Command: help
//
// Print the help strings for all commands.
//
//*****************************************************************************
int
CMD_help (int argc, char **argv)
{
int index;
(void)argc;
(void)argv;
UARTprintf("\n");
for (index = 0; index < NUM_CMD; index++)
{
UARTprintf("%17s %s\n\n",
g_sCmdTable[index].pcCmd,
g_sCmdTable[index].pcHelp);
}
UARTprintf("\n");
return (0);
}
//*****************************************************************************
//
// Command: hib
//
// Force the device into hibernate mode now.
//
//*****************************************************************************
int
CMD_hib (int argc, char **argv)
{
(void) argc;
(void) argv;
AppHibernateEnter();
return (0);
}
//*****************************************************************************
//
// Command: rand
//
// Starts the automatic light sequence immediately.
//
//*****************************************************************************
int
CMD_rand (int argc, char **argv)
{
(void) argc;
(void) argv;
g_sAppState.ulMode = 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)
{
unsigned long ulIntensity;
if(argc == 2)
{
ulIntensity = ustrtoul(argv[1], 0, 10);
g_sAppState.fIntensity = ((float) ulIntensity) / 100.0f;
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)
{
unsigned long ulHTMLColor;
if(argc == 2)
{
ulHTMLColor = ustrtoul(argv[1], 0, 16);
g_sAppState.ulColors[RED] = (ulHTMLColor & 0xFF0000) >> 8;
g_sAppState.ulColors[GREEN] = (ulHTMLColor & 0x00FF00);
g_sAppState.ulColors[BLUE] = (ulHTMLColor & 0x0000FF) << 8;
g_sAppState.ulMode = APP_MODE_REMOTE;
g_sAppState.ulModeTimer = 0;
RGBColorSet(g_sAppState.ulColors);
}
return (0);
}
|