Generates a test signal on an AnalogOut and monitors a signal on an AnalogIn, plotting the test signal or the actual signal depending on a conditional compile. The wait() and wait_ms() library calls for this board are highly inaccurate so a new function is provided to wait for X number of milliseconds -- which is not very accurate.

Dependencies:   LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI mbed-os BSP_DISCO_F429ZI

LaserMon-Main.cpp

Committer:
Damotclese
Date:
2019-06-14
Revision:
1:b9d4b9b8884c
Parent:
0:1ebe7d222470
Child:
2:cbcf2695a4a1

File content as of revision 1:b9d4b9b8884c:


// ----------------------------------------------------------------------
// LaserMon-Main.cpp
//
// Fredric L. Rice, June 2019
//
// ----------------------------------------------------------------------

#include "mbed.h"                   // The mbed operating system
#include "LCD_DISCO_F429ZI.h"       // For controlling the LCD
#include "TS_DISCO_F429ZI.h"        // For controlling the touch screen
#include "LaserMon-TestOutput.h"    // For generating test output signal
#include "LaserMon-ScanInput.h"     // For monitoring laser power pin
#include "LaserMon-Main.h"          // Always include ourself

// ----------------------------------------------------------------------
// Local data storage
//
// ----------------------------------------------------------------------

    const char * pch_firstMessage  = "Test signal on PA_5";
    const char * pch_secondMessage = "Laser Scan on PC_1";

// ----------------------------------------------------------------------
// Define global data storage which we will export
//
// ----------------------------------------------------------------------

    // We will be using the LCD so instantiate an object locally
    LCD_DISCO_F429ZI st_lcd;

    // We will be using the touch screen so instantiate an object
    TS_DISCO_F429ZI st_touchScreen;
    
// ----------------------------------------------------------------------
// MainInit()
//
// ----------------------------------------------------------------------
static void MainInit(void)
{
    // Bring the LCD up 
    st_lcd.Clear(LCD_COLOR_WHITE);
    
    // Set the default text color
    st_lcd.SetTextColor(LCD_COLOR_BLUE);
    
    // Set the background color
    st_lcd.SetBackColor(LCD_COLOR_WHITE);        

    // Set the default font size
    BSP_LCD_SetFont(&Font16);
}

// ----------------------------------------------------------------------
// main()
//
//
// ----------------------------------------------------------------------
int main(void)
{
    // Perform local module initialization, if any
    MainInit();
    
    // Start generating the putput test signal
    TestOutputInit();
    
    // Start scanning the laser drive power
    ScanInputInit();
    
    // Display information about what signal pigs have what
    st_lcd.DisplayStringAt(1, LINE(1), (uint8_t *)pch_firstMessage, LEFT_MODE);
    st_lcd.DisplayStringAt(1, LINE(2), (uint8_t *)pch_secondMessage, LEFT_MODE);
    
    // Go in to a forever loop for the main thread which does nothing
    while(true)
    {
        // Wait for 1 millisecond
        wait_us(899);
        TestOutputThread();
        ScanInputThread();
    }
}

// End of file