Andriy Makukha / Mbed 2 deprecated football_project_wo_output

Dependencies:   mbed

Fork of football_project by MZJ

Committer:
andriym
Date:
Mon May 09 01:08:01 2016 +0000
Revision:
78:43a6b54f0372
Changed radio configs, Player tracking table, Switch team button, Output class (for different displays and Serial), different boards support.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andriym 78:43a6b54f0372 1
andriym 78:43a6b54f0372 2 #include "mbed.h"
andriym 78:43a6b54f0372 3 #include "ssd1306.h"
andriym 78:43a6b54f0372 4
andriym 78:43a6b54f0372 5 #include <stdarg.h>
andriym 78:43a6b54f0372 6
andriym 78:43a6b54f0372 7 SSD1306::SSD1306(PinName cs, PinName rs, PinName dc, PinName clk, PinName data)
andriym 78:43a6b54f0372 8 : _spi(data, NC, clk),
andriym 78:43a6b54f0372 9 _cs(cs),
andriym 78:43a6b54f0372 10 _reset(rs),
andriym 78:43a6b54f0372 11 _dc(dc),
andriym 78:43a6b54f0372 12 _cursor_x(0),
andriym 78:43a6b54f0372 13 _cursor_y(0)
andriym 78:43a6b54f0372 14 {
andriym 78:43a6b54f0372 15 }
andriym 78:43a6b54f0372 16
andriym 78:43a6b54f0372 17 void SSD1306::off()
andriym 78:43a6b54f0372 18 {
andriym 78:43a6b54f0372 19 _send_command(0xAE);
andriym 78:43a6b54f0372 20 }
andriym 78:43a6b54f0372 21
andriym 78:43a6b54f0372 22 void SSD1306::on()
andriym 78:43a6b54f0372 23 {
andriym 78:43a6b54f0372 24 _send_command(0xAF);
andriym 78:43a6b54f0372 25 }
andriym 78:43a6b54f0372 26
andriym 78:43a6b54f0372 27 void SSD1306::sleep()
andriym 78:43a6b54f0372 28 {
andriym 78:43a6b54f0372 29 _send_command(0xAE);
andriym 78:43a6b54f0372 30 }
andriym 78:43a6b54f0372 31
andriym 78:43a6b54f0372 32 void SSD1306::wake()
andriym 78:43a6b54f0372 33 {
andriym 78:43a6b54f0372 34 _send_command(0xAF);
andriym 78:43a6b54f0372 35 }
andriym 78:43a6b54f0372 36
andriym 78:43a6b54f0372 37 void SSD1306::set_inverse(unsigned char value)
andriym 78:43a6b54f0372 38 {
andriym 78:43a6b54f0372 39 _send_command(value ? 0xA7 : 0xA6);
andriym 78:43a6b54f0372 40 }
andriym 78:43a6b54f0372 41
andriym 78:43a6b54f0372 42 void SSD1306::set_display_offset(unsigned char value)
andriym 78:43a6b54f0372 43 {
andriym 78:43a6b54f0372 44 _send_command(0xD3);
andriym 78:43a6b54f0372 45 _send_command(value & 0x3F);
andriym 78:43a6b54f0372 46 }
andriym 78:43a6b54f0372 47
andriym 78:43a6b54f0372 48 void SSD1306::set_contrast(unsigned char value)
andriym 78:43a6b54f0372 49 {
andriym 78:43a6b54f0372 50 _send_command(0x81);
andriym 78:43a6b54f0372 51 _send_command(value);
andriym 78:43a6b54f0372 52 }
andriym 78:43a6b54f0372 53
andriym 78:43a6b54f0372 54 void SSD1306::set_display_start_line(unsigned char value)
andriym 78:43a6b54f0372 55 {
andriym 78:43a6b54f0372 56 _send_command(0x40 | value);
andriym 78:43a6b54f0372 57 }
andriym 78:43a6b54f0372 58
andriym 78:43a6b54f0372 59 void SSD1306::set_segment_remap(unsigned char value)
andriym 78:43a6b54f0372 60 {
andriym 78:43a6b54f0372 61 _send_command(value ? 0xA1 : 0xA0);
andriym 78:43a6b54f0372 62 }
andriym 78:43a6b54f0372 63
andriym 78:43a6b54f0372 64 void SSD1306::set_multiplex_ratio(unsigned char value)
andriym 78:43a6b54f0372 65 {
andriym 78:43a6b54f0372 66 _send_command(0xA8);
andriym 78:43a6b54f0372 67 _send_command(value & 0x3F);
andriym 78:43a6b54f0372 68 }
andriym 78:43a6b54f0372 69
andriym 78:43a6b54f0372 70 void SSD1306::set_com_output_scan_direction(unsigned char value)
andriym 78:43a6b54f0372 71 {
andriym 78:43a6b54f0372 72 _send_command(value ? 0xC8 : 0xC0);
andriym 78:43a6b54f0372 73 }
andriym 78:43a6b54f0372 74
andriym 78:43a6b54f0372 75 void SSD1306::set_com_pins_hardware_configuration(unsigned char sequential, unsigned char lr_remap)
andriym 78:43a6b54f0372 76 {
andriym 78:43a6b54f0372 77 _send_command(0xDA);
andriym 78:43a6b54f0372 78 _send_command(0x02 | ((sequential & 1) << 4) | ((lr_remap & 1) << 5));
andriym 78:43a6b54f0372 79 }
andriym 78:43a6b54f0372 80
andriym 78:43a6b54f0372 81 void SSD1306::start_horizontal_scroll(unsigned char direction, unsigned char start, unsigned char end, unsigned char interval)
andriym 78:43a6b54f0372 82 {
andriym 78:43a6b54f0372 83 _send_command(direction ? 0x27 : 0x26);
andriym 78:43a6b54f0372 84 _send_command(0x00);
andriym 78:43a6b54f0372 85 _send_command(start & 0x07);
andriym 78:43a6b54f0372 86 switch (interval) {
andriym 78:43a6b54f0372 87 case 2: _send_command(0x07); break; // 111b
andriym 78:43a6b54f0372 88 case 3: _send_command(0x04); break; // 100b
andriym 78:43a6b54f0372 89 case 4: _send_command(0x05); break; // 101b
andriym 78:43a6b54f0372 90 case 5: _send_command(0x00); break; // 000b
andriym 78:43a6b54f0372 91 case 25: _send_command(0x06); break; // 110b
andriym 78:43a6b54f0372 92 case 64: _send_command(0x01); break; // 001b
andriym 78:43a6b54f0372 93 case 128: _send_command(0x02); break; // 010b
andriym 78:43a6b54f0372 94 case 256: _send_command(0x03); break; // 011b
andriym 78:43a6b54f0372 95 default:
andriym 78:43a6b54f0372 96 // default to 2 frame interval
andriym 78:43a6b54f0372 97 _send_command(0x07); break;
andriym 78:43a6b54f0372 98 }
andriym 78:43a6b54f0372 99 _send_command(end & 0x07);
andriym 78:43a6b54f0372 100 _send_command(0x00);
andriym 78:43a6b54f0372 101 _send_command(0xFF);
andriym 78:43a6b54f0372 102
andriym 78:43a6b54f0372 103 // activate scroll
andriym 78:43a6b54f0372 104 _send_command(0x2F);
andriym 78:43a6b54f0372 105 }
andriym 78:43a6b54f0372 106
andriym 78:43a6b54f0372 107 void SSD1306::start_vertical_and_horizontal_scroll(unsigned char direction, unsigned char start, unsigned char end, unsigned char interval, unsigned char vertical_offset)
andriym 78:43a6b54f0372 108 {
andriym 78:43a6b54f0372 109 _send_command(direction ? 0x2A : 0x29);
andriym 78:43a6b54f0372 110 _send_command(0x00);
andriym 78:43a6b54f0372 111 _send_command(start & 0x07);
andriym 78:43a6b54f0372 112 switch (interval) {
andriym 78:43a6b54f0372 113 case 2: _send_command(0x07); break; // 111b
andriym 78:43a6b54f0372 114 case 3: _send_command(0x04); break; // 100b
andriym 78:43a6b54f0372 115 case 4: _send_command(0x05); break; // 101b
andriym 78:43a6b54f0372 116 case 5: _send_command(0x00); break; // 000b
andriym 78:43a6b54f0372 117 case 25: _send_command(0x06); break; // 110b
andriym 78:43a6b54f0372 118 case 64: _send_command(0x01); break; // 001b
andriym 78:43a6b54f0372 119 case 128: _send_command(0x02); break; // 010b
andriym 78:43a6b54f0372 120 case 256: _send_command(0x03); break; // 011b
andriym 78:43a6b54f0372 121 default:
andriym 78:43a6b54f0372 122 // default to 2 frame interval
andriym 78:43a6b54f0372 123 _send_command(0x07); break;
andriym 78:43a6b54f0372 124 }
andriym 78:43a6b54f0372 125 _send_command(end & 0x07);
andriym 78:43a6b54f0372 126 _send_command(vertical_offset);
andriym 78:43a6b54f0372 127
andriym 78:43a6b54f0372 128 // activate scroll
andriym 78:43a6b54f0372 129 _send_command(0x2F);
andriym 78:43a6b54f0372 130 }
andriym 78:43a6b54f0372 131
andriym 78:43a6b54f0372 132 void SSD1306::stop_scroll()
andriym 78:43a6b54f0372 133 {
andriym 78:43a6b54f0372 134 // all scroll configurations are removed from the display when executing this command.
andriym 78:43a6b54f0372 135 _send_command(0x2E);
andriym 78:43a6b54f0372 136 }
andriym 78:43a6b54f0372 137
andriym 78:43a6b54f0372 138 void SSD1306::pam_set_start_address(unsigned char address)
andriym 78:43a6b54f0372 139 {
andriym 78:43a6b54f0372 140 // "Set Lower Column Start Address for Page Addressing Mode"
andriym 78:43a6b54f0372 141 _send_command(address & 0x0F);
andriym 78:43a6b54f0372 142
andriym 78:43a6b54f0372 143 // "Set Higher Column Start Address for Page Addressing Mode"
andriym 78:43a6b54f0372 144 _send_command((address << 4) & 0x0F);
andriym 78:43a6b54f0372 145 }
andriym 78:43a6b54f0372 146
andriym 78:43a6b54f0372 147 void SSD1306::set_memory_addressing_mode(unsigned char mode)
andriym 78:43a6b54f0372 148 {
andriym 78:43a6b54f0372 149 _send_command(0x20);
andriym 78:43a6b54f0372 150 _send_command(mode & 0x3);
andriym 78:43a6b54f0372 151 }
andriym 78:43a6b54f0372 152
andriym 78:43a6b54f0372 153 void SSD1306::hv_set_column_address(unsigned char start, unsigned char end)
andriym 78:43a6b54f0372 154 {
andriym 78:43a6b54f0372 155 _send_command(0x21);
andriym 78:43a6b54f0372 156 _send_command(start & 0x7F);
andriym 78:43a6b54f0372 157 _send_command(end & 0x7F);
andriym 78:43a6b54f0372 158 }
andriym 78:43a6b54f0372 159
andriym 78:43a6b54f0372 160 void SSD1306::hv_set_page_address(unsigned char start, unsigned char end)
andriym 78:43a6b54f0372 161 {
andriym 78:43a6b54f0372 162 _send_command(0x22);
andriym 78:43a6b54f0372 163 _send_command(start & 0x07);
andriym 78:43a6b54f0372 164 _send_command(end & 0x07);
andriym 78:43a6b54f0372 165 }
andriym 78:43a6b54f0372 166
andriym 78:43a6b54f0372 167 void SSD1306::pam_set_page_start(unsigned char address)
andriym 78:43a6b54f0372 168 {
andriym 78:43a6b54f0372 169 _send_command(0xB0 | (address & 0x07));
andriym 78:43a6b54f0372 170 }
andriym 78:43a6b54f0372 171
andriym 78:43a6b54f0372 172 void SSD1306::set_display_clock_ratio_and_frequency(unsigned char ratio, unsigned char frequency)
andriym 78:43a6b54f0372 173 {
andriym 78:43a6b54f0372 174 _send_command(0xD5);
andriym 78:43a6b54f0372 175 _send_command((ratio & 0x0F) | ((frequency & 0x0F) << 4));
andriym 78:43a6b54f0372 176 }
andriym 78:43a6b54f0372 177
andriym 78:43a6b54f0372 178 void SSD1306::set_precharge_period(unsigned char phase1, unsigned char phase2)
andriym 78:43a6b54f0372 179 {
andriym 78:43a6b54f0372 180 _send_command(0xD9);
andriym 78:43a6b54f0372 181 _send_command((phase1 & 0x0F) | ((phase2 & 0x0F ) << 4));
andriym 78:43a6b54f0372 182 }
andriym 78:43a6b54f0372 183
andriym 78:43a6b54f0372 184 void SSD1306::set_vcomh_deselect_level(unsigned char level)
andriym 78:43a6b54f0372 185 {
andriym 78:43a6b54f0372 186 _send_command(0xDB);
andriym 78:43a6b54f0372 187 _send_command((level & 0x03) << 4);
andriym 78:43a6b54f0372 188 }
andriym 78:43a6b54f0372 189
andriym 78:43a6b54f0372 190 void SSD1306::nop()
andriym 78:43a6b54f0372 191 {
andriym 78:43a6b54f0372 192 _send_command(0xE3);
andriym 78:43a6b54f0372 193 }
andriym 78:43a6b54f0372 194
andriym 78:43a6b54f0372 195 void SSD1306::set_charge_pump_enable(unsigned char enable)
andriym 78:43a6b54f0372 196 {
andriym 78:43a6b54f0372 197 _send_command(0x8D);
andriym 78:43a6b54f0372 198 _send_command(enable ? 0x14 : 0x10);
andriym 78:43a6b54f0372 199 }
andriym 78:43a6b54f0372 200
andriym 78:43a6b54f0372 201 void SSD1306::initialise()
andriym 78:43a6b54f0372 202 {
andriym 78:43a6b54f0372 203 // Init
andriym 78:43a6b54f0372 204 _reset = 1;
andriym 78:43a6b54f0372 205 wait(0.01);
andriym 78:43a6b54f0372 206 _reset = 0;
andriym 78:43a6b54f0372 207 wait(0.10);
andriym 78:43a6b54f0372 208 _reset = 1;
andriym 78:43a6b54f0372 209
andriym 78:43a6b54f0372 210 off();
andriym 78:43a6b54f0372 211
andriym 78:43a6b54f0372 212 set_display_clock_ratio_and_frequency(0, 8);
andriym 78:43a6b54f0372 213 set_multiplex_ratio(0x3F); // 1/64 duty
andriym 78:43a6b54f0372 214 set_precharge_period(0xF, 0x01);
andriym 78:43a6b54f0372 215 set_display_offset(0);
andriym 78:43a6b54f0372 216 set_display_start_line(0);
andriym 78:43a6b54f0372 217 set_charge_pump_enable(1);
andriym 78:43a6b54f0372 218 set_memory_addressing_mode(0); // horizontal addressing mode; across then down
andriym 78:43a6b54f0372 219 set_segment_remap(1);
andriym 78:43a6b54f0372 220 set_com_output_scan_direction(1);
andriym 78:43a6b54f0372 221 set_com_pins_hardware_configuration(1, 0);
andriym 78:43a6b54f0372 222 set_contrast(0xFF);
andriym 78:43a6b54f0372 223 set_vcomh_deselect_level(1);
andriym 78:43a6b54f0372 224
andriym 78:43a6b54f0372 225 wake();
andriym 78:43a6b54f0372 226 set_inverse(0);
andriym 78:43a6b54f0372 227
andriym 78:43a6b54f0372 228 hv_set_column_address(0, 127);
andriym 78:43a6b54f0372 229 hv_set_page_address(0, 7);
andriym 78:43a6b54f0372 230
andriym 78:43a6b54f0372 231 pam_set_start_address(0);
andriym 78:43a6b54f0372 232 pam_set_page_start(0);
andriym 78:43a6b54f0372 233
andriym 78:43a6b54f0372 234 // set_precharge_period(2, 2);
andriym 78:43a6b54f0372 235 }
andriym 78:43a6b54f0372 236
andriym 78:43a6b54f0372 237 void SSD1306::update()
andriym 78:43a6b54f0372 238 {
andriym 78:43a6b54f0372 239 hv_set_column_address(0, 127);
andriym 78:43a6b54f0372 240 hv_set_page_address(0, 7);
andriym 78:43a6b54f0372 241
andriym 78:43a6b54f0372 242 for (int i = 0; i < 1024; i++)
andriym 78:43a6b54f0372 243 _send_data(_screen[i]);
andriym 78:43a6b54f0372 244 }
andriym 78:43a6b54f0372 245
andriym 78:43a6b54f0372 246 void SSD1306::set_pixel(int x, int y)
andriym 78:43a6b54f0372 247 {
andriym 78:43a6b54f0372 248 if (x >= SSD1306_LCDWIDTH || y >= SSD1306_LCDHEIGHT) return;
andriym 78:43a6b54f0372 249
andriym 78:43a6b54f0372 250 _screen[x + (y / 8) * 128] |= 1 << (y % 8);
andriym 78:43a6b54f0372 251 }
andriym 78:43a6b54f0372 252
andriym 78:43a6b54f0372 253 void SSD1306::clear_pixel(int x, int y)
andriym 78:43a6b54f0372 254 {
andriym 78:43a6b54f0372 255 if (x >= SSD1306_LCDWIDTH || y >= SSD1306_LCDHEIGHT) return;
andriym 78:43a6b54f0372 256
andriym 78:43a6b54f0372 257 _screen[x + (y / 8) * 128] &= ~(1 << (y % 8));
andriym 78:43a6b54f0372 258 }
andriym 78:43a6b54f0372 259
andriym 78:43a6b54f0372 260 void SSD1306::line(int x0, int y0, int x1, int y1) {
andriym 78:43a6b54f0372 261 int steep = abs(y1 - y0) > abs(x1 - x0);
andriym 78:43a6b54f0372 262 int t;
andriym 78:43a6b54f0372 263
andriym 78:43a6b54f0372 264 if (steep) {
andriym 78:43a6b54f0372 265 t = x0; x0 = y0; y0 = t;
andriym 78:43a6b54f0372 266 t = x1; x1 = y1; y1 = t;
andriym 78:43a6b54f0372 267 }
andriym 78:43a6b54f0372 268
andriym 78:43a6b54f0372 269 if (x0 > x1) {
andriym 78:43a6b54f0372 270 t = x0; x0 = x1; x1 = t;
andriym 78:43a6b54f0372 271 t = y0; y0 = y1; y1 = t;
andriym 78:43a6b54f0372 272 }
andriym 78:43a6b54f0372 273
andriym 78:43a6b54f0372 274 int dx, dy;
andriym 78:43a6b54f0372 275
andriym 78:43a6b54f0372 276 dx = x1 - x0;
andriym 78:43a6b54f0372 277 dy = abs(y1 - y0);
andriym 78:43a6b54f0372 278
andriym 78:43a6b54f0372 279 int err = dx / 2;
andriym 78:43a6b54f0372 280 int ystep;
andriym 78:43a6b54f0372 281
andriym 78:43a6b54f0372 282 if (y0 < y1) {
andriym 78:43a6b54f0372 283 ystep = 1;
andriym 78:43a6b54f0372 284 } else {
andriym 78:43a6b54f0372 285 ystep = -1;}
andriym 78:43a6b54f0372 286
andriym 78:43a6b54f0372 287 for (; x0<x1; x0++) {
andriym 78:43a6b54f0372 288 if (steep) {
andriym 78:43a6b54f0372 289 set_pixel(y0, x0);
andriym 78:43a6b54f0372 290 } else {
andriym 78:43a6b54f0372 291 set_pixel(x0, y0);
andriym 78:43a6b54f0372 292 }
andriym 78:43a6b54f0372 293 err -= dy;
andriym 78:43a6b54f0372 294 if (err < 0) {
andriym 78:43a6b54f0372 295 y0 += ystep;
andriym 78:43a6b54f0372 296 err += dx;
andriym 78:43a6b54f0372 297 }
andriym 78:43a6b54f0372 298 }
andriym 78:43a6b54f0372 299 }
andriym 78:43a6b54f0372 300
andriym 78:43a6b54f0372 301 void SSD1306::set_font(unsigned char *font, unsigned int width)
andriym 78:43a6b54f0372 302 {
andriym 78:43a6b54f0372 303 _console_font_data = font;
andriym 78:43a6b54f0372 304 _console_font_width = width;
andriym 78:43a6b54f0372 305 }
andriym 78:43a6b54f0372 306
andriym 78:43a6b54f0372 307 void SSD1306::set_double_height_text(unsigned int double_height)
andriym 78:43a6b54f0372 308 {
andriym 78:43a6b54f0372 309 _double_height_text = double_height;
andriym 78:43a6b54f0372 310 }
andriym 78:43a6b54f0372 311
andriym 78:43a6b54f0372 312 void SSD1306::putc(unsigned char c)
andriym 78:43a6b54f0372 313 {
andriym 78:43a6b54f0372 314 while (_cursor_x >= (128 / _console_font_width))
andriym 78:43a6b54f0372 315 {
andriym 78:43a6b54f0372 316 _cursor_x -= (128 / _console_font_width);
andriym 78:43a6b54f0372 317 _cursor_y++;
andriym 78:43a6b54f0372 318 }
andriym 78:43a6b54f0372 319
andriym 78:43a6b54f0372 320 while (_cursor_y > 7)
andriym 78:43a6b54f0372 321 {
andriym 78:43a6b54f0372 322 scroll_up();
andriym 78:43a6b54f0372 323 }
andriym 78:43a6b54f0372 324
andriym 78:43a6b54f0372 325 switch (c)
andriym 78:43a6b54f0372 326 {
andriym 78:43a6b54f0372 327 case '\n':
andriym 78:43a6b54f0372 328 _cursor_y++;
andriym 78:43a6b54f0372 329 break;
andriym 78:43a6b54f0372 330
andriym 78:43a6b54f0372 331 case '\r':
andriym 78:43a6b54f0372 332 _cursor_x = 0;
andriym 78:43a6b54f0372 333 break;
andriym 78:43a6b54f0372 334
andriym 78:43a6b54f0372 335 case '\t':
andriym 78:43a6b54f0372 336 _cursor_x = (_cursor_x + 4) % 4;
andriym 78:43a6b54f0372 337 break;
andriym 78:43a6b54f0372 338
andriym 78:43a6b54f0372 339 default:
andriym 78:43a6b54f0372 340 for (int b = 0; b < _console_font_width; b++)
andriym 78:43a6b54f0372 341 {
andriym 78:43a6b54f0372 342 _screen[_cursor_x * _console_font_width + _cursor_y * 128 + b] = _console_font_data[(c - FONT_START) * _console_font_width + b];
andriym 78:43a6b54f0372 343 }
andriym 78:43a6b54f0372 344
andriym 78:43a6b54f0372 345 _cursor_x++;
andriym 78:43a6b54f0372 346 }
andriym 78:43a6b54f0372 347 }
andriym 78:43a6b54f0372 348
andriym 78:43a6b54f0372 349 void SSD1306::scroll_up()
andriym 78:43a6b54f0372 350 {
andriym 78:43a6b54f0372 351 for (int y = 1; y <= 7; y++)
andriym 78:43a6b54f0372 352 {
andriym 78:43a6b54f0372 353 for (int x = 0; x < 128; x++)
andriym 78:43a6b54f0372 354 {
andriym 78:43a6b54f0372 355 _screen[x + 128 * (y - 1)] = _screen[x + 128 * y];
andriym 78:43a6b54f0372 356 }
andriym 78:43a6b54f0372 357 }
andriym 78:43a6b54f0372 358
andriym 78:43a6b54f0372 359 for (int x = 0; x < 128; x++)
andriym 78:43a6b54f0372 360 {
andriym 78:43a6b54f0372 361 _screen[x + 128 * 7] = 0;
andriym 78:43a6b54f0372 362 }
andriym 78:43a6b54f0372 363
andriym 78:43a6b54f0372 364 _cursor_y--;
andriym 78:43a6b54f0372 365 }
andriym 78:43a6b54f0372 366
andriym 78:43a6b54f0372 367 void SSD1306::printf(const char *format, ...)
andriym 78:43a6b54f0372 368 {
andriym 78:43a6b54f0372 369 static char buffer[128];
andriym 78:43a6b54f0372 370
andriym 78:43a6b54f0372 371 va_list args;
andriym 78:43a6b54f0372 372 va_start(args, format);
andriym 78:43a6b54f0372 373 vsprintf(buffer, format, args);
andriym 78:43a6b54f0372 374 va_end(args);
andriym 78:43a6b54f0372 375
andriym 78:43a6b54f0372 376 char *c = (char *)&buffer;
andriym 78:43a6b54f0372 377 while (*c != 0)
andriym 78:43a6b54f0372 378 {
andriym 78:43a6b54f0372 379 putc(*c++);
andriym 78:43a6b54f0372 380 }
andriym 78:43a6b54f0372 381 }
andriym 78:43a6b54f0372 382
andriym 78:43a6b54f0372 383 void SSD1306::clear()
andriym 78:43a6b54f0372 384 {
andriym 78:43a6b54f0372 385 for (int i = 0; i < 1024; i++)
andriym 78:43a6b54f0372 386 _screen[i] = 0;
andriym 78:43a6b54f0372 387
andriym 78:43a6b54f0372 388 _cursor_x = 0;
andriym 78:43a6b54f0372 389 _cursor_y = 0;
andriym 78:43a6b54f0372 390 }
andriym 78:43a6b54f0372 391
andriym 78:43a6b54f0372 392 void SSD1306::_send_command(unsigned char code)
andriym 78:43a6b54f0372 393 {
andriym 78:43a6b54f0372 394 _cs = 1;
andriym 78:43a6b54f0372 395 _dc = 0;
andriym 78:43a6b54f0372 396 _cs = 0;
andriym 78:43a6b54f0372 397 _spi.write(code);
andriym 78:43a6b54f0372 398 _cs = 1;
andriym 78:43a6b54f0372 399 }
andriym 78:43a6b54f0372 400
andriym 78:43a6b54f0372 401 void SSD1306::_send_data(unsigned char value)
andriym 78:43a6b54f0372 402 {
andriym 78:43a6b54f0372 403 _cs = 1;
andriym 78:43a6b54f0372 404 _dc = 1;
andriym 78:43a6b54f0372 405 _cs = 0;
andriym 78:43a6b54f0372 406 _spi.write(value);
andriym 78:43a6b54f0372 407 _cs = 1;
andriym 78:43a6b54f0372 408 }