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@46:cdc24a24e4e3, 2018-03-29 (annotated)
- Committer:
- aeschsim
- Date:
- Thu Mar 29 14:14:13 2018 +0000
- Revision:
- 46:cdc24a24e4e3
- Parent:
- 45:4359c9efc134
- Child:
- 47:0f44c88e7643
changed set PWM to 0...4095 scale
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 | { |
cittecla | 11:e8a7a4a9af05 | 5 | float red = ((color >> 16) & 0xff)/2.55; |
cittecla | 11:e8a7a4a9af05 | 6 | float green = ((color >> 8) & 0xff)/2.55; |
cittecla | 11:e8a7a4a9af05 | 7 | float blue = (color & 0xff)/2.55; |
aeschsim | 24:da1af5214804 | 8 | |
cittecla | 38:5bbf548e6872 | 9 | /* PWM channel 10-15, Button is 0 or 1 |
cittecla | 38:5bbf548e6872 | 10 | * -> if Button = 0, set Channel 10,11,12 |
cittecla | 38:5bbf548e6872 | 11 | * -> if Button = 1, set Channel 13,14,15 |
aeschsim | 24:da1af5214804 | 12 | */ |
aeschsim | 24:da1af5214804 | 13 | |
cittecla | 38:5bbf548e6872 | 14 | setPWM(10+(3*button) , red); |
cittecla | 38:5bbf548e6872 | 15 | setPWM(10+(3*button)+1 , green); |
cittecla | 38:5bbf548e6872 | 16 | setPWM(10+(3*button)+2 , blue); |
aeschsim | 24:da1af5214804 | 17 | |
EHess | 22:828b393dff51 | 18 | } |
itslinear | 17:bbafd216e059 | 19 | |
aeschsim | 24:da1af5214804 | 20 | |
itslinear | 17:bbafd216e059 | 21 | void setValvePosition(char pos) |
itslinear | 17:bbafd216e059 | 22 | { |
aeschsim | 23:79638b0e9b16 | 23 | switch(pos) { |
aeschsim | 23:79638b0e9b16 | 24 | case 0: // neutrale Position |
aeschsim | 23:79638b0e9b16 | 25 | setPWM(0, 50); |
aeschsim | 23:79638b0e9b16 | 26 | break; |
aeschsim | 23:79638b0e9b16 | 27 | case 1: // Glas |
aeschsim | 23:79638b0e9b16 | 28 | setPWM(0, 100); |
aeschsim | 23:79638b0e9b16 | 29 | break; |
aeschsim | 23:79638b0e9b16 | 30 | case 2: // Auswurf |
aeschsim | 23:79638b0e9b16 | 31 | setPWM(0, 0); |
aeschsim | 23:79638b0e9b16 | 32 | break; |
aeschsim | 23:79638b0e9b16 | 33 | } |
itslinear | 17:bbafd216e059 | 34 | } |
itslinear | 17:bbafd216e059 | 35 | |
aeschsim | 23:79638b0e9b16 | 36 | void setSpeed(char container, char direction) |
aeschsim | 23:79638b0e9b16 | 37 | { |
EHess | 45:4359c9efc134 | 38 | switch(direction) { |
EHess | 45:4359c9efc134 | 39 | case 0: // Stillstand |
EHess | 45:4359c9efc134 | 40 | setPWM(container, 50); |
EHess | 45:4359c9efc134 | 41 | break; |
EHess | 45:4359c9efc134 | 42 | case 1: // Rückwärts |
EHess | 45:4359c9efc134 | 43 | setPWM(container, 0); |
EHess | 45:4359c9efc134 | 44 | break; |
aeschsim | 46:cdc24a24e4e3 | 45 | case 2: // Vorwärts |
EHess | 45:4359c9efc134 | 46 | setPWM(container, 100); |
EHess | 45:4359c9efc134 | 47 | break; |
EHess | 45:4359c9efc134 | 48 | } |
aeschsim | 23:79638b0e9b16 | 49 | } |
aeschsim | 12:f28a798d2661 | 50 | |
EHess | 22:828b393dff51 | 51 | |
itslinear | 17:bbafd216e059 | 52 | bool controlPosition(char container) |
itslinear | 17:bbafd216e059 | 53 | { |
itslinear | 17:bbafd216e059 | 54 | return 0; |
itslinear | 17:bbafd216e059 | 55 | } |
itslinear | 17:bbafd216e059 | 56 | int getServoAngle(char container) |
itslinear | 17:bbafd216e059 | 57 | { |
itslinear | 17:bbafd216e059 | 58 | return 0; |
itslinear | 17:bbafd216e059 | 59 | } |