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 PES4_Programme by
Diff: source/main.cpp
- Revision:
- 87:a0b824c35b1b
- Parent:
- 85:04fe3dff23f4
- Child:
- 91:443b0ac21de0
--- a/source/main.cpp Mon Apr 09 15:05:43 2018 +0000
+++ b/source/main.cpp Mon Apr 09 15:40:56 2018 +0000
@@ -2,12 +2,12 @@
#define FADESPEED 5
#define DEMOTIME 5
-int state = 44;
+int state = 44; // 44 für Initialisierung!
int oldState;
-Serial pc(USBTX, USBRX); // tx, rx
-
+/* Input / Output */
+Serial pc(USBTX, USBRX);
DigitalIn lichtschranke(PC_5);
InterruptIn userButton1(PB_5);
InterruptIn userButton2(PB_4);
@@ -31,34 +31,24 @@
s_time outputTime;
s_time currentTime;
s_medContainer medication;
-//s_medContainer medInventory;
s_medInventory medInventory;
-
int success = 1;
-
char user = 1;
-/*
-char med1[] = "A";
-char med2[] = "B";
-char med3[] = "C";
-char med4[] = "D";
-char med5[] = "E";
-char med6[] = "F";
-*/
char fail[] = "shit happens";
-
char *send;
-/*********/
-/* Switch Summer On/Off for demo Tool */
+/* Switch Summer On/Off for demo Tool (Interrupt)*/
void summ(void)
{
+ userButton1.disable_irq();
if(summer.read()>0) {
summer.write(0.0f);
} else {
summer.write(0.5f);
}
+ wait_ms(50);
+ userButton1.enable_irq();
}
@@ -142,7 +132,7 @@
/**************************************************************/
/* Test Zone */
-
+
/* Speedtest Servo */
case 41:
setSpeed(1, 2);
@@ -153,27 +143,27 @@
wait(3);
state = 43;
break;
-
+
/* DutyCycle */
case 42:
printf("case 42:\r\n");
initInterrupt();
printf("initInterrupt\r\n");
enableContainer(1);
- while(1){
+ while(1) {
printf("%i\r\n", getDutyCycle());
printf("--- END ---\r\n");
wait(0.2);
}
break;
-
+
/* Drehung 90° */
case 43:
printf("case 43:\r\n");
initInterrupt();
printf("initInterrupt\r\n");
enableContainer(1);
- while(1){
+ while(1) {
nextPosition(1);
printf("--- END ---\r\n");
wait(3);
@@ -185,7 +175,7 @@
printf("Init PWM\r\n");
initPWM(50);
enableOutput();
- state = 43;
+ state = 47; // 47 for state switch
break;
/* Time test tool: set Time */
@@ -216,13 +206,22 @@
/* Console State Switch */
case 47:
printf("\n\rState Switch: Enter next State: \n\r");
+ printf("41\tSet Speed Function test\n\r");
+ printf("42\tGet Duty Cycle Function test\n\r");
+ printf("43\tTurn 90deg Function test\n\r");
+ printf("44\tInit Servoboard\n\r");
printf("45\tset Time\n\r46\tread Time\n\r47\tState Switch\n\r48\tServo Board Test Tool\n\r");
printf("49\tenable servo output\n\r50\tdisable servo output\n\r");
printf("51\ttest SD Card\n\r52\tread medication\n\r53\tMedication display test tool\n\r");
printf("54\tWrite Medication\n\r55\tDemo Tool for Summer and RGB LED\n\r");
- printf("60\t \n\r");
- printf("61\t \n\r");
- printf("62\t \n\r");
+ printf("60\tWrite Medication Protocol\n\r");
+ printf("61\twrite_medInventory\n\r");
+ printf("62\twrite_medError\n\r");
+ printf("63\terase_errorPotocol\n\r");
+ printf("64\t \n\r");
+ printf("65\t \n\r");
+ printf("66\t \n\r");
+ printf("67\t \n\r");
pc.scanf("%d", &state);
printf("Switch to State %d\n\r",state);
fflush(stdin);
