PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Social
libbadgetools
leds_set_1_rgb.c
1
#include <propeller.h>
2
#include "
badgetools.h
"
3
4
light
badgeLight;
5
light
*ledsself;
6
7
int32_t cpcog;
8
9
void
set_1_rgb(
int
idx)
10
{
11
//int32_t result = 0;
12
// LOCKED 30 JUN 2015
13
// Set one of the LEDs within the RGB modules
14
// -- connections designed for Charlieplexing
15
// * make one high, one low, the other high-z (input)
16
// -- for multiple LEDs/colors use Charlieplex driver methods
17
if
(cpcog) {
18
// Charlieplex driver loaded?
19
if
((idx >= RGB_B1) && (idx <= RGB_R2)) {
20
// valid element?
21
// set via mask
22
light_set_rgb((1 << idx));
23
}
else
{
24
// clear all
25
light_set_rgb(0);
26
}
27
return
;
28
}
29
// if no driver loaded, use direct control
30
if
(idx == RGB_B1) {
31
// CP2 = H, CP1 = Z, CP0 = L
32
OUTA
= ((
OUTA
& 0xfffffff1) | 0x8);
33
DIRA
= ((
DIRA
& 0xfffffff1) | 0xa);
34
}
else
if
(idx == RGB_G1) {
35
// CP2 = Z, CP1 = H, CP0 = L
36
OUTA
= ((
OUTA
& 0xfffffff1) | 0x4);
37
DIRA
= ((
DIRA
& 0xfffffff1) | 0x6);
38
}
else
if
(idx == RGB_R1) {
39
// CP2 = L, CP1 = H, CP0 = Z
40
OUTA
= ((
OUTA
& 0xfffffff1) | 0x4);
41
DIRA
= ((
DIRA
& 0xfffffff1) | 0xc);
42
}
else
if
(idx == RGB_B2) {
43
// CP2 = L, CP1 = Z, CP0 = H
44
OUTA
= ((
OUTA
& 0xfffffff1) | 0x2);
45
DIRA
= ((
DIRA
& 0xfffffff1) | 0xa);
46
}
else
if
(idx == RGB_G2) {
47
// CP2 = Z, CP1 = L, CP0 = H
48
OUTA
= ((
OUTA
& 0xfffffff1) | 0x2);
49
DIRA
= ((
DIRA
& 0xfffffff1) | 0x6);
50
}
else
if
(idx == RGB_R2) {
51
// CP2 = H, CP1 = L, CP0 = Z
52
OUTA
= ((
OUTA
& 0xfffffff1) | 0x8);
53
DIRA
= ((
DIRA
& 0xfffffff1) | 0xc);
54
}
else
if
(1) {
55
// disable all
56
OUTA
&= ~(7<<
RGB_CP0
);
57
DIRA
&= ~(7<<
RGB_CP0
);
58
}
59
}
60
61
/*
62
TERMS OF USE: MIT License
63
64
Permission is hereby granted, free of charge, to any person obtaining a
65
copy of this software and associated documentation files (the "Software"),
66
to deal in the Software without restriction, including without limitation
67
the rights to use, copy, modify, merge, publish, distribute, sublicense,
68
and/or sell copies of the Software, and to permit persons to whom the
69
Software is furnished to do so, subject to the following conditions:
70
71
The above copyright notice and this permission notice shall be included in
72
all copies or substantial portions of the Software.
73
74
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
75
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
76
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
77
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
78
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
79
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
80
DEALINGS IN THE SOFTWARE.
81
*/
82
OUTA
#define OUTA
Use to set output pin states when corresponding DIRA bits are 1.
Definition:
propeller1.h:157
light
Definition:
badgetools.h:1224
RGB_CP0
#define RGB_CP0
brief description.
Definition:
badgetools.h:1221
badgetools.h
This library provides convenient functions for a variety of Parallax eBadge operations.
DIRA
#define DIRA
Use to set pins to input (0) or output (1).
Definition:
propeller1.h:161
Generated on Fri May 20 2022 16:48:05 for PropWare by
1.8.17