Graphical demo for the LPC4088 Experiment Base Board with one of the Display Expansion Kits. This demo shows a number of bubbles bouncing around.

Dependencies:   EALib mbed

Committer:
embeddedartists
Date:
Fri Oct 03 13:09:11 2014 +0000
Revision:
0:4839ec6c350d
First version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 0:4839ec6c350d 1 /*
embeddedartists 0:4839ec6c350d 2 * Copyright 2013 Embedded Artists AB
embeddedartists 0:4839ec6c350d 3 *
embeddedartists 0:4839ec6c350d 4 * Licensed under the Apache License, Version 2.0 (the "License");
embeddedartists 0:4839ec6c350d 5 * you may not use this file except in compliance with the License.
embeddedartists 0:4839ec6c350d 6 * You may obtain a copy of the License at
embeddedartists 0:4839ec6c350d 7 *
embeddedartists 0:4839ec6c350d 8 * http://www.apache.org/licenses/LICENSE-2.0
embeddedartists 0:4839ec6c350d 9 *
embeddedartists 0:4839ec6c350d 10 * Unless required by applicable law or agreed to in writing, software
embeddedartists 0:4839ec6c350d 11 * distributed under the License is distributed on an "AS IS" BASIS,
embeddedartists 0:4839ec6c350d 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
embeddedartists 0:4839ec6c350d 13 * See the License for the specific language governing permissions and
embeddedartists 0:4839ec6c350d 14 * limitations under the License.
embeddedartists 0:4839ec6c350d 15 */
embeddedartists 0:4839ec6c350d 16
embeddedartists 0:4839ec6c350d 17 /******************************************************************************
embeddedartists 0:4839ec6c350d 18 * Includes
embeddedartists 0:4839ec6c350d 19 *****************************************************************************/
embeddedartists 0:4839ec6c350d 20
embeddedartists 0:4839ec6c350d 21 #include "mbed.h"
embeddedartists 0:4839ec6c350d 22 #include "EaLcdBoardGPIO.h"
embeddedartists 0:4839ec6c350d 23
embeddedartists 0:4839ec6c350d 24 /******************************************************************************
embeddedartists 0:4839ec6c350d 25 * Defines and typedefs
embeddedartists 0:4839ec6c350d 26 *****************************************************************************/
embeddedartists 0:4839ec6c350d 27
embeddedartists 0:4839ec6c350d 28
embeddedartists 0:4839ec6c350d 29 EaLcdBoardGPIO::EaLcdBoardGPIO(PinName sda, PinName scl)
embeddedartists 0:4839ec6c350d 30 : EaLcdBoard(sda, scl), /*pinWP(P4_15),*/ pin3v3(P2_0), pin5v(P2_21), pinDE(P2_11), pinContrast(P2_1)
embeddedartists 0:4839ec6c350d 31 {
embeddedartists 0:4839ec6c350d 32 pinContrast.period_ms(10);
embeddedartists 0:4839ec6c350d 33 setWriteProtect(true);
embeddedartists 0:4839ec6c350d 34 set3V3Signal(false);
embeddedartists 0:4839ec6c350d 35 set5VSignal(false);
embeddedartists 0:4839ec6c350d 36 setDisplayEnableSignal(false);
embeddedartists 0:4839ec6c350d 37 setBacklightContrast(0);
embeddedartists 0:4839ec6c350d 38 }
embeddedartists 0:4839ec6c350d 39
embeddedartists 0:4839ec6c350d 40
embeddedartists 0:4839ec6c350d 41 void EaLcdBoardGPIO::setWriteProtect(bool enable)
embeddedartists 0:4839ec6c350d 42 {
embeddedartists 0:4839ec6c350d 43 // Not Applicable
embeddedartists 0:4839ec6c350d 44 }
embeddedartists 0:4839ec6c350d 45
embeddedartists 0:4839ec6c350d 46 void EaLcdBoardGPIO::set3V3Signal(bool enabled) { //P2.0 L=3.3V on
embeddedartists 0:4839ec6c350d 47 if (enabled) {
embeddedartists 0:4839ec6c350d 48 pin3v3 = 0;
embeddedartists 0:4839ec6c350d 49 } else {
embeddedartists 0:4839ec6c350d 50 pin3v3 = 1;
embeddedartists 0:4839ec6c350d 51 }
embeddedartists 0:4839ec6c350d 52 }
embeddedartists 0:4839ec6c350d 53
embeddedartists 0:4839ec6c350d 54 void EaLcdBoardGPIO::set5VSignal(bool enabled) { //P2.21 H=5V on
embeddedartists 0:4839ec6c350d 55 if (enabled) {
embeddedartists 0:4839ec6c350d 56 pin5v = 1;
embeddedartists 0:4839ec6c350d 57 } else {
embeddedartists 0:4839ec6c350d 58 pin5v = 0;
embeddedartists 0:4839ec6c350d 59 }
embeddedartists 0:4839ec6c350d 60 }
embeddedartists 0:4839ec6c350d 61
embeddedartists 0:4839ec6c350d 62 void EaLcdBoardGPIO::setDisplayEnableSignal(bool enabled) { //P2.11 H=enabled
embeddedartists 0:4839ec6c350d 63 LPC_IOCON->P2_11 &= ~7; /* GPIO2[11] @ P2.11 */
embeddedartists 0:4839ec6c350d 64 if (enabled) {
embeddedartists 0:4839ec6c350d 65 pinDE = 1;
embeddedartists 0:4839ec6c350d 66 } else {
embeddedartists 0:4839ec6c350d 67 pinDE = 0;
embeddedartists 0:4839ec6c350d 68 }
embeddedartists 0:4839ec6c350d 69 }
embeddedartists 0:4839ec6c350d 70
embeddedartists 0:4839ec6c350d 71 void EaLcdBoardGPIO::setBacklightContrast(uint32_t value) { //P2.1, set to 4.30 for now
embeddedartists 0:4839ec6c350d 72 #if 0
embeddedartists 0:4839ec6c350d 73 LPC_IOCON->P2_1 &= ~7; /* GPIO2[1] @ P2.1 */
embeddedartists 0:4839ec6c350d 74 if (value > 50) {
embeddedartists 0:4839ec6c350d 75 pinContrast = 1;
embeddedartists 0:4839ec6c350d 76 } else {
embeddedartists 0:4839ec6c350d 77 pinContrast = 0;
embeddedartists 0:4839ec6c350d 78 }
embeddedartists 0:4839ec6c350d 79 #else
embeddedartists 0:4839ec6c350d 80 uint32_t tmp = LPC_IOCON->P2_1;
embeddedartists 0:4839ec6c350d 81 tmp &= ~7;
embeddedartists 0:4839ec6c350d 82 tmp |= 1;
embeddedartists 0:4839ec6c350d 83 LPC_IOCON->P2_1 = tmp; /* PWM2[1] @ P2.1 */
embeddedartists 0:4839ec6c350d 84 float f = value;
embeddedartists 0:4839ec6c350d 85 pinContrast = f/100.0f;
embeddedartists 0:4839ec6c350d 86 #endif
embeddedartists 0:4839ec6c350d 87
embeddedartists 0:4839ec6c350d 88 // if (value > 100) return;
embeddedartists 0:4839ec6c350d 89
embeddedartists 0:4839ec6c350d 90 // pca9532_setBlink0Duty(100-value);
embeddedartists 0:4839ec6c350d 91 // pca9532_setBlink0Period(0);
embeddedartists 0:4839ec6c350d 92 // pca9532_setBlink0Leds(LCDB_CTRL_BL_C);
embeddedartists 0:4839ec6c350d 93 }
embeddedartists 0:4839ec6c350d 94
embeddedartists 0:4839ec6c350d 95
embeddedartists 0:4839ec6c350d 96