TTDC / Mbed 2 deprecated switches

Dependencies:   C12832 MMA7660 mbed

Committer:
ksaito
Date:
Wed Mar 14 11:15:31 2018 +0000
Revision:
5:614e3ac042df
Parent:
4:d61f6d186db0
Child:
7:8b0019dd26d3
????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ksaito 0:c3bc6981ad28 1 #include "mbed.h"
ksaito 1:2967eac08981 2 #include "commands.h"
ksaito 0:c3bc6981ad28 3
ksaito 0:c3bc6981ad28 4 PwmOut r (p23);
ksaito 0:c3bc6981ad28 5 PwmOut g (p24);
ksaito 0:c3bc6981ad28 6 PwmOut b (p25);
ksaito 0:c3bc6981ad28 7
ksaito 1:2967eac08981 8 static void _Finalize(void) {
ksaito 1:2967eac08981 9 r = 1.0;
ksaito 1:2967eac08981 10 g = 1.0;
ksaito 5:614e3ac042df 11 b = 1.0;
ksaito 5:614e3ac042df 12 r.period(0.000);
ksaito 0:c3bc6981ad28 13 }
ksaito 0:c3bc6981ad28 14
ksaito 1:2967eac08981 15 static void _Initialize(void) {
ksaito 1:2967eac08981 16 _Finalize();
ksaito 1:2967eac08981 17 }
ksaito 1:2967eac08981 18
ksaito 4:d61f6d186db0 19 static float _ColorRange = 0.0;
ksaito 4:d61f6d186db0 20 static void _ProcessInitialize(void) {
ksaito 4:d61f6d186db0 21 _ColorRange = 0.0;
ksaito 4:d61f6d186db0 22 }
ksaito 4:d61f6d186db0 23
ksaito 4:d61f6d186db0 24 static bool _ProcessIsContinue(void) {
ksaito 4:d61f6d186db0 25 return _ColorRange < 1.0;
ksaito 4:d61f6d186db0 26 }
ksaito 4:d61f6d186db0 27
ksaito 4:d61f6d186db0 28 static void _ProcessRunning(void) {
ksaito 4:d61f6d186db0 29 float p = 3 * _ColorRange;
ksaito 4:d61f6d186db0 30 r = 1.0 - ((p < 1.0) ? 1.0 - p : (p > 2.0) ? p - 2.0 : 0.0);
ksaito 4:d61f6d186db0 31 g = 1.0 - ((p < 1.0) ? p : (p > 2.0) ? 0.0 : 2.0 - p);
ksaito 4:d61f6d186db0 32 b = 1.0 - ((p < 1.0) ? 0.0 : (p > 2.0) ? 3.0 - p : p - 1.0); ;
ksaito 4:d61f6d186db0 33 wait (0.01);
ksaito 4:d61f6d186db0 34
ksaito 4:d61f6d186db0 35 _ColorRange += 0.001;
ksaito 4:d61f6d186db0 36 }
ksaito 4:d61f6d186db0 37
ksaito 5:614e3ac042df 38 COMMAND_DEFINE Command_color = {"color", 0x04, _Initialize, _Finalize,
ksaito 4:d61f6d186db0 39 _ProcessInitialize, _ProcessIsContinue, _ProcessRunning
ksaito 4:d61f6d186db0 40 };