Testé pour projet BTS SN

Fork of MODMAX7456 by Andy K

Committer:
cdupaty
Date:
Sat Apr 30 17:10:04 2016 +0000
Revision:
1:780cc760c05f
Parent:
0:d7cd54ad4c3d
Test? pour projet BTS SN

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AjK 0:d7cd54ad4c3d 1 /*
AjK 0:d7cd54ad4c3d 2 Copyright (c) 2010 Andy Kirkham
AjK 0:d7cd54ad4c3d 3
AjK 0:d7cd54ad4c3d 4 Permission is hereby granted, free of charge, to any person obtaining a copy
AjK 0:d7cd54ad4c3d 5 of this software and associated documentation files (the "Software"), to deal
AjK 0:d7cd54ad4c3d 6 in the Software without restriction, including without limitation the rights
AjK 0:d7cd54ad4c3d 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
AjK 0:d7cd54ad4c3d 8 copies of the Software, and to permit persons to whom the Software is
AjK 0:d7cd54ad4c3d 9 furnished to do so, subject to the following conditions:
AjK 0:d7cd54ad4c3d 10
AjK 0:d7cd54ad4c3d 11 The above copyright notice and this permission notice shall be included in
AjK 0:d7cd54ad4c3d 12 all copies or substantial portions of the Software.
AjK 0:d7cd54ad4c3d 13
AjK 0:d7cd54ad4c3d 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
AjK 0:d7cd54ad4c3d 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
AjK 0:d7cd54ad4c3d 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AjK 0:d7cd54ad4c3d 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
AjK 0:d7cd54ad4c3d 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
AjK 0:d7cd54ad4c3d 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
AjK 0:d7cd54ad4c3d 20 THE SOFTWARE.
AjK 0:d7cd54ad4c3d 21 */
AjK 0:d7cd54ad4c3d 22
AjK 0:d7cd54ad4c3d 23 #ifndef MODMAX7456_H
AjK 0:d7cd54ad4c3d 24 #define MODMAX7456_H
AjK 0:d7cd54ad4c3d 25
AjK 0:d7cd54ad4c3d 26 #include "mbed.h"
AjK 0:d7cd54ad4c3d 27
AjK 0:d7cd54ad4c3d 28 /** @defgroup MAX7456_API */
AjK 0:d7cd54ad4c3d 29 /** @defgroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 30
AjK 0:d7cd54ad4c3d 31 /** MAX7456 module
AjK 0:d7cd54ad4c3d 32 *
AjK 0:d7cd54ad4c3d 33 * @see http://mbed.org/cookbook/
AjK 0:d7cd54ad4c3d 34 * @see example1.cpp
AjK 0:d7cd54ad4c3d 35 *
AjK 0:d7cd54ad4c3d 36 * Example:
AjK 0:d7cd54ad4c3d 37 * @code
AjK 0:d7cd54ad4c3d 38 * #include "mbed.h"
AjK 0:d7cd54ad4c3d 39 * #include "MAX7456.h"
AjK 0:d7cd54ad4c3d 40 *
AjK 0:d7cd54ad4c3d 41 * DigitalOut led1(LED1);
AjK 0:d7cd54ad4c3d 42 *
AjK 0:d7cd54ad4c3d 43 * MAX7456 *max7456;
AjK 0:d7cd54ad4c3d 44 *
AjK 0:d7cd54ad4c3d 45 * int main() {
AjK 0:d7cd54ad4c3d 46 *
AjK 0:d7cd54ad4c3d 47 * max7456 = new MAX7456(p5, p6, p7, p8, p20, p15);
AjK 0:d7cd54ad4c3d 48 *
AjK 0:d7cd54ad4c3d 49 * max7456->stringxy(1, 1, "Hello World");
AjK 0:d7cd54ad4c3d 50 *
AjK 0:d7cd54ad4c3d 51 * while(1) {
AjK 0:d7cd54ad4c3d 52 * led1 = 1;
AjK 0:d7cd54ad4c3d 53 * wait(0.5);
AjK 0:d7cd54ad4c3d 54 * led1 = 0;
AjK 0:d7cd54ad4c3d 55 * wait(0.5);
AjK 0:d7cd54ad4c3d 56 * }
AjK 0:d7cd54ad4c3d 57 * }
AjK 0:d7cd54ad4c3d 58 * @endcode
AjK 0:d7cd54ad4c3d 59 */
AjK 0:d7cd54ad4c3d 60
AjK 0:d7cd54ad4c3d 61 class MAX7456
AjK 0:d7cd54ad4c3d 62 {
AjK 0:d7cd54ad4c3d 63 public:
AjK 0:d7cd54ad4c3d 64
AjK 0:d7cd54ad4c3d 65 //! MAX7456 register definitions
AjK 0:d7cd54ad4c3d 66 enum Registers {
AjK 0:d7cd54ad4c3d 67 VM0 = 0, VM1, HOS, VOS, DMM, DMAH, DMAL, DMDI, CMM, CMAH, CMAL, CMDI, OSDM,
AjK 0:d7cd54ad4c3d 68 OSDBL = 0x6C
AjK 0:d7cd54ad4c3d 69 };
AjK 0:d7cd54ad4c3d 70
AjK 0:d7cd54ad4c3d 71 //! MAX7456 Row brightness register definitions.
AjK 0:d7cd54ad4c3d 72 enum RowBrightnessReg {
AjK 0:d7cd54ad4c3d 73 RB0 = 16, RB1, RB2, RB3, RB4, RB5, RB6, RB7, RB8, RB9, RB10, RB11, RB12, RB13, RB14, RB15,
AjK 0:d7cd54ad4c3d 74 };
AjK 0:d7cd54ad4c3d 75
AjK 0:d7cd54ad4c3d 76 //! Character attributes.
AjK 0:d7cd54ad4c3d 77 enum Attributes {
AjK 0:d7cd54ad4c3d 78 //! Inverse background
AjK 0:d7cd54ad4c3d 79 Inverse = (1 << 5),
AjK 0:d7cd54ad4c3d 80 //! Character blinks
AjK 0:d7cd54ad4c3d 81 Blink = (1 << 6),
AjK 0:d7cd54ad4c3d 82 //! Use "local background"
AjK 0:d7cd54ad4c3d 83 LocalBG = (1 << 7)
AjK 0:d7cd54ad4c3d 84 };
AjK 0:d7cd54ad4c3d 85
AjK 0:d7cd54ad4c3d 86 //! Background brightness levels (see register VM1)
AjK 0:d7cd54ad4c3d 87 enum BGbrightness {
AjK 0:d7cd54ad4c3d 88 //! 0%
AjK 0:d7cd54ad4c3d 89 Percent_0 = (0 << 4),
AjK 0:d7cd54ad4c3d 90 //! 7%
AjK 0:d7cd54ad4c3d 91 Percent_7 = (1 << 4),
AjK 0:d7cd54ad4c3d 92 //! 14%
AjK 0:d7cd54ad4c3d 93 Percent_14 = (2 << 4),
AjK 0:d7cd54ad4c3d 94 //! 21%
AjK 0:d7cd54ad4c3d 95 Percent_21 = (3 << 4),
AjK 0:d7cd54ad4c3d 96 //! 28%
AjK 0:d7cd54ad4c3d 97 Percent_28 = (4 << 4),
AjK 0:d7cd54ad4c3d 98 //! 35%
AjK 0:d7cd54ad4c3d 99 Percent_35 = (5 << 4),
AjK 0:d7cd54ad4c3d 100 //! 42%
AjK 0:d7cd54ad4c3d 101 Percent_42 = (6 << 4),
AjK 0:d7cd54ad4c3d 102 //! 49%
AjK 0:d7cd54ad4c3d 103 Percent_49 = (7 << 4)
AjK 0:d7cd54ad4c3d 104 };
AjK 0:d7cd54ad4c3d 105
AjK 0:d7cd54ad4c3d 106 //! Character blink time.
AjK 0:d7cd54ad4c3d 107 enum BlinkTime {
AjK 0:d7cd54ad4c3d 108 //! 33milliseconds
AjK 0:d7cd54ad4c3d 109 ms_33 = (0 << 2),
AjK 0:d7cd54ad4c3d 110 //! 67milliseconds
AjK 0:d7cd54ad4c3d 111 ms_67 = (1 << 2),
AjK 0:d7cd54ad4c3d 112 //! 100milliseconds
AjK 0:d7cd54ad4c3d 113 ms_100 = (2 << 2),
AjK 0:d7cd54ad4c3d 114 //! 133milliseconds
AjK 0:d7cd54ad4c3d 115 ms_133 = (3 << 2)
AjK 0:d7cd54ad4c3d 116 };
AjK 0:d7cd54ad4c3d 117
AjK 0:d7cd54ad4c3d 118 // Blink Time duty cycle.
AjK 0:d7cd54ad4c3d 119 enum BlinkingDutyCycle {
AjK 0:d7cd54ad4c3d 120 //! 1:1 duty cycle
AjK 0:d7cd54ad4c3d 121 BT_BT = (0 << 0),
AjK 0:d7cd54ad4c3d 122 //! 1:2 duty cycle
AjK 0:d7cd54ad4c3d 123 BT_BT2 = (1 << 0),
AjK 0:d7cd54ad4c3d 124 //! 1:3 duty cycle
AjK 0:d7cd54ad4c3d 125 BT_BT3 = (2 << 0),
AjK 0:d7cd54ad4c3d 126 //! 3:1 duty cycle
AjK 0:d7cd54ad4c3d 127 BT3_BT = (3 << 0)
AjK 0:d7cd54ad4c3d 128 };
AjK 0:d7cd54ad4c3d 129
AjK 0:d7cd54ad4c3d 130 //! MAX7456 constructor.
AjK 0:d7cd54ad4c3d 131 /**
AjK 0:d7cd54ad4c3d 132 * The MAX7456 constructor is used to initialise the MAX7456 object.
AjK 0:d7cd54ad4c3d 133 *
AjK 0:d7cd54ad4c3d 134 * Example 1
AjK 0:d7cd54ad4c3d 135 * @code
AjK 0:d7cd54ad4c3d 136 * #include "mbed.h"
AjK 0:d7cd54ad4c3d 137 * #include "MAX7456.h"
AjK 0:d7cd54ad4c3d 138 *
AjK 0:d7cd54ad4c3d 139 * MAX7456 max(p5, p6, p7, NULL, p8, p20, p15);
AjK 0:d7cd54ad4c3d 140 *
AjK 0:d7cd54ad4c3d 141 * int main() {
AjK 0:d7cd54ad4c3d 142 *
AjK 0:d7cd54ad4c3d 143 * max.stringxy(1, 1, "Hello World");
AjK 0:d7cd54ad4c3d 144 *
AjK 0:d7cd54ad4c3d 145 * while(1);
AjK 0:d7cd54ad4c3d 146 * }
AjK 0:d7cd54ad4c3d 147 * @endcode
AjK 0:d7cd54ad4c3d 148 *
AjK 0:d7cd54ad4c3d 149 * Example 2
AjK 0:d7cd54ad4c3d 150 * @code
AjK 0:d7cd54ad4c3d 151 * #include "mbed.h"
AjK 0:d7cd54ad4c3d 152 * #include "MAX7456.h"
AjK 0:d7cd54ad4c3d 153 *
AjK 0:d7cd54ad4c3d 154 * int main() {
AjK 0:d7cd54ad4c3d 155 *
AjK 0:d7cd54ad4c3d 156 * MAX7456 max = new MAX7456(p5, p6, p7, NULL, p8, p20, p15);
AjK 0:d7cd54ad4c3d 157 *
AjK 0:d7cd54ad4c3d 158 * max->stringxy(1, 1, "Hello World");
AjK 0:d7cd54ad4c3d 159 *
AjK 0:d7cd54ad4c3d 160 * while(1);
AjK 0:d7cd54ad4c3d 161 * }
AjK 0:d7cd54ad4c3d 162 * @endcode
AjK 0:d7cd54ad4c3d 163 *
AjK 0:d7cd54ad4c3d 164 * @ingroup MAX7456_API
AjK 0:d7cd54ad4c3d 165 * @param miso PinName p5 or p11
AjK 0:d7cd54ad4c3d 166 * @param mosi PinName p6 or p12
AjK 0:d7cd54ad4c3d 167 * @param sclk PinName p7 pr p13
AjK 0:d7cd54ad4c3d 168 * @param name Optional const char * SSP object name
AjK 0:d7cd54ad4c3d 169 * @param cs PinName CS signal
AjK 0:d7cd54ad4c3d 170 * @param rst PinName RESET signal
AjK 0:d7cd54ad4c3d 171 * @param vsync PinName Vertical sync signal
AjK 0:d7cd54ad4c3d 172 */
AjK 0:d7cd54ad4c3d 173 MAX7456(PinName mosi, PinName miso, PinName sclk, const char *name, PinName cs, PinName rst, PinName vsync);
AjK 0:d7cd54ad4c3d 174
AjK 0:d7cd54ad4c3d 175 //! MAX7456 constructor.
AjK 0:d7cd54ad4c3d 176 /**
AjK 0:d7cd54ad4c3d 177 * The MAX7456 constructor is used to initialise the MAX7456 object.
AjK 0:d7cd54ad4c3d 178 *
AjK 0:d7cd54ad4c3d 179 * Example 1
AjK 0:d7cd54ad4c3d 180 * @code
AjK 0:d7cd54ad4c3d 181 * #include "mbed.h"
AjK 0:d7cd54ad4c3d 182 * #include "MAX7456.h"
AjK 0:d7cd54ad4c3d 183 *
AjK 0:d7cd54ad4c3d 184 * MAX7456 max(p5, p6, p7, p8, p20, p15);
AjK 0:d7cd54ad4c3d 185 *
AjK 0:d7cd54ad4c3d 186 * int main() {
AjK 0:d7cd54ad4c3d 187 *
AjK 0:d7cd54ad4c3d 188 * max.stringxy(1, 1, "Hello World");
AjK 0:d7cd54ad4c3d 189 *
AjK 0:d7cd54ad4c3d 190 * while(1);
AjK 0:d7cd54ad4c3d 191 * }
AjK 0:d7cd54ad4c3d 192 * @endcode
AjK 0:d7cd54ad4c3d 193 *
AjK 0:d7cd54ad4c3d 194 * Example 2
AjK 0:d7cd54ad4c3d 195 * @code
AjK 0:d7cd54ad4c3d 196 * #include "mbed.h"
AjK 0:d7cd54ad4c3d 197 * #include "MAX7456.h"
AjK 0:d7cd54ad4c3d 198 *
AjK 0:d7cd54ad4c3d 199 * int main() {
AjK 0:d7cd54ad4c3d 200 *
AjK 0:d7cd54ad4c3d 201 * MAX7456 max = new MAX7456(p5, p6, p7, p8, p20, p15);
AjK 0:d7cd54ad4c3d 202 *
AjK 0:d7cd54ad4c3d 203 * max->stringxy(1, 1, "Hello World");
AjK 0:d7cd54ad4c3d 204 *
AjK 0:d7cd54ad4c3d 205 * while(1);
AjK 0:d7cd54ad4c3d 206 * }
AjK 0:d7cd54ad4c3d 207 * @endcode
AjK 0:d7cd54ad4c3d 208 *
AjK 0:d7cd54ad4c3d 209 * @ingroup MAX7456_API
AjK 0:d7cd54ad4c3d 210 * @param miso PinName p5 or p11
AjK 0:d7cd54ad4c3d 211 * @param mosi PinName p6 or p12
AjK 0:d7cd54ad4c3d 212 * @param sclk PinName p7 pr p13
AjK 0:d7cd54ad4c3d 213 * @param cs PinName CS signal
AjK 0:d7cd54ad4c3d 214 * @param rst PinName RESET signal
AjK 0:d7cd54ad4c3d 215 * @param vsync PinName Vertical sync signal
AjK 0:d7cd54ad4c3d 216 */
AjK 0:d7cd54ad4c3d 217 MAX7456(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName rst, PinName vsync);
AjK 0:d7cd54ad4c3d 218
AjK 0:d7cd54ad4c3d 219 ~MAX7456();
AjK 0:d7cd54ad4c3d 220
AjK 0:d7cd54ad4c3d 221 //! reset()
AjK 0:d7cd54ad4c3d 222 /**
AjK 0:d7cd54ad4c3d 223 * Resets the MAX7456 device.
AjK 0:d7cd54ad4c3d 224 *
AjK 0:d7cd54ad4c3d 225 * @ingroup MAX7456_API
AjK 0:d7cd54ad4c3d 226 */
AjK 0:d7cd54ad4c3d 227 void reset(void);
AjK 0:d7cd54ad4c3d 228
AjK 0:d7cd54ad4c3d 229 //! clear_display()
AjK 0:d7cd54ad4c3d 230 /**
AjK 0:d7cd54ad4c3d 231 * Cleasr the entire display area.
AjK 0:d7cd54ad4c3d 232 *
AjK 0:d7cd54ad4c3d 233 * @ingroup MAX7456_API
AjK 0:d7cd54ad4c3d 234 */
AjK 0:d7cd54ad4c3d 235 void clear_display(void);
AjK 0:d7cd54ad4c3d 236
AjK 0:d7cd54ad4c3d 237 //! cursor(x,y)
AjK 0:d7cd54ad4c3d 238 /**
AjK 0:d7cd54ad4c3d 239 * Moves the "cursor" to the screen X,Y position. Future writes to the
AjK 0:d7cd54ad4c3d 240 * screen ram will occur at this position.
AjK 0:d7cd54ad4c3d 241 *
AjK 0:d7cd54ad4c3d 242 * @ingroup MAX7456_API
AjK 0:d7cd54ad4c3d 243 * @param x The X position
AjK 0:d7cd54ad4c3d 244 * @param y The Y position
AjK 0:d7cd54ad4c3d 245 */
AjK 0:d7cd54ad4c3d 246 void cursor(int x, int y);
AjK 0:d7cd54ad4c3d 247
AjK 0:d7cd54ad4c3d 248 //! convert_string(*s)
AjK 0:d7cd54ad4c3d 249 /**
AjK 0:d7cd54ad4c3d 250 * Takes a pointer to an ascii string and converts it to chars that will
AjK 0:d7cd54ad4c3d 251 * display via teh MAX7456 character set. Note, the string is converted.
AjK 0:d7cd54ad4c3d 252 *
AjK 0:d7cd54ad4c3d 253 * @param s A char * pointer to the NULL terminated string to convert.
AjK 0:d7cd54ad4c3d 254 */
AjK 0:d7cd54ad4c3d 255 void convert_string(char *s);
AjK 0:d7cd54ad4c3d 256
AjK 0:d7cd54ad4c3d 257 //! string(*s)
AjK 0:d7cd54ad4c3d 258 /**
AjK 0:d7cd54ad4c3d 259 * Print the string pointed to by s at the current cursor position.
AjK 0:d7cd54ad4c3d 260 * The string should be an ASCII NULL terminated string.
AjK 0:d7cd54ad4c3d 261 *
AjK 0:d7cd54ad4c3d 262 * @ingroup MAX7456_API
AjK 0:d7cd54ad4c3d 263 * @param s A char * pointer to the NULL terminated string to print.
AjK 0:d7cd54ad4c3d 264 */
AjK 0:d7cd54ad4c3d 265 int string(char *s);
AjK 0:d7cd54ad4c3d 266
AjK 0:d7cd54ad4c3d 267 //! stringxy(x,y,s)
AjK 0:d7cd54ad4c3d 268 /**
AjK 0:d7cd54ad4c3d 269 * Print the string pointed to by s at the position supplied by x,y.
AjK 0:d7cd54ad4c3d 270 * The string should be an ASCII NULL terminated string.
AjK 0:d7cd54ad4c3d 271 *
AjK 0:d7cd54ad4c3d 272 * @ingroup MAX7456_API
AjK 0:d7cd54ad4c3d 273 * @param x The X position
AjK 0:d7cd54ad4c3d 274 * @param y The Y position
AjK 0:d7cd54ad4c3d 275 * @param s A char * pointer to the NULL terminated string to print.
AjK 0:d7cd54ad4c3d 276 * @return int The length of the string written.
AjK 0:d7cd54ad4c3d 277 */
AjK 0:d7cd54ad4c3d 278 int stringxy(int x, int y, char *s);
AjK 0:d7cd54ad4c3d 279
AjK 0:d7cd54ad4c3d 280 //! stringxy(x,y,s,a)
AjK 0:d7cd54ad4c3d 281 /**
AjK 0:d7cd54ad4c3d 282 * Print the string pointed to by s at the position supplied by x,y.
AjK 0:d7cd54ad4c3d 283 * The string should be an ASCII NULL terminated string.
AjK 0:d7cd54ad4c3d 284 *
AjK 0:d7cd54ad4c3d 285 * @ingroup MAX7456_API
AjK 0:d7cd54ad4c3d 286 * @param x The X position
AjK 0:d7cd54ad4c3d 287 * @param y The Y position
AjK 0:d7cd54ad4c3d 288 * @param s A char * pointer to the NULL terminated string to print.
AjK 0:d7cd54ad4c3d 289 * @param a An attribute byte to appply to the string.
AjK 0:d7cd54ad4c3d 290 * @return int The length of the string written.
AjK 0:d7cd54ad4c3d 291 */
AjK 0:d7cd54ad4c3d 292 int stringxy(int x, int y, char *s, uint8_t a);
AjK 0:d7cd54ad4c3d 293
AjK 0:d7cd54ad4c3d 294 //! stringxy(x,y,s,a)
AjK 0:d7cd54ad4c3d 295 /**
AjK 0:d7cd54ad4c3d 296 * Print the string pointed to by s at the position supplied by x,y.
AjK 0:d7cd54ad4c3d 297 * The string should be an ASCII NULL terminated string.
AjK 0:d7cd54ad4c3d 298 *
AjK 0:d7cd54ad4c3d 299 * @ingroup MAX7456_API
AjK 0:d7cd54ad4c3d 300 * @param x The X position
AjK 0:d7cd54ad4c3d 301 * @param y The Y position
AjK 0:d7cd54ad4c3d 302 * @param s A char * pointer to the NULL terminated string to print.
AjK 0:d7cd54ad4c3d 303 * @param a A char * pointer to the 30byte attribute string.
AjK 0:d7cd54ad4c3d 304 * @return int The length of the string written.
AjK 0:d7cd54ad4c3d 305 */
AjK 0:d7cd54ad4c3d 306 int stringxy(int x, int y, char *s, char *a);
AjK 0:d7cd54ad4c3d 307
AjK 0:d7cd54ad4c3d 308 //! stringxy(x,y,s,len)
AjK 0:d7cd54ad4c3d 309 /**
AjK 0:d7cd54ad4c3d 310 * Print the string pointed to by s at the position supplied by x,y.
AjK 0:d7cd54ad4c3d 311 * The string should be an ASCII terminated string.
AjK 0:d7cd54ad4c3d 312 * len determines the length of the string to print (not the term NULL).
AjK 0:d7cd54ad4c3d 313 *
AjK 0:d7cd54ad4c3d 314 * @ingroup MAX7456_API
AjK 0:d7cd54ad4c3d 315 * @param x The X position
AjK 0:d7cd54ad4c3d 316 * @param y The Y position
AjK 0:d7cd54ad4c3d 317 * @param s A char * pointer to the NULL terminated string to print.
AjK 0:d7cd54ad4c3d 318 * @param len The length of teh string to print.
AjK 0:d7cd54ad4c3d 319 */
AjK 0:d7cd54ad4c3d 320 void stringl(int x, int y, char *s, int len);
AjK 0:d7cd54ad4c3d 321
AjK 0:d7cd54ad4c3d 322 //! attribute_xyl(x,y,s,len)
AjK 0:d7cd54ad4c3d 323 /**
AjK 0:d7cd54ad4c3d 324 * Write the character attribute bytes at x,y
AjK 0:d7cd54ad4c3d 325 * Since attributes can be zero (NULL), the string length
AjK 0:d7cd54ad4c3d 326 * must be provided.
AjK 0:d7cd54ad4c3d 327 *
AjK 0:d7cd54ad4c3d 328 * @ingroup MAX7456_API
AjK 0:d7cd54ad4c3d 329 * @param x The X position
AjK 0:d7cd54ad4c3d 330 * @param y The Y position
AjK 0:d7cd54ad4c3d 331 * @param s A char * pointer to the NULL terminated string of attributes.
AjK 0:d7cd54ad4c3d 332 * @param len The length of the string of attributes.
AjK 0:d7cd54ad4c3d 333 */
AjK 0:d7cd54ad4c3d 334 void attributes_xyl(int x, int y, char *s, int len);
AjK 0:d7cd54ad4c3d 335
AjK 0:d7cd54ad4c3d 336 /**
AjK 0:d7cd54ad4c3d 337 * Set the background brightness
AjK 0:d7cd54ad4c3d 338 *
AjK 0:d7cd54ad4c3d 339 * @see BGbrightness
AjK 0:d7cd54ad4c3d 340 * @ingroup MAX7456_API
AjK 0:d7cd54ad4c3d 341 * @param i The brightness level
AjK 0:d7cd54ad4c3d 342 */
AjK 0:d7cd54ad4c3d 343 void backGround(BGbrightness i) { vm1((vm1() & ~(7 << 4)) | i); }
AjK 0:d7cd54ad4c3d 344
AjK 0:d7cd54ad4c3d 345 /**
AjK 0:d7cd54ad4c3d 346 * Set the character blink rate
AjK 0:d7cd54ad4c3d 347 *
AjK 0:d7cd54ad4c3d 348 * @see BlinkTime
AjK 0:d7cd54ad4c3d 349 * @see BlinkingDutyCycle
AjK 0:d7cd54ad4c3d 350 * @ingroup MAX7456_API
AjK 0:d7cd54ad4c3d 351 * @param bt The blink time
AjK 0:d7cd54ad4c3d 352 * @param dc The duty cycle
AjK 0:d7cd54ad4c3d 353 */
AjK 0:d7cd54ad4c3d 354 void blinkRate(BlinkTime bt, BlinkingDutyCycle dc) { vm1((vm1() & ~(0xf)) | (bt | dc)); }
AjK 0:d7cd54ad4c3d 355
AjK 0:d7cd54ad4c3d 356 //! read_char_map(address,data54)
AjK 0:d7cd54ad4c3d 357 /**
AjK 0:d7cd54ad4c3d 358 * Read the 54byte character map from MAX7456 ROM.
AjK 0:d7cd54ad4c3d 359 *
AjK 0:d7cd54ad4c3d 360 * @ingroup MAX7456_API
AjK 0:d7cd54ad4c3d 361 * @param address The uchar address to read from (which character)
AjK 0:d7cd54ad4c3d 362 * @param data54 A char * pointer to a buffer where to write to.
AjK 0:d7cd54ad4c3d 363 */
AjK 0:d7cd54ad4c3d 364 void read_char_map(unsigned char address, unsigned char *data54);
AjK 0:d7cd54ad4c3d 365
AjK 0:d7cd54ad4c3d 366 //! write_char_map(address,data54)
AjK 0:d7cd54ad4c3d 367 /**
AjK 0:d7cd54ad4c3d 368 * Write the 54byte character map to the MAX7456 ROM.
AjK 0:d7cd54ad4c3d 369 *
AjK 0:d7cd54ad4c3d 370 * @ingroup MAX7456_API
AjK 0:d7cd54ad4c3d 371 * @param address The uchar address to write to
AjK 0:d7cd54ad4c3d 372 * @param data54 A char * pointer to a buffer where to read from.
AjK 0:d7cd54ad4c3d 373 */
AjK 0:d7cd54ad4c3d 374 void write_char_map(unsigned char address, const unsigned char *data54);
AjK 0:d7cd54ad4c3d 375
AjK 0:d7cd54ad4c3d 376 //! attach(tptr,mptr)
AjK 0:d7cd54ad4c3d 377 /**
AjK 0:d7cd54ad4c3d 378 * Attach a callback method to teh vertical sync interrupt.
AjK 0:d7cd54ad4c3d 379 *
AjK 0:d7cd54ad4c3d 380 * @ingroup MAX7456_API
AjK 0:d7cd54ad4c3d 381 * @param tptr The class object pointer conatining the method.
AjK 0:d7cd54ad4c3d 382 * @param mptr The method within the object to invoke.
AjK 0:d7cd54ad4c3d 383 */
AjK 0:d7cd54ad4c3d 384 template<typename T>
AjK 0:d7cd54ad4c3d 385 void vsync_set_callback(T* tptr, void (T::*mptr)(void)) {
AjK 0:d7cd54ad4c3d 386 _vsync_callback.attach(tptr, mptr);
AjK 0:d7cd54ad4c3d 387 }
AjK 0:d7cd54ad4c3d 388
AjK 0:d7cd54ad4c3d 389 //! attach(tptr,mptr)
AjK 0:d7cd54ad4c3d 390 /**
AjK 0:d7cd54ad4c3d 391 * Attach a callback function to the vertical sync interrupt.
AjK 0:d7cd54ad4c3d 392 *
AjK 0:d7cd54ad4c3d 393 * @ingroup MAX7456_API
AjK 0:d7cd54ad4c3d 394 * @param fptr A function pointer to call on vertical sync irq.
AjK 0:d7cd54ad4c3d 395 */
AjK 0:d7cd54ad4c3d 396 void vsync_set_callback(void (*fptr)(void)) { _vsync_callback.attach(fptr); }
AjK 0:d7cd54ad4c3d 397
AjK 0:d7cd54ad4c3d 398 // Must be reimplemented by the child class.
AjK 0:d7cd54ad4c3d 399 virtual void vsync_isr(void) { _vsync_callback.call(); };
AjK 0:d7cd54ad4c3d 400
AjK 0:d7cd54ad4c3d 401 // Register level API.
AjK 0:d7cd54ad4c3d 402
AjK 0:d7cd54ad4c3d 403 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 404 __INLINE void vm0(uint8_t i) { write(VM0, i); }
AjK 0:d7cd54ad4c3d 405 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 406 __INLINE uint8_t vm0(void) { return (uint8_t)read(VM0); }
AjK 0:d7cd54ad4c3d 407 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 408 __INLINE void vm1(uint8_t i) { write(VM1, i); }
AjK 0:d7cd54ad4c3d 409 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 410 __INLINE uint8_t vm1(void) { return (uint8_t)read(VM1); }
AjK 0:d7cd54ad4c3d 411 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 412 __INLINE void hos(uint8_t i) { write(HOS, i); }
AjK 0:d7cd54ad4c3d 413 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 414 __INLINE uint8_t hos(void) { return (uint8_t)read(HOS); }
AjK 0:d7cd54ad4c3d 415 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 416 __INLINE void vos(uint8_t i) { write(VOS, i); }
AjK 0:d7cd54ad4c3d 417 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 418 __INLINE uint8_t vos(void) { return (uint8_t)read(VOS); }
AjK 0:d7cd54ad4c3d 419 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 420 __INLINE void dmm(uint8_t i) { write(DMM, i); }
AjK 0:d7cd54ad4c3d 421 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 422 __INLINE uint8_t dmm(void) { return (uint8_t)read(DMM); }
AjK 0:d7cd54ad4c3d 423 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 424 __INLINE void dmah(uint8_t i) { write(DMAH, i); }
AjK 0:d7cd54ad4c3d 425 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 426 __INLINE uint8_t dmah(void) { return (uint8_t)read(DMAH); }
AjK 0:d7cd54ad4c3d 427 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 428 __INLINE void dmal(uint8_t i) { write(DMAL, i); }
AjK 0:d7cd54ad4c3d 429 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 430 __INLINE uint8_t dmal(void) { return (uint8_t)read(DMAL); }
AjK 0:d7cd54ad4c3d 431 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 432 __INLINE void dmdi(uint8_t i) { write(DMDI, i); }
AjK 0:d7cd54ad4c3d 433 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 434 __INLINE uint8_t dmai(void) { return (uint8_t)read(DMDI); }
AjK 0:d7cd54ad4c3d 435 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 436 __INLINE void cmm(uint8_t i) { write(CMM, i); }
AjK 0:d7cd54ad4c3d 437 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 438 __INLINE uint8_t cmm(void) { return (uint8_t)read(CMM); }
AjK 0:d7cd54ad4c3d 439 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 440 __INLINE void cmah(uint8_t i) { write(CMAH, i); }
AjK 0:d7cd54ad4c3d 441 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 442 __INLINE uint8_t cmah(void) { return (uint8_t)read(CMAH); }
AjK 0:d7cd54ad4c3d 443 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 444 __INLINE void cmal(uint8_t i) { write(CMAL, i); }
AjK 0:d7cd54ad4c3d 445 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 446 __INLINE uint8_t cmal(void) { return (uint8_t)read(CMAL); }
AjK 0:d7cd54ad4c3d 447 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 448 __INLINE void cmdi(uint8_t i) { write(CMDI, i); }
AjK 0:d7cd54ad4c3d 449 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 450 __INLINE uint8_t cmai(void) { return (uint8_t)read(CMDI); }
AjK 0:d7cd54ad4c3d 451 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 452 __INLINE void osdm(uint8_t i) { write(OSDM, i); }
AjK 0:d7cd54ad4c3d 453 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 454 __INLINE uint8_t osdm(void) { return (uint8_t)read(OSDM); }
AjK 0:d7cd54ad4c3d 455 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 456
AjK 0:d7cd54ad4c3d 457 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 458 __INLINE uint8_t stat(void) { return read(0xA0); }
AjK 0:d7cd54ad4c3d 459
AjK 0:d7cd54ad4c3d 460 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 461 __INLINE bool los(void) { return (bool)!(stat() & (1 << 2)); }
AjK 0:d7cd54ad4c3d 462
AjK 0:d7cd54ad4c3d 463 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 464 __INLINE uint8_t osdbl(void) { return (uint8_t)read(OSDBL); }
AjK 0:d7cd54ad4c3d 465 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 466 __INLINE void osdbl(bool b) { uint8_t t = osdbl(); if (b) osdbl(t & ~(1 << 4)); else osdbl(t | (1 << 4)); }
AjK 0:d7cd54ad4c3d 467
AjK 0:d7cd54ad4c3d 468 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 469 __INLINE void RowBrightness(RowBrightnessReg r, uint8_t i) { write(r, i); }
AjK 0:d7cd54ad4c3d 470 /** @ingroup MAX7456_REGISTER_API */
AjK 0:d7cd54ad4c3d 471 __INLINE uint8_t RowBrightness(RowBrightnessReg r) { return read (r); }
AjK 0:d7cd54ad4c3d 472
AjK 0:d7cd54ad4c3d 473 protected:
AjK 0:d7cd54ad4c3d 474 void init(PinName mosi, PinName miso, PinName sclk, const char *name, PinName cs, PinName rst, PinName vsync = NC);
AjK 0:d7cd54ad4c3d 475 void write(unsigned char address, unsigned char byte);
AjK 0:d7cd54ad4c3d 476 int read(unsigned char address);
AjK 0:d7cd54ad4c3d 477
AjK 0:d7cd54ad4c3d 478 SPI *_ssp;
AjK 0:d7cd54ad4c3d 479 DigitalOut *_cs;
AjK 0:d7cd54ad4c3d 480 DigitalOut *_rst;
AjK 0:d7cd54ad4c3d 481 InterruptIn *_vsync;
AjK 0:d7cd54ad4c3d 482 FunctionPointer _vsync_callback;
AjK 0:d7cd54ad4c3d 483 };
AjK 0:d7cd54ad4c3d 484
AjK 0:d7cd54ad4c3d 485 #endif