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.
Dependencies: mbed
Fork of WaG by
Diff: display.cpp
- Revision:
- 8:d8bc78bda829
- Parent:
- 7:161fe3793ddb
- Child:
- 9:06c0d5737e5c
--- a/display.cpp Thu Feb 22 02:06:07 2018 +0000 +++ b/display.cpp Thu Feb 22 03:10:01 2018 +0000 @@ -11,6 +11,92 @@ * Last Modified: 02/21/2018 * ******************************************************************************/ +#include "mbed.h" +#include "io_pins.h" +#include "display.h" +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +int bcd[4]; + + +/* + * void initial_setup(DigitalOut SS, int data_length, int frequency); + * Description: setup spi data length (in bit), spi frequency, set LED + * display to normal operation, and set all display numbers + * to 0. + * + * Inputs: + * Parameters: + * SPI spi: spi object + * DigitalOut SS: chip select pin + * int data_length: spi data length in bit + * int frequency: frequency of SPI communication + * + * Outputs: + * Returns: void +*/ +void initial_setup(DigitalOut SS, int data_length, int frequency) { + SS = 1; + spi.format(data_length, 0); + spi.frequency(frequency); + + SS = 0; + spi.write(0x0C01); //normal operation + SS = 1; + + SS = 0; + spi.write(0x090F); //decode to bits 0:3 + SS = 1; + + SS = 0; + spi.write(0x0F00); //set to normal mode + SS = 1; + + SS = 0; + spi.write(0x0A0F); //intensity set to max + SS = 1; + + SS = 0; + spi.write(0x0B04); //display digits 0:4 + SS = 1; + + SS = 0; + spi.write(0x0100); //set digit 1 to 0 + SS = 1; + + SS = 0; + spi.write(0x0200); //set digit 2 to 0 + SS = 1; + + SS = 0; + spi.write(0x0300); //set digit 3 to 0 + SS = 1; + + SS = 0; + spi.write(0x0400); //set digit 4 to 0 + SS = 1; + + SS = 0; + spi.write(0x0500); //set digit 5 to 0 + SS = 1; +} + +/* + * void mod_bcd(int num); + * Description: + * + * Inputs: + * Parameters: + * int num: + * Globals: + * + * Outputs: + * Parameters: + * Globals: + * Returns: void +*/ void mod_bcd(int num) { int size = 4; int dec_arr[size]; @@ -26,6 +112,20 @@ } } +/* + * int convert(int dec); + * Description: + * + * Inputs: + * Parameters: + * int dec: + * Globals: + * + * Outputs: + * Parameters: + * Globals: + * Returns: void +*/ int convert(int dec) {//convert decimal to binary if (dec == 0) //function complete return 0; @@ -33,6 +133,21 @@ return (dec % 2 + 10 * convert(dec / 2)); } +/* + * char to_command(char input, int place); + * Description: + * + * Inputs: + * Parameters: + * char input: + * int place: + * Globals: + * + * Outputs: + * Parameters: + * Globals: + * Returns: char +*/ char to_command(char input, int place) { - + return 'a'; } \ No newline at end of file