Use the MAXREFDES99 to display the time from a DS3231 RTC. Requires the DS3231 RTC, or a MAXREFDES72 which has the rtc on it.

Dependencies:   MAX7219 ds3231 mbed

Committer:
j3
Date:
Fri Mar 25 22:50:52 2016 +0000
Revision:
0:52f9ecc09233
Child:
1:ce6a3accca77
Init Commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
j3 0:52f9ecc09233 1 /******************************************************************//**
j3 0:52f9ecc09233 2 * @file maxrefdes99.h
j3 0:52f9ecc09233 3 *
j3 0:52f9ecc09233 4 * @author Justin Jordan
j3 0:52f9ecc09233 5 *
j3 0:52f9ecc09233 6 * @version 0.0
j3 0:52f9ecc09233 7 *
j3 0:52f9ecc09233 8 * Started: 08JAN16
j3 0:52f9ecc09233 9 *
j3 0:52f9ecc09233 10 * Updated:
j3 0:52f9ecc09233 11 *
j3 0:52f9ecc09233 12 * @brief Header file for maxrefdes99 demo
j3 0:52f9ecc09233 13 ***********************************************************************
j3 0:52f9ecc09233 14 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
j3 0:52f9ecc09233 15 *
j3 0:52f9ecc09233 16 * Permission is hereby granted, free of charge, to any person obtaining a
j3 0:52f9ecc09233 17 * copy of this software and associated documentation files (the "Software"),
j3 0:52f9ecc09233 18 * to deal in the Software without restriction, including without limitation
j3 0:52f9ecc09233 19 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
j3 0:52f9ecc09233 20 * and/or sell copies of the Software, and to permit persons to whom the
j3 0:52f9ecc09233 21 * Software is furnished to do so, subject to the following conditions:
j3 0:52f9ecc09233 22 *
j3 0:52f9ecc09233 23 * The above copyright notice and this permission notice shall be included
j3 0:52f9ecc09233 24 * in all copies or substantial portions of the Software.
j3 0:52f9ecc09233 25 *
j3 0:52f9ecc09233 26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
j3 0:52f9ecc09233 27 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
j3 0:52f9ecc09233 28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
j3 0:52f9ecc09233 29 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
j3 0:52f9ecc09233 30 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
j3 0:52f9ecc09233 31 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
j3 0:52f9ecc09233 32 * OTHER DEALINGS IN THE SOFTWARE.
j3 0:52f9ecc09233 33 *
j3 0:52f9ecc09233 34 * Except as contained in this notice, the name of Maxim Integrated
j3 0:52f9ecc09233 35 * Products, Inc. shall not be used except as stated in the Maxim Integrated
j3 0:52f9ecc09233 36 * Products, Inc. Branding Policy.
j3 0:52f9ecc09233 37 *
j3 0:52f9ecc09233 38 * The mere transfer of this software does not imply any licenses
j3 0:52f9ecc09233 39 * of trade secrets, proprietary technology, copyrights, patents,
j3 0:52f9ecc09233 40 * trademarks, maskwork rights, or any other form of intellectual
j3 0:52f9ecc09233 41 * property whatsoever. Maxim Integrated Products, Inc. retains all
j3 0:52f9ecc09233 42 * ownership rights.
j3 0:52f9ecc09233 43 **********************************************************************/
j3 0:52f9ecc09233 44
j3 0:52f9ecc09233 45
j3 0:52f9ecc09233 46 #ifndef MAXREFDES99_H
j3 0:52f9ecc09233 47 #define MAXREFDES99_H
j3 0:52f9ecc09233 48
j3 0:52f9ecc09233 49
j3 0:52f9ecc09233 50 #include "mbed.h"
j3 0:52f9ecc09233 51 #include "max7219.h"
j3 0:52f9ecc09233 52
j3 0:52f9ecc09233 53 #define ESC 0x1B
j3 0:52f9ecc09233 54
j3 0:52f9ecc09233 55
j3 0:52f9ecc09233 56 /**********************************************************//**
j3 0:52f9ecc09233 57 * @brief gets character bitmap fom memory
j3 0:52f9ecc09233 58 *
j3 0:52f9ecc09233 59 * @details
j3 0:52f9ecc09233 60 *
j3 0:52f9ecc09233 61 * On Entry:
j3 0:52f9ecc09233 62 * @param[in] c - character to get bitmap for
j3 0:52f9ecc09233 63 * @param[in] char_buff - pointer to buffer to store bitmap in
j3 0:52f9ecc09233 64 * must be at least 6 bytes
j3 0:52f9ecc09233 65 *
j3 0:52f9ecc09233 66 * On Exit:
j3 0:52f9ecc09233 67 * @return none
j3 0:52f9ecc09233 68 **************************************************************/
j3 0:52f9ecc09233 69 void get_5x7_character(char c, uint8_t *char_buff);
j3 0:52f9ecc09233 70
j3 0:52f9ecc09233 71
j3 0:52f9ecc09233 72 /**********************************************************//**
j3 0:52f9ecc09233 73 * @brief prints character to MAXREFDES99 at given position
j3 0:52f9ecc09233 74 *
j3 0:52f9ecc09233 75 * @details
j3 0:52f9ecc09233 76 *
j3 0:52f9ecc09233 77 * On Entry:
j3 0:52f9ecc09233 78 * @param[in] p_display - pointer to Max7219 object
j3 0:52f9ecc09233 79 * @param[in] position - position to print char to
j3 0:52f9ecc09233 80 * posiion 1 is top left column, position 32
j3 0:52f9ecc09233 81 * is bottom right column
j3 0:52f9ecc09233 82 * @param[in] c - char to print
j3 0:52f9ecc09233 83 *
j3 0:52f9ecc09233 84 * On Exit:
j3 0:52f9ecc09233 85 * @return none
j3 0:52f9ecc09233 86 **************************************************************/
j3 0:52f9ecc09233 87 void print_char(Max7219 *p_display, uint8_t position, char c);
j3 0:52f9ecc09233 88
j3 0:52f9ecc09233 89
j3 0:52f9ecc09233 90 /**********************************************************//**
j3 0:52f9ecc09233 91 * @brief prints given string to MAXREFDES99 at given position
j3 0:52f9ecc09233 92 *
j3 0:52f9ecc09233 93 * @details
j3 0:52f9ecc09233 94 *
j3 0:52f9ecc09233 95 * On Entry:
j3 0:52f9ecc09233 96 * @param[in] p_display - pointer to Max7219 object
j3 0:52f9ecc09233 97 * @param[in] position - position to print char to
j3 0:52f9ecc09233 98 * posiion 1 is top left column, position 32
j3 0:52f9ecc09233 99 * is bottom right column
j3 0:52f9ecc09233 100 * @param[in] s - pointer to string to print
j3 0:52f9ecc09233 101 *
j3 0:52f9ecc09233 102 * On Exit:
j3 0:52f9ecc09233 103 * @return none
j3 0:52f9ecc09233 104 **************************************************************/
j3 0:52f9ecc09233 105 void print_string(Max7219 *p_display, uint8_t position, const char *s);
j3 0:52f9ecc09233 106
j3 0:52f9ecc09233 107
j3 0:52f9ecc09233 108 /**********************************************************//**
j3 0:52f9ecc09233 109 * @brief shifts display right 'count' positions with given
j3 0:52f9ecc09233 110 * delay between shifts
j3 0:52f9ecc09233 111 *
j3 0:52f9ecc09233 112 * @details
j3 0:52f9ecc09233 113 *
j3 0:52f9ecc09233 114 * On Entry:
j3 0:52f9ecc09233 115 * @param[in] p_display - pointer to Max7219 object
j3 0:52f9ecc09233 116 * @param[in] count - number of positions to shift
j3 0:52f9ecc09233 117 * @param[in] delay - delay between shifts
j3 0:52f9ecc09233 118 *
j3 0:52f9ecc09233 119 * On Exit:
j3 0:52f9ecc09233 120 * @return none
j3 0:52f9ecc09233 121 **************************************************************/
j3 0:52f9ecc09233 122 void shift_display_right(Max7219 *p_display, uint8_t count, uint8_t delay);
j3 0:52f9ecc09233 123
j3 0:52f9ecc09233 124
j3 0:52f9ecc09233 125 /**********************************************************//**
j3 0:52f9ecc09233 126 * @brief shifts display left 'count' positions with given
j3 0:52f9ecc09233 127 * delay between shifts
j3 0:52f9ecc09233 128 *
j3 0:52f9ecc09233 129 * @details
j3 0:52f9ecc09233 130 *
j3 0:52f9ecc09233 131 * On Entry:
j3 0:52f9ecc09233 132 * @param[in] p_display - pointer to Max7219 object
j3 0:52f9ecc09233 133 * @param[in] count - number of positions to shift
j3 0:52f9ecc09233 134 * @param[in] delay - delay between shifts
j3 0:52f9ecc09233 135 *
j3 0:52f9ecc09233 136 * On Exit:
j3 0:52f9ecc09233 137 * @return none
j3 0:52f9ecc09233 138 **************************************************************/
j3 0:52f9ecc09233 139 void shift_display_left(Max7219 *p_display, uint8_t count, uint8_t delay);
j3 0:52f9ecc09233 140
j3 0:52f9ecc09233 141
j3 0:52f9ecc09233 142 /**********************************************************//**
j3 0:52f9ecc09233 143 * @brief turns on all leds for given quadrant, with quad 1 being
j3 0:52f9ecc09233 144 * top left and quad 4 being bottom right
j3 0:52f9ecc09233 145 *
j3 0:52f9ecc09233 146 * @details
j3 0:52f9ecc09233 147 *
j3 0:52f9ecc09233 148 * On Entry:
j3 0:52f9ecc09233 149 * @param[in] p_display - pointer to Max7219 object
j3 0:52f9ecc09233 150 * @param[in] quad - see brief
j3 0:52f9ecc09233 151 *
j3 0:52f9ecc09233 152 * On Exit:
j3 0:52f9ecc09233 153 * @return none
j3 0:52f9ecc09233 154 **************************************************************/
j3 0:52f9ecc09233 155 void quad_all_on(Max7219 *p_display, uint8_t quad);
j3 0:52f9ecc09233 156
j3 0:52f9ecc09233 157
j3 0:52f9ecc09233 158 /**********************************************************//**
j3 0:52f9ecc09233 159 * @brief turns off all leds for given quadrant, with quad 1 being
j3 0:52f9ecc09233 160 * top left and quad 4 being bottom right
j3 0:52f9ecc09233 161 *
j3 0:52f9ecc09233 162 * @details
j3 0:52f9ecc09233 163 *
j3 0:52f9ecc09233 164 * On Entry:
j3 0:52f9ecc09233 165 * @param[in] p_display - pointer to Max7219 object
j3 0:52f9ecc09233 166 * @param[in] quad - see brief
j3 0:52f9ecc09233 167 *
j3 0:52f9ecc09233 168 * On Exit:
j3 0:52f9ecc09233 169 * @return none
j3 0:52f9ecc09233 170 **************************************************************/
j3 0:52f9ecc09233 171 void quad_all_off(Max7219 *p_display, uint8_t quad);
j3 0:52f9ecc09233 172
j3 0:52f9ecc09233 173
j3 0:52f9ecc09233 174 /**********************************************************//**
j3 0:52f9ecc09233 175 * @brief turns all leds for whole display on
j3 0:52f9ecc09233 176 *
j3 0:52f9ecc09233 177 * @details
j3 0:52f9ecc09233 178 *
j3 0:52f9ecc09233 179 * On Entry:
j3 0:52f9ecc09233 180 * @param[in] p_display - pointer to Max7219 object
j3 0:52f9ecc09233 181 *
j3 0:52f9ecc09233 182 * On Exit:
j3 0:52f9ecc09233 183 * @return none
j3 0:52f9ecc09233 184 **************************************************************/
j3 0:52f9ecc09233 185 void all_on(Max7219 *p_display);
j3 0:52f9ecc09233 186
j3 0:52f9ecc09233 187
j3 0:52f9ecc09233 188 /**********************************************************//**
j3 0:52f9ecc09233 189 * @brief turns all leds for whole display off
j3 0:52f9ecc09233 190 *
j3 0:52f9ecc09233 191 * @details
j3 0:52f9ecc09233 192 *
j3 0:52f9ecc09233 193 * On Entry:
j3 0:52f9ecc09233 194 * @param[in] p_display - pointer to Max7219 object
j3 0:52f9ecc09233 195 *
j3 0:52f9ecc09233 196 * On Exit:
j3 0:52f9ecc09233 197 * @return none
j3 0:52f9ecc09233 198 **************************************************************/
j3 0:52f9ecc09233 199 void all_off(Max7219 *p_display);
j3 0:52f9ecc09233 200
j3 0:52f9ecc09233 201
j3 0:52f9ecc09233 202 void clear_buffer(void);
j3 0:52f9ecc09233 203
j3 0:52f9ecc09233 204
j3 0:52f9ecc09233 205 /**********************************************************//**
j3 0:52f9ecc09233 206 * @brief demo loop for MAXREFDES99
j3 0:52f9ecc09233 207 *
j3 0:52f9ecc09233 208 * @details
j3 0:52f9ecc09233 209 *
j3 0:52f9ecc09233 210 * On Entry:
j3 0:52f9ecc09233 211 * @param[in] p_display - pointer to Max7219 object
j3 0:52f9ecc09233 212 * @param[in] display_config - structure holding configuration data
j3 0:52f9ecc09233 213 * @param[in] endless_loop - if true run demo in endless loop
j3 0:52f9ecc09233 214 *
j3 0:52f9ecc09233 215 * On Exit:
j3 0:52f9ecc09233 216 * @return none
j3 0:52f9ecc09233 217 **************************************************************/
j3 0:52f9ecc09233 218 void demo(Max7219 *display, max7219_configuration_t display_config, bool endless_loop);
j3 0:52f9ecc09233 219
j3 0:52f9ecc09233 220
j3 0:52f9ecc09233 221 /**********************************************************//**
j3 0:52f9ecc09233 222 * @brief shift display in given direction forever
j3 0:52f9ecc09233 223 *
j3 0:52f9ecc09233 224 * @details
j3 0:52f9ecc09233 225 *
j3 0:52f9ecc09233 226 * On Entry:
j3 0:52f9ecc09233 227 * @param[in] p_display - pointer to Max7219 object
j3 0:52f9ecc09233 228 * @param[in] scroll_right - if true shift right, else shift left
j3 0:52f9ecc09233 229 *
j3 0:52f9ecc09233 230 * On Exit:
j3 0:52f9ecc09233 231 * @return none
j3 0:52f9ecc09233 232 **************************************************************/
j3 0:52f9ecc09233 233 void endless_scroll_display(Max7219 *display, uint32_t scroll_right);
j3 0:52f9ecc09233 234
j3 0:52f9ecc09233 235
j3 0:52f9ecc09233 236 /**********************************************************//**
j3 0:52f9ecc09233 237 * @brief print demo menu
j3 0:52f9ecc09233 238 *
j3 0:52f9ecc09233 239 * @details
j3 0:52f9ecc09233 240 *
j3 0:52f9ecc09233 241 * On Entry:
j3 0:52f9ecc09233 242 *
j3 0:52f9ecc09233 243 * On Exit:
j3 0:52f9ecc09233 244 * @return user entry
j3 0:52f9ecc09233 245 **************************************************************/
j3 0:52f9ecc09233 246 uint32_t print_menu(void);
j3 0:52f9ecc09233 247
j3 0:52f9ecc09233 248
j3 0:52f9ecc09233 249 /**********************************************************//**
j3 0:52f9ecc09233 250 * @brief get integer value from user
j3 0:52f9ecc09233 251 *
j3 0:52f9ecc09233 252 * @details
j3 0:52f9ecc09233 253 *
j3 0:52f9ecc09233 254 * On Entry:
j3 0:52f9ecc09233 255 * @param[in] msg - prompt for user
j3 0:52f9ecc09233 256 * @param[in] max_val - maximum allowable input
j3 0:52f9ecc09233 257 *
j3 0:52f9ecc09233 258 * On Exit:
j3 0:52f9ecc09233 259 * @return user entry
j3 0:52f9ecc09233 260 **************************************************************/
j3 0:52f9ecc09233 261 uint32_t get_user_input(char *msg, uint32_t max_val);
j3 0:52f9ecc09233 262
j3 0:52f9ecc09233 263
j3 0:52f9ecc09233 264 /**********************************************************//**
j3 0:52f9ecc09233 265 * @brief get char from user
j3 0:52f9ecc09233 266 *
j3 0:52f9ecc09233 267 * @details
j3 0:52f9ecc09233 268 *
j3 0:52f9ecc09233 269 * On Entry:
j3 0:52f9ecc09233 270 * @param[in] msg - prompt for user
j3 0:52f9ecc09233 271 *
j3 0:52f9ecc09233 272 * On Exit:
j3 0:52f9ecc09233 273 * @return user entry
j3 0:52f9ecc09233 274 **************************************************************/
j3 0:52f9ecc09233 275 char get_user_char(char *msg);
j3 0:52f9ecc09233 276
j3 0:52f9ecc09233 277
j3 0:52f9ecc09233 278 /**********************************************************//**
j3 0:52f9ecc09233 279 * @brief get string from user
j3 0:52f9ecc09233 280 *
j3 0:52f9ecc09233 281 * @details
j3 0:52f9ecc09233 282 *
j3 0:52f9ecc09233 283 * On Entry:
j3 0:52f9ecc09233 284 * @param[in] msg - prompt for user
j3 0:52f9ecc09233 285 *
j3 0:52f9ecc09233 286 * On Exit:
j3 0:52f9ecc09233 287 * @return user entry
j3 0:52f9ecc09233 288 **************************************************************/
j3 0:52f9ecc09233 289 char * get_user_string(char *msg);
j3 0:52f9ecc09233 290
j3 0:52f9ecc09233 291
j3 0:52f9ecc09233 292 #endif /*MAXREFDES99_H*/
j3 0:52f9ecc09233 293