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
source/functions.cpp@85:04fe3dff23f4, 2018-04-09 (annotated)
- Committer:
- EHess
- Date:
- Mon Apr 09 15:05:43 2018 +0000
- Revision:
- 85:04fe3dff23f4
- Parent:
- 47:0f44c88e7643
- Child:
- 95:b02e1b2a6cbd
worked on servotest and nextPosition
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aeschsim | 8:6ece7caefb33 | 1 | #include "functions.h" |
aeschsim | 8:6ece7caefb33 | 2 | |
cittecla | 11:e8a7a4a9af05 | 3 | void setLED(char button, uint32_t color) |
cittecla | 11:e8a7a4a9af05 | 4 | { |
aeschsim | 47:0f44c88e7643 | 5 | /* 0xFF - 4095, 0x00 - 0 -> factor 1/16.06 */ |
aeschsim | 47:0f44c88e7643 | 6 | float red = ((color >> 16) & 0xff)/16.06; |
aeschsim | 47:0f44c88e7643 | 7 | float green = ((color >> 8) & 0xff)/16.06; |
aeschsim | 47:0f44c88e7643 | 8 | float blue = (color & 0xff)/16.06; |
aeschsim | 24:da1af5214804 | 9 | |
cittecla | 38:5bbf548e6872 | 10 | /* PWM channel 10-15, Button is 0 or 1 |
cittecla | 38:5bbf548e6872 | 11 | * -> if Button = 0, set Channel 10,11,12 |
cittecla | 38:5bbf548e6872 | 12 | * -> if Button = 1, set Channel 13,14,15 |
aeschsim | 24:da1af5214804 | 13 | */ |
aeschsim | 24:da1af5214804 | 14 | |
cittecla | 38:5bbf548e6872 | 15 | setPWM(10+(3*button) , red); |
cittecla | 38:5bbf548e6872 | 16 | setPWM(10+(3*button)+1 , green); |
cittecla | 38:5bbf548e6872 | 17 | setPWM(10+(3*button)+2 , blue); |
aeschsim | 24:da1af5214804 | 18 | |
EHess | 22:828b393dff51 | 19 | } |
itslinear | 17:bbafd216e059 | 20 | |
aeschsim | 24:da1af5214804 | 21 | |
itslinear | 17:bbafd216e059 | 22 | void setValvePosition(char pos) |
itslinear | 17:bbafd216e059 | 23 | { |
aeschsim | 47:0f44c88e7643 | 24 | /* 1ms = 0° = 218E, 2ms = 180° = 436E; 1E = 4.59us */ |
aeschsim | 23:79638b0e9b16 | 25 | switch(pos) { |
aeschsim | 23:79638b0e9b16 | 26 | case 0: // neutrale Position |
aeschsim | 47:0f44c88e7643 | 27 | setPWM(0, 218); |
aeschsim | 23:79638b0e9b16 | 28 | break; |
aeschsim | 23:79638b0e9b16 | 29 | case 1: // Glas |
aeschsim | 47:0f44c88e7643 | 30 | setPWM(0, 326); |
aeschsim | 23:79638b0e9b16 | 31 | break; |
aeschsim | 23:79638b0e9b16 | 32 | case 2: // Auswurf |
aeschsim | 47:0f44c88e7643 | 33 | setPWM(0, 436); |
aeschsim | 23:79638b0e9b16 | 34 | break; |
aeschsim | 23:79638b0e9b16 | 35 | } |
itslinear | 17:bbafd216e059 | 36 | } |
itslinear | 17:bbafd216e059 | 37 | |
aeschsim | 23:79638b0e9b16 | 38 | void setSpeed(char container, char direction) |
aeschsim | 23:79638b0e9b16 | 39 | { |
aeschsim | 47:0f44c88e7643 | 40 | /* CW 279...322; Stop 322...331; CCW 331...374 */ |
EHess | 45:4359c9efc134 | 41 | switch(direction) { |
EHess | 45:4359c9efc134 | 42 | case 0: // Stillstand |
aeschsim | 47:0f44c88e7643 | 43 | setPWM(container, 326); |
EHess | 45:4359c9efc134 | 44 | break; |
EHess | 45:4359c9efc134 | 45 | case 1: // Rückwärts |
EHess | 85:04fe3dff23f4 | 46 | setPWM(container, 340); |
EHess | 45:4359c9efc134 | 47 | break; |
aeschsim | 46:cdc24a24e4e3 | 48 | case 2: // Vorwärts |
aeschsim | 47:0f44c88e7643 | 49 | setPWM(container, 320); |
EHess | 45:4359c9efc134 | 50 | break; |
EHess | 45:4359c9efc134 | 51 | } |
aeschsim | 23:79638b0e9b16 | 52 | } |
aeschsim | 12:f28a798d2661 | 53 | |
EHess | 22:828b393dff51 | 54 | |
itslinear | 17:bbafd216e059 | 55 | bool controlPosition(char container) |
itslinear | 17:bbafd216e059 | 56 | { |
itslinear | 17:bbafd216e059 | 57 | return 0; |
itslinear | 17:bbafd216e059 | 58 | } |
itslinear | 17:bbafd216e059 | 59 | int getServoAngle(char container) |
itslinear | 17:bbafd216e059 | 60 | { |
itslinear | 17:bbafd216e059 | 61 | return 0; |
itslinear | 17:bbafd216e059 | 62 | } |