lib for realteimMM funcs

Committer:
GTNicholson
Date:
Fri Feb 16 10:03:35 2018 +0000
Revision:
5:3906f93b8b39
Parent:
4:af34fda1dfb0
Changing Pin assignment

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GTNicholson 0:9f82ee1feae7 1
GTNicholson 0:9f82ee1feae7 2 #include "MBedStation.h"
GTNicholson 0:9f82ee1feae7 3 #include "sensor_base.h"
GTNicholson 0:9f82ee1feae7 4 #include "qeihw.h"
GTNicholson 0:9f82ee1feae7 5 #include <cstdint>
GTNicholson 0:9f82ee1feae7 6
GTNicholson 0:9f82ee1feae7 7
GTNicholson 5:3906f93b8b39 8 MBedStation::MBedStation() :light_1(p22), light_2(p23)
GTNicholson 0:9f82ee1feae7 9 {
ChrisAydon 1:b80e5f26b233 10
GTNicholson 0:9f82ee1feae7 11 }
GTNicholson 0:9f82ee1feae7 12
GTNicholson 0:9f82ee1feae7 13 //sensor_base MBed::sensors[1]
GTNicholson 0:9f82ee1feae7 14
GTNicholson 0:9f82ee1feae7 15 void MBedStation::setup()
GTNicholson 0:9f82ee1feae7 16 {
GTNicholson 0:9f82ee1feae7 17
GTNicholson 0:9f82ee1feae7 18 sensor_onoff sensor0(p5);
GTNicholson 0:9f82ee1feae7 19 sensor0.sensor_id = 1;
GTNicholson 0:9f82ee1feae7 20 sensor0.enabled = true;
GTNicholson 0:9f82ee1feae7 21 MBedStation::sensors[0] = sensor0;
GTNicholson 0:9f82ee1feae7 22 sensor_0 = sensor0;
GTNicholson 0:9f82ee1feae7 23
GTNicholson 0:9f82ee1feae7 24 sensor_vin sensor1(p15);
GTNicholson 0:9f82ee1feae7 25 sensor1.sensor_id = 2;
GTNicholson 0:9f82ee1feae7 26 sensor1.enabled = true;
GTNicholson 0:9f82ee1feae7 27 MBedStation::sensors[1] = sensor1;
GTNicholson 0:9f82ee1feae7 28 sensor_1 = sensor1;
GTNicholson 0:9f82ee1feae7 29
GTNicholson 0:9f82ee1feae7 30 sensor_vin sensor2(p16);
GTNicholson 0:9f82ee1feae7 31 sensor2.sensor_id = 3;
GTNicholson 0:9f82ee1feae7 32 sensor2.enabled = true;
GTNicholson 0:9f82ee1feae7 33 MBedStation::sensors[2] = sensor2;
GTNicholson 0:9f82ee1feae7 34 sensor_2 = sensor2;
GTNicholson 0:9f82ee1feae7 35
GTNicholson 5:3906f93b8b39 36 DigitalOut light1(p22);
ChrisAydon 1:b80e5f26b233 37 light_1 = light1;
ChrisAydon 1:b80e5f26b233 38
GTNicholson 5:3906f93b8b39 39 DigitalOut light2(p23);
ChrisAydon 1:b80e5f26b233 40 light_2 = light2;
ChrisAydon 1:b80e5f26b233 41
GTNicholson 0:9f82ee1feae7 42 /*
GTNicholson 0:9f82ee1feae7 43 sensor_pulse sensor3(p6);
GTNicholson 0:9f82ee1feae7 44 sensor3.sensor_id = 4;
GTNicholson 0:9f82ee1feae7 45 sensor3.enabled = true;
GTNicholson 0:9f82ee1feae7 46 MBedStation::sensors[3] = sensor3;
GTNicholson 0:9f82ee1feae7 47 sensor_3 = sensor3;
GTNicholson 3:13301255d95a 48
GTNicholson 3:13301255d95a 49
GTNicholson 3:13301255d95a 50 sensor_max6675 sensor4(p11,p12,p13,p18);
GTNicholson 3:13301255d95a 51 sensor4.sensor_id = 5;
GTNicholson 3:13301255d95a 52 sensor4.enabled = true;
GTNicholson 3:13301255d95a 53 MBedStation::sensors[4] = sensor4;
GTNicholson 3:13301255d95a 54 sensor_4 = sensor4;
GTNicholson 3:13301255d95a 55
GTNicholson 3:13301255d95a 56
GTNicholson 3:13301255d95a 57 sensor_max6675 sensor5(p11,p12,p13,p17);
GTNicholson 3:13301255d95a 58 sensor5.sensor_id = 6;
GTNicholson 3:13301255d95a 59 sensor5.enabled = true;
GTNicholson 3:13301255d95a 60 MBedStation::sensors[5] = sensor5;
GTNicholson 3:13301255d95a 61 sensor_5 = sensor5;
GTNicholson 3:13301255d95a 62 */
GTNicholson 3:13301255d95a 63
GTNicholson 0:9f82ee1feae7 64 }
ChrisAydon 1:b80e5f26b233 65
ChrisAydon 1:b80e5f26b233 66 int MBedStation::ProcessResponse(char * Response)
ChrisAydon 1:b80e5f26b233 67 {
ChrisAydon 1:b80e5f26b233 68 int led_response;
ChrisAydon 1:b80e5f26b233 69 led_response = atoi(Response);
ChrisAydon 1:b80e5f26b233 70 if (led_response == 1 or led_response == 3)
ChrisAydon 1:b80e5f26b233 71 {
ChrisAydon 1:b80e5f26b233 72 light_1 = 1;
ChrisAydon 1:b80e5f26b233 73 }
ChrisAydon 1:b80e5f26b233 74 else
ChrisAydon 1:b80e5f26b233 75 {
ChrisAydon 1:b80e5f26b233 76 light_1 =0;
ChrisAydon 1:b80e5f26b233 77 }
ChrisAydon 1:b80e5f26b233 78
ChrisAydon 1:b80e5f26b233 79 if (led_response == 2 or led_response == 3)
ChrisAydon 1:b80e5f26b233 80 {
ChrisAydon 1:b80e5f26b233 81 light_2 = 1;
ChrisAydon 1:b80e5f26b233 82 }
ChrisAydon 1:b80e5f26b233 83 else
ChrisAydon 1:b80e5f26b233 84 {
ChrisAydon 1:b80e5f26b233 85 light_2 =0;
ChrisAydon 1:b80e5f26b233 86 }
ChrisAydon 1:b80e5f26b233 87 return 1;
ChrisAydon 1:b80e5f26b233 88 }