Subdirectory provided by Embedded Artists
Dependencies: DM_FATFileSystem DM_HttpServer DM_USBHost EthernetInterface USBDevice mbed-rpc mbed-rtos mbed-src
Dependents: lpc4088_displaymodule_hello_world_Sept_2018
Fork of DMSupport by
DMBoard.cpp@2:887c6b45e7fa, 2014-12-02 (annotated)
- Committer:
- embeddedartists
- Date:
- Tue Dec 02 15:21:18 2014 +0000
- Revision:
- 2:887c6b45e7fa
- Parent:
- 0:6b68dac0d986
- Child:
- 3:2fa7755f2cef
Added RTOS-safe logger (RtosLog). Switched USBHost library so that it works in an RTOS setting. Modified the FAT file system to work in an RTOS setting.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:6b68dac0d986 | 1 | /* |
embeddedartists | 0:6b68dac0d986 | 2 | * Copyright 2014 Embedded Artists AB |
embeddedartists | 0:6b68dac0d986 | 3 | * |
embeddedartists | 0:6b68dac0d986 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
embeddedartists | 0:6b68dac0d986 | 5 | * you may not use this file except in compliance with the License. |
embeddedartists | 0:6b68dac0d986 | 6 | * You may obtain a copy of the License at |
embeddedartists | 0:6b68dac0d986 | 7 | * |
embeddedartists | 0:6b68dac0d986 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
embeddedartists | 0:6b68dac0d986 | 9 | * |
embeddedartists | 0:6b68dac0d986 | 10 | * Unless required by applicable law or agreed to in writing, software |
embeddedartists | 0:6b68dac0d986 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
embeddedartists | 0:6b68dac0d986 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
embeddedartists | 0:6b68dac0d986 | 13 | * See the License for the specific language governing permissions and |
embeddedartists | 0:6b68dac0d986 | 14 | * limitations under the License. |
embeddedartists | 0:6b68dac0d986 | 15 | */ |
embeddedartists | 0:6b68dac0d986 | 16 | |
embeddedartists | 0:6b68dac0d986 | 17 | #include "mbed.h" |
embeddedartists | 0:6b68dac0d986 | 18 | #include "DMBoard.h" |
embeddedartists | 0:6b68dac0d986 | 19 | #include "InternalEEPROM.h" |
embeddedartists | 0:6b68dac0d986 | 20 | |
embeddedartists | 0:6b68dac0d986 | 21 | #if defined(DM_BOARD_USE_TOUCH) |
embeddedartists | 0:6b68dac0d986 | 22 | #include "AR1021.h" |
embeddedartists | 0:6b68dac0d986 | 23 | #endif |
embeddedartists | 0:6b68dac0d986 | 24 | |
embeddedartists | 0:6b68dac0d986 | 25 | /****************************************************************************** |
embeddedartists | 0:6b68dac0d986 | 26 | * Defines and typedefs |
embeddedartists | 0:6b68dac0d986 | 27 | *****************************************************************************/ |
embeddedartists | 0:6b68dac0d986 | 28 | |
embeddedartists | 2:887c6b45e7fa | 29 | #if defined(DM_BOARD_DISABLE_STANDARD_PRINTF) |
embeddedartists | 2:887c6b45e7fa | 30 | class DevNull : public Stream { |
embeddedartists | 2:887c6b45e7fa | 31 | |
embeddedartists | 2:887c6b45e7fa | 32 | public: |
embeddedartists | 2:887c6b45e7fa | 33 | DevNull(const char *name=NULL) : Stream(name) {} |
embeddedartists | 2:887c6b45e7fa | 34 | |
embeddedartists | 2:887c6b45e7fa | 35 | protected: |
embeddedartists | 2:887c6b45e7fa | 36 | virtual int _getc() {return 0;} |
embeddedartists | 2:887c6b45e7fa | 37 | virtual int _putc(int c) {return c;} |
embeddedartists | 2:887c6b45e7fa | 38 | }; |
embeddedartists | 2:887c6b45e7fa | 39 | |
embeddedartists | 2:887c6b45e7fa | 40 | static DevNull null("null"); |
embeddedartists | 2:887c6b45e7fa | 41 | #endif |
embeddedartists | 2:887c6b45e7fa | 42 | |
embeddedartists | 0:6b68dac0d986 | 43 | /****************************************************************************** |
embeddedartists | 0:6b68dac0d986 | 44 | * Local variables |
embeddedartists | 0:6b68dac0d986 | 45 | *****************************************************************************/ |
embeddedartists | 0:6b68dac0d986 | 46 | |
embeddedartists | 0:6b68dac0d986 | 47 | /****************************************************************************** |
embeddedartists | 0:6b68dac0d986 | 48 | * Private Functions |
embeddedartists | 0:6b68dac0d986 | 49 | *****************************************************************************/ |
embeddedartists | 0:6b68dac0d986 | 50 | |
embeddedartists | 0:6b68dac0d986 | 51 | DMBoard::DMBoard() : |
embeddedartists | 0:6b68dac0d986 | 52 | _initialized(false), |
embeddedartists | 0:6b68dac0d986 | 53 | #if defined(DM_BOARD_USE_MCI_FS) |
embeddedartists | 0:6b68dac0d986 | 54 | _mcifs("mci", P4_16), |
embeddedartists | 0:6b68dac0d986 | 55 | #endif |
embeddedartists | 0:6b68dac0d986 | 56 | #if defined(DM_BOARD_USE_QSPI_FS) |
embeddedartists | 0:6b68dac0d986 | 57 | _qspifs("qspi"), |
embeddedartists | 0:6b68dac0d986 | 58 | #endif |
embeddedartists | 0:6b68dac0d986 | 59 | #if defined(DM_BOARD_USE_TOUCH) |
embeddedartists | 0:6b68dac0d986 | 60 | _touch(NULL), |
embeddedartists | 0:6b68dac0d986 | 61 | #endif |
embeddedartists | 0:6b68dac0d986 | 62 | _buzzer(P1_5), |
embeddedartists | 0:6b68dac0d986 | 63 | _button(p23), |
embeddedartists | 0:6b68dac0d986 | 64 | _led1(LED1), |
embeddedartists | 0:6b68dac0d986 | 65 | _led2(LED2), |
embeddedartists | 0:6b68dac0d986 | 66 | _led3(LED3), |
embeddedartists | 0:6b68dac0d986 | 67 | _led4(LED4) |
embeddedartists | 0:6b68dac0d986 | 68 | { |
embeddedartists | 0:6b68dac0d986 | 69 | } |
embeddedartists | 0:6b68dac0d986 | 70 | |
embeddedartists | 0:6b68dac0d986 | 71 | DMBoard::~DMBoard() |
embeddedartists | 0:6b68dac0d986 | 72 | { |
embeddedartists | 2:887c6b45e7fa | 73 | #if defined(DM_BOARD_USE_TOUCH) |
embeddedartists | 0:6b68dac0d986 | 74 | if (_touch != NULL) { |
embeddedartists | 0:6b68dac0d986 | 75 | delete _touch; |
embeddedartists | 0:6b68dac0d986 | 76 | _touch = NULL; |
embeddedartists | 0:6b68dac0d986 | 77 | } |
embeddedartists | 2:887c6b45e7fa | 78 | #endif |
embeddedartists | 0:6b68dac0d986 | 79 | } |
embeddedartists | 0:6b68dac0d986 | 80 | |
embeddedartists | 0:6b68dac0d986 | 81 | DMBoard::BoardError DMBoard::readConfiguration() |
embeddedartists | 0:6b68dac0d986 | 82 | { |
embeddedartists | 0:6b68dac0d986 | 83 | InternalEEPROM mem; |
embeddedartists | 0:6b68dac0d986 | 84 | mem.init(); |
embeddedartists | 0:6b68dac0d986 | 85 | |
embeddedartists | 0:6b68dac0d986 | 86 | uint8_t* buff = (uint8_t*)malloc(mem.memorySize()); |
embeddedartists | 0:6b68dac0d986 | 87 | mem.read(0, 0, buff, mem.memorySize()); |
embeddedartists | 0:6b68dac0d986 | 88 | mem.powerDown(); |
embeddedartists | 0:6b68dac0d986 | 89 | #if 0 |
embeddedartists | 0:6b68dac0d986 | 90 | uint8_t* p = buff; |
embeddedartists | 2:887c6b45e7fa | 91 | _logger.printf("\n-------\nBEFORE:\n-------\n"); |
embeddedartists | 0:6b68dac0d986 | 92 | for (int i = 0; i < 63; i++) { |
embeddedartists | 0:6b68dac0d986 | 93 | for (int j = 0; j < 4; j++) { |
embeddedartists | 2:887c6b45e7fa | 94 | _logger.printf("0x%04x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", |
embeddedartists | 0:6b68dac0d986 | 95 | i, |
embeddedartists | 0:6b68dac0d986 | 96 | p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7], |
embeddedartists | 0:6b68dac0d986 | 97 | p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]); |
embeddedartists | 0:6b68dac0d986 | 98 | p += 16; |
embeddedartists | 0:6b68dac0d986 | 99 | } |
embeddedartists | 2:887c6b45e7fa | 100 | _logger.printf("\n"); |
embeddedartists | 0:6b68dac0d986 | 101 | } |
embeddedartists | 0:6b68dac0d986 | 102 | |
embeddedartists | 0:6b68dac0d986 | 103 | // find first non-zero page and write to that |
embeddedartists | 0:6b68dac0d986 | 104 | for (int page = 0; page < mem.numPages(); page++) { |
embeddedartists | 0:6b68dac0d986 | 105 | bool zeroPage = true; |
embeddedartists | 0:6b68dac0d986 | 106 | for (int i = 0; i < mem.pageSize(); i++) { |
embeddedartists | 0:6b68dac0d986 | 107 | if (buff[i + page*mem.pageSize()] != 0) { |
embeddedartists | 0:6b68dac0d986 | 108 | zeroPage = false; |
embeddedartists | 0:6b68dac0d986 | 109 | break; |
embeddedartists | 0:6b68dac0d986 | 110 | } |
embeddedartists | 0:6b68dac0d986 | 111 | } |
embeddedartists | 0:6b68dac0d986 | 112 | if (zeroPage) { |
embeddedartists | 2:887c6b45e7fa | 113 | _logger.printf("Will fill page 0x%04x (%d) with 0x00..0x3f\n", page, page); |
embeddedartists | 0:6b68dac0d986 | 114 | p = buff; |
embeddedartists | 0:6b68dac0d986 | 115 | for (int i = 0; i < mem.pageSize(); i++) { |
embeddedartists | 0:6b68dac0d986 | 116 | *p++ = i; |
embeddedartists | 0:6b68dac0d986 | 117 | } |
embeddedartists | 0:6b68dac0d986 | 118 | mem.write(page, 0, buff, mem.pageSize()); |
embeddedartists | 0:6b68dac0d986 | 119 | memset(buff, 0, mem.memorySize()); |
embeddedartists | 0:6b68dac0d986 | 120 | mem.read(0, 0, buff, mem.memorySize()); |
embeddedartists | 0:6b68dac0d986 | 121 | p = buff; |
embeddedartists | 2:887c6b45e7fa | 122 | _logger.printf("\n-------\nAFTER:\n-------\n"); |
embeddedartists | 0:6b68dac0d986 | 123 | for (int i = 0; i < 63; i++) { |
embeddedartists | 0:6b68dac0d986 | 124 | for (int j = 0; j < 4; j++) { |
embeddedartists | 2:887c6b45e7fa | 125 | _logger.printf("0x%04x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", |
embeddedartists | 0:6b68dac0d986 | 126 | i, |
embeddedartists | 0:6b68dac0d986 | 127 | p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7], |
embeddedartists | 0:6b68dac0d986 | 128 | p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]); |
embeddedartists | 0:6b68dac0d986 | 129 | p += 16; |
embeddedartists | 0:6b68dac0d986 | 130 | } |
embeddedartists | 2:887c6b45e7fa | 131 | _logger.printf("\n"); |
embeddedartists | 0:6b68dac0d986 | 132 | } |
embeddedartists | 0:6b68dac0d986 | 133 | break; |
embeddedartists | 0:6b68dac0d986 | 134 | } |
embeddedartists | 0:6b68dac0d986 | 135 | } |
embeddedartists | 0:6b68dac0d986 | 136 | #endif |
embeddedartists | 0:6b68dac0d986 | 137 | return Ok; |
embeddedartists | 0:6b68dac0d986 | 138 | } |
embeddedartists | 0:6b68dac0d986 | 139 | |
embeddedartists | 0:6b68dac0d986 | 140 | #if defined(DM_BOARD_USE_DISPLAY) |
embeddedartists | 0:6b68dac0d986 | 141 | DMBoard::BoardError DMBoard::readDisplayConfiguration(uint8_t** data, uint32_t* size) |
embeddedartists | 0:6b68dac0d986 | 142 | { |
embeddedartists | 0:6b68dac0d986 | 143 | uint32_t allocsize = 17*sizeof(uint32_t); |
embeddedartists | 0:6b68dac0d986 | 144 | uint32_t* stuff = (uint32_t*)malloc(allocsize); |
embeddedartists | 0:6b68dac0d986 | 145 | if (stuff == NULL) { |
embeddedartists | 0:6b68dac0d986 | 146 | return MemoryError; |
embeddedartists | 0:6b68dac0d986 | 147 | } |
embeddedartists | 0:6b68dac0d986 | 148 | #if defined(DM_BOARD_USE_4_3_DISPLAY_TMP) |
embeddedartists | 0:6b68dac0d986 | 149 | // Temporary setup, for a 4.3" display |
embeddedartists | 0:6b68dac0d986 | 150 | |
embeddedartists | 0:6b68dac0d986 | 151 | stuff[ 0] = 40, //horizontalBackPorch == HSYNC back porch |
embeddedartists | 0:6b68dac0d986 | 152 | stuff[ 1] = 5, //horizontalFrontPorch == HSYNC front porch |
embeddedartists | 0:6b68dac0d986 | 153 | stuff[ 2] = 2, //hsync == HSYNC width |
embeddedartists | 0:6b68dac0d986 | 154 | stuff[ 3] = 480, //width == Horizontal active area |
embeddedartists | 0:6b68dac0d986 | 155 | stuff[ 4] = 8, //verticalBackPorch == VSYNC back porch |
embeddedartists | 0:6b68dac0d986 | 156 | stuff[ 5] = 8, //verticalFrontPorch == VSYNC front porch |
embeddedartists | 0:6b68dac0d986 | 157 | stuff[ 6] = 2, //vsync == VSYNC width |
embeddedartists | 0:6b68dac0d986 | 158 | stuff[ 7] = 272, //height == Vertical display area |
embeddedartists | 0:6b68dac0d986 | 159 | stuff[ 8] = false, |
embeddedartists | 0:6b68dac0d986 | 160 | stuff[ 9] = false, |
embeddedartists | 0:6b68dac0d986 | 161 | stuff[10] = true, |
embeddedartists | 0:6b68dac0d986 | 162 | stuff[11] = true, |
embeddedartists | 0:6b68dac0d986 | 163 | stuff[12] = 1, |
embeddedartists | 0:6b68dac0d986 | 164 | stuff[13] = Display::Resolution_16bit_rgb565; |
embeddedartists | 0:6b68dac0d986 | 165 | stuff[14] = 9000000, //clock or 0 for external |
embeddedartists | 0:6b68dac0d986 | 166 | stuff[15] = 0, //LcdController::Tft, |
embeddedartists | 0:6b68dac0d986 | 167 | stuff[16] = false; |
embeddedartists | 0:6b68dac0d986 | 168 | #else |
embeddedartists | 0:6b68dac0d986 | 169 | // Temporary setup, for a 5" rogin display |
embeddedartists | 0:6b68dac0d986 | 170 | |
embeddedartists | 0:6b68dac0d986 | 171 | stuff[ 0] = 46, //horizontalBackPorch == HSYNC back porch |
embeddedartists | 0:6b68dac0d986 | 172 | stuff[ 1] = 20, //horizontalFrontPorch == HSYNC front porch |
embeddedartists | 0:6b68dac0d986 | 173 | stuff[ 2] = 2, //hsync == HSYNC width |
embeddedartists | 0:6b68dac0d986 | 174 | stuff[ 3] = 800, //width == Horizontal active area |
embeddedartists | 0:6b68dac0d986 | 175 | stuff[ 4] = 23, //verticalBackPorch == VSYNC back porch |
embeddedartists | 0:6b68dac0d986 | 176 | stuff[ 5] = 10, //verticalFrontPorch == VSYNC front porch |
embeddedartists | 0:6b68dac0d986 | 177 | stuff[ 6] = 3, //vsync == VSYNC width |
embeddedartists | 0:6b68dac0d986 | 178 | stuff[ 7] = 480, //height == Vertical display area |
embeddedartists | 0:6b68dac0d986 | 179 | stuff[ 8] = false, |
embeddedartists | 0:6b68dac0d986 | 180 | stuff[ 9] = false, |
embeddedartists | 0:6b68dac0d986 | 181 | stuff[10] = true, |
embeddedartists | 0:6b68dac0d986 | 182 | stuff[11] = true, |
embeddedartists | 0:6b68dac0d986 | 183 | stuff[12] = 1, |
embeddedartists | 0:6b68dac0d986 | 184 | stuff[13] = Display::Resolution_16bit_rgb565; |
embeddedartists | 0:6b68dac0d986 | 185 | stuff[14] = 30000000, //clock or 0 for external |
embeddedartists | 0:6b68dac0d986 | 186 | stuff[15] = 0, //LcdController::Tft, |
embeddedartists | 0:6b68dac0d986 | 187 | stuff[16] = false; |
embeddedartists | 0:6b68dac0d986 | 188 | #endif |
embeddedartists | 0:6b68dac0d986 | 189 | *data = (uint8_t*)&(stuff[0]); |
embeddedartists | 0:6b68dac0d986 | 190 | *size = allocsize; |
embeddedartists | 0:6b68dac0d986 | 191 | |
embeddedartists | 0:6b68dac0d986 | 192 | return Ok; |
embeddedartists | 0:6b68dac0d986 | 193 | } |
embeddedartists | 0:6b68dac0d986 | 194 | #endif |
embeddedartists | 0:6b68dac0d986 | 195 | |
embeddedartists | 0:6b68dac0d986 | 196 | /****************************************************************************** |
embeddedartists | 0:6b68dac0d986 | 197 | * Public Functions |
embeddedartists | 0:6b68dac0d986 | 198 | *****************************************************************************/ |
embeddedartists | 0:6b68dac0d986 | 199 | |
embeddedartists | 0:6b68dac0d986 | 200 | DMBoard::BoardError DMBoard::init() |
embeddedartists | 0:6b68dac0d986 | 201 | { |
embeddedartists | 0:6b68dac0d986 | 202 | BoardError err = Ok; |
embeddedartists | 0:6b68dac0d986 | 203 | if (!_initialized) { |
embeddedartists | 0:6b68dac0d986 | 204 | do { |
embeddedartists | 0:6b68dac0d986 | 205 | // Turn off the buzzer |
embeddedartists | 0:6b68dac0d986 | 206 | _buzzer.period_ms(1); |
embeddedartists | 0:6b68dac0d986 | 207 | _buzzer = 0; |
embeddedartists | 0:6b68dac0d986 | 208 | |
embeddedartists | 0:6b68dac0d986 | 209 | // Make sure the button is configured correctly |
embeddedartists | 0:6b68dac0d986 | 210 | _button.mode(PullUp); |
embeddedartists | 0:6b68dac0d986 | 211 | |
embeddedartists | 0:6b68dac0d986 | 212 | // Turn off all LEDs |
embeddedartists | 0:6b68dac0d986 | 213 | _led1 = 1; |
embeddedartists | 0:6b68dac0d986 | 214 | _led2 = 1; |
embeddedartists | 0:6b68dac0d986 | 215 | _led3 = 0; |
embeddedartists | 0:6b68dac0d986 | 216 | _led4 = 0; |
embeddedartists | 0:6b68dac0d986 | 217 | |
embeddedartists | 2:887c6b45e7fa | 218 | // Make sure that the logger is always initialized even if |
embeddedartists | 2:887c6b45e7fa | 219 | // other initialization tasks fail |
embeddedartists | 2:887c6b45e7fa | 220 | _logger.init(); |
embeddedartists | 2:887c6b45e7fa | 221 | |
embeddedartists | 2:887c6b45e7fa | 222 | #if defined(DM_BOARD_DISABLE_STANDARD_PRINTF) |
embeddedartists | 2:887c6b45e7fa | 223 | // Kill all ouput of calls to printf() so that there is no |
embeddedartists | 2:887c6b45e7fa | 224 | // simultaneous calls into the non-thread-safe standard libraries. |
embeddedartists | 2:887c6b45e7fa | 225 | // User code should use the RtosLogger anyway. |
embeddedartists | 2:887c6b45e7fa | 226 | freopen("/null", "w", stdout); |
embeddedartists | 2:887c6b45e7fa | 227 | #endif |
embeddedartists | 2:887c6b45e7fa | 228 | |
embeddedartists | 0:6b68dac0d986 | 229 | #if defined(DM_BOARD_USE_QSPI) && !defined(DM_BOARD_USE_QSPI_FS) |
embeddedartists | 0:6b68dac0d986 | 230 | if (SPIFI::instance().init() != SPIFI::Ok) { |
embeddedartists | 0:6b68dac0d986 | 231 | err = SpifiError; |
embeddedartists | 0:6b68dac0d986 | 232 | break; |
embeddedartists | 0:6b68dac0d986 | 233 | } |
embeddedartists | 0:6b68dac0d986 | 234 | #endif |
embeddedartists | 0:6b68dac0d986 | 235 | |
embeddedartists | 0:6b68dac0d986 | 236 | readConfiguration(); |
embeddedartists | 0:6b68dac0d986 | 237 | |
embeddedartists | 0:6b68dac0d986 | 238 | #if defined(DM_BOARD_USE_DISPLAY) |
embeddedartists | 0:6b68dac0d986 | 239 | if (Display::instance().init() != Display::Ok) { |
embeddedartists | 0:6b68dac0d986 | 240 | err = DisplayError; |
embeddedartists | 0:6b68dac0d986 | 241 | break; |
embeddedartists | 0:6b68dac0d986 | 242 | } |
embeddedartists | 0:6b68dac0d986 | 243 | #endif |
embeddedartists | 0:6b68dac0d986 | 244 | |
embeddedartists | 0:6b68dac0d986 | 245 | #if defined(DM_BOARD_USE_TOUCH) |
embeddedartists | 0:6b68dac0d986 | 246 | //if (... configuration says AR1021...) { |
embeddedartists | 0:6b68dac0d986 | 247 | _touch = new AR1021(P2_27, P2_26, P2_22, P2_23, P2_25); |
embeddedartists | 0:6b68dac0d986 | 248 | if (!_touch->init(Display::instance().width(), Display::instance().height())) { |
embeddedartists | 0:6b68dac0d986 | 249 | err = TouchError; |
embeddedartists | 0:6b68dac0d986 | 250 | break; |
embeddedartists | 0:6b68dac0d986 | 251 | } |
embeddedartists | 0:6b68dac0d986 | 252 | //} |
embeddedartists | 0:6b68dac0d986 | 253 | #endif |
embeddedartists | 0:6b68dac0d986 | 254 | |
embeddedartists | 0:6b68dac0d986 | 255 | |
embeddedartists | 0:6b68dac0d986 | 256 | _initialized = true; |
embeddedartists | 0:6b68dac0d986 | 257 | } while(0); |
embeddedartists | 0:6b68dac0d986 | 258 | } |
embeddedartists | 0:6b68dac0d986 | 259 | return err; |
embeddedartists | 0:6b68dac0d986 | 260 | } |
embeddedartists | 0:6b68dac0d986 | 261 | |
embeddedartists | 2:887c6b45e7fa | 262 | void DMBoard::setLED(Leds led, bool on) |
embeddedartists | 0:6b68dac0d986 | 263 | { |
embeddedartists | 0:6b68dac0d986 | 264 | switch(led) { |
embeddedartists | 2:887c6b45e7fa | 265 | case Led1: |
embeddedartists | 0:6b68dac0d986 | 266 | _led1 = (on ? 0 : 1); |
embeddedartists | 0:6b68dac0d986 | 267 | break; |
embeddedartists | 2:887c6b45e7fa | 268 | case Led2: |
embeddedartists | 0:6b68dac0d986 | 269 | _led2 = (on ? 0 : 1); |
embeddedartists | 0:6b68dac0d986 | 270 | break; |
embeddedartists | 2:887c6b45e7fa | 271 | case Led3: |
embeddedartists | 0:6b68dac0d986 | 272 | _led3 = (on ? 1 : 0); |
embeddedartists | 0:6b68dac0d986 | 273 | break; |
embeddedartists | 2:887c6b45e7fa | 274 | case Led4: |
embeddedartists | 0:6b68dac0d986 | 275 | _led4 = (on ? 1 : 0); |
embeddedartists | 0:6b68dac0d986 | 276 | break; |
embeddedartists | 0:6b68dac0d986 | 277 | } |
embeddedartists | 0:6b68dac0d986 | 278 | } |
embeddedartists | 0:6b68dac0d986 | 279 | |
embeddedartists | 0:6b68dac0d986 | 280 | void DMBoard::buzzer(float value) |
embeddedartists | 0:6b68dac0d986 | 281 | { |
embeddedartists | 0:6b68dac0d986 | 282 | if (value < 0) { |
embeddedartists | 0:6b68dac0d986 | 283 | value = 0; |
embeddedartists | 0:6b68dac0d986 | 284 | } else if (value > 1) { |
embeddedartists | 0:6b68dac0d986 | 285 | value = 1; |
embeddedartists | 0:6b68dac0d986 | 286 | } |
embeddedartists | 0:6b68dac0d986 | 287 | _buzzer = value; |
embeddedartists | 0:6b68dac0d986 | 288 | } |
embeddedartists | 0:6b68dac0d986 | 289 | |
embeddedartists | 0:6b68dac0d986 | 290 | bool DMBoard::buttonPressed() |
embeddedartists | 0:6b68dac0d986 | 291 | { |
embeddedartists | 0:6b68dac0d986 | 292 | return _button.read() == 0; |
embeddedartists | 0:6b68dac0d986 | 293 | } |
embeddedartists | 0:6b68dac0d986 | 294 |