Prep for v1.1.0
[hackover2013-badge-firmware.git] / project / commands / drawing / cmd_bmp.c
1 /**************************************************************************/
2 /*!
3 @file cmd_bmp.c
4 @author K. Townsend (microBuilder.eu)
5
6 @brief Code to execute for cmd_bmp 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 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.
26
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.
37 */
38 /**************************************************************************/
39 #include <stdio.h>
40
41 #include "projectconfig.h"
42 #include "core/cmd/cmd.h"
43 #include "project/commands.h" // Generic helper functions
44
45 #if defined CFG_TFTLCD && defined CFG_SDCARD
46 #include "drivers/displays/tft/lcd.h"
47 #include "drivers/displays/tft/drawing.h"
48 #include "drivers/displays/tft/bmp.h"
49
50 /**************************************************************************/
51 /*!
52 Displays a bitmap image on the LCD.
53 */
54 /**************************************************************************/
55 void cmd_bmp(uint8_t argc, char **argv)
56 {
57 int32_t x, y;
58 char* filename;
59
60 // Convert supplied parameters
61 getNumber (argv[0], &x);
62 getNumber (argv[1], &y);
63 filename = argv[2];
64
65 // Render image
66 bmp_error_t error;
67 error = bmpDrawBitmap(x, y, filename);
68
69 switch (error)
70 {
71 case BMP_ERROR_SDINITFAIL:
72 printf("SD Init Failed%s", CFG_PRINTF_NEWLINE);
73 break;
74 case BMP_ERROR_FILENOTFOUND:
75 printf("File Not Found: '%s'%s", filename, CFG_PRINTF_NEWLINE);
76 break;
77 case BMP_ERROR_UNABLETOCREATEFILE:
78 printf("Unable to create file: '%s'%s", filename, CFG_PRINTF_NEWLINE);
79 break;
80 case BMP_ERROR_NOTABITMAP:
81 printf("Not a Bitmap: '%s'%s", filename, CFG_PRINTF_NEWLINE);
82 break;
83 case BMP_ERROR_INVALIDBITDEPTH:
84 printf("Not a 24-Bit Image%s", CFG_PRINTF_NEWLINE);
85 break;
86 case BMP_ERROR_INVALIDDIMENSIONS:
87 printf("Image Exceeds %d x %d Pixels%s", lcdGetWidth(), lcdGetHeight(), CFG_PRINTF_NEWLINE);
88 break;
89 case BMP_ERROR_COMPRESSEDDATA:
90 printf("Compressed Images Unsupported%s", CFG_PRINTF_NEWLINE);
91 break;
92 case BMP_ERROR_PREMATUREEOF:
93 printf("Premature EOF%s", CFG_PRINTF_NEWLINE);
94 break;
95 case BMP_ERROR_NONE:
96 break;
97 }
98 }
99
100 #endif
This page took 0.052458 seconds and 5 git commands to generate.