Charles Tritt / Mbed 2 deprecated NoHeaderTest

Dependencies:   mbed

Fork of HeaderTest by Charles Tritt

Files at this revision

API Documentation at this revision

Comitter:
CSTritt
Date:
Fri Oct 20 01:22:53 2017 +0000
Parent:
0:cc014c610423
Commit message:
Initial version. A blink example with all code in one file. Compare to HeaderTest.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
myProj.h Show diff for this revision Revisions of this file
myStuff.cpp Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Oct 19 21:05:11 2017 +0000
+++ b/main.cpp	Fri Oct 20 01:22:53 2017 +0000
@@ -1,10 +1,10 @@
 /*
-  Project: HeaderTest
+  Project: NoHeaderTest
   File: main.cpp
   Last revised by: Dr. C. S. Tritt
   Last revision on: 9/19/17 (v. 1.0)
   
-  Repeatedly toggles on-board LED.
+  Repeatedly toggles on-board LED. Demonstrates single file project approach.
  
   This example code is in the public domain.
 */
@@ -13,14 +13,15 @@
 // must also be added to the project either by importing it or by "Fixing" the
 // error that is generated when it has not been imported.
 #include "mbed.h"
-// Use this type of #include to include your own custom header files. Typically 
-// 1 per project or library. 
-#include <myProj.h>
+
 // Mbed driver class objects are typically declared and defined as global.
 DigitalOut board_LED(LED1);
-// Define global variables here.
+
 const float BASE_WAIT = 0.1;
 int cycles = 1;
+
+void myStuff(void); // Declared here, defined after main.
+
 /*  The "main" function defines your main program -- it executes as soon as
     you program the board.
 */  
@@ -32,4 +33,10 @@
             cycles = 1;
         }
     }
+}
+
+void myStuff(void) {
+    board_LED = !board_LED; // Toggle LED state.
+    wait(BASE_WAIT * (float) cycles); // Wait varying intervals.
+    cycles++; // Slowly slow down flash rate.
 }
\ No newline at end of file
--- a/myProj.h	Thu Oct 19 21:05:11 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-/*
-  Project: HeaderTest
-  File: myProj.h
-  Last revised by: Dr. C. S. Tritt
-  Last revision on: 10/19/17 (v. 1.0)
-  
-  This is the header files for the HeaderTest project. It declares stuff that
-  will be used in/by multiple cpp files.
-*/
-// Declare mbed objects. The extern indicates it is defined elsewhere (main.cpp
-// in this case).
-extern DigitalOut board_LED;
-// Declare global variables (extern required to avoid errors).
-extern const float BASE_WAIT; // Defined in main.cpp.
-extern int cycles; // Defined in main.cpp.
-// Declare your function(s.
-void myStuff(void); // Defined in myStuff.cpp.
\ No newline at end of file
--- a/myStuff.cpp	Thu Oct 19 21:05:11 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-/*
-  Project: HeaderTest
-  File: myStuff.cpp
-  Last revised by: Dr. C. S. Tritt
-  Last revision on: 10/19/17 (v. 1.0)
-  
-  This is the source file for the myStuff function. It toggles the LED.
-*/
-// See include comments in main.cpp and myProj.h.
-#include "mbed.h"
-#include <myProj.h>
-
-void myStuff(void) {
-    board_LED = !board_LED; // Toggle LED state.
-    wait(BASE_WAIT * (float) cycles); // Wait varying intervals.
-    cycles++; // Slowly slow down flash rate.
-}
\ No newline at end of file