Testé pour projet BTS SN
Fork of MODMAX7456 by
MAX7456.cpp@1:780cc760c05f, 2016-04-30 (annotated)
- 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?
User | Revision | Line number | New 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 | #include "mbed.h" |
AjK | 0:d7cd54ad4c3d | 24 | #include "MAX7456.h" |
AjK | 0:d7cd54ad4c3d | 25 | |
AjK | 0:d7cd54ad4c3d | 26 | #ifdef MAX7456_DEBUG |
AjK | 0:d7cd54ad4c3d | 27 | #include "IOMACROS.h" |
AjK | 0:d7cd54ad4c3d | 28 | extern Serial pc; |
AjK | 0:d7cd54ad4c3d | 29 | #endif |
AjK | 0:d7cd54ad4c3d | 30 | |
AjK | 0:d7cd54ad4c3d | 31 | #define CS_ASSERT _cs->write(0) |
AjK | 0:d7cd54ad4c3d | 32 | #define CS_DEASSERT _cs->write(1) |
AjK | 0:d7cd54ad4c3d | 33 | |
AjK | 0:d7cd54ad4c3d | 34 | // This header should only be included once here in this |
AjK | 0:d7cd54ad4c3d | 35 | // file as it compiles inline directly. Include within |
AjK | 0:d7cd54ad4c3d | 36 | // the library namespace. |
AjK | 0:d7cd54ad4c3d | 37 | #include "MAX7456CHARS.h" |
AjK | 0:d7cd54ad4c3d | 38 | |
AjK | 0:d7cd54ad4c3d | 39 | /* Map ASCII table to the MAX7456 character map. |
AjK | 0:d7cd54ad4c3d | 40 | Note, the MAX7456 in-built character map is no where near the ascii |
AjK | 0:d7cd54ad4c3d | 41 | table mapping and very few characters are available to map. Where |
AjK | 0:d7cd54ad4c3d | 42 | possible we create new characters for those we need that are missing |
AjK | 0:d7cd54ad4c3d | 43 | from the MAX7456 that we want to use and also we create some special |
AjK | 0:d7cd54ad4c3d | 44 | characters of our own that are not ASCII chars (crosshair for example). |
AjK | 0:d7cd54ad4c3d | 45 | These additional character definitions are listed below the table. |
AjK | 0:d7cd54ad4c3d | 46 | Character maps we have create can be found in MAX7456CHARS.h */ |
AjK | 0:d7cd54ad4c3d | 47 | const unsigned char MAX7456_ascii[256] = { |
AjK | 0:d7cd54ad4c3d | 48 | |
AjK | 0:d7cd54ad4c3d | 49 | /* Regular ASCII table. */ |
AjK | 0:d7cd54ad4c3d | 50 | /* 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F */ |
AjK | 0:d7cd54ad4c3d | 51 | /* 00 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
AjK | 0:d7cd54ad4c3d | 52 | /* 10 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
AjK | 0:d7cd54ad4c3d | 53 | /* 20 */ 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x46, 0x3F, 0x40, 0x00, 0x4d, 0x45, 0x49, 0x41, 0x47, |
AjK | 0:d7cd54ad4c3d | 54 | /* 30 */ 0x0A, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x44, 0x43, 0x4A, 0x00, 0x4B, 0x42, |
AjK | 0:d7cd54ad4c3d | 55 | /* 40 */ 0x4C, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, |
AjK | 0:d7cd54ad4c3d | 56 | /* 50 */ 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, |
AjK | 0:d7cd54ad4c3d | 57 | /* 60 */ 0x46, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, |
AjK | 0:d7cd54ad4c3d | 58 | /* 70 */ 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, |
AjK | 0:d7cd54ad4c3d | 59 | |
AjK | 0:d7cd54ad4c3d | 60 | /* Extended ASCII table. */ |
AjK | 0:d7cd54ad4c3d | 61 | /* 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F */ |
AjK | 0:d7cd54ad4c3d | 62 | /* 80 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
AjK | 0:d7cd54ad4c3d | 63 | /* 90 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
AjK | 0:d7cd54ad4c3d | 64 | /* A0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
AjK | 0:d7cd54ad4c3d | 65 | /* B0 */ 0xB0, 0x00, 0x00, 0xB3, 0xB4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, |
AjK | 0:d7cd54ad4c3d | 66 | /* C0 */ 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
AjK | 0:d7cd54ad4c3d | 67 | /* D0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD9, 0xDA, 0x00, 0x00, 0x00, 0x00, 0x00, |
AjK | 0:d7cd54ad4c3d | 68 | /* E0 */ 0xe0, 0xe1, 0xe2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
AjK | 0:d7cd54ad4c3d | 69 | /* F0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
AjK | 0:d7cd54ad4c3d | 70 | }; |
AjK | 0:d7cd54ad4c3d | 71 | |
AjK | 0:d7cd54ad4c3d | 72 | MAX7456::MAX7456(PinName mosi, PinName miso, PinName sclk, const char *name, PinName cs, PinName rst, PinName vsync) |
AjK | 0:d7cd54ad4c3d | 73 | { |
AjK | 0:d7cd54ad4c3d | 74 | init(mosi, miso, sclk, name, cs, rst, vsync); |
AjK | 0:d7cd54ad4c3d | 75 | } |
AjK | 0:d7cd54ad4c3d | 76 | |
AjK | 0:d7cd54ad4c3d | 77 | MAX7456::MAX7456(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName rst, PinName vsync) |
AjK | 0:d7cd54ad4c3d | 78 | { |
AjK | 0:d7cd54ad4c3d | 79 | init(mosi, miso, sclk, NULL, cs, rst, vsync); |
AjK | 0:d7cd54ad4c3d | 80 | } |
AjK | 0:d7cd54ad4c3d | 81 | |
AjK | 0:d7cd54ad4c3d | 82 | MAX7456::~MAX7456() |
AjK | 0:d7cd54ad4c3d | 83 | { |
AjK | 0:d7cd54ad4c3d | 84 | delete(_ssp); |
AjK | 0:d7cd54ad4c3d | 85 | delete(_cs); |
AjK | 0:d7cd54ad4c3d | 86 | delete(_rst); |
AjK | 0:d7cd54ad4c3d | 87 | delete(_vsync); |
AjK | 0:d7cd54ad4c3d | 88 | } |
AjK | 0:d7cd54ad4c3d | 89 | |
AjK | 0:d7cd54ad4c3d | 90 | void |
AjK | 0:d7cd54ad4c3d | 91 | MAX7456::init(PinName mosi, PinName miso, PinName sclk, const char *name, PinName cs, PinName rst, PinName vsync) |
AjK | 0:d7cd54ad4c3d | 92 | { |
cdupaty | 1:780cc760c05f | 93 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
cdupaty | 1:780cc760c05f | 94 | // Here code change !!!! "name" is not use in new library |
cdupaty | 1:780cc760c05f | 95 | // Christian Dupaty 03/2016 |
cdupaty | 1:780cc760c05f | 96 | // original is : |
cdupaty | 1:780cc760c05f | 97 | //_ssp = new SPI(mosi, miso, sclk, name); |
cdupaty | 1:780cc760c05f | 98 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
cdupaty | 1:780cc760c05f | 99 | _ssp = new SPI(mosi, miso, sclk); |
AjK | 0:d7cd54ad4c3d | 100 | _cs = new DigitalOut(cs); |
AjK | 0:d7cd54ad4c3d | 101 | _rst = new DigitalOut(rst); |
AjK | 0:d7cd54ad4c3d | 102 | if (vsync != NC) { |
AjK | 0:d7cd54ad4c3d | 103 | _vsync = new InterruptIn(vsync); |
AjK | 0:d7cd54ad4c3d | 104 | _vsync->fall(this, &MAX7456::vsync_isr); |
AjK | 0:d7cd54ad4c3d | 105 | } |
AjK | 0:d7cd54ad4c3d | 106 | |
AjK | 0:d7cd54ad4c3d | 107 | // Set default output signals. |
AjK | 0:d7cd54ad4c3d | 108 | CS_DEASSERT; |
AjK | 0:d7cd54ad4c3d | 109 | _rst->write(1); |
AjK | 0:d7cd54ad4c3d | 110 | |
AjK | 0:d7cd54ad4c3d | 111 | // Setup the SSP. |
AjK | 0:d7cd54ad4c3d | 112 | _ssp->format(8,0); |
AjK | 0:d7cd54ad4c3d | 113 | _ssp->frequency(25000000); |
AjK | 0:d7cd54ad4c3d | 114 | |
AjK | 0:d7cd54ad4c3d | 115 | // Reset the MAX7456 |
AjK | 0:d7cd54ad4c3d | 116 | reset(); |
AjK | 0:d7cd54ad4c3d | 117 | |
AjK | 0:d7cd54ad4c3d | 118 | /* Write the custom CM map. */ |
AjK | 0:d7cd54ad4c3d | 119 | write(0, read(0) & 0xF7); |
AjK | 0:d7cd54ad4c3d | 120 | for (int index = 0; custom_chars[index].ascii != 0; index++) { |
AjK | 0:d7cd54ad4c3d | 121 | write_char_map(custom_chars[index].ascii, custom_chars[index].map); |
AjK | 0:d7cd54ad4c3d | 122 | } |
AjK | 0:d7cd54ad4c3d | 123 | |
AjK | 0:d7cd54ad4c3d | 124 | wait_us(100000); |
AjK | 0:d7cd54ad4c3d | 125 | |
AjK | 0:d7cd54ad4c3d | 126 | /* Change the vertical offset. */ |
AjK | 0:d7cd54ad4c3d | 127 | vos(0x16); |
AjK | 0:d7cd54ad4c3d | 128 | |
AjK | 0:d7cd54ad4c3d | 129 | /* Set the blink rate. */ |
AjK | 0:d7cd54ad4c3d | 130 | //vm1((3 << 2) | 3); |
AjK | 0:d7cd54ad4c3d | 131 | |
AjK | 0:d7cd54ad4c3d | 132 | /* Enable display of OSD image. */ |
AjK | 0:d7cd54ad4c3d | 133 | vm0(0x48); |
AjK | 0:d7cd54ad4c3d | 134 | } |
AjK | 0:d7cd54ad4c3d | 135 | |
AjK | 0:d7cd54ad4c3d | 136 | void |
AjK | 0:d7cd54ad4c3d | 137 | MAX7456::write(unsigned char address, unsigned char byte) |
AjK | 0:d7cd54ad4c3d | 138 | { |
AjK | 0:d7cd54ad4c3d | 139 | CS_ASSERT; |
AjK | 0:d7cd54ad4c3d | 140 | |
AjK | 0:d7cd54ad4c3d | 141 | /* MAX7456 addresses are always less than 0x80 so if the |
AjK | 0:d7cd54ad4c3d | 142 | address is > 0x7F then the caller is requesting an direct |
AjK | 0:d7cd54ad4c3d | 143 | 8bit data transfer. */ |
AjK | 0:d7cd54ad4c3d | 144 | if (address < 0x80) { _ssp->write(address); } |
AjK | 0:d7cd54ad4c3d | 145 | |
AjK | 0:d7cd54ad4c3d | 146 | _ssp->write(byte); |
AjK | 0:d7cd54ad4c3d | 147 | CS_DEASSERT; |
AjK | 0:d7cd54ad4c3d | 148 | } |
AjK | 0:d7cd54ad4c3d | 149 | |
AjK | 0:d7cd54ad4c3d | 150 | int |
AjK | 0:d7cd54ad4c3d | 151 | MAX7456::read(unsigned char address) |
AjK | 0:d7cd54ad4c3d | 152 | { |
AjK | 0:d7cd54ad4c3d | 153 | int data; |
AjK | 0:d7cd54ad4c3d | 154 | address |= 0x80; |
AjK | 0:d7cd54ad4c3d | 155 | CS_ASSERT; |
AjK | 0:d7cd54ad4c3d | 156 | _ssp->write(address); |
AjK | 0:d7cd54ad4c3d | 157 | data = _ssp->write(0xFF); |
AjK | 0:d7cd54ad4c3d | 158 | CS_DEASSERT; |
AjK | 0:d7cd54ad4c3d | 159 | return data; |
AjK | 0:d7cd54ad4c3d | 160 | } |
AjK | 0:d7cd54ad4c3d | 161 | |
AjK | 0:d7cd54ad4c3d | 162 | void |
AjK | 0:d7cd54ad4c3d | 163 | MAX7456::reset(void) |
AjK | 0:d7cd54ad4c3d | 164 | { |
AjK | 0:d7cd54ad4c3d | 165 | _rst->write(0); |
AjK | 0:d7cd54ad4c3d | 166 | wait_us(100000); |
AjK | 0:d7cd54ad4c3d | 167 | _rst->write(1); |
AjK | 0:d7cd54ad4c3d | 168 | wait_us(100000); |
AjK | 0:d7cd54ad4c3d | 169 | } |
AjK | 0:d7cd54ad4c3d | 170 | |
AjK | 0:d7cd54ad4c3d | 171 | void |
AjK | 0:d7cd54ad4c3d | 172 | MAX7456::clear_display(void) |
AjK | 0:d7cd54ad4c3d | 173 | { |
AjK | 0:d7cd54ad4c3d | 174 | dmm(1 << 2); |
AjK | 0:d7cd54ad4c3d | 175 | while(dmm() & (1 << 2)); |
AjK | 0:d7cd54ad4c3d | 176 | } |
AjK | 0:d7cd54ad4c3d | 177 | |
AjK | 0:d7cd54ad4c3d | 178 | void |
AjK | 0:d7cd54ad4c3d | 179 | MAX7456::cursor(int x, int y) |
AjK | 0:d7cd54ad4c3d | 180 | { |
AjK | 0:d7cd54ad4c3d | 181 | uint16_t pos = (y * 30) + x; |
AjK | 0:d7cd54ad4c3d | 182 | dmah((pos >> 8) & 0x1); |
AjK | 0:d7cd54ad4c3d | 183 | dmal(pos & 0xFF); |
AjK | 0:d7cd54ad4c3d | 184 | } |
AjK | 0:d7cd54ad4c3d | 185 | |
AjK | 0:d7cd54ad4c3d | 186 | void |
AjK | 0:d7cd54ad4c3d | 187 | MAX7456::convert_string(char *s) |
AjK | 0:d7cd54ad4c3d | 188 | { |
AjK | 0:d7cd54ad4c3d | 189 | while(*(s)) { |
AjK | 0:d7cd54ad4c3d | 190 | *(s) = MAX7456_ascii[*(s)]; |
AjK | 0:d7cd54ad4c3d | 191 | s++; |
AjK | 0:d7cd54ad4c3d | 192 | } |
AjK | 0:d7cd54ad4c3d | 193 | } |
AjK | 0:d7cd54ad4c3d | 194 | |
AjK | 0:d7cd54ad4c3d | 195 | int |
AjK | 0:d7cd54ad4c3d | 196 | MAX7456::string(char *s) |
AjK | 0:d7cd54ad4c3d | 197 | { |
AjK | 0:d7cd54ad4c3d | 198 | int len = 0; |
AjK | 0:d7cd54ad4c3d | 199 | dmm(1 | (1 << 6)); /* Enable 8bit write */ |
AjK | 0:d7cd54ad4c3d | 200 | while(*(s)) { |
AjK | 0:d7cd54ad4c3d | 201 | write(0x80, MAX7456_ascii[*s++]); |
AjK | 0:d7cd54ad4c3d | 202 | len++; |
AjK | 0:d7cd54ad4c3d | 203 | } |
AjK | 0:d7cd54ad4c3d | 204 | write(0x80, 0xFF); |
AjK | 0:d7cd54ad4c3d | 205 | return len; |
AjK | 0:d7cd54ad4c3d | 206 | } |
AjK | 0:d7cd54ad4c3d | 207 | |
AjK | 0:d7cd54ad4c3d | 208 | void |
AjK | 0:d7cd54ad4c3d | 209 | MAX7456::attributes_xyl(int x, int y, char *s, int len) |
AjK | 0:d7cd54ad4c3d | 210 | { |
AjK | 0:d7cd54ad4c3d | 211 | uint16_t pos = (y * 30) + x; |
AjK | 0:d7cd54ad4c3d | 212 | dmah(((pos >> 8) & 0x1) | (1 << 1)); |
AjK | 0:d7cd54ad4c3d | 213 | dmdi(pos & 0xFF); |
AjK | 0:d7cd54ad4c3d | 214 | dmm(1 | (1 << 6)); /* Enable 8bit write */ |
AjK | 0:d7cd54ad4c3d | 215 | while (len--) { |
AjK | 0:d7cd54ad4c3d | 216 | write(0x80, *s++); |
AjK | 0:d7cd54ad4c3d | 217 | } |
AjK | 0:d7cd54ad4c3d | 218 | write(0x80, 0xFF); |
AjK | 0:d7cd54ad4c3d | 219 | } |
AjK | 0:d7cd54ad4c3d | 220 | |
AjK | 0:d7cd54ad4c3d | 221 | int |
AjK | 0:d7cd54ad4c3d | 222 | MAX7456::stringxy(int x, int y, char *s) |
AjK | 0:d7cd54ad4c3d | 223 | { |
AjK | 0:d7cd54ad4c3d | 224 | cursor(x, y); |
AjK | 0:d7cd54ad4c3d | 225 | return string(s); |
AjK | 0:d7cd54ad4c3d | 226 | } |
AjK | 0:d7cd54ad4c3d | 227 | |
AjK | 0:d7cd54ad4c3d | 228 | int |
AjK | 0:d7cd54ad4c3d | 229 | MAX7456::stringxy(int x, int y, char *s, uint8_t a) |
AjK | 0:d7cd54ad4c3d | 230 | { |
AjK | 0:d7cd54ad4c3d | 231 | char *q = NULL; |
AjK | 0:d7cd54ad4c3d | 232 | int len; |
AjK | 0:d7cd54ad4c3d | 233 | cursor(x, y); |
AjK | 0:d7cd54ad4c3d | 234 | len = string(s); |
AjK | 0:d7cd54ad4c3d | 235 | q = (char *)malloc(len); |
AjK | 0:d7cd54ad4c3d | 236 | if (!q) { |
AjK | 0:d7cd54ad4c3d | 237 | return -1; |
AjK | 0:d7cd54ad4c3d | 238 | } |
AjK | 0:d7cd54ad4c3d | 239 | memset(q, a, len); |
AjK | 0:d7cd54ad4c3d | 240 | attributes_xyl(x, y, q, len); |
AjK | 0:d7cd54ad4c3d | 241 | free(q); |
AjK | 0:d7cd54ad4c3d | 242 | return len; |
AjK | 0:d7cd54ad4c3d | 243 | } |
AjK | 0:d7cd54ad4c3d | 244 | |
AjK | 0:d7cd54ad4c3d | 245 | int |
AjK | 0:d7cd54ad4c3d | 246 | MAX7456::stringxy(int x, int y, char *s, char *a) |
AjK | 0:d7cd54ad4c3d | 247 | { |
AjK | 0:d7cd54ad4c3d | 248 | int len; |
AjK | 0:d7cd54ad4c3d | 249 | cursor(x, y); |
AjK | 0:d7cd54ad4c3d | 250 | len = string(s); |
AjK | 0:d7cd54ad4c3d | 251 | attributes_xyl(x, y, a, 30); |
AjK | 0:d7cd54ad4c3d | 252 | return len; |
AjK | 0:d7cd54ad4c3d | 253 | } |
AjK | 0:d7cd54ad4c3d | 254 | |
AjK | 0:d7cd54ad4c3d | 255 | void |
AjK | 0:d7cd54ad4c3d | 256 | MAX7456::stringl(int x, int y, char *s, int len) |
AjK | 0:d7cd54ad4c3d | 257 | { |
AjK | 0:d7cd54ad4c3d | 258 | cursor(x, y); |
AjK | 0:d7cd54ad4c3d | 259 | dmm(1); /* Enable 8bit write */ |
AjK | 0:d7cd54ad4c3d | 260 | while(len--) { |
AjK | 0:d7cd54ad4c3d | 261 | if (*s == '\0') break; |
AjK | 0:d7cd54ad4c3d | 262 | write(0x80, MAX7456_ascii[*s++]); |
AjK | 0:d7cd54ad4c3d | 263 | } |
AjK | 0:d7cd54ad4c3d | 264 | write(0x80, 0xFF); |
AjK | 0:d7cd54ad4c3d | 265 | } |
AjK | 0:d7cd54ad4c3d | 266 | |
AjK | 0:d7cd54ad4c3d | 267 | void |
AjK | 0:d7cd54ad4c3d | 268 | MAX7456::read_char_map(unsigned char address, unsigned char *data54) |
AjK | 0:d7cd54ad4c3d | 269 | { |
AjK | 0:d7cd54ad4c3d | 270 | cmah((uint8_t)address); |
AjK | 0:d7cd54ad4c3d | 271 | cmm(0x50); |
AjK | 0:d7cd54ad4c3d | 272 | for (uint8_t index = 0; index < 54; index++) { |
AjK | 0:d7cd54ad4c3d | 273 | cmal(index); |
AjK | 0:d7cd54ad4c3d | 274 | wait_us(1000); |
AjK | 0:d7cd54ad4c3d | 275 | *(data54 + index) = read(0xC0); |
AjK | 0:d7cd54ad4c3d | 276 | } |
AjK | 0:d7cd54ad4c3d | 277 | } |
AjK | 0:d7cd54ad4c3d | 278 | |
AjK | 0:d7cd54ad4c3d | 279 | void |
AjK | 0:d7cd54ad4c3d | 280 | MAX7456::write_char_map(unsigned char address, const unsigned char *data54) |
AjK | 0:d7cd54ad4c3d | 281 | { |
AjK | 0:d7cd54ad4c3d | 282 | unsigned char index, c, match = 1; |
AjK | 0:d7cd54ad4c3d | 283 | |
AjK | 0:d7cd54ad4c3d | 284 | write(CMAH, address); |
AjK | 0:d7cd54ad4c3d | 285 | write(CMM, 0x50); |
AjK | 0:d7cd54ad4c3d | 286 | wait_us(20000); |
AjK | 0:d7cd54ad4c3d | 287 | for (index = 0; index < 54; index++) { |
AjK | 0:d7cd54ad4c3d | 288 | write(CMAL, index); |
AjK | 0:d7cd54ad4c3d | 289 | c = read(0xC0); |
AjK | 0:d7cd54ad4c3d | 290 | if (c != data54[index]) { |
AjK | 0:d7cd54ad4c3d | 291 | match = 0; |
AjK | 0:d7cd54ad4c3d | 292 | break; |
AjK | 0:d7cd54ad4c3d | 293 | } |
AjK | 0:d7cd54ad4c3d | 294 | } |
AjK | 0:d7cd54ad4c3d | 295 | |
AjK | 0:d7cd54ad4c3d | 296 | if (!match) { |
AjK | 0:d7cd54ad4c3d | 297 | write(CMAH, address); |
AjK | 0:d7cd54ad4c3d | 298 | for (index = 0; index < 0x36; index++) { |
AjK | 0:d7cd54ad4c3d | 299 | write(CMAL, index); |
AjK | 0:d7cd54ad4c3d | 300 | write(CMDI, data54[index]); |
AjK | 0:d7cd54ad4c3d | 301 | } |
AjK | 0:d7cd54ad4c3d | 302 | write(CMM, 0xA0); |
AjK | 0:d7cd54ad4c3d | 303 | wait_us(20000); |
AjK | 0:d7cd54ad4c3d | 304 | while ((read(0xA0) & 0x20) != 0x00); |
AjK | 0:d7cd54ad4c3d | 305 | } |
AjK | 0:d7cd54ad4c3d | 306 | } |
AjK | 0:d7cd54ad4c3d | 307 | |
AjK | 0:d7cd54ad4c3d | 308 | |
AjK | 0:d7cd54ad4c3d | 309 |