02texttest.ino
1 // Text mode demo 2 // With apologies to Stanley Kubrick et al 3 #include <Adafruit_dvhstx.h> 4 5 // If your board definition has PIN_CKP and related defines, 6 // DVHSTX_PINOUT_DEFAULT is available 7 DVHSTXText3 display(DVHSTX_PINOUT_DEFAULT); 8 // If you get the message "error: 'DVHSTX_PINOUT_DEFAULTx' was not declared" 9 // then you need to give the pins numbers explicitly, like the example below. 10 // The order is: {CKP, D0P, D1P, D2P}. 11 // 12 // DVHSTXText3 display({12, 14, 16, 18}); 13 14 void setup() { 15 Serial.begin(115200); 16 if (!display.begin()) { // Blink LED if insufficient RAM 17 pinMode(LED_BUILTIN, OUTPUT); 18 for (;;) 19 digitalWrite(LED_BUILTIN, (millis() / 500) & 1); 20 } 21 display.show_cursor(); 22 display.print("display initialized\n\n\n\n\n"); 23 } 24 25 const char message[] = "All work and no play makes Jack a dull boy\n"; 26 27 int cx, cy, i; 28 void loop() { 29 const static TextColor colors[] = { 30 TextColor::TEXT_RED, TextColor::TEXT_GREEN, TextColor::TEXT_BLUE, 31 TextColor::TEXT_YELLOW, TextColor::TEXT_MAGENTA, TextColor::TEXT_CYAN, 32 TextColor::TEXT_WHITE, 33 }; 34 35 if (i == 0) { 36 auto attr = colors[random(std::size(colors))]; 37 for (int j = random(91 - sizeof(message)); j; j--) 38 display.write(' '); 39 display.set_color(attr); 40 } 41 42 int ch = message[i++]; 43 if (ch) { 44 display.write(ch); 45 } else 46 i = 0; 47 48 sleep_ms(32 + random(32)); 49 }