A demo for using the Sharp LCD display component.
Dependencies: SharpLCD mbed-src
main.cpp@2:a3c53e712ed6, 2014-07-30 (annotated)
- Committer:
- rgrover1
- Date:
- Wed Jul 30 08:07:12 2014 +0000
- Revision:
- 2:a3c53e712ed6
- Parent:
- 0:83402e2aa37d
minor update needed in the initialization of SharpLCD--adding the chip-select pin.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rgrover1 | 0:83402e2aa37d | 1 | /* mbed Microcontroller Library |
rgrover1 | 0:83402e2aa37d | 2 | * Copyright (c) 2006-2013 ARM Limited |
rgrover1 | 0:83402e2aa37d | 3 | * |
rgrover1 | 0:83402e2aa37d | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
rgrover1 | 0:83402e2aa37d | 5 | * you may not use this file except in compliance with the License. |
rgrover1 | 0:83402e2aa37d | 6 | * You may obtain a copy of the License at |
rgrover1 | 0:83402e2aa37d | 7 | * |
rgrover1 | 0:83402e2aa37d | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
rgrover1 | 0:83402e2aa37d | 9 | * |
rgrover1 | 0:83402e2aa37d | 10 | * Unless required by applicable law or agreed to in writing, software |
rgrover1 | 0:83402e2aa37d | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
rgrover1 | 0:83402e2aa37d | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
rgrover1 | 0:83402e2aa37d | 13 | * See the License for the specific language governing permissions and |
rgrover1 | 0:83402e2aa37d | 14 | * limitations under the License. |
rgrover1 | 0:83402e2aa37d | 15 | */ |
rgrover1 | 0:83402e2aa37d | 16 | |
rgrover1 | 0:83402e2aa37d | 17 | #include "mbed.h" |
rgrover1 | 0:83402e2aa37d | 18 | #include "SharpLCD.hpp" |
rgrover1 | 0:83402e2aa37d | 19 | #include "font.h" |
rgrover1 | 0:83402e2aa37d | 20 | |
rgrover1 | 0:83402e2aa37d | 21 | DigitalOut led1(LED1); |
rgrover1 | 2:a3c53e712ed6 | 22 | SharpLCD lcd(p9, p8, MBED_SPI0); |
rgrover1 | 0:83402e2aa37d | 23 | |
rgrover1 | 0:83402e2aa37d | 24 | uint8_t framebuffer[SharpLCD::SIZEOF_FRAMEBUFFER_FOR_ALLOC]; |
rgrover1 | 0:83402e2aa37d | 25 | |
rgrover1 | 0:83402e2aa37d | 26 | int main(void) |
rgrover1 | 0:83402e2aa37d | 27 | { |
rgrover1 | 0:83402e2aa37d | 28 | SharpLCD::FrameBuffer fb(framebuffer); |
rgrover1 | 0:83402e2aa37d | 29 | |
rgrover1 | 0:83402e2aa37d | 30 | lcd.enableDisplay(); |
rgrover1 | 0:83402e2aa37d | 31 | lcd.clear(); |
rgrover1 | 0:83402e2aa37d | 32 | fb.printString(lookupFontFace("DejaVu Serif", 8), |
rgrover1 | 0:83402e2aa37d | 33 | 20, |
rgrover1 | 0:83402e2aa37d | 34 | 40, |
rgrover1 | 0:83402e2aa37d | 35 | BLACK, |
rgrover1 | 0:83402e2aa37d | 36 | "Rohit"); |
rgrover1 | 0:83402e2aa37d | 37 | lcd.drawFrameBuffer(fb); |
rgrover1 | 0:83402e2aa37d | 38 | |
rgrover1 | 0:83402e2aa37d | 39 | led1 = 1; |
rgrover1 | 0:83402e2aa37d | 40 | while (true) { |
rgrover1 | 0:83402e2aa37d | 41 | wait(0.5); |
rgrover1 | 0:83402e2aa37d | 42 | led1 = !led1; |
rgrover1 | 0:83402e2aa37d | 43 | } |
rgrover1 | 0:83402e2aa37d | 44 | } |