0168e0540ad658ed08f946eb288b82892c57fcf2
1 /**************************************************************************/
4 @author K. Townsend (microBuilder.eu)
6 @brief Code to execute for cmd_progress in the 'core/cmd'
7 command-line interpretter.
11 Software License Agreement (BSD License)
13 Copyright (c) 2010, microBuilder SARL
16 Redistribution and use in source and binary forms, with or without
17 modification, are permitted provided that the following conditions are met:
18 1. Redistributions of source code must retain the above copyright
19 notice, this list of conditions and the following disclaimer.
20 2. Redistributions in binary form must reproduce the above copyright
21 notice, this list of conditions and the following disclaimer in the
22 documentation and/or other materials provided with the distribution.
23 3. Neither the name of the copyright holders nor the
24 names of its contributors may be used to endorse or promote products
25 derived from this software without specific prior written permission.
27 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
28 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
29 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
31 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
32 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
34 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 /**************************************************************************/
41 #include "projectconfig.h"
42 #include "core/cmd/cmd.h"
43 #include "project/commands.h" // Generic helper functions
46 #include "drivers/displays/tft/lcd.h"
47 #include "drivers/displays/tft/drawing.h"
49 /**************************************************************************/
51 Displays a progress bar on the LCD.
53 /**************************************************************************/
54 void cmd_progress(uint8_t argc
, char **argv
)
56 int32_t x
, y
, w
, h
, percent
, border
, borderfill
, progressborder
, progressfill
;
58 // Convert supplied parameters
59 getNumber (argv
[0], &x
);
60 getNumber (argv
[1], &y
);
61 getNumber (argv
[2], &w
);
62 getNumber (argv
[3], &h
);
63 getNumber (argv
[4], &percent
);
64 getNumber (argv
[5], &border
);
65 getNumber (argv
[6], &borderfill
);
66 getNumber (argv
[7], &progressborder
);
67 getNumber (argv
[8], &progressfill
);
69 // ToDo: Validate data!
70 if (border
< 0 || border
> 0xFFFF || borderfill
< 0 || borderfill
> 0xFFFF || progressborder
< 0 || progressborder
> 0xFFFF || progressfill
< 0 || progressfill
> 0xFFFF)
72 printf("Invalid Color%s", CFG_PRINTF_NEWLINE
);
75 if (percent
< 0 || percent
> 100)
77 printf("Invalid Percentage%s", CFG_PRINTF_NEWLINE
);
81 // Draw the progress bar (always use rounded corners for simplicity sake)
82 drawProgressBar(x
, y
, w
, h
, DRAW_ROUNDEDCORNERS_ALL
, DRAW_ROUNDEDCORNERS_ALL
, border
, borderfill
, progressborder
, progressfill
, percent
);
This page took 0.046665 seconds and 3 git commands to generate.