06-05 ModularCodeExample
From Manuals
This program is an example that uses modular code. It performs the same function as Example 6.3. Using modular code allows programmers to reuse code.
/* Program Example 6.5: main.cpp file for modular 7-seg keyboard controller
This example program includes example code PE6.06, PE6.07, PE6.08, PE6.09
*/
#include "mbed.h"
#include "HostIO.h"
#include "SegDisplay.h"
char data1, data2; // variable declarations
int main() { // main program
SegInit(); // call init function
HostInit(); // call init function
while (1) { // infinite loop
data2 = GetKeyInput(); // call to get 1st key press
Seg2 = SegConvert(data2); // call to convert and output
data1 = GetKeyInput(); // call to get 2nd key press
Seg1 = SegConvert(data1); // call to convert and output
pc.printf(" "); // display spaces on host
}
}
File:BAM210 06 05 SCH.png
Schematic for example 06-05
