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.
Main.cpp
00001 /* 00002 * Main.cpp 00003 * Copyright (c) 2020, ZHAW 00004 * All rights reserved. 00005 */ 00006 00007 #include <mbed.h> 00008 #include <EthernetInterface.h> 00009 #include "IMU.h" 00010 #include "TiltAngle.h" 00011 #include "HTTPServer.h" 00012 #include "HTTPScriptTiltAngle.h" 00013 00014 int main() { 00015 00016 // initialise digital inputs and outputs 00017 00018 printf("Initialise digital inputs and outputs...\r\n"); 00019 00020 DigitalIn button(USER_BUTTON); 00021 00022 DigitalOut ledGreen(LED1); 00023 DigitalOut ledBlue(LED2); 00024 DigitalOut ledRed(LED3); 00025 00026 // create inertial measurement unit object 00027 00028 printf("Create inertial measurement unit object...\r\n"); 00029 00030 SPI spi(PC_12, PC_11, PC_10); 00031 DigitalOut csAG(PC_8); 00032 DigitalOut csM(PC_9); 00033 00034 IMU imu(spi, csAG, csM); 00035 00036 TiltAngle tiltAngle(imu); 00037 00038 // create ethernet interface and webserver 00039 00040 printf("Create ethernet interface and webserver (please wait!)...\r\n"); 00041 00042 EthernetInterface* ethernet = new EthernetInterface(); 00043 ethernet->set_network("192.168.201.44", "255.255.255.0", "192.168.201.1"); // configure IP address, netmask and gateway address 00044 ethernet->connect(); 00045 00046 HTTPServer* httpServer = new HTTPServer(*ethernet); 00047 httpServer->add("tiltAngle", new HTTPScriptTiltAngle(tiltAngle)); 00048 00049 // enter main loop 00050 00051 printf("Enter main loop...\r\n"); 00052 00053 while (true) { 00054 00055 // set LEDs on microcontroller 00056 00057 ledGreen = 1; 00058 ledBlue = 0; 00059 ledRed = 0; 00060 00061 ThisThread::sleep_for(100); 00062 00063 ledGreen = 0; 00064 ledBlue = 1; 00065 ledRed = 0; 00066 00067 ThisThread::sleep_for(100); 00068 00069 ledGreen = 0; 00070 ledBlue = 0; 00071 ledRed = 1; 00072 00073 ThisThread::sleep_for(100); 00074 00075 ledGreen = 0; 00076 ledBlue = 0; 00077 ledRed = 0; 00078 00079 // print data into terminal 00080 00081 printf("TiltAngle: %.3f\r\n", tiltAngle.readTiltAngleK()); 00082 } 00083 } 00084
Generated on Fri Jul 29 2022 01:28:48 by
1.7.2