GroupA / Mbed 2 deprecated WaG_final

Dependencies:   mbed

Fork of Lab_6_WaG by GroupA

main.cpp

Committer:
spm71
Date:
2018-03-02
Revision:
18:0e281922212c
Parent:
17:75d567b60214
Child:
20:d23bcd97f2c5

File content as of revision 18:0e281922212c:

/******************************************************************************
* EECS 397
*
* Assignment Name: Lab 5: WaG
* 
* Authors: Sam Morrison and Phong Nguyen 
* File name: main.cpp
* Purpose: Configures the dispaly for 4-digit display
*
* Created: 03/01/2018
* Last Modified: 03/02/2018
*
******************************************************************************/
#include "mbed.h"
#include "io_pins.h"
#include "display.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int data_length = 16;
int frequency = 1000000;

DigitalOut SS(DSP_AS1107_NCS);
SPI wag_spi(MOSI, MISO, SCLK);
Serial pc(USBTX, USBRX);

int main(void) {
    initial_setup(SS, data_length, frequency);
    char bcd[4];
    int input;
    while(1) { //clears bcd array
        for (int i = 0; i < 4; i++)
            bcd[i] = 0;
        input = 0;
        pc.printf("Select a digit between 0 and 9999:\n");
        pc.scanf("%d", &input);
        
        while (input < 0 or input > 9999) { //ask for input until 0-9999 is selected
            pc.printf("You entered a number out of range\n");
            pc.printf("Select a digit between 0 and 9999:\n");
            input = 0;
            pc.scanf("%d", &input);
        }
        
        
        printf("you entered: %d\n", input);
        bin2bcd_array(input, bcd);
        
        send_command_to_display(bcd);
    }
}