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: SDFileSystem mbed
Fork of shomberg_hw_6 by
Revision 12:ea407dcaff78, committed 2018-10-25
- Comitter:
- rshomberg
- Date:
- Thu Oct 25 22:43:36 2018 +0000
- Parent:
- 11:42914083ac70
- Child:
- 13:fa74bf0c3b8d
- Commit message:
- made SegWrite function and moved pin assignments to header files. This does not work.
Changed in this revision
--- a/OCE360Input.cpp Thu Oct 25 18:58:41 2018 +0000 +++ b/OCE360Input.cpp Thu Oct 25 22:43:36 2018 +0000 @@ -19,11 +19,10 @@ // DEFINES #define VREF 3.5 -#define TEMP_CALIBRATION_A 0.01 +#define TEMP_CALIBRATION_A 0.1 #define TEMP_CALIBRATION_B 0 -DigitalIn myswitch(p7); -AnalogIn Ain(p20); + int switchPosition; int sensorVoltage;
--- a/OCE360Input.h Thu Oct 25 18:58:41 2018 +0000 +++ b/OCE360Input.h Thu Oct 25 22:43:36 2018 +0000 @@ -2,7 +2,8 @@ #define OCE360INPUT_H #include "mbed.h" - +DigitalIn myswitch(p7); +AnalogIn Ain(p20); int read_switch(void);
--- a/SegDisplay.cpp Thu Oct 25 18:58:41 2018 +0000 +++ b/SegDisplay.cpp Thu Oct 25 22:43:36 2018 +0000 @@ -22,8 +22,10 @@ #include "mbed.h" #include "SegDisplay.h" -BusOut Seg1(p12,p13,p14,p15,p16,p17,p18,p19); //01 02 03 04 05 06 07 08 09 10 -BusOut Seg2(p21,p22,p23,p24,p25,p26,p27,p28); //E D CC C DP B A CC F G +int ones; +int tens; + + char SegConvert(int SegValue) { // function 'SegConvert' char SegByte=0x00; @@ -40,4 +42,13 @@ case 9 : SegByte= 0x6F;break; // 11011110 binary } return ~SegByte; +} + +void SegWrite(float val){ + // Convert val to ones and tens char + ones = fmod(rint(val),10); + tens = fmod(rint(val) / 10, 10); + + Seg1 = SegConvert(ones); + Seg2 = SegConvert(tens); } \ No newline at end of file
--- a/SegDisplay.h Thu Oct 25 18:58:41 2018 +0000 +++ b/SegDisplay.h Thu Oct 25 22:43:36 2018 +0000 @@ -4,9 +4,11 @@ #include "mbed.h" // INPUTS -extern BusOut Seg1; //01 02 03 04 05 06 07 08 09 10 -extern BusOut Seg2; //E D CC C DP B A CC F G +BusOut Seg1(p12,p13,p14,p15,p16,p17,p18,p19); //01 02 03 04 05 06 07 08 09 10 +BusOut Seg2(p21,p22,p23,p24,p25,p26,p27,p28); //E D CC C DP B A CC F G char SegConvert(int SegValue); +void SegWrite(float val); + #endif \ No newline at end of file
--- a/main.cpp Thu Oct 25 18:58:41 2018 +0000 +++ b/main.cpp Thu Oct 25 22:43:36 2018 +0000 @@ -30,8 +30,6 @@ float v0; float deltav; float val; -int ones; -int tens; int main() { @@ -55,15 +53,8 @@ //printf("Voltage Difference = %1.2f mV\n\r", val); } - // Convert val to ones and tens char - ones = fmod(rint(val),10); - tens = fmod(rint(val) / 10, 10); - - - Seg1 = SegConvert(ones); - Seg2 = SegConvert(tens); - - + SegWrite(val); + wait(1); }