A simple 128x32 graphical LCD program to quickstart with LCD on ARM mbed IoT Starter Kit. This requires mbed Applciation Shield with FRDM-K64F platform.

Dependencies:   C12832

Committer:
tushki7
Date:
Sun Apr 12 15:45:52 2015 +0000
Revision:
1:eb68c94a8ee5
Parent:
0:60d829a0353a
A simple 128x32 LCD program with ARM mbed IoT Starter Kit;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tushki7 0:60d829a0353a 1 /* mbed Microcontroller Library
tushki7 0:60d829a0353a 2 * Copyright (c) 2006-2013 ARM Limited
tushki7 0:60d829a0353a 3 *
tushki7 0:60d829a0353a 4 * Licensed under the Apache License, Version 2.0 (the "License");
tushki7 0:60d829a0353a 5 * you may not use this file except in compliance with the License.
tushki7 0:60d829a0353a 6 * You may obtain a copy of the License at
tushki7 0:60d829a0353a 7 *
tushki7 0:60d829a0353a 8 * http://www.apache.org/licenses/LICENSE-2.0
tushki7 0:60d829a0353a 9 *
tushki7 0:60d829a0353a 10 * Unless required by applicable law or agreed to in writing, software
tushki7 0:60d829a0353a 11 * distributed under the License is distributed on an "AS IS" BASIS,
tushki7 0:60d829a0353a 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
tushki7 0:60d829a0353a 13 * See the License for the specific language governing permissions and
tushki7 0:60d829a0353a 14 * limitations under the License.
tushki7 0:60d829a0353a 15 */
tushki7 0:60d829a0353a 16 #ifndef MBED_PORTOUT_H
tushki7 0:60d829a0353a 17 #define MBED_PORTOUT_H
tushki7 0:60d829a0353a 18
tushki7 0:60d829a0353a 19 #include "platform.h"
tushki7 0:60d829a0353a 20
tushki7 0:60d829a0353a 21 #if DEVICE_PORTOUT
tushki7 0:60d829a0353a 22
tushki7 0:60d829a0353a 23 #include "port_api.h"
tushki7 0:60d829a0353a 24
tushki7 0:60d829a0353a 25 namespace mbed {
tushki7 0:60d829a0353a 26 /** A multiple pin digital out
tushki7 0:60d829a0353a 27 *
tushki7 0:60d829a0353a 28 * Example:
tushki7 0:60d829a0353a 29 * @code
tushki7 0:60d829a0353a 30 * // Toggle all four LEDs
tushki7 0:60d829a0353a 31 *
tushki7 0:60d829a0353a 32 * #include "mbed.h"
tushki7 0:60d829a0353a 33 *
tushki7 0:60d829a0353a 34 * // LED1 = P1.18 LED2 = P1.20 LED3 = P1.21 LED4 = P1.23
tushki7 0:60d829a0353a 35 * #define LED_MASK 0x00B40000
tushki7 0:60d829a0353a 36 *
tushki7 0:60d829a0353a 37 * PortOut ledport(Port1, LED_MASK);
tushki7 0:60d829a0353a 38 *
tushki7 0:60d829a0353a 39 * int main() {
tushki7 0:60d829a0353a 40 * while(1) {
tushki7 0:60d829a0353a 41 * ledport = LED_MASK;
tushki7 0:60d829a0353a 42 * wait(1);
tushki7 0:60d829a0353a 43 * ledport = 0;
tushki7 0:60d829a0353a 44 * wait(1);
tushki7 0:60d829a0353a 45 * }
tushki7 0:60d829a0353a 46 * }
tushki7 0:60d829a0353a 47 * @endcode
tushki7 0:60d829a0353a 48 */
tushki7 0:60d829a0353a 49 class PortOut {
tushki7 0:60d829a0353a 50 public:
tushki7 0:60d829a0353a 51
tushki7 0:60d829a0353a 52 /** Create an PortOut, connected to the specified port
tushki7 0:60d829a0353a 53 *
tushki7 0:60d829a0353a 54 * @param port Port to connect to (Port0-Port5)
tushki7 0:60d829a0353a 55 * @param mask A bitmask to identify which bits in the port should be included (0 - ignore)
tushki7 0:60d829a0353a 56 */
tushki7 0:60d829a0353a 57 PortOut(PortName port, int mask = 0xFFFFFFFF) {
tushki7 0:60d829a0353a 58 port_init(&_port, port, mask, PIN_OUTPUT);
tushki7 0:60d829a0353a 59 }
tushki7 0:60d829a0353a 60
tushki7 0:60d829a0353a 61 /** Write the value to the output port
tushki7 0:60d829a0353a 62 *
tushki7 0:60d829a0353a 63 * @param value An integer specifying a bit to write for every corresponding PortOut pin
tushki7 0:60d829a0353a 64 */
tushki7 0:60d829a0353a 65 void write(int value) {
tushki7 0:60d829a0353a 66 port_write(&_port, value);
tushki7 0:60d829a0353a 67 }
tushki7 0:60d829a0353a 68
tushki7 0:60d829a0353a 69 /** Read the value currently output on the port
tushki7 0:60d829a0353a 70 *
tushki7 0:60d829a0353a 71 * @returns
tushki7 0:60d829a0353a 72 * An integer with each bit corresponding to associated PortOut pin setting
tushki7 0:60d829a0353a 73 */
tushki7 0:60d829a0353a 74 int read() {
tushki7 0:60d829a0353a 75 return port_read(&_port);
tushki7 0:60d829a0353a 76 }
tushki7 0:60d829a0353a 77
tushki7 0:60d829a0353a 78 /** A shorthand for write()
tushki7 0:60d829a0353a 79 */
tushki7 0:60d829a0353a 80 PortOut& operator= (int value) {
tushki7 0:60d829a0353a 81 write(value);
tushki7 0:60d829a0353a 82 return *this;
tushki7 0:60d829a0353a 83 }
tushki7 0:60d829a0353a 84
tushki7 0:60d829a0353a 85 PortOut& operator= (PortOut& rhs) {
tushki7 0:60d829a0353a 86 write(rhs.read());
tushki7 0:60d829a0353a 87 return *this;
tushki7 0:60d829a0353a 88 }
tushki7 0:60d829a0353a 89
tushki7 0:60d829a0353a 90 /** A shorthand for read()
tushki7 0:60d829a0353a 91 */
tushki7 0:60d829a0353a 92 operator int() {
tushki7 0:60d829a0353a 93 return read();
tushki7 0:60d829a0353a 94 }
tushki7 0:60d829a0353a 95
tushki7 0:60d829a0353a 96 private:
tushki7 0:60d829a0353a 97 port_t _port;
tushki7 0:60d829a0353a 98 };
tushki7 0:60d829a0353a 99
tushki7 0:60d829a0353a 100 } // namespace mbed
tushki7 0:60d829a0353a 101
tushki7 0:60d829a0353a 102 #endif
tushki7 0:60d829a0353a 103
tushki7 0:60d829a0353a 104 #endif