This sketch demonstrates the use of the autoscroll() and noAutoscroll() functions to make new text scroll or not.

Dependencies:   Hotboards_SpiLcd mbed

Committer:
Hotboards
Date:
Tue Feb 02 21:15:21 2016 +0000
Revision:
0:272f1d80b7d0
Firts release: Hotboards_SpiLcd_AutoScroll

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Hotboards 0:272f1d80b7d0 1 /*
Hotboards 0:272f1d80b7d0 2 LiquidCrystal Library - Autoscroll
Hotboards 0:272f1d80b7d0 3 Demonstrates the use a 16x2 LCD display. The Hotboards_SpiLcd
Hotboards 0:272f1d80b7d0 4 library works with all LCD displays that are compatible with the
Hotboards 0:272f1d80b7d0 5 ST7032 driver presented on Spi Lcd board (http://www.hotboards.org).
Hotboards 0:272f1d80b7d0 6 This sketch demonstrates the use of the autoscroll()
Hotboards 0:272f1d80b7d0 7 and noAutoscroll() functions to make new text scroll or not.
Hotboards 0:272f1d80b7d0 8 The circuit:
Hotboards 0:272f1d80b7d0 9 The circuit:
Hotboards 0:272f1d80b7d0 10 * BKL --> GND
Hotboards 0:272f1d80b7d0 11 * VDD --> 3.3v
Hotboards 0:272f1d80b7d0 12 * GND --> GND
Hotboards 0:272f1d80b7d0 13 * SCK --> PA_5
Hotboards 0:272f1d80b7d0 14 * SI --> PA_6
Hotboards 0:272f1d80b7d0 15 * CS --> PB_15
Hotboards 0:272f1d80b7d0 16 * RS --> PB_14
Hotboards 0:272f1d80b7d0 17 * RST --> PB_13
Hotboards 0:272f1d80b7d0 18
Hotboards 0:272f1d80b7d0 19 Library and example ported by Diego from Hotboards and originally created by
Hotboards 0:272f1d80b7d0 20 David A. Mellis
Hotboards 0:272f1d80b7d0 21 library modified 5 Jul 2009
Hotboards 0:272f1d80b7d0 22 by Limor Fried (http://www.ladyada.net)
Hotboards 0:272f1d80b7d0 23 example added 9 Jul 2009
Hotboards 0:272f1d80b7d0 24 by Tom Igoe
Hotboards 0:272f1d80b7d0 25 modified 22 Nov 2010
Hotboards 0:272f1d80b7d0 26 by Tom Igoe
Hotboards 0:272f1d80b7d0 27 This example code is in the public domain.
Hotboards 0:272f1d80b7d0 28 */
Hotboards 0:272f1d80b7d0 29
Hotboards 0:272f1d80b7d0 30 #include "mbed.h"
Hotboards 0:272f1d80b7d0 31 #include <Hotboards_SpiLcd.h>
Hotboards 0:272f1d80b7d0 32
Hotboards 0:272f1d80b7d0 33 /* initialize an instance of SPI bus,setting the SPI pins*/
Hotboards 0:272f1d80b7d0 34 SPI device(PA_7,PA_6,PA_5); /* SO, SI, SCK*/
Hotboards 0:272f1d80b7d0 35 /* initialize the library with the numbers of the interface pins*/
Hotboards 0:272f1d80b7d0 36 Hotboards_SpiLcd display( device, PB_15, PB_14, PB_13 ); /* SPI, CS, RS, RST */
Hotboards 0:272f1d80b7d0 37
Hotboards 0:272f1d80b7d0 38 int main()
Hotboards 0:272f1d80b7d0 39 {
Hotboards 0:272f1d80b7d0 40 /* set the spi frequency to 5MHz*/
Hotboards 0:272f1d80b7d0 41 device.frequency(5000000);
Hotboards 0:272f1d80b7d0 42 /* initialize internal lcd controller:*/
Hotboards 0:272f1d80b7d0 43 display.init();
Hotboards 0:272f1d80b7d0 44
Hotboards 0:272f1d80b7d0 45 while(1)
Hotboards 0:272f1d80b7d0 46 {
Hotboards 0:272f1d80b7d0 47 // set the cursor to (0,0):
Hotboards 0:272f1d80b7d0 48 display.setCursor(0, 0);
Hotboards 0:272f1d80b7d0 49 // print from 0 to 9:
Hotboards 0:272f1d80b7d0 50 for(int thisChar = 0; thisChar < 10; thisChar++)
Hotboards 0:272f1d80b7d0 51 {
Hotboards 0:272f1d80b7d0 52 display.printf("%d",thisChar);
Hotboards 0:272f1d80b7d0 53 wait(0.5);
Hotboards 0:272f1d80b7d0 54 }
Hotboards 0:272f1d80b7d0 55
Hotboards 0:272f1d80b7d0 56 // set the cursor to (16,1):
Hotboards 0:272f1d80b7d0 57 display.setCursor(16, 1);
Hotboards 0:272f1d80b7d0 58 // set the display to automatically scroll:
Hotboards 0:272f1d80b7d0 59 display.autoscroll();
Hotboards 0:272f1d80b7d0 60 // print from 0 to 9:
Hotboards 0:272f1d80b7d0 61 for (int thisChar = 0; thisChar < 10; thisChar++)
Hotboards 0:272f1d80b7d0 62 {
Hotboards 0:272f1d80b7d0 63 display.printf("%d",thisChar);
Hotboards 0:272f1d80b7d0 64 wait(0.5);
Hotboards 0:272f1d80b7d0 65 }
Hotboards 0:272f1d80b7d0 66 // turn off automatic scrolling
Hotboards 0:272f1d80b7d0 67 display.noAutoscroll();
Hotboards 0:272f1d80b7d0 68
Hotboards 0:272f1d80b7d0 69 // clear screen for the next loop:
Hotboards 0:272f1d80b7d0 70 display.clear();
Hotboards 0:272f1d80b7d0 71 // reset the display shift for the next loop
Hotboards 0:272f1d80b7d0 72 display.home();
Hotboards 0:272f1d80b7d0 73 }
Hotboards 0:272f1d80b7d0 74 }
Hotboards 0:272f1d80b7d0 75