openchronos-ng
opensource firmware for the ez430 chronos
display.h
Go to the documentation of this file.
00001 /**************************************************************************
00002 
00003         Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
00004 
00005 
00006           Redistribution and use in source and binary forms, with or without
00007           modification, are permitted provided that the following conditions
00008           are met:
00009 
00010             Redistributions of source code must retain the above copyright
00011             notice, this list of conditions and the following disclaimer.
00012 
00013             Redistributions in binary form must reproduce the above copyright
00014             notice, this list of conditions and the following disclaimer in the
00015             documentation and/or other materials provided with the
00016             distribution.
00017 
00018             Neither the name of Texas Instruments Incorporated nor the names of
00019             its contributors may be used to endorse or promote products derived
00020             from this software without specific prior written permission.
00021 
00022           THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023           "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024           LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00025           A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00026           OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00027           SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00028           LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00029           DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00030           THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00031           (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00032           OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 
00034 ****************************************************************************/
00035 
00041 #ifndef __DISPLAY_H__
00042 #define __DISPLAY_H__
00043 
00044 #include <openchronos.h>
00045 
00049 enum display_segstate {
00050         SEG_OFF         = 1u, 
00051         SEG_ON          = 2u, 
00052         SEG_SET         = 3u, 
00053         BLINK_OFF       = 4u, 
00054         BLINK_ON                = 8u, 
00055         BLINK_SET       = 12u 
00056 };
00057 
00061 enum display_segment {
00062         /* Symbols for Line1 */
00063         LCD_SYMB_AM                             =       0, 
00064         LCD_SYMB_PM                             =       1, 
00065         LCD_SYMB_ARROW_UP               =       2, 
00066         LCD_SYMB_ARROW_DOWN     =       3, 
00067         LCD_SYMB_PERCENT                =       4, 
00069         /* Symbols for Line2 */
00070         LCD_SYMB_TOTAL                  =       5, 
00071         LCD_SYMB_AVERAGE                =       6, 
00072         LCD_SYMB_MAX                    =       7, 
00073         LCD_SYMB_BATTERY                =       8, 
00075         /* Units for Line1 */
00076         LCD_UNIT_L1_FT                  =       9,  
00077         LCD_UNIT_L1_K                   =       10, 
00078         LCD_UNIT_L1_M                   =       11, 
00079         LCD_UNIT_L1_I                   =       12, 
00080         LCD_UNIT_L1_PER_S               =       13, 
00081         LCD_UNIT_L1_PER_H               =       14, 
00082         LCD_UNIT_L1_DEGREE      =       15, 
00084         /* Units for Line2 */
00085         LCD_UNIT_L2_KCAL                =       16, 
00086         LCD_UNIT_L2_KM                  =       17, 
00087         LCD_UNIT_L2_MI                  =       18, 
00089         /* Icons */
00090         LCD_ICON_HEART                  =       19, 
00091         LCD_ICON_STOPWATCH      =       20, 
00092         LCD_ICON_RECORD         =       21, 
00093         LCD_ICON_ALARM                  =       22, 
00094         LCD_ICON_BEEPER1                =       23, 
00095         LCD_ICON_BEEPER2                =       24, 
00096         LCD_ICON_BEEPER3                =       25, 
00098         /* Line1 7-segments */
00099         LCD_SEG_L1_3                    =       26, 
00100         LCD_SEG_L1_2                    =       27, 
00101         LCD_SEG_L1_1                    =       28, 
00102         LCD_SEG_L1_0                    =       29, 
00103         LCD_SEG_L1_COL                  =       30, 
00104         LCD_SEG_L1_DP1                  =       31, 
00105         LCD_SEG_L1_DP0                  =       32, 
00107         /* Line2 7-segments */
00108         LCD_SEG_L2_5                    =       33, 
00109         LCD_SEG_L2_4                    =       34, 
00110         LCD_SEG_L2_3                    =       35, 
00111         LCD_SEG_L2_2                    =       36, 
00112         LCD_SEG_L2_1                    =       37, 
00113         LCD_SEG_L2_0                    =       38, 
00114         LCD_SEG_L2_COL1         =       39, 
00115         LCD_SEG_L2_COL0         =       40, 
00116         LCD_SEG_L2_DP                   =       41, 
00117 };
00118 
00124 enum display_segment_array {
00125         /* Line1 7-segment arrays */
00126         LCD_SEG_L1_3_2                  =       0xc2, 
00127         LCD_SEG_L1_3_1                  =       0xc3, 
00128         LCD_SEG_L1_3_0                  =       0xc4, 
00129         LCD_SEG_L1_2_1                  =       0xb2, 
00130         LCD_SEG_L1_2_0                  =       0xb3, 
00131         LCD_SEG_L1_1_0                  =       0xa2, 
00133         /* Line2 7-segment arrays */
00134         LCD_SEG_L2_5_4                  =       0x52, 
00135         LCD_SEG_L2_5_3                  =       0x53, 
00136         LCD_SEG_L2_5_2                  =       0x54, 
00137         LCD_SEG_L2_5_1                  =       0x55, 
00138         LCD_SEG_L2_5_0                  =       0x56, 
00139         LCD_SEG_L2_4_3                  =       0x42, 
00140         LCD_SEG_L2_4_2                  =       0x43, 
00141         LCD_SEG_L2_4_1                  =       0x44, 
00142         LCD_SEG_L2_4_0                  =       0x45, 
00143         LCD_SEG_L2_3_2                  =       0x32, 
00144         LCD_SEG_L2_3_1                  =       0x33, 
00145         LCD_SEG_L2_3_0                  =       0x34, 
00146         LCD_SEG_L2_2_1                  =       0x22, 
00147         LCD_SEG_L2_2_0                  =       0x23, 
00148         LCD_SEG_L2_1_0                  =       0x12, 
00149 };
00150 
00157 void lcd_init(void);
00158 
00163 struct lcd_screen {
00164         uint8_t *segmem; 
00165         uint8_t *blkmem; 
00166 };
00167 
00181 void lcd_screens_create(
00182         uint8_t nr 
00183 );
00184 
00189 void lcd_screens_destroy(void);
00190 
00198 void lcd_screen_activate(
00199         uint8_t scr_nr 
00200 );
00201 
00202 /* Not to be used by modules */
00203 void start_blink(void);
00204 void stop_blink(void);
00205 void clear_blink_mem(void);
00206 
00211 void display_clear(
00212         uint8_t scr_nr, 
00213         uint8_t line 
00214 );
00215 
00242 void display_char(
00243         uint8_t scr_nr, 
00244         enum display_segment segment, 
00245         char chr, 
00246         enum display_segstate state 
00247 );
00248 
00249 
00273 void display_chars(
00274         uint8_t scr_nr, 
00275         enum display_segment_array segments, 
00276         char const * str, 
00277         enum display_segstate state 
00278 );
00279 
00289 void display_symbol(
00290         uint8_t scr_nr,       
00291         enum display_segment symbol, 
00292         enum display_segstate state 
00293 );
00294 
00301 #define _printf(scr_nr, segments, fmt, n) \
00302         display_chars((scr_nr), (segments), _sprintf((fmt), (n)), SEG_SET)
00303 
00304 
00334 char *_sprintf(
00335         const char *fmt, 
00336         int16_t n        
00337 );
00338 
00350 char *_itopct(
00351                 uint32_t low,     
00352                 uint32_t high,     
00353                 uint32_t n
00354 );
00355 
00356 #endif /* __DISPLAY_H__ */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines