Red Light Work
Fork of realtimeMMLib by
Embed:
(wiki syntax)
Show/hide line numbers
MBedStation.cpp
00001 00002 #include "MBedStation.h" 00003 #include "sensor_base.h" 00004 #include "qeihw.h" 00005 #include <cstdint> 00006 00007 00008 MBedStation::MBedStation() :light_1(p17), light_2(LED4) 00009 { 00010 00011 } 00012 00013 //sensor_base MBed::sensors[1] 00014 00015 void MBedStation::setup() 00016 { 00017 00018 sensor_onoff sensor0(p5); 00019 sensor0.sensor_id = 1; 00020 sensor0.enabled = true; 00021 MBedStation::sensors[0] = sensor0; 00022 sensor_0 = sensor0; 00023 00024 sensor_vin sensor1(p15); 00025 sensor1.sensor_id = 2; 00026 sensor1.enabled = true; 00027 MBedStation::sensors[1] = sensor1; 00028 sensor_1 = sensor1; 00029 00030 sensor_vin sensor2(p16); 00031 sensor2.sensor_id = 3; 00032 sensor2.enabled = true; 00033 MBedStation::sensors[2] = sensor2; 00034 sensor_2 = sensor2; 00035 00036 DigitalOut light1(p17); 00037 light_1 = light1; 00038 00039 DigitalOut light2(LED4); 00040 light_2 = light2; 00041 00042 /* 00043 sensor_pulse sensor3(p6); 00044 sensor3.sensor_id = 4; 00045 sensor3.enabled = true; 00046 MBedStation::sensors[3] = sensor3; 00047 sensor_3 = sensor3; 00048 */ 00049 } 00050 00051 int MBedStation::ProcessResponse(char * Response) 00052 { 00053 int led_response; 00054 led_response = atoi(Response); 00055 if (led_response == 1 or led_response == 3) 00056 { 00057 light_1 = 1; 00058 } 00059 else 00060 { 00061 light_1 =0; 00062 } 00063 00064 if (led_response == 2 or led_response == 3) 00065 { 00066 light_2 = 1; 00067 } 00068 else 00069 { 00070 light_2 =0; 00071 } 00072 return 1; 00073 }
Generated on Tue Jul 26 2022 06:36:17 by 1.7.2