Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DMBasicGUI DMSupport
Demo running on several LPC4088 Display Modules on the Embedded World 2015 exhibition.
Information
To run the demo first drag-n-drop the to_sync.fs3 file to the MBED drive and then drag-n-drop the demo itself. This way both the file system and software are up to date.
This is what the launcher will look like:

Revision 1:1a01ef434a72, committed 2019-11-05
- Comitter:
- embeddedartists
- Date:
- Tue Nov 05 08:20:16 2019 +0000
- Parent:
- 0:6bd24cbb88a1
- Commit message:
- Updates related to mbed OS 5
Changed in this revision
--- a/AppLauncherSpecial.cpp Thu Feb 19 13:54:53 2015 +0000
+++ b/AppLauncherSpecial.cpp Tue Nov 05 08:20:16 2019 +0000
@@ -161,16 +161,20 @@
// Render the current time in the upper right corner once every second
bool updateClock = false;
- RtosTimer updateClockTimer(onTimeoutEvent, osTimerPeriodic, &updateClock);
- updateClockTimer.start(1000);
+ //RtosTimer updateClockTimer(onTimeoutEvent, osTimerPeriodic, &updateClock);
+ //updateClockTimer.start(1000);
+ EventQueue updateClockTimer(4*EVENTS_EVENT_SIZE);
+ int updateClockTimerId = updateClockTimer.call_in(1000, onTimeoutEvent, &updateClock);
// To keep track of the button pushes
bool buttonPressed = false;
bool buttonTimeout = false;
InterruptIn button(P2_10);
- button.rise(this, &AppLauncherSpecial::onButtonEvent);
- button.fall(this, &AppLauncherSpecial::onButtonEvent);
- RtosTimer buttonTimer(onTimeoutEvent, osTimerOnce, &buttonTimeout);
+ button.rise(callback(this, &AppLauncherSpecial::onButtonEvent));
+ button.fall(callback(this, &AppLauncherSpecial::onButtonEvent));
+
+ EventQueue buttonTimer(4*EVENTS_EVENT_SIZE);
+ int buttonTimerId = buttonTimer.call_in(2000, onTimeoutEvent, &buttonTimeout);
// To prevent the "exit" click of a launched application to launch
// a new application. This could happen on a multitouch display if
@@ -181,15 +185,15 @@
// Wait for touches
TouchPanel* touch = board->touchPanel();
- FunctionPointer* fpOld = touch->setListener(new FunctionPointer(this, &AppLauncherSpecial::onTouchEvent));
+ touch->setListener(callback(this, &AppLauncherSpecial::onTouchEvent));
touch_coordinate_t coord;
while (true) {
- Thread::signal_wait(APP_SIGID_TOUCH);
+ ThisThread::flags_wait_all(APP_SIGID_TOUCH);
if (_newTouchEvent) {
if (buttonPressed) {
// cancel
buttonPressed = false;
- buttonTimer.stop();
+ buttonTimer.cancel(buttonTimerId);
}
_newTouchEvent = false;
if (touch->read(coord) != TouchPanel::TouchError_Ok) {
@@ -214,10 +218,10 @@
_newButtonEvent = false;
if (board->buttonPressed()) {
buttonPressed = true;
- buttonTimer.start(2000);
+ buttonTimer.dispatch(0);
} else {
buttonPressed = false;
- buttonTimer.stop();
+ buttonTimer.cancel(buttonTimerId);
}
continue;
} else if (updateClock) {
@@ -249,9 +253,6 @@
}
}
- // restore old touch listener (get our listener in return)
- fpOld = touch->setListener(fpOld);
- delete fpOld;
}
bool AppLauncherSpecial::teardown()
--- a/AppStatus.cpp Thu Feb 19 13:54:53 2015 +0000
+++ b/AppStatus.cpp Tue Nov 05 08:20:16 2019 +0000
@@ -103,9 +103,9 @@
swim_put_text_xy(_win, ethUsingDHCP?"DHCP":"Static IP", ITEM_VALUE_X_OFF-20, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 5);
if (ethInitialized) {
- swim_put_text_xy(_win, eth.getIPAddress(), ITEM_VALUE_X_OFF-20, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 6);
- swim_put_text_xy(_win, eth.getNetworkMask(), ITEM_VALUE_X_OFF-20, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 7);
- swim_put_text_xy(_win, eth.getGateway(), ITEM_VALUE_X_OFF-20, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 8);
+ swim_put_text_xy(_win, eth.get_ip_address(), ITEM_VALUE_X_OFF-20, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 6);
+ swim_put_text_xy(_win, eth.get_netmask(), ITEM_VALUE_X_OFF-20, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 7);
+ swim_put_text_xy(_win, eth.get_gateway(), ITEM_VALUE_X_OFF-20, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 8);
//swim_put_text_xy(_win, eth.getMACAddress(), ITEM_VALUE_X_OFF, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 4);
} else {
swim_put_text_xy(_win, "Not Initialized", ITEM_VALUE_X_OFF-20, HEADER_Y_SPACING + ITEM_CAPTION_Y_SPACING * 6);
--- a/DMBasicGUI.lib Thu Feb 19 13:54:53 2015 +0000 +++ b/DMBasicGUI.lib Tue Nov 05 08:20:16 2019 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/teams/Embedded-Artists/code/DMBasicGUI/#53601973f7eb +http://developer.mbed.org/teams/Embedded-Artists/code/DMBasicGUI/#f0d00f29bfeb
--- a/DMSupport.lib Thu Feb 19 13:54:53 2015 +0000 +++ b/DMSupport.lib Tue Nov 05 08:20:16 2019 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/teams/Embedded-Artists/code/DMSupport/#8a0a99d54bf8 +http://developer.mbed.org/teams/Embedded-Artists/code/DMSupport/#bbfe299d4a0c
--- a/image_data.h Thu Feb 19 13:54:53 2015 +0000 +++ b/image_data.h Tue Nov 05 08:20:16 2019 +0000 @@ -1,4 +1,3 @@ -#include "basic_image_data.h" extern const unsigned char img_arrow_down[]; extern const unsigned int img_size_arrow_down; @@ -63,3 +62,13 @@ extern const unsigned char img_about[]; extern const unsigned int img_size_about; +extern const unsigned char img_ok[]; +extern const unsigned int img_size_ok; + +extern const unsigned char img_cancel[]; +extern const unsigned int img_size_cancel; + +extern const unsigned char img_repeat[]; +extern const unsigned int img_size_repeat; + +
--- a/main.cpp Thu Feb 19 13:54:53 2015 +0000
+++ b/main.cpp Tue Nov 05 08:20:16 2019 +0000
@@ -7,7 +7,6 @@
#include "rtos.h"
#include "EthernetInterface.h"
#include "HTTPServer.h"
-#include "mbed_rpc.h"
#include "USBHostMSD.h"
#include "USBHostMouse.h"
#include "USBHostKeyboard.h"
@@ -50,7 +49,7 @@
* Local functions
*****************************************************************************/
-void aliveTask(void const* args)
+void aliveTask(void)
{
DMBoard* board = &DMBoard::instance();
@@ -58,16 +57,16 @@
{
board->setLED(DMBoard::Led4, false);
board->setLED(DMBoard::Led1, true);
- Thread::wait(300);
+ ThisThread::sleep_for(300);
board->setLED(DMBoard::Led1, false);
board->setLED(DMBoard::Led2, true);
- Thread::wait(300);
+ ThisThread::sleep_for(300);
board->setLED(DMBoard::Led2, false);
board->setLED(DMBoard::Led3, true);
- Thread::wait(300);
+ ThisThread::sleep_for(300);
board->setLED(DMBoard::Led3, false);
board->setLED(DMBoard::Led4, true);
- Thread::wait(300);
+ ThisThread::sleep_for(300);
}
}
@@ -125,7 +124,7 @@
}
#define SWIM_TASK_PREFIX "[SWIM] "
-void swimTask(void const* args)
+void swimTask(void)
{
RtosLog* log = DMBoard::instance().logger();
@@ -162,34 +161,30 @@
#define NET_TASK_PREFIX "[NET] "
-void netTask(void const* args)
+void netTask(void)
{
RtosLog* log = DMBoard::instance().logger();
log->printf(NET_TASK_PREFIX"EthernetInterface Setting up...\r\n");
- if(eth.init()!=0) { //for DHCP Server
- //if(eth.init(IPAddress,NetMasks,Gateway)!=0) { //for Static IP Address
- log->printf(NET_TASK_PREFIX"EthernetInterface Initialize Error \r\n");
- mbed_die();
+ nsapi_error_t net_err = eth.connect();
+
+ if (net_err != NSAPI_ERROR_OK) {
+ log->printf(NET_TASK_PREFIX"EthernetInterface connect Error %d\r\n", net_err);
}
- while (eth.connect() != 0) {
- Thread::wait(1000);
- }
+ else {
- ethInitialized = true;
- ethUsingDHCP = true;
+ ethInitialized = true;
+ ethUsingDHCP = true;
- log->printf(NET_TASK_PREFIX"IP Address is %s\r\n", eth.getIPAddress());
- log->printf(NET_TASK_PREFIX"NetMask is %s\r\n", eth.getNetworkMask());
- log->printf(NET_TASK_PREFIX"Gateway Address is %s\r\n", eth.getGateway());
- log->printf(NET_TASK_PREFIX"Ethernet Setup OK\r\n");
+ log->printf(NET_TASK_PREFIX"IP Address is %s\r\n", eth.get_ip_address());
+ log->printf(NET_TASK_PREFIX"NetMask is %s\r\n", eth.get_netmask());
+ log->printf(NET_TASK_PREFIX"Gateway Address is %s\r\n", eth.get_gateway());
+ log->printf(NET_TASK_PREFIX"Ethernet Setup OK\r\n");
- HTTPServerAddHandler<SimpleHandler>("/hello"); //Default handler
- FSHandler::mount("/usb", "/");
- HTTPServerAddHandler<FSHandler>("/");
- //HTTPServerAddHandler<RPCHandler>("/rpc");
- //lcd.locate(0,0);
- //lcd.printf("%s",eth.getIPAddress());
- HTTPServerStart(80);
+ HTTPServerAddHandler<SimpleHandler>("/hello"); //Default handler
+ FSHandler::mount("/mci", "/");
+ HTTPServerAddHandler<FSHandler>("/");
+ HTTPServerStart(80);
+ }
}
static volatile int8_t mouse_button, mouse_x, mouse_y, mouse_z;
@@ -338,13 +333,14 @@
#define USB_TASK_PREFIX "[USB] "
#define USB_CONNECTION_EVENT (1<<4)
-void usbTask(void const* args)
+void usbTask(void)
{
USBHostMSD* msd = new USBHostMSD("usb");
USBHostKeyboard* keyboard = new USBHostKeyboard();
USBHostMouse* mouse = new USBHostMouse();
USBHost* host = USBHost::getHostInst();
- host->signalOnConnections(Thread::gettid(), USB_CONNECTION_EVENT);
+ EventFlags connectionEvent;
+ host->signalOnConnections(&connectionEvent, USB_CONNECTION_EVENT);
RtosLog* log = DMBoard::instance().logger();
@@ -354,7 +350,7 @@
while (true) {
// wait for connect/disconnect message from USBHost
- Thread::signal_wait(USB_CONNECTION_EVENT);
+ connectionEvent.wait_any(USB_CONNECTION_EVENT);
log->printf(USB_TASK_PREFIX"got USB event\n");
if (msd->connected()) {
@@ -432,30 +428,34 @@
if (err != DMBoard::Ok) {
log->printf("Failed to initialize the board, got error %d\r\n", err);
log->printf("\nTERMINATING\n");
- wait_ms(2000); // allow RtosLog to flush messages
+ ThisThread::sleep_for(2000); // allow RtosLog to flush messages
mbed_die();
}
board->buzzer(440,50);
- wait_ms(30);
+ ThisThread::sleep_for(30);
board->buzzer(660,50);
- wait_ms(30);
+ ThisThread::sleep_for(30);
board->buzzer(440,50);
log->printf("\n\n---\nDemo for Embedded World 2015\nBuilt: " __DATE__ " at " __TIME__ "\n\n");
- Thread tAlive(aliveTask);
+ Thread tAlive;
+ tAlive.start(aliveTask);
#if defined(DM_BOARD_USE_DISPLAY)
- Thread tSwim(swimTask, NULL, osPriorityNormal, 8192);
+ Thread tSwim(osPriorityNormal, 8192);
+ tSwim.start(swimTask);
#endif
- Thread tNetwork(netTask, NULL, osPriorityNormal, 8192);
- Thread tUSBHandler(usbTask, NULL, osPriorityNormal, 8192);
+ Thread tNetwork(osPriorityNormal, 8192);
+ tNetwork.start(netTask);
+ Thread tUSBHandler(osPriorityNormal, 8192);
+ tUSBHandler.start(usbTask);
while(1) {
// Wait forever (in 1h increments) to prevent the tAlive, tSwim,
// tNetwork and tUSBHandler thread from being garbage collected.
- Thread::wait(3600*1000);
+ ThisThread::sleep_for(3600*1000);
}
}