![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ft. button press reset
Fork of BeaconDemo_RobotCode by
PsiSwarm/display.cpp@23:fd0f0931768a, 2017-03-13 (annotated)
- Committer:
- jhok500
- Date:
- Mon Mar 13 10:07:07 2017 +0000
- Revision:
- 23:fd0f0931768a
- Parent:
- 9:085e090e1ec1
ft. reset button press
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jah128 | 0:8a5497a2e366 | 1 | /* University of York Robotics Laboratory PsiSwarm Library: Display Driver Source File |
jah128 | 0:8a5497a2e366 | 2 | * |
jah128 | 0:8a5497a2e366 | 3 | * File: display.cpp |
jah128 | 0:8a5497a2e366 | 4 | * |
jah128 | 0:8a5497a2e366 | 5 | * (C) Dr James Hilder, Dept. Electronics & Computer Science, University of York |
jah128 | 0:8a5497a2e366 | 6 | * |
jah128 | 6:ff3c66f7372b | 7 | * PsiSwarm Library Version: 0.3 |
jah128 | 0:8a5497a2e366 | 8 | * Display Driver Version: 0.2 |
jah128 | 0:8a5497a2e366 | 9 | * |
jah128 | 6:ff3c66f7372b | 10 | * October 2015 |
jah128 | 0:8a5497a2e366 | 11 | * |
jah128 | 0:8a5497a2e366 | 12 | * Driver for the Midas 16x2 I2C LCD Display (MCCOG21605x6W) LCD |
jah128 | 0:8a5497a2e366 | 13 | * [Farnell part 2218942 or 2063206] |
jah128 | 0:8a5497a2e366 | 14 | * |
jah128 | 0:8a5497a2e366 | 15 | */ |
jah128 | 0:8a5497a2e366 | 16 | |
jah128 | 0:8a5497a2e366 | 17 | #include "psiswarm.h" |
jah128 | 0:8a5497a2e366 | 18 | |
jah128 | 0:8a5497a2e366 | 19 | Timeout init_timeout; |
jah128 | 0:8a5497a2e366 | 20 | Timeout backlight_timeout; |
jah128 | 0:8a5497a2e366 | 21 | Timeout debug_timeout; |
jah128 | 0:8a5497a2e366 | 22 | int backlight_on_time; |
jah128 | 0:8a5497a2e366 | 23 | int backlight_off_time; |
jah128 | 0:8a5497a2e366 | 24 | char backlight_step; |
jah128 | 0:8a5497a2e366 | 25 | char multipage[200]; |
jah128 | 0:8a5497a2e366 | 26 | char multipage_length = 0; |
jah128 | 0:8a5497a2e366 | 27 | char preserve_line_1 [17]; |
jah128 | 0:8a5497a2e366 | 28 | char preserve_line_2 [17]; |
jah128 | 0:8a5497a2e366 | 29 | char c_row=0; |
jah128 | 0:8a5497a2e366 | 30 | char c_column=0; |
jah128 | 0:8a5497a2e366 | 31 | char p_row; |
jah128 | 0:8a5497a2e366 | 32 | char p_column; |
jah128 | 0:8a5497a2e366 | 33 | |
jah128 | 0:8a5497a2e366 | 34 | |
jah128 | 0:8a5497a2e366 | 35 | Display::Display(PinName sda, PinName scl, PinName reset, PinName backlight) : Stream("display"), _i2c(sda,scl), _reset(reset), _backlight(backlight) { |
jah128 | 0:8a5497a2e366 | 36 | } |
jah128 | 0:8a5497a2e366 | 37 | |
jah128 | 0:8a5497a2e366 | 38 | Display::Display() : Stream("display"), _i2c(p28,p27), _reset(p29), _backlight(p30) { |
jah128 | 0:8a5497a2e366 | 39 | } |
jah128 | 0:8a5497a2e366 | 40 | |
jah128 | 0:8a5497a2e366 | 41 | int Display::i2c_message(char byte){ |
jah128 | 0:8a5497a2e366 | 42 | char bytes [2]; |
jah128 | 0:8a5497a2e366 | 43 | bytes[0]=0x80; |
jah128 | 0:8a5497a2e366 | 44 | bytes[1]=byte; |
jah128 | 0:8a5497a2e366 | 45 | int ret=_i2c.write(LCD_ADDRESS,bytes,2); |
jah128 | 0:8a5497a2e366 | 46 | wait(0.01); |
jah128 | 0:8a5497a2e366 | 47 | return ret; |
jah128 | 0:8a5497a2e366 | 48 | } |
jah128 | 0:8a5497a2e366 | 49 | |
jah128 | 0:8a5497a2e366 | 50 | int Display::disp_putc(int c){ |
jah128 | 0:8a5497a2e366 | 51 | char message [2]; |
jah128 | 0:8a5497a2e366 | 52 | message[0]=0x40; |
jah128 | 0:8a5497a2e366 | 53 | message[1]=c; |
jah128 | 0:8a5497a2e366 | 54 | _i2c.write(LCD_ADDRESS,message,2); |
jah128 | 0:8a5497a2e366 | 55 | wait(0.01); |
jah128 | 0:8a5497a2e366 | 56 | return c; |
jah128 | 0:8a5497a2e366 | 57 | } |
jah128 | 0:8a5497a2e366 | 58 | |
jah128 | 0:8a5497a2e366 | 59 | void Display::init_display(char mode){ |
jah128 | 0:8a5497a2e366 | 60 | //Set initial states: display on, cursor off |
jah128 | 0:8a5497a2e366 | 61 | display_on = 1; |
jah128 | 0:8a5497a2e366 | 62 | set_backlight_brightness(1); |
jah128 | 0:8a5497a2e366 | 63 | cursor_on = 0; |
jah128 | 0:8a5497a2e366 | 64 | blink_on = 0; |
jah128 | 0:8a5497a2e366 | 65 | |
jah128 | 0:8a5497a2e366 | 66 | _reset=1; |
jah128 | 0:8a5497a2e366 | 67 | wait(0.02); |
jah128 | 0:8a5497a2e366 | 68 | //Set reset low |
jah128 | 0:8a5497a2e366 | 69 | _reset=0; |
jah128 | 0:8a5497a2e366 | 70 | wait(0.001); |
jah128 | 0:8a5497a2e366 | 71 | _reset=1; |
jah128 | 0:8a5497a2e366 | 72 | wait(0.03); |
jah128 | 0:8a5497a2e366 | 73 | i2c_message(0x38); |
jah128 | 0:8a5497a2e366 | 74 | i2c_message(0x39); |
jah128 | 0:8a5497a2e366 | 75 | i2c_message(0x14); |
jah128 | 0:8a5497a2e366 | 76 | i2c_message(0x74); |
jah128 | 0:8a5497a2e366 | 77 | i2c_message(0x54); |
jah128 | 0:8a5497a2e366 | 78 | i2c_message(0x6F); |
jah128 | 0:8a5497a2e366 | 79 | _set_display(); |
jah128 | 0:8a5497a2e366 | 80 | clear_display(); |
jah128 | 0:8a5497a2e366 | 81 | char psis[17]; |
jah128 | 0:8a5497a2e366 | 82 | for(int i=0;i<16;i++){ |
jah128 | 0:8a5497a2e366 | 83 | psis[i]=0x1D; |
jah128 | 0:8a5497a2e366 | 84 | } |
jah128 | 0:8a5497a2e366 | 85 | set_position(0,0); |
jah128 | 0:8a5497a2e366 | 86 | write_string(psis,16); |
jah128 | 0:8a5497a2e366 | 87 | set_position(1,0); |
jah128 | 0:8a5497a2e366 | 88 | write_string(psis,16); |
jah128 | 9:085e090e1ec1 | 89 | wait(0.25); |
jah128 | 0:8a5497a2e366 | 90 | clear_display(); |
jah128 | 0:8a5497a2e366 | 91 | if(mode == 0){ |
jah128 | 0:8a5497a2e366 | 92 | set_position(0,0); |
jah128 | 0:8a5497a2e366 | 93 | write_string(" YORK ROBOTICS"); |
jah128 | 0:8a5497a2e366 | 94 | set_position(1,0); |
jah128 | 0:8a5497a2e366 | 95 | write_string(" LABORATORY"); |
jah128 | 9:085e090e1ec1 | 96 | init_timeout.attach(this,&Display::post_init,0.3);} |
jah128 | 0:8a5497a2e366 | 97 | else { |
jah128 | 0:8a5497a2e366 | 98 | set_position(0,0); |
jah128 | 0:8a5497a2e366 | 99 | write_string("Hold button to"); |
jah128 | 0:8a5497a2e366 | 100 | set_position(1,0); |
jah128 | 0:8a5497a2e366 | 101 | write_string("launch demo code"); |
jah128 | 0:8a5497a2e366 | 102 | } |
jah128 | 0:8a5497a2e366 | 103 | } |
jah128 | 0:8a5497a2e366 | 104 | |
jah128 | 0:8a5497a2e366 | 105 | void Display::post_init(){ |
jah128 | 0:8a5497a2e366 | 106 | clear_display(); |
jah128 | 0:8a5497a2e366 | 107 | home(); |
jah128 | 0:8a5497a2e366 | 108 | write_string("PSI SWARM ROBOT"); |
jah128 | 0:8a5497a2e366 | 109 | set_position(1,0); |
jah128 | 0:8a5497a2e366 | 110 | char line [17]; |
jah128 | 0:8a5497a2e366 | 111 | sprintf(line,"VERSION %1.2f", SOFTWARE_VERSION_CODE ); |
jah128 | 0:8a5497a2e366 | 112 | set_position(1,0); |
jah128 | 0:8a5497a2e366 | 113 | write_string(line); |
jah128 | 9:085e090e1ec1 | 114 | init_timeout.attach(this,&Display::post_post_init,0.3); |
jah128 | 0:8a5497a2e366 | 115 | } |
jah128 | 0:8a5497a2e366 | 116 | |
jah128 | 0:8a5497a2e366 | 117 | void Display::post_post_init(){ |
jah128 | 0:8a5497a2e366 | 118 | clear_display(); |
jah128 | 0:8a5497a2e366 | 119 | home(); |
jah128 | 0:8a5497a2e366 | 120 | } |
jah128 | 0:8a5497a2e366 | 121 | |
jah128 | 0:8a5497a2e366 | 122 | void Display::write_string(char * message){ |
jah128 | 0:8a5497a2e366 | 123 | size_t length = strlen(message); |
jah128 | 0:8a5497a2e366 | 124 | if (length > 16) length = 16; |
jah128 | 0:8a5497a2e366 | 125 | char to_send [length+1]; |
jah128 | 0:8a5497a2e366 | 126 | to_send[0]=0x40; |
jah128 | 0:8a5497a2e366 | 127 | for(int i=0;i<length;i++){ |
jah128 | 0:8a5497a2e366 | 128 | to_send[i+1] = message[i]; |
jah128 | 0:8a5497a2e366 | 129 | } |
jah128 | 0:8a5497a2e366 | 130 | _i2c.write(LCD_ADDRESS,to_send,length+1); |
jah128 | 0:8a5497a2e366 | 131 | // Add to saved buffer |
jah128 | 0:8a5497a2e366 | 132 | int count = 0; |
jah128 | 0:8a5497a2e366 | 133 | for(int i=c_column;i<16;i++){ |
jah128 | 0:8a5497a2e366 | 134 | if(count < length){ |
jah128 | 0:8a5497a2e366 | 135 | if(c_row == 0) preserve_line_1[i] = message[count]; |
jah128 | 0:8a5497a2e366 | 136 | else preserve_line_2[i] = message[count]; |
jah128 | 0:8a5497a2e366 | 137 | } |
jah128 | 0:8a5497a2e366 | 138 | count++; |
jah128 | 0:8a5497a2e366 | 139 | } |
jah128 | 0:8a5497a2e366 | 140 | c_column+=length; |
jah128 | 0:8a5497a2e366 | 141 | if(c_column>15) c_column=15; |
jah128 | 0:8a5497a2e366 | 142 | } |
jah128 | 0:8a5497a2e366 | 143 | |
jah128 | 0:8a5497a2e366 | 144 | |
jah128 | 0:8a5497a2e366 | 145 | void Display::write_string(char * message, char length){ |
jah128 | 0:8a5497a2e366 | 146 | char to_send [length+1]; |
jah128 | 0:8a5497a2e366 | 147 | to_send[0]=0x40; |
jah128 | 0:8a5497a2e366 | 148 | for(int i=0;i<length;i++){ |
jah128 | 0:8a5497a2e366 | 149 | to_send[i+1] = message[i]; |
jah128 | 0:8a5497a2e366 | 150 | } |
jah128 | 0:8a5497a2e366 | 151 | _i2c.write(LCD_ADDRESS,to_send,length+1); |
jah128 | 0:8a5497a2e366 | 152 | // Add to saved buffer |
jah128 | 0:8a5497a2e366 | 153 | int count = 0; |
jah128 | 0:8a5497a2e366 | 154 | for(int i=c_column;i<16;i++){ |
jah128 | 0:8a5497a2e366 | 155 | if(count < length){ |
jah128 | 0:8a5497a2e366 | 156 | if(c_row == 0) preserve_line_1[i] = message[count]; |
jah128 | 0:8a5497a2e366 | 157 | else preserve_line_2[i] = message[count]; |
jah128 | 0:8a5497a2e366 | 158 | } |
jah128 | 0:8a5497a2e366 | 159 | count++; |
jah128 | 0:8a5497a2e366 | 160 | } |
jah128 | 0:8a5497a2e366 | 161 | c_column+=length; |
jah128 | 0:8a5497a2e366 | 162 | if(c_column>15) c_column=15; |
jah128 | 0:8a5497a2e366 | 163 | } |
jah128 | 0:8a5497a2e366 | 164 | |
jah128 | 0:8a5497a2e366 | 165 | void Display::set_position(char row, char column){ |
jah128 | 0:8a5497a2e366 | 166 | if(row < 2 && column < 16){ |
jah128 | 0:8a5497a2e366 | 167 | char pos = 128 +((row * 64)+column); |
jah128 | 0:8a5497a2e366 | 168 | i2c_message(pos); |
jah128 | 0:8a5497a2e366 | 169 | c_row= row; |
jah128 | 0:8a5497a2e366 | 170 | c_column = column; |
jah128 | 0:8a5497a2e366 | 171 | } |
jah128 | 0:8a5497a2e366 | 172 | } |
jah128 | 0:8a5497a2e366 | 173 | |
jah128 | 0:8a5497a2e366 | 174 | void Display::set_cursor(char enable){ |
jah128 | 0:8a5497a2e366 | 175 | cursor_on=enable; |
jah128 | 0:8a5497a2e366 | 176 | _set_display(); |
jah128 | 0:8a5497a2e366 | 177 | } |
jah128 | 0:8a5497a2e366 | 178 | |
jah128 | 0:8a5497a2e366 | 179 | void Display::set_blink(char enable){ |
jah128 | 0:8a5497a2e366 | 180 | blink_on=enable; |
jah128 | 0:8a5497a2e366 | 181 | _set_display(); |
jah128 | 0:8a5497a2e366 | 182 | } |
jah128 | 0:8a5497a2e366 | 183 | |
jah128 | 0:8a5497a2e366 | 184 | void Display::set_display(char enable){ |
jah128 | 0:8a5497a2e366 | 185 | display_on=enable; |
jah128 | 0:8a5497a2e366 | 186 | _set_display(); |
jah128 | 0:8a5497a2e366 | 187 | } |
jah128 | 0:8a5497a2e366 | 188 | |
jah128 | 0:8a5497a2e366 | 189 | void Display::set_backlight_brightness(float brightness){ |
jah128 | 0:8a5497a2e366 | 190 | if(brightness > 1) brightness = 0; |
jah128 | 0:8a5497a2e366 | 191 | if(brightness < 0) brightness = 0; |
jah128 | 0:8a5497a2e366 | 192 | backlight_brightness = brightness; |
jah128 | 0:8a5497a2e366 | 193 | if(backlight_brightness == 1) { |
jah128 | 0:8a5497a2e366 | 194 | backlight_timeout.detach(); |
jah128 | 0:8a5497a2e366 | 195 | _backlight = 1; |
jah128 | 0:8a5497a2e366 | 196 | }else{ |
jah128 | 0:8a5497a2e366 | 197 | if(backlight_brightness == 0){ |
jah128 | 0:8a5497a2e366 | 198 | backlight_timeout.detach(); |
jah128 | 0:8a5497a2e366 | 199 | _backlight = 0; |
jah128 | 0:8a5497a2e366 | 200 | } else { |
jah128 | 0:8a5497a2e366 | 201 | backlight_on_time = (int) (10000.0f * backlight_brightness); |
jah128 | 0:8a5497a2e366 | 202 | backlight_off_time = 10000 - backlight_on_time; |
jah128 | 0:8a5497a2e366 | 203 | backlight_step = 0; |
jah128 | 0:8a5497a2e366 | 204 | _backlight = 0; |
jah128 | 0:8a5497a2e366 | 205 | backlight_timeout.attach_us(this,&Display::IF_backlight_toggle,backlight_off_time); |
jah128 | 0:8a5497a2e366 | 206 | } |
jah128 | 0:8a5497a2e366 | 207 | } |
jah128 | 0:8a5497a2e366 | 208 | } |
jah128 | 0:8a5497a2e366 | 209 | |
jah128 | 0:8a5497a2e366 | 210 | void Display::IF_backlight_toggle(){ |
jah128 | 0:8a5497a2e366 | 211 | if(backlight_step == 0){ |
jah128 | 0:8a5497a2e366 | 212 | _backlight = 1; |
jah128 | 0:8a5497a2e366 | 213 | backlight_step = 1; |
jah128 | 0:8a5497a2e366 | 214 | backlight_timeout.attach_us(this,&Display::IF_backlight_toggle,backlight_on_time); |
jah128 | 0:8a5497a2e366 | 215 | } else { |
jah128 | 0:8a5497a2e366 | 216 | _backlight = 0; |
jah128 | 0:8a5497a2e366 | 217 | backlight_step = 0; |
jah128 | 0:8a5497a2e366 | 218 | backlight_timeout.attach_us(this,&Display::IF_backlight_toggle,backlight_off_time); |
jah128 | 0:8a5497a2e366 | 219 | } |
jah128 | 0:8a5497a2e366 | 220 | } |
jah128 | 0:8a5497a2e366 | 221 | void Display::clear_display(){ |
jah128 | 0:8a5497a2e366 | 222 | for(int i=0;i<16;i++){ |
jah128 | 0:8a5497a2e366 | 223 | preserve_line_1[i] = 0x20; |
jah128 | 0:8a5497a2e366 | 224 | preserve_line_2[i] = 0x20; |
jah128 | 0:8a5497a2e366 | 225 | } |
jah128 | 0:8a5497a2e366 | 226 | i2c_message(0x01); |
jah128 | 0:8a5497a2e366 | 227 | } |
jah128 | 0:8a5497a2e366 | 228 | |
jah128 | 0:8a5497a2e366 | 229 | void Display::home(){ |
jah128 | 0:8a5497a2e366 | 230 | c_row = 0; |
jah128 | 0:8a5497a2e366 | 231 | c_column = 0; |
jah128 | 0:8a5497a2e366 | 232 | i2c_message(0x02); |
jah128 | 0:8a5497a2e366 | 233 | } |
jah128 | 0:8a5497a2e366 | 234 | |
jah128 | 0:8a5497a2e366 | 235 | void Display::debug_page(char * message, char length){ |
jah128 | 0:8a5497a2e366 | 236 | p_row=c_row; |
jah128 | 0:8a5497a2e366 | 237 | p_column=c_column; |
jah128 | 0:8a5497a2e366 | 238 | i2c_message(0x01); |
jah128 | 0:8a5497a2e366 | 239 | home(); |
jah128 | 0:8a5497a2e366 | 240 | char multipage_mode = 0; |
jah128 | 0:8a5497a2e366 | 241 | char line_1[18]; |
jah128 | 0:8a5497a2e366 | 242 | char line_2[18]; |
jah128 | 0:8a5497a2e366 | 243 | line_1[0]=0x40; |
jah128 | 0:8a5497a2e366 | 244 | line_2[0]=0x40; |
jah128 | 0:8a5497a2e366 | 245 | if(length > 16){ |
jah128 | 0:8a5497a2e366 | 246 | strncpy(line_1+1, message, 16); |
jah128 | 0:8a5497a2e366 | 247 | char f_length = length - 16; |
jah128 | 0:8a5497a2e366 | 248 | if(f_length > 16) { |
jah128 | 0:8a5497a2e366 | 249 | f_length = 16; |
jah128 | 0:8a5497a2e366 | 250 | multipage_mode = 1; |
jah128 | 0:8a5497a2e366 | 251 | } |
jah128 | 0:8a5497a2e366 | 252 | strncpy(line_2+1, message+16, f_length); |
jah128 | 0:8a5497a2e366 | 253 | line_1[17]=0; |
jah128 | 0:8a5497a2e366 | 254 | line_2[f_length+1]=0; |
jah128 | 0:8a5497a2e366 | 255 | _i2c.write(LCD_ADDRESS,line_1,17); |
jah128 | 0:8a5497a2e366 | 256 | set_position(1,0); |
jah128 | 0:8a5497a2e366 | 257 | _i2c.write(LCD_ADDRESS,line_2,f_length+1); |
jah128 | 0:8a5497a2e366 | 258 | } else { |
jah128 | 0:8a5497a2e366 | 259 | strncpy(line_1+1, message, length); |
jah128 | 0:8a5497a2e366 | 260 | _i2c.write(LCD_ADDRESS,line_1,length+1); |
jah128 | 0:8a5497a2e366 | 261 | } |
jah128 | 0:8a5497a2e366 | 262 | if(multipage_mode == 1){ |
jah128 | 0:8a5497a2e366 | 263 | strncpy(multipage, message + 32, length - 32); |
jah128 | 0:8a5497a2e366 | 264 | multipage_length = length - 32; |
jah128 | 0:8a5497a2e366 | 265 | debug_timeout.attach(this,&Display::IF_debug_multipage,PAGE_TIME); |
jah128 | 0:8a5497a2e366 | 266 | } else debug_timeout.attach(this,&Display::IF_restore_page,CLEAR_TIME); |
jah128 | 0:8a5497a2e366 | 267 | } |
jah128 | 0:8a5497a2e366 | 268 | |
jah128 | 0:8a5497a2e366 | 269 | void Display::IF_restore_page(){ |
jah128 | 0:8a5497a2e366 | 270 | i2c_message(0x01); |
jah128 | 0:8a5497a2e366 | 271 | home(); |
jah128 | 0:8a5497a2e366 | 272 | char line_1[17]; |
jah128 | 0:8a5497a2e366 | 273 | char line_2[17]; |
jah128 | 0:8a5497a2e366 | 274 | line_1[0]=0x40; |
jah128 | 0:8a5497a2e366 | 275 | line_2[0]=0x40; |
jah128 | 0:8a5497a2e366 | 276 | strncpy(line_1+1, preserve_line_1, 16); |
jah128 | 0:8a5497a2e366 | 277 | strncpy(line_2+1, preserve_line_2, 16); |
jah128 | 0:8a5497a2e366 | 278 | _i2c.write(LCD_ADDRESS,line_1,17); |
jah128 | 0:8a5497a2e366 | 279 | set_position(1,0); |
jah128 | 0:8a5497a2e366 | 280 | _i2c.write(LCD_ADDRESS,line_2,17); |
jah128 | 0:8a5497a2e366 | 281 | set_position(p_row,p_column); |
jah128 | 0:8a5497a2e366 | 282 | } |
jah128 | 0:8a5497a2e366 | 283 | |
jah128 | 0:8a5497a2e366 | 284 | void Display::IF_debug_multipage(){ |
jah128 | 0:8a5497a2e366 | 285 | i2c_message(0x01); |
jah128 | 0:8a5497a2e366 | 286 | home(); |
jah128 | 0:8a5497a2e366 | 287 | char multipage_mode = 0; |
jah128 | 0:8a5497a2e366 | 288 | char line_1[18]; |
jah128 | 0:8a5497a2e366 | 289 | char line_2[18]; |
jah128 | 0:8a5497a2e366 | 290 | line_1[0]=0x40; |
jah128 | 0:8a5497a2e366 | 291 | line_2[0]=0x40; |
jah128 | 0:8a5497a2e366 | 292 | if(multipage_length > 16){ |
jah128 | 0:8a5497a2e366 | 293 | strncpy(line_1+1, multipage, 16); |
jah128 | 0:8a5497a2e366 | 294 | char f_length = multipage_length - 16; |
jah128 | 0:8a5497a2e366 | 295 | if(f_length > 16) { |
jah128 | 0:8a5497a2e366 | 296 | f_length = 16; |
jah128 | 0:8a5497a2e366 | 297 | multipage_mode = 1; |
jah128 | 0:8a5497a2e366 | 298 | } |
jah128 | 0:8a5497a2e366 | 299 | strncpy(line_2+1, multipage+16, f_length); |
jah128 | 0:8a5497a2e366 | 300 | line_1[17]=0; |
jah128 | 0:8a5497a2e366 | 301 | line_2[f_length+1]=0; |
jah128 | 0:8a5497a2e366 | 302 | _i2c.write(LCD_ADDRESS,line_1,17); |
jah128 | 0:8a5497a2e366 | 303 | set_position(1,0); |
jah128 | 0:8a5497a2e366 | 304 | _i2c.write(LCD_ADDRESS,line_2,f_length+1); |
jah128 | 0:8a5497a2e366 | 305 | } else { |
jah128 | 0:8a5497a2e366 | 306 | strncpy(line_1+1, multipage, multipage_length); |
jah128 | 0:8a5497a2e366 | 307 | _i2c.write(LCD_ADDRESS,line_1,multipage_length+1); |
jah128 | 0:8a5497a2e366 | 308 | } |
jah128 | 0:8a5497a2e366 | 309 | if(multipage_mode == 1){ |
jah128 | 0:8a5497a2e366 | 310 | char temp[200]; |
jah128 | 0:8a5497a2e366 | 311 | strncpy(temp, multipage + 32, multipage_length - 32); |
jah128 | 0:8a5497a2e366 | 312 | multipage_length -= 32; |
jah128 | 0:8a5497a2e366 | 313 | strncpy(multipage, temp, multipage_length); |
jah128 | 0:8a5497a2e366 | 314 | debug_timeout.attach(this,&Display::IF_debug_multipage,PAGE_TIME); |
jah128 | 0:8a5497a2e366 | 315 | }else debug_timeout.attach(this,&Display::IF_restore_page,CLEAR_TIME); |
jah128 | 0:8a5497a2e366 | 316 | } |
jah128 | 0:8a5497a2e366 | 317 | |
jah128 | 0:8a5497a2e366 | 318 | void Display::_set_display(){ |
jah128 | 0:8a5497a2e366 | 319 | char mode = 8; |
jah128 | 0:8a5497a2e366 | 320 | if(display_on>0) mode += 4; |
jah128 | 0:8a5497a2e366 | 321 | if(cursor_on>0) mode += 2; |
jah128 | 0:8a5497a2e366 | 322 | if(blink_on>0) mode ++; |
jah128 | 0:8a5497a2e366 | 323 | i2c_message(mode); |
jah128 | 0:8a5497a2e366 | 324 | } |
jah128 | 0:8a5497a2e366 | 325 | |
jah128 | 0:8a5497a2e366 | 326 | |
jah128 | 0:8a5497a2e366 | 327 | int Display::_putc (int c) { |
jah128 | 0:8a5497a2e366 | 328 | putc(c); |
jah128 | 0:8a5497a2e366 | 329 | return(c); |
jah128 | 0:8a5497a2e366 | 330 | } |
jah128 | 0:8a5497a2e366 | 331 | |
jah128 | 0:8a5497a2e366 | 332 | int Display::_getc (void) { |
jah128 | 0:8a5497a2e366 | 333 | char r = 0; |
jah128 | 0:8a5497a2e366 | 334 | return(r); |
jah128 | 0:8a5497a2e366 | 335 | } |