Simple demo for MultipinRGB lib.

Dependencies:   MultipinRGB max32630fthr

Committer:
j3
Date:
Tue Mar 28 20:28:33 2017 +0000
Revision:
0:8a5a157f2603
Child:
1:e10e0ccddca1
init commit;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
j3 0:8a5a157f2603 1 /*******************************************************************************
j3 0:8a5a157f2603 2 * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
j3 0:8a5a157f2603 3 *
j3 0:8a5a157f2603 4 * Permission is hereby granted, free of charge, to any person obtaining a
j3 0:8a5a157f2603 5 * copy of this software and associated documentation files (the "Software"),
j3 0:8a5a157f2603 6 * to deal in the Software without restriction, including without limitation
j3 0:8a5a157f2603 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
j3 0:8a5a157f2603 8 * and/or sell copies of the Software, and to permit persons to whom the
j3 0:8a5a157f2603 9 * Software is furnished to do so, subject to the following conditions:
j3 0:8a5a157f2603 10 *
j3 0:8a5a157f2603 11 * The above copyright notice and this permission notice shall be included
j3 0:8a5a157f2603 12 * in all copies or substantial portions of the Software.
j3 0:8a5a157f2603 13 *
j3 0:8a5a157f2603 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
j3 0:8a5a157f2603 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
j3 0:8a5a157f2603 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
j3 0:8a5a157f2603 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
j3 0:8a5a157f2603 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
j3 0:8a5a157f2603 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
j3 0:8a5a157f2603 20 * OTHER DEALINGS IN THE SOFTWARE.
j3 0:8a5a157f2603 21 *
j3 0:8a5a157f2603 22 * Except as contained in this notice, the name of Maxim Integrated
j3 0:8a5a157f2603 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
j3 0:8a5a157f2603 24 * Products, Inc. Branding Policy.
j3 0:8a5a157f2603 25 *
j3 0:8a5a157f2603 26 * The mere transfer of this software does not imply any licenses
j3 0:8a5a157f2603 27 * of trade secrets, proprietary technology, copyrights, patents,
j3 0:8a5a157f2603 28 * trademarks, maskwork rights, or any other form of intellectual
j3 0:8a5a157f2603 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
j3 0:8a5a157f2603 30 * ownership rights.
j3 0:8a5a157f2603 31 *******************************************************************************
j3 0:8a5a157f2603 32 */
j3 0:8a5a157f2603 33
j3 0:8a5a157f2603 34
j3 0:8a5a157f2603 35 #include "mbed.h"
j3 0:8a5a157f2603 36 #include "max32630fthr.h"
j3 0:8a5a157f2603 37 #include "MultipinRGB.h"
j3 0:8a5a157f2603 38
j3 0:8a5a157f2603 39
j3 0:8a5a157f2603 40 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
j3 0:8a5a157f2603 41
j3 0:8a5a157f2603 42
j3 0:8a5a157f2603 43 int main()
j3 0:8a5a157f2603 44 {
j3 0:8a5a157f2603 45 MultipinRGB leds(LED1, LED2, LED3);
j3 0:8a5a157f2603 46 float redDutyCycle(0.5F), grnDutyCycle(0.0F), bluDutyCycle(0.0F), temp;
j3 0:8a5a157f2603 47
j3 0:8a5a157f2603 48 while(1)
j3 0:8a5a157f2603 49 {
j3 0:8a5a157f2603 50 leds.writeRGB(redDutyCycle, grnDutyCycle, bluDutyCycle);
j3 0:8a5a157f2603 51
j3 0:8a5a157f2603 52 printf("RGB Duty Cycles = %3.1f, %3.1f, %3.1f\r\n",
j3 0:8a5a157f2603 53 redDutyCycle, grnDutyCycle, bluDutyCycle);
j3 0:8a5a157f2603 54
j3 0:8a5a157f2603 55 //shift r->g->b->r
j3 0:8a5a157f2603 56 temp = bluDutyCycle;
j3 0:8a5a157f2603 57 bluDutyCycle = grnDutyCycle;
j3 0:8a5a157f2603 58 grnDutyCycle = redDutyCycle;
j3 0:8a5a157f2603 59 redDutyCycle = temp;
j3 0:8a5a157f2603 60
j3 0:8a5a157f2603 61 wait(0.25);
j3 0:8a5a157f2603 62 }
j3 0:8a5a157f2603 63 }