Example using the support package for LPC4088 DisplayModule
Dependencies: DMBasicGUI DMSupport
Example using a lot of the features in the software package for the LPC4088 Display Module.
This project can be selected as a template when creating a new project based on the LPC4088 Display Module.
Information
This project works on the 4.3" display modules.
Some of the apps works on the 5" display modules. The ImageViewer and Slideshow app will show the images distorted as it does not take the resolution into consideration.
Information
The USB Status app is disabled. The Image viewer looks for images in the root of SD cards, USB memory sticks or the file system on the QSPI flash. The Slideshow app expects to find a slideshow script in /mci/elec14/ea_logo.txt.
This is what it looks like on the 4.3" display:
main.cpp@13:57e65aba9802, 2015-01-08 (annotated)
- Committer:
- embeddedartists
- Date:
- Thu Jan 08 19:31:23 2015 +0100
- Revision:
- 13:57e65aba9802
- Parent:
- 11:4830c7689843
- Child:
- 14:73f6c425b2b5
- Moved AppImageViewer and AppStatus here from DMBasicGUI
- Added new AppNetworkSettings
- New images in image_data
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:dfad71908d59 | 1 | /****************************************************************************** |
embeddedartists | 0:dfad71908d59 | 2 | * Includes |
embeddedartists | 0:dfad71908d59 | 3 | *****************************************************************************/ |
embeddedartists | 0:dfad71908d59 | 4 | |
embeddedartists | 0:dfad71908d59 | 5 | #include "mbed.h" |
embeddedartists | 0:dfad71908d59 | 6 | #include "mbed_interface.h" |
embeddedartists | 0:dfad71908d59 | 7 | #include "rtos.h" |
embeddedartists | 0:dfad71908d59 | 8 | #include "EthernetInterface.h" |
embeddedartists | 0:dfad71908d59 | 9 | #include "HTTPServer.h" |
embeddedartists | 0:dfad71908d59 | 10 | #include "mbed_rpc.h" |
embeddedartists | 0:dfad71908d59 | 11 | #include "USBHostMSD.h" |
embeddedartists | 1:15ea03d72dd7 | 12 | #include "USBHostMouse.h" |
embeddedartists | 1:15ea03d72dd7 | 13 | #include "USBHostKeyboard.h" |
embeddedartists | 0:dfad71908d59 | 14 | |
embeddedartists | 0:dfad71908d59 | 15 | #include "DMBoard.h" |
embeddedartists | 0:dfad71908d59 | 16 | |
embeddedartists | 2:070e9c054796 | 17 | #include "AppLauncher.h" |
embeddedartists | 2:070e9c054796 | 18 | #include "meas.h" |
embeddedartists | 2:070e9c054796 | 19 | |
embeddedartists | 13:57e65aba9802 | 20 | #include "AppNetworkSettings.h" |
embeddedartists | 13:57e65aba9802 | 21 | #include "AppStatus.h" |
embeddedartists | 7:c8bef6a4b019 | 22 | #include "AppTouchCalibration.h" |
embeddedartists | 7:c8bef6a4b019 | 23 | #include "AppColorPicker.h" |
embeddedartists | 7:c8bef6a4b019 | 24 | #include "AppImageViewer.h" |
embeddedartists | 7:c8bef6a4b019 | 25 | #include "AppSlideShow.h" |
embeddedartists | 7:c8bef6a4b019 | 26 | #include "image_data.h" |
embeddedartists | 7:c8bef6a4b019 | 27 | |
embeddedartists | 2:070e9c054796 | 28 | |
embeddedartists | 0:dfad71908d59 | 29 | /****************************************************************************** |
embeddedartists | 0:dfad71908d59 | 30 | * Typedefs and defines |
embeddedartists | 0:dfad71908d59 | 31 | *****************************************************************************/ |
embeddedartists | 0:dfad71908d59 | 32 | |
embeddedartists | 0:dfad71908d59 | 33 | /* Number of colors in 565 mode */ |
embeddedartists | 0:dfad71908d59 | 34 | #define NUM_COLORS 65536 |
embeddedartists | 0:dfad71908d59 | 35 | /* Number of red colors in 565 mode */ |
embeddedartists | 0:dfad71908d59 | 36 | #define RED_COLORS 0x20 |
embeddedartists | 0:dfad71908d59 | 37 | /* Number of green colors in 565 mode */ |
embeddedartists | 0:dfad71908d59 | 38 | #define GREEN_COLORS 0x40 |
embeddedartists | 0:dfad71908d59 | 39 | /* Number of blue colors in 565 mode */ |
embeddedartists | 0:dfad71908d59 | 40 | #define BLUE_COLORS 0x20 |
embeddedartists | 0:dfad71908d59 | 41 | /* Black color, 565 mode */ |
embeddedartists | 0:dfad71908d59 | 42 | #define BLACK 0x0000 |
embeddedartists | 0:dfad71908d59 | 43 | |
embeddedartists | 0:dfad71908d59 | 44 | /****************************************************************************** |
embeddedartists | 0:dfad71908d59 | 45 | * Local variables |
embeddedartists | 0:dfad71908d59 | 46 | *****************************************************************************/ |
embeddedartists | 0:dfad71908d59 | 47 | |
embeddedartists | 1:15ea03d72dd7 | 48 | Mutex usbInitGuard; |
embeddedartists | 0:dfad71908d59 | 49 | |
embeddedartists | 0:dfad71908d59 | 50 | /****************************************************************************** |
embeddedartists | 0:dfad71908d59 | 51 | * Global variables |
embeddedartists | 0:dfad71908d59 | 52 | *****************************************************************************/ |
embeddedartists | 0:dfad71908d59 | 53 | |
embeddedartists | 2:070e9c054796 | 54 | EthernetInterface eth; |
embeddedartists | 2:070e9c054796 | 55 | bool ethInitialized = false; |
embeddedartists | 2:070e9c054796 | 56 | bool ethUsingDHCP = true; |
embeddedartists | 4:37a60b9bdb99 | 57 | bool haveUSBMSD = false; |
embeddedartists | 2:070e9c054796 | 58 | |
embeddedartists | 0:dfad71908d59 | 59 | /****************************************************************************** |
embeddedartists | 0:dfad71908d59 | 60 | * Local functions |
embeddedartists | 0:dfad71908d59 | 61 | *****************************************************************************/ |
embeddedartists | 0:dfad71908d59 | 62 | |
embeddedartists | 0:dfad71908d59 | 63 | void aliveTask(void const* args) |
embeddedartists | 0:dfad71908d59 | 64 | { |
embeddedartists | 0:dfad71908d59 | 65 | DMBoard* board = &DMBoard::instance(); |
embeddedartists | 0:dfad71908d59 | 66 | |
embeddedartists | 0:dfad71908d59 | 67 | while(true) |
embeddedartists | 0:dfad71908d59 | 68 | { |
embeddedartists | 0:dfad71908d59 | 69 | board->setLED(DMBoard::Led4, false); |
embeddedartists | 0:dfad71908d59 | 70 | board->setLED(DMBoard::Led1, true); |
embeddedartists | 0:dfad71908d59 | 71 | Thread::wait(300); |
embeddedartists | 0:dfad71908d59 | 72 | board->setLED(DMBoard::Led1, false); |
embeddedartists | 0:dfad71908d59 | 73 | board->setLED(DMBoard::Led2, true); |
embeddedartists | 0:dfad71908d59 | 74 | Thread::wait(300); |
embeddedartists | 0:dfad71908d59 | 75 | board->setLED(DMBoard::Led2, false); |
embeddedartists | 0:dfad71908d59 | 76 | board->setLED(DMBoard::Led3, true); |
embeddedartists | 0:dfad71908d59 | 77 | Thread::wait(300); |
embeddedartists | 0:dfad71908d59 | 78 | board->setLED(DMBoard::Led3, false); |
embeddedartists | 0:dfad71908d59 | 79 | board->setLED(DMBoard::Led4, true); |
embeddedartists | 0:dfad71908d59 | 80 | Thread::wait(300); |
embeddedartists | 0:dfad71908d59 | 81 | } |
embeddedartists | 0:dfad71908d59 | 82 | } |
embeddedartists | 0:dfad71908d59 | 83 | |
embeddedartists | 0:dfad71908d59 | 84 | /* |
embeddedartists | 0:dfad71908d59 | 85 | * Reads the /message.txt file from the file system and prints the content |
embeddedartists | 0:dfad71908d59 | 86 | */ |
embeddedartists | 0:dfad71908d59 | 87 | void readMessageFile(const char* prefix) |
embeddedartists | 0:dfad71908d59 | 88 | { |
embeddedartists | 0:dfad71908d59 | 89 | RtosLog* log = DMBoard::instance().logger(); |
embeddedartists | 0:dfad71908d59 | 90 | log->printf("%sTesting to read from USB\n", prefix); |
embeddedartists | 0:dfad71908d59 | 91 | |
embeddedartists | 1:15ea03d72dd7 | 92 | FILE * fp = fopen("/usb/message.txt", "r"); |
embeddedartists | 0:dfad71908d59 | 93 | |
embeddedartists | 0:dfad71908d59 | 94 | if (fp != NULL) { |
embeddedartists | 0:dfad71908d59 | 95 | uint8_t* buff = (uint8_t*)malloc(1024+1); |
embeddedartists | 0:dfad71908d59 | 96 | if (buff == NULL) { |
embeddedartists | 0:dfad71908d59 | 97 | log->printf("%sFailed to allocate memory for test\n", prefix); |
embeddedartists | 0:dfad71908d59 | 98 | } else { |
embeddedartists | 0:dfad71908d59 | 99 | int num = fread(buff, 1, 1024, fp); |
embeddedartists | 0:dfad71908d59 | 100 | if (num <= 0) { |
embeddedartists | 0:dfad71908d59 | 101 | log->printf("%sUnable to read file, got %d as result\n", prefix, num); |
embeddedartists | 0:dfad71908d59 | 102 | } else if (num < 1024) { |
embeddedartists | 3:4301d34173cf | 103 | log->printf("%sHave read all %d bytes in the file:\n---\n", prefix, num); |
embeddedartists | 0:dfad71908d59 | 104 | buff[num] = '\0'; |
embeddedartists | 0:dfad71908d59 | 105 | log->printf((const char*)buff); |
embeddedartists | 3:4301d34173cf | 106 | log->printf("\n---\n"); |
embeddedartists | 0:dfad71908d59 | 107 | } else { |
embeddedartists | 0:dfad71908d59 | 108 | log->printf("%sHave read %d bytes with more to read\n", prefix, num); |
embeddedartists | 0:dfad71908d59 | 109 | } |
embeddedartists | 0:dfad71908d59 | 110 | free(buff); |
embeddedartists | 0:dfad71908d59 | 111 | } |
embeddedartists | 0:dfad71908d59 | 112 | fclose(fp); |
embeddedartists | 0:dfad71908d59 | 113 | } else { |
embeddedartists | 0:dfad71908d59 | 114 | log->printf("%sFILE == NULL\r\n", prefix); |
embeddedartists | 0:dfad71908d59 | 115 | } |
embeddedartists | 0:dfad71908d59 | 116 | } |
embeddedartists | 0:dfad71908d59 | 117 | |
embeddedartists | 0:dfad71908d59 | 118 | |
embeddedartists | 0:dfad71908d59 | 119 | #if defined(DM_BOARD_USE_DISPLAY) |
embeddedartists | 2:070e9c054796 | 120 | |
embeddedartists | 7:c8bef6a4b019 | 121 | typedef enum { |
embeddedartists | 7:c8bef6a4b019 | 122 | ColorPickerApp, |
embeddedartists | 7:c8bef6a4b019 | 123 | ImageViewerApp, |
embeddedartists | 7:c8bef6a4b019 | 124 | SlideshowApp, |
embeddedartists | 7:c8bef6a4b019 | 125 | SettingsApp, |
embeddedartists | 13:57e65aba9802 | 126 | StatusApp, |
embeddedartists | 7:c8bef6a4b019 | 127 | TouchTestApp, |
embeddedartists | 7:c8bef6a4b019 | 128 | CalibrationApp = AppLauncher::CalibrationApp, |
embeddedartists | 7:c8bef6a4b019 | 129 | Placeholder, |
embeddedartists | 7:c8bef6a4b019 | 130 | } myapps_t; |
embeddedartists | 7:c8bef6a4b019 | 131 | |
embeddedartists | 7:c8bef6a4b019 | 132 | static App* launchApp(uint32_t id) |
embeddedartists | 7:c8bef6a4b019 | 133 | { |
embeddedartists | 7:c8bef6a4b019 | 134 | App* a = NULL; |
embeddedartists | 7:c8bef6a4b019 | 135 | switch ((myapps_t)id) { |
embeddedartists | 7:c8bef6a4b019 | 136 | case CalibrationApp: |
embeddedartists | 7:c8bef6a4b019 | 137 | a = new AppTouchCalibration(); |
embeddedartists | 7:c8bef6a4b019 | 138 | break; |
embeddedartists | 7:c8bef6a4b019 | 139 | case SettingsApp: |
embeddedartists | 13:57e65aba9802 | 140 | a = new AppNetworkSettings(); |
embeddedartists | 7:c8bef6a4b019 | 141 | break; |
embeddedartists | 7:c8bef6a4b019 | 142 | case ColorPickerApp: |
embeddedartists | 7:c8bef6a4b019 | 143 | a = new AppColorPicker(); |
embeddedartists | 7:c8bef6a4b019 | 144 | break; |
embeddedartists | 7:c8bef6a4b019 | 145 | case ImageViewerApp: |
embeddedartists | 7:c8bef6a4b019 | 146 | a = new AppImageViewer(); |
embeddedartists | 7:c8bef6a4b019 | 147 | break; |
embeddedartists | 7:c8bef6a4b019 | 148 | case SlideshowApp: |
embeddedartists | 7:c8bef6a4b019 | 149 | a = new AppSlideShow(); |
embeddedartists | 7:c8bef6a4b019 | 150 | break; |
embeddedartists | 13:57e65aba9802 | 151 | case StatusApp: |
embeddedartists | 13:57e65aba9802 | 152 | a = new AppStatus(); |
embeddedartists | 13:57e65aba9802 | 153 | break; |
embeddedartists | 7:c8bef6a4b019 | 154 | default: |
embeddedartists | 7:c8bef6a4b019 | 155 | break; |
embeddedartists | 7:c8bef6a4b019 | 156 | } |
embeddedartists | 7:c8bef6a4b019 | 157 | return a; |
embeddedartists | 7:c8bef6a4b019 | 158 | } |
embeddedartists | 7:c8bef6a4b019 | 159 | |
embeddedartists | 2:070e9c054796 | 160 | #define SWIM_TASK_PREFIX "[SWIM] " |
embeddedartists | 2:070e9c054796 | 161 | void swimTask(void const* args) |
embeddedartists | 2:070e9c054796 | 162 | { |
embeddedartists | 2:070e9c054796 | 163 | RtosLog* log = DMBoard::instance().logger(); |
embeddedartists | 2:070e9c054796 | 164 | |
embeddedartists | 2:070e9c054796 | 165 | log->printf(SWIM_TASK_PREFIX"swimTask started\n"); |
embeddedartists | 4:37a60b9bdb99 | 166 | |
embeddedartists | 2:070e9c054796 | 167 | AppLauncher launcher; |
embeddedartists | 7:c8bef6a4b019 | 168 | |
embeddedartists | 7:c8bef6a4b019 | 169 | |
embeddedartists | 2:070e9c054796 | 170 | if (launcher.setup()) { |
embeddedartists | 7:c8bef6a4b019 | 171 | launcher.addImageButton(SettingsApp, img_preferences_desktop_applications, img_size_preferences_desktop_applications); |
embeddedartists | 7:c8bef6a4b019 | 172 | launcher.addImageButton(Placeholder, img_bijiben, img_size_bijiben); |
embeddedartists | 7:c8bef6a4b019 | 173 | launcher.addImageButton(SlideshowApp, img_multimedia_photo_manager, img_size_multimedia_photo_manager); |
embeddedartists | 7:c8bef6a4b019 | 174 | //launcher.addImageButton(TouchGFXApp, "TouchGFX"); |
embeddedartists | 7:c8bef6a4b019 | 175 | //launcher.addImageButton(EmWinApp, "emWin"); |
embeddedartists | 7:c8bef6a4b019 | 176 | launcher.addImageButton(ColorPickerApp, img_preferences_color, img_size_preferences_color); |
embeddedartists | 7:c8bef6a4b019 | 177 | launcher.addImageButton(ImageViewerApp, img_multimedia_photo_manager, img_size_multimedia_photo_manager); |
embeddedartists | 13:57e65aba9802 | 178 | launcher.addImageButton(StatusApp, img_help_info, img_size_help_info); |
embeddedartists | 7:c8bef6a4b019 | 179 | launcher.addImageButton(Placeholder, img_unetbootin, img_size_unetbootin); |
embeddedartists | 4:37a60b9bdb99 | 180 | |
embeddedartists | 7:c8bef6a4b019 | 181 | launcher.setAppCreatorFunc(launchApp); |
embeddedartists | 2:070e9c054796 | 182 | log->printf(SWIM_TASK_PREFIX"Starting menu system\n"); |
embeddedartists | 2:070e9c054796 | 183 | launcher.runToCompletion(); |
embeddedartists | 2:070e9c054796 | 184 | launcher.teardown(); |
embeddedartists | 2:070e9c054796 | 185 | } else { |
embeddedartists | 4:37a60b9bdb99 | 186 | log->printf(SWIM_TASK_PREFIX"Failed to prepare menu system\n"); |
embeddedartists | 2:070e9c054796 | 187 | } |
embeddedartists | 2:070e9c054796 | 188 | |
embeddedartists | 2:070e9c054796 | 189 | // Should never end up here |
embeddedartists | 2:070e9c054796 | 190 | mbed_die(); |
embeddedartists | 2:070e9c054796 | 191 | } |
embeddedartists | 2:070e9c054796 | 192 | |
embeddedartists | 0:dfad71908d59 | 193 | #endif //DM_BOARD_USE_DISPLAY |
embeddedartists | 0:dfad71908d59 | 194 | |
embeddedartists | 0:dfad71908d59 | 195 | #define MSD_TASK_PREFIX "[MSD] " |
embeddedartists | 0:dfad71908d59 | 196 | |
embeddedartists | 0:dfad71908d59 | 197 | void msdTask(void const* args) |
embeddedartists | 1:15ea03d72dd7 | 198 | { |
embeddedartists | 1:15ea03d72dd7 | 199 | usbInitGuard.lock(); |
embeddedartists | 1:15ea03d72dd7 | 200 | USBHostMSD* msd = new USBHostMSD("usb"); |
embeddedartists | 1:15ea03d72dd7 | 201 | usbInitGuard.unlock(); |
embeddedartists | 0:dfad71908d59 | 202 | USBHost* host = USBHost::getHostInst(); |
embeddedartists | 0:dfad71908d59 | 203 | RtosLog* log = DMBoard::instance().logger(); |
embeddedartists | 0:dfad71908d59 | 204 | |
embeddedartists | 0:dfad71908d59 | 205 | log->printf(MSD_TASK_PREFIX"msdTask started\n"); |
embeddedartists | 0:dfad71908d59 | 206 | |
embeddedartists | 0:dfad71908d59 | 207 | while(1) { |
embeddedartists | 0:dfad71908d59 | 208 | |
embeddedartists | 0:dfad71908d59 | 209 | log->printf(MSD_TASK_PREFIX"Attempting to connect...\n"); |
embeddedartists | 0:dfad71908d59 | 210 | |
embeddedartists | 0:dfad71908d59 | 211 | // try to connect a MSD device |
embeddedartists | 1:15ea03d72dd7 | 212 | bool connected = false; |
embeddedartists | 1:15ea03d72dd7 | 213 | do { |
embeddedartists | 1:15ea03d72dd7 | 214 | usbInitGuard.lock(); |
embeddedartists | 1:15ea03d72dd7 | 215 | connected = msd->connect(); |
embeddedartists | 1:15ea03d72dd7 | 216 | usbInitGuard.unlock(); |
embeddedartists | 1:15ea03d72dd7 | 217 | if (!connected) { |
embeddedartists | 1:15ea03d72dd7 | 218 | //log->printf(MSD_TASK_PREFIX"Failed to connect, waiting and trying again!\n"); |
embeddedartists | 1:15ea03d72dd7 | 219 | Thread::wait(500); |
embeddedartists | 3:4301d34173cf | 220 | //DMBoard::instance().buzzer(440, 100); |
embeddedartists | 0:dfad71908d59 | 221 | } |
embeddedartists | 1:15ea03d72dd7 | 222 | } while(!connected); |
embeddedartists | 0:dfad71908d59 | 223 | |
embeddedartists | 0:dfad71908d59 | 224 | log->printf(MSD_TASK_PREFIX"Connected!\n"); |
embeddedartists | 4:37a60b9bdb99 | 225 | haveUSBMSD = true; |
embeddedartists | 0:dfad71908d59 | 226 | |
embeddedartists | 0:dfad71908d59 | 227 | // read a file |
embeddedartists | 4:37a60b9bdb99 | 228 | //readMessageFile(MSD_TASK_PREFIX); |
embeddedartists | 0:dfad71908d59 | 229 | |
embeddedartists | 0:dfad71908d59 | 230 | // if/when the device is disconnected, we try to connect it again |
embeddedartists | 0:dfad71908d59 | 231 | while(1) { |
embeddedartists | 0:dfad71908d59 | 232 | |
embeddedartists | 0:dfad71908d59 | 233 | Thread::wait(500); |
embeddedartists | 0:dfad71908d59 | 234 | |
embeddedartists | 0:dfad71908d59 | 235 | // if device disconnected, try to connect again |
embeddedartists | 4:37a60b9bdb99 | 236 | if (!msd->connected()) { |
embeddedartists | 0:dfad71908d59 | 237 | break; |
embeddedartists | 4:37a60b9bdb99 | 238 | } |
embeddedartists | 0:dfad71908d59 | 239 | } |
embeddedartists | 4:37a60b9bdb99 | 240 | haveUSBMSD = false; |
embeddedartists | 0:dfad71908d59 | 241 | log->printf(MSD_TASK_PREFIX"Disconnected\n"); |
embeddedartists | 0:dfad71908d59 | 242 | } |
embeddedartists | 0:dfad71908d59 | 243 | } |
embeddedartists | 0:dfad71908d59 | 244 | |
embeddedartists | 0:dfad71908d59 | 245 | #define NET_TASK_PREFIX "[NET] " |
embeddedartists | 0:dfad71908d59 | 246 | |
embeddedartists | 0:dfad71908d59 | 247 | void netTask(void const* args) |
embeddedartists | 0:dfad71908d59 | 248 | { |
embeddedartists | 0:dfad71908d59 | 249 | RtosLog* log = DMBoard::instance().logger(); |
embeddedartists | 0:dfad71908d59 | 250 | log->printf(NET_TASK_PREFIX"EthernetInterface Setting up...\r\n"); |
embeddedartists | 0:dfad71908d59 | 251 | if(eth.init()!=0) { //for DHCP Server |
embeddedartists | 0:dfad71908d59 | 252 | //if(eth.init(IPAddress,NetMasks,Gateway)!=0) { //for Static IP Address |
embeddedartists | 0:dfad71908d59 | 253 | log->printf(NET_TASK_PREFIX"EthernetInterface Initialize Error \r\n"); |
embeddedartists | 0:dfad71908d59 | 254 | mbed_die(); |
embeddedartists | 0:dfad71908d59 | 255 | } |
embeddedartists | 2:070e9c054796 | 256 | while (eth.connect() != 0) { |
embeddedartists | 2:070e9c054796 | 257 | Thread::wait(1000); |
embeddedartists | 0:dfad71908d59 | 258 | } |
embeddedartists | 0:dfad71908d59 | 259 | |
embeddedartists | 2:070e9c054796 | 260 | ethInitialized = true; |
embeddedartists | 2:070e9c054796 | 261 | ethUsingDHCP = true; |
embeddedartists | 2:070e9c054796 | 262 | |
embeddedartists | 0:dfad71908d59 | 263 | log->printf(NET_TASK_PREFIX"IP Address is %s\r\n", eth.getIPAddress()); |
embeddedartists | 0:dfad71908d59 | 264 | log->printf(NET_TASK_PREFIX"NetMask is %s\r\n", eth.getNetworkMask()); |
embeddedartists | 0:dfad71908d59 | 265 | log->printf(NET_TASK_PREFIX"Gateway Address is %s\r\n", eth.getGateway()); |
embeddedartists | 0:dfad71908d59 | 266 | log->printf(NET_TASK_PREFIX"Ethernet Setup OK\r\n"); |
embeddedartists | 0:dfad71908d59 | 267 | |
embeddedartists | 0:dfad71908d59 | 268 | HTTPServerAddHandler<SimpleHandler>("/hello"); //Default handler |
embeddedartists | 0:dfad71908d59 | 269 | FSHandler::mount("/usb", "/"); |
embeddedartists | 0:dfad71908d59 | 270 | HTTPServerAddHandler<FSHandler>("/"); |
embeddedartists | 0:dfad71908d59 | 271 | //HTTPServerAddHandler<RPCHandler>("/rpc"); |
embeddedartists | 0:dfad71908d59 | 272 | //lcd.locate(0,0); |
embeddedartists | 0:dfad71908d59 | 273 | //lcd.printf("%s",eth.getIPAddress()); |
embeddedartists | 0:dfad71908d59 | 274 | HTTPServerStart(80); |
embeddedartists | 0:dfad71908d59 | 275 | } |
embeddedartists | 0:dfad71908d59 | 276 | |
embeddedartists | 13:57e65aba9802 | 277 | static int8_t mouse_button, mouse_x, mouse_y, mouse_z; |
embeddedartists | 13:57e65aba9802 | 278 | static uint16_t cursor_x=0, cursor_y=0; |
embeddedartists | 1:15ea03d72dd7 | 279 | void mouseEvent(uint8_t buttons, int8_t x, int8_t y, int8_t z) |
embeddedartists | 1:15ea03d72dd7 | 280 | { |
embeddedartists | 1:15ea03d72dd7 | 281 | mouse_button = buttons; |
embeddedartists | 1:15ea03d72dd7 | 282 | mouse_x = x; |
embeddedartists | 1:15ea03d72dd7 | 283 | mouse_y = y; |
embeddedartists | 1:15ea03d72dd7 | 284 | mouse_z = z; |
embeddedartists | 13:57e65aba9802 | 285 | |
embeddedartists | 13:57e65aba9802 | 286 | if (x < 0) { |
embeddedartists | 13:57e65aba9802 | 287 | if (cursor_x > -x) { |
embeddedartists | 13:57e65aba9802 | 288 | cursor_x += x; |
embeddedartists | 13:57e65aba9802 | 289 | } else { |
embeddedartists | 13:57e65aba9802 | 290 | cursor_x = 0; |
embeddedartists | 13:57e65aba9802 | 291 | } |
embeddedartists | 13:57e65aba9802 | 292 | } else { |
embeddedartists | 13:57e65aba9802 | 293 | if ((cursor_x + x) >= 480) { |
embeddedartists | 13:57e65aba9802 | 294 | cursor_x = 479; |
embeddedartists | 13:57e65aba9802 | 295 | } else { |
embeddedartists | 13:57e65aba9802 | 296 | cursor_x += x; |
embeddedartists | 13:57e65aba9802 | 297 | } |
embeddedartists | 13:57e65aba9802 | 298 | } |
embeddedartists | 13:57e65aba9802 | 299 | y = y/8; |
embeddedartists | 13:57e65aba9802 | 300 | if (y < 0) { |
embeddedartists | 13:57e65aba9802 | 301 | if (cursor_y > -y) { |
embeddedartists | 13:57e65aba9802 | 302 | cursor_y += y; |
embeddedartists | 13:57e65aba9802 | 303 | } else { |
embeddedartists | 13:57e65aba9802 | 304 | cursor_y = 0; |
embeddedartists | 13:57e65aba9802 | 305 | } |
embeddedartists | 13:57e65aba9802 | 306 | } else { |
embeddedartists | 13:57e65aba9802 | 307 | if ((cursor_y + y) >= 272) { |
embeddedartists | 13:57e65aba9802 | 308 | cursor_y = 271; |
embeddedartists | 13:57e65aba9802 | 309 | } else { |
embeddedartists | 13:57e65aba9802 | 310 | cursor_y += y; |
embeddedartists | 13:57e65aba9802 | 311 | } |
embeddedartists | 13:57e65aba9802 | 312 | } |
embeddedartists | 13:57e65aba9802 | 313 | |
embeddedartists | 13:57e65aba9802 | 314 | //Chip_LCD_Cursor_SetPos(LPC_LCD, cursor_x, cursor_y); |
embeddedartists | 13:57e65aba9802 | 315 | LPC_LCD->CRSR_XY = (cursor_x & 0x3FF) | ((cursor_y & 0x3FF) << 16); |
embeddedartists | 13:57e65aba9802 | 316 | } |
embeddedartists | 13:57e65aba9802 | 317 | |
embeddedartists | 13:57e65aba9802 | 318 | #define LCD_CURSOR_32x32 0 |
embeddedartists | 13:57e65aba9802 | 319 | #define LCD_CURSOR_64x64 1 |
embeddedartists | 13:57e65aba9802 | 320 | #define CURSOR_SIZE LCD_CURSOR_32x32 |
embeddedartists | 13:57e65aba9802 | 321 | #define CURSOR_H_SIZE 32 |
embeddedartists | 13:57e65aba9802 | 322 | #define CURSOR_V_SIZE 32 |
embeddedartists | 13:57e65aba9802 | 323 | #define CURSOR_NUM 0 |
embeddedartists | 13:57e65aba9802 | 324 | #define CURSOR_H_OFS (10) |
embeddedartists | 13:57e65aba9802 | 325 | #define CURSOR_V_OFS (6) |
embeddedartists | 13:57e65aba9802 | 326 | |
embeddedartists | 13:57e65aba9802 | 327 | const unsigned char __attribute__ ((aligned(4))) Cursor[(CURSOR_H_SIZE / 4) * CURSOR_V_SIZE] = |
embeddedartists | 13:57e65aba9802 | 328 | { |
embeddedartists | 13:57e65aba9802 | 329 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 330 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 331 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 332 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 333 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 334 | 0xAA, 0xAA, 0xAA, 0xFA, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 335 | 0xAA, 0xAA, 0xAB, 0xFE, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 336 | 0xAA, 0xAA, 0xAB, 0xFE, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 337 | 0xAA, 0xAA, 0xAB, 0xFE, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 338 | 0xAA, 0xAA, 0xAB, 0xFE, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 339 | 0xAA, 0xAA, 0xAB, 0xFF, 0xEA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 340 | 0xAA, 0xAA, 0xAB, 0xFF, 0xFF, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 341 | 0xAA, 0xAA, 0xAB, 0xFF, 0xFF, 0xFA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 342 | 0xAA, 0xAA, 0xAB, 0xFF, 0xFF, 0xFE, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 343 | 0xAA, 0xAB, 0xFB, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 344 | 0xAA, 0xAB, 0xFF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 345 | 0xAA, 0xAB, 0xFF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 346 | 0xAA, 0xAA, 0xFF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 347 | 0xAA, 0xAA, 0xBF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 348 | 0xAA, 0xAA, 0xBF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 349 | 0xAA, 0xAA, 0xAF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 350 | 0xAA, 0xAA, 0xAF, 0xFF, 0xFF, 0xFE, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 351 | 0xAA, 0xAA, 0xAB, 0xFF, 0xFF, 0xFE, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 352 | 0xAA, 0xAA, 0xAB, 0xFF, 0xFF, 0xFE, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 353 | 0xAA, 0xAA, 0xAA, 0xFF, 0xFF, 0xFA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 354 | 0xAA, 0xAA, 0xAA, 0xFF, 0xFF, 0xFA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 355 | 0xAA, 0xAA, 0xAA, 0xFF, 0xFF, 0xFA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 356 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 357 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 358 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 359 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
embeddedartists | 13:57e65aba9802 | 360 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA |
embeddedartists | 13:57e65aba9802 | 361 | }; |
embeddedartists | 13:57e65aba9802 | 362 | |
embeddedartists | 13:57e65aba9802 | 363 | void prepareCursor(bool enable) { |
embeddedartists | 13:57e65aba9802 | 364 | //Chip_LCD_Cursor_Disable(LPC_LCD, 0); |
embeddedartists | 13:57e65aba9802 | 365 | LPC_LCD->CRSR_CTRL = (CURSOR_NUM << 4); |
embeddedartists | 13:57e65aba9802 | 366 | |
embeddedartists | 13:57e65aba9802 | 367 | if (enable) { |
embeddedartists | 13:57e65aba9802 | 368 | //Chip_LCD_Cursor_Config(LPC_LCD, LCD_CURSOR_32x32, true); |
embeddedartists | 13:57e65aba9802 | 369 | LPC_LCD->CRSR_CFG = ((true ? 1 : 0) << 1) | CURSOR_SIZE; |
embeddedartists | 13:57e65aba9802 | 370 | |
embeddedartists | 13:57e65aba9802 | 371 | //Chip_LCD_Cursor_WriteImage(LPC_LCD, 0, (void *) Cursor); |
embeddedartists | 13:57e65aba9802 | 372 | { |
embeddedartists | 13:57e65aba9802 | 373 | int i, j; |
embeddedartists | 13:57e65aba9802 | 374 | uint32_t *fifoptr, *crsr_ptr = (uint32_t *) Cursor; |
embeddedartists | 13:57e65aba9802 | 375 | |
embeddedartists | 13:57e65aba9802 | 376 | /* Check if Cursor Size was configured as 32x32 or 64x64*/ |
embeddedartists | 13:57e65aba9802 | 377 | if (CURSOR_SIZE == LCD_CURSOR_32x32) { |
embeddedartists | 13:57e65aba9802 | 378 | i = CURSOR_NUM * 64; |
embeddedartists | 13:57e65aba9802 | 379 | j = i + 64; |
embeddedartists | 13:57e65aba9802 | 380 | } |
embeddedartists | 13:57e65aba9802 | 381 | else { |
embeddedartists | 13:57e65aba9802 | 382 | i = 0; |
embeddedartists | 13:57e65aba9802 | 383 | j = 256; |
embeddedartists | 13:57e65aba9802 | 384 | } |
embeddedartists | 13:57e65aba9802 | 385 | fifoptr = (uint32_t *) &(LPC_LCD->CRSR_IMG[0]); |
embeddedartists | 13:57e65aba9802 | 386 | |
embeddedartists | 13:57e65aba9802 | 387 | /* Copy Cursor Image content to FIFO */ |
embeddedartists | 13:57e65aba9802 | 388 | for (; i < j; i++) { |
embeddedartists | 13:57e65aba9802 | 389 | |
embeddedartists | 13:57e65aba9802 | 390 | *fifoptr = *crsr_ptr; |
embeddedartists | 13:57e65aba9802 | 391 | crsr_ptr++; |
embeddedartists | 13:57e65aba9802 | 392 | fifoptr++; |
embeddedartists | 13:57e65aba9802 | 393 | } |
embeddedartists | 13:57e65aba9802 | 394 | } |
embeddedartists | 13:57e65aba9802 | 395 | |
embeddedartists | 13:57e65aba9802 | 396 | //Chip_LCD_Cursor_SetClip(LPC_LCD, CURSOR_H_OFS, CURSOR_V_OFS); |
embeddedartists | 13:57e65aba9802 | 397 | LPC_LCD->CRSR_CLIP = (CURSOR_H_OFS & 0x3F) | ((CURSOR_V_OFS & 0x3F) << 8); |
embeddedartists | 13:57e65aba9802 | 398 | |
embeddedartists | 13:57e65aba9802 | 399 | //Chip_LCD_Cursor_SetPos(LPC_LCD, cursor_x, cursor_y); |
embeddedartists | 13:57e65aba9802 | 400 | |
embeddedartists | 13:57e65aba9802 | 401 | //Chip_LCD_Cursor_Enable(LPC_LCD, 0); |
embeddedartists | 13:57e65aba9802 | 402 | LPC_LCD->CRSR_CTRL = (CURSOR_NUM << 4) | 1; |
embeddedartists | 13:57e65aba9802 | 403 | } |
embeddedartists | 1:15ea03d72dd7 | 404 | } |
embeddedartists | 1:15ea03d72dd7 | 405 | |
embeddedartists | 1:15ea03d72dd7 | 406 | #define MOUSE_TASK_PREFIX "[MOUSE] " |
embeddedartists | 1:15ea03d72dd7 | 407 | |
embeddedartists | 1:15ea03d72dd7 | 408 | void mouseTask(void const* args) |
embeddedartists | 1:15ea03d72dd7 | 409 | { |
embeddedartists | 1:15ea03d72dd7 | 410 | usbInitGuard.lock(); |
embeddedartists | 1:15ea03d72dd7 | 411 | USBHostMouse* mouse = new USBHostMouse(); |
embeddedartists | 1:15ea03d72dd7 | 412 | usbInitGuard.unlock(); |
embeddedartists | 1:15ea03d72dd7 | 413 | RtosLog* log = DMBoard::instance().logger(); |
embeddedartists | 13:57e65aba9802 | 414 | |
embeddedartists | 1:15ea03d72dd7 | 415 | log->printf(MOUSE_TASK_PREFIX"mouseTask started\n"); |
embeddedartists | 1:15ea03d72dd7 | 416 | |
embeddedartists | 1:15ea03d72dd7 | 417 | while(1) { |
embeddedartists | 1:15ea03d72dd7 | 418 | |
embeddedartists | 13:57e65aba9802 | 419 | prepareCursor(false); |
embeddedartists | 1:15ea03d72dd7 | 420 | log->printf(MOUSE_TASK_PREFIX"Attempting to connect...\n"); |
embeddedartists | 1:15ea03d72dd7 | 421 | |
embeddedartists | 1:15ea03d72dd7 | 422 | // try to connect a mouse |
embeddedartists | 1:15ea03d72dd7 | 423 | bool connected = false; |
embeddedartists | 1:15ea03d72dd7 | 424 | do { |
embeddedartists | 1:15ea03d72dd7 | 425 | usbInitGuard.lock(); |
embeddedartists | 1:15ea03d72dd7 | 426 | connected = mouse->connect(); |
embeddedartists | 1:15ea03d72dd7 | 427 | usbInitGuard.unlock(); |
embeddedartists | 1:15ea03d72dd7 | 428 | if (!connected) { |
embeddedartists | 1:15ea03d72dd7 | 429 | //log->printf(MOUSE_TASK_PREFIX"Failed to connect, waiting and trying again!\n"); |
embeddedartists | 1:15ea03d72dd7 | 430 | Thread::wait(500); |
embeddedartists | 1:15ea03d72dd7 | 431 | } |
embeddedartists | 1:15ea03d72dd7 | 432 | } while(!connected); |
embeddedartists | 1:15ea03d72dd7 | 433 | |
embeddedartists | 1:15ea03d72dd7 | 434 | log->printf(MOUSE_TASK_PREFIX"Connected!\n"); |
embeddedartists | 1:15ea03d72dd7 | 435 | mouse->attachEvent(mouseEvent); |
embeddedartists | 13:57e65aba9802 | 436 | prepareCursor(true); |
embeddedartists | 1:15ea03d72dd7 | 437 | |
embeddedartists | 1:15ea03d72dd7 | 438 | while(mouse->connected()) { |
embeddedartists | 1:15ea03d72dd7 | 439 | log->printf(MOUSE_TASK_PREFIX"Buttons: 0x%02x, X %3d, Y %3d, Z %3d\n", mouse_button, mouse_x, mouse_y, mouse_z); |
embeddedartists | 1:15ea03d72dd7 | 440 | Thread::wait(500); |
embeddedartists | 1:15ea03d72dd7 | 441 | } |
embeddedartists | 1:15ea03d72dd7 | 442 | |
embeddedartists | 1:15ea03d72dd7 | 443 | log->printf(MOUSE_TASK_PREFIX"Disconnected\n"); |
embeddedartists | 1:15ea03d72dd7 | 444 | } |
embeddedartists | 1:15ea03d72dd7 | 445 | } |
embeddedartists | 1:15ea03d72dd7 | 446 | |
embeddedartists | 1:15ea03d72dd7 | 447 | #define CIRCBUFF_SIZE 256 |
embeddedartists | 1:15ea03d72dd7 | 448 | static uint8_t circbuff[CIRCBUFF_SIZE]; |
embeddedartists | 1:15ea03d72dd7 | 449 | static uint32_t circbuff_read = 0; |
embeddedartists | 1:15ea03d72dd7 | 450 | static uint32_t circbuff_write = 0; |
embeddedartists | 1:15ea03d72dd7 | 451 | void keyEvent(uint8_t key) |
embeddedartists | 1:15ea03d72dd7 | 452 | { |
embeddedartists | 1:15ea03d72dd7 | 453 | circbuff[circbuff_write%CIRCBUFF_SIZE] = key; |
embeddedartists | 1:15ea03d72dd7 | 454 | circbuff_write++; |
embeddedartists | 1:15ea03d72dd7 | 455 | } |
embeddedartists | 1:15ea03d72dd7 | 456 | |
embeddedartists | 1:15ea03d72dd7 | 457 | #define KEY_TASK_PREFIX "[KEY] " |
embeddedartists | 1:15ea03d72dd7 | 458 | |
embeddedartists | 1:15ea03d72dd7 | 459 | void keyTask(void const* args) |
embeddedartists | 1:15ea03d72dd7 | 460 | { |
embeddedartists | 1:15ea03d72dd7 | 461 | usbInitGuard.lock(); |
embeddedartists | 1:15ea03d72dd7 | 462 | USBHostKeyboard* keyboard = new USBHostKeyboard(); |
embeddedartists | 1:15ea03d72dd7 | 463 | usbInitGuard.unlock(); |
embeddedartists | 1:15ea03d72dd7 | 464 | |
embeddedartists | 1:15ea03d72dd7 | 465 | RtosLog* log = DMBoard::instance().logger(); |
embeddedartists | 1:15ea03d72dd7 | 466 | uint8_t buff[10+1] = {0}; |
embeddedartists | 1:15ea03d72dd7 | 467 | int pos; |
embeddedartists | 1:15ea03d72dd7 | 468 | |
embeddedartists | 1:15ea03d72dd7 | 469 | log->printf(KEY_TASK_PREFIX"keyTask started\n"); |
embeddedartists | 1:15ea03d72dd7 | 470 | |
embeddedartists | 1:15ea03d72dd7 | 471 | while(1) { |
embeddedartists | 1:15ea03d72dd7 | 472 | |
embeddedartists | 1:15ea03d72dd7 | 473 | log->printf(KEY_TASK_PREFIX"Attempting to connect...\n"); |
embeddedartists | 1:15ea03d72dd7 | 474 | |
embeddedartists | 1:15ea03d72dd7 | 475 | // try to connect a keyboard |
embeddedartists | 1:15ea03d72dd7 | 476 | bool connected = false; |
embeddedartists | 1:15ea03d72dd7 | 477 | do { |
embeddedartists | 1:15ea03d72dd7 | 478 | usbInitGuard.lock(); |
embeddedartists | 1:15ea03d72dd7 | 479 | connected = keyboard->connect(); |
embeddedartists | 1:15ea03d72dd7 | 480 | usbInitGuard.unlock(); |
embeddedartists | 1:15ea03d72dd7 | 481 | if (!connected) { |
embeddedartists | 1:15ea03d72dd7 | 482 | //log->printf(KEY_TASK_PREFIX"Failed to connect, waiting and trying again!\n"); |
embeddedartists | 1:15ea03d72dd7 | 483 | Thread::wait(1000); |
embeddedartists | 1:15ea03d72dd7 | 484 | } |
embeddedartists | 1:15ea03d72dd7 | 485 | } while(!connected); |
embeddedartists | 1:15ea03d72dd7 | 486 | |
embeddedartists | 1:15ea03d72dd7 | 487 | log->printf(KEY_TASK_PREFIX"Connected!\n"); |
embeddedartists | 1:15ea03d72dd7 | 488 | keyboard->attach(keyEvent); |
embeddedartists | 1:15ea03d72dd7 | 489 | |
embeddedartists | 1:15ea03d72dd7 | 490 | while(keyboard->connected()) { |
embeddedartists | 1:15ea03d72dd7 | 491 | for (pos = 0; pos < 10; pos++) { |
embeddedartists | 1:15ea03d72dd7 | 492 | if (circbuff_read < circbuff_write) { |
embeddedartists | 1:15ea03d72dd7 | 493 | buff[pos++] = circbuff[circbuff_read%CIRCBUFF_SIZE]; |
embeddedartists | 1:15ea03d72dd7 | 494 | circbuff_read++; |
embeddedartists | 1:15ea03d72dd7 | 495 | } else { |
embeddedartists | 1:15ea03d72dd7 | 496 | break; |
embeddedartists | 1:15ea03d72dd7 | 497 | } |
embeddedartists | 1:15ea03d72dd7 | 498 | } |
embeddedartists | 1:15ea03d72dd7 | 499 | if (pos > 0) { |
embeddedartists | 1:15ea03d72dd7 | 500 | log->printf(KEY_TASK_PREFIX"%s\n", buff); |
embeddedartists | 1:15ea03d72dd7 | 501 | } |
embeddedartists | 1:15ea03d72dd7 | 502 | Thread::wait(20); |
embeddedartists | 1:15ea03d72dd7 | 503 | } |
embeddedartists | 1:15ea03d72dd7 | 504 | |
embeddedartists | 1:15ea03d72dd7 | 505 | log->printf(KEY_TASK_PREFIX"Disconnected\n"); |
embeddedartists | 1:15ea03d72dd7 | 506 | } |
embeddedartists | 1:15ea03d72dd7 | 507 | } |
embeddedartists | 1:15ea03d72dd7 | 508 | |
embeddedartists | 0:dfad71908d59 | 509 | /****************************************************************************** |
embeddedartists | 0:dfad71908d59 | 510 | * Main function |
embeddedartists | 0:dfad71908d59 | 511 | *****************************************************************************/ |
embeddedartists | 0:dfad71908d59 | 512 | int main() |
embeddedartists | 0:dfad71908d59 | 513 | { |
embeddedartists | 0:dfad71908d59 | 514 | DMBoard::BoardError err; |
embeddedartists | 0:dfad71908d59 | 515 | DMBoard* board = &DMBoard::instance(); |
embeddedartists | 0:dfad71908d59 | 516 | RtosLog* log = board->logger(); |
embeddedartists | 0:dfad71908d59 | 517 | err = board->init(); |
embeddedartists | 0:dfad71908d59 | 518 | if (err != DMBoard::Ok) { |
embeddedartists | 0:dfad71908d59 | 519 | log->printf("Failed to initialize the board, got error %d\r\n", err); |
embeddedartists | 0:dfad71908d59 | 520 | mbed_die(); |
embeddedartists | 0:dfad71908d59 | 521 | } |
embeddedartists | 0:dfad71908d59 | 522 | |
embeddedartists | 11:4830c7689843 | 523 | board->buzzer(440,50); |
embeddedartists | 11:4830c7689843 | 524 | wait_ms(30); |
embeddedartists | 11:4830c7689843 | 525 | board->buzzer(660,50); |
embeddedartists | 11:4830c7689843 | 526 | wait_ms(30); |
embeddedartists | 11:4830c7689843 | 527 | board->buzzer(440,50); |
embeddedartists | 11:4830c7689843 | 528 | |
embeddedartists | 0:dfad71908d59 | 529 | log->printf("\n\n---\nMulti-threaded demo\nBuilt: " __DATE__ " at " __TIME__ "\n\n"); |
embeddedartists | 0:dfad71908d59 | 530 | |
embeddedartists | 1:15ea03d72dd7 | 531 | //log->printf("Press button to start...\r\n"); |
embeddedartists | 1:15ea03d72dd7 | 532 | //while(!board->buttonPressed()); |
embeddedartists | 1:15ea03d72dd7 | 533 | //while(board->buttonPressed()); |
embeddedartists | 0:dfad71908d59 | 534 | |
embeddedartists | 0:dfad71908d59 | 535 | Thread tAlive(aliveTask); |
embeddedartists | 0:dfad71908d59 | 536 | #if defined(DM_BOARD_USE_DISPLAY) |
embeddedartists | 2:070e9c054796 | 537 | Thread tSwim(swimTask, NULL, osPriorityNormal, 8192); |
embeddedartists | 0:dfad71908d59 | 538 | #endif |
embeddedartists | 0:dfad71908d59 | 539 | Thread tMemstick(msdTask, NULL, osPriorityNormal, 8192); |
embeddedartists | 0:dfad71908d59 | 540 | Thread tNetwork(netTask, NULL, osPriorityNormal, 8192); |
embeddedartists | 1:15ea03d72dd7 | 541 | Thread tMouse(mouseTask); |
embeddedartists | 1:15ea03d72dd7 | 542 | Thread tKeyboard(keyTask); |
embeddedartists | 0:dfad71908d59 | 543 | |
embeddedartists | 0:dfad71908d59 | 544 | while(1) { wait(5); } |
embeddedartists | 0:dfad71908d59 | 545 | } |